Subversion Repositories Applications.papyrus

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1463 alexandre_ 1
<?php
2
// +----------------------------------------------------------------------+
3
// | PEAR :: I18Nv2 :: AreaCode                                           |
4
// +----------------------------------------------------------------------+
5
// | This source file is subject to version 3.0 of the PHP license,       |
6
// | that is available at http://www.php.net/license/3_0.txt              |
7
// | If you did not receive a copy of the PHP license and are unable      |
8
// | to obtain it through the world-wide-web, please send a note to       |
9
// | license@php.net so we can mail you a copy immediately.               |
10
// +----------------------------------------------------------------------+
11
// | Copyright (c) 2004 Michael Wallner <mike@iworks.at>                  |
12
// +----------------------------------------------------------------------+
13
//
14
// $Id: AreaCode.php,v 1.1 2007-06-25 09:55:28 alexandre_tb Exp $
15
 
16
/**
17
 * I18Nv2::AreaCode
18
 *
19
 * @package     I18Nv2
20
 * @category    Internationalization
21
 */
22
 
23
require_once 'I18Nv2/CommonList.php';
24
 
25
/**
26
 * I18Nv2_AreaCode
27
 *
28
 * List of two letter country code to international area code mapping.
29
 *
30
 * @author      Michael Wallner <mike@php.net>
31
 * @version     $Revision: 1.1 $
32
 * @access      public
33
 * @package     I18Nv2
34
 */
35
class I18Nv2_AreaCode extends I18Nv2_CommonList
36
{
37
    /**
38
     * Codes
39
     *
40
     * @access  protected
41
     * @var     array
42
     */
43
    var $codes = array(
44
        'AF' => 93,
45
        'AL' => 355,
46
        'DZ' => 213,
47
        'AS' => 684,
48
        'AD' => 376,
49
        'AO' => 244,
50
        'AQ' => 672,
51
        'AR' => 54,
52
        'AM' => 374,
53
        'AW' => 297,
54
        'AC' => 247,
55
        'AU' => 61,
56
        'AT' => 43,
57
        'AZ' => 994,
58
        'BH' => 973,
59
        'BD' => 880,
60
        'BY' => 375,
61
        'BE' => 32,
62
        'BZ' => 501,
63
        'BJ' => 229,
64
        'BT' => 975,
65
        'GW' => 245,
66
        'BO' => 591,
67
        'BA' => 387,
68
        'BW' => 267,
69
        'BR' => 55,
70
        'BN' => 673,
71
        'BG' => 359,
72
        'BF' => 226,
73
        'BI' => 257,
74
        'KH' => 855,
75
        'CM' => 237,
76
        'CV' => 238,
77
        'CF' => 236,
78
        'TD' => 235,
79
        'CL' => 56,
80
        'CN' => 86,
81
        'CO' => 57,
82
        'KM' => 2690,
83
        'CG' => 242,
84
        'CK' => 682,
85
        'CR' => 506,
86
        'HR' => 385,
87
        'CU' => 53,
88
        'CY' => 357,
89
        'CZ' => 420,
90
        'DK' => 45,
91
        'DG' => 246,
92
        'DJ' => 253,
93
        'EC' => 593,
94
        'EG' => 20,
95
        'SV' => 503,
96
        'GQ' => 240,
97
        'ER' => 291,
98
        'EE' => 372,
99
        'ET' => 251,
100
        'FO' => 298,
101
        'FK' => 500,
102
        'FJ' => 679,
103
        'FI' => 358,
104
        'FR' => 33,
105
        'GF' => 594,
106
        'PF' => 689,
107
        'GA' => 241,
108
        'GM' => 220,
109
        'GE' => 995,
110
        'DE' => 49,
111
        'GH' => 233,
112
        'GI' => 350,
113
        'GR' => 30,
114
        'GL' => 299,
115
        'GP' => 590,
116
        'GT' => 502,
117
        'GN' => 224,
118
        'GY' => 592,
119
        'HT' => 509,
120
        'HN' => 504,
121
        'HK' => 852,
122
        'HU' => 36,
123
        'IS' => 354,
124
        'IN' => 91,
125
        'ID' => 62,
126
        'QB' => 871,
127
        'QE' => 873,
128
        'QD' => 872,
129
        'QC' => 874,
130
        'IR' => 98,
131
        'IQ' => 964,
132
        'IE' => 353,
133
        'IM' => 881,
134
        'IL' => 972,
135
        'IT' => 39,
136
        'IC' => 225,
137
        'JP' => 81,
138
        'JO' => 962,
139
        'KE' => 254,
140
        'KI' => 686,
141
        'KP' => 850,
142
        'KR' => 82,
143
        'KW' => 965,
144
        'KG' => 9962,
145
        'LA' => 856,
146
        'LV' => 371,
147
        'LB' => 961,
148
        'LS' => 266,
149
        'LR' => 231,
150
        'LY' => 218,
151
        'LI' => 423,
152
        'LT' => 370,
153
        'LU' => 352,
154
        'MO' => 853,
155
        'MK' => 389,
156
        'MG' => 261,
157
        'MW' => 265,
158
        'MY' => 60,
159
        'MV' => 960,
160
        'ML' => 223,
161
        'MT' => 356,
162
        'MH' => 692,
163
        'MQ' => 596,
164
        'MR' => 222,
165
        'MU' => 230,
166
        'MX' => 52,
167
        'FM' => 691,
168
        'MD' => 373,
169
        'MC' => 377,
170
        'MN' => 976,
171
        'MA' => 212,
172
        'MZ' => 258,
173
        'MM' => 95,
174
        'NA' => 264,
175
        'NR' => 674,
176
        'NP' => 977,
177
        'NL' => 31,
178
        'AN' => 599,
179
        'NC' => 687,
180
        'NZ' => 64,
181
        'NI' => 505,
182
        'NE' => 227,
183
        'NG' => 234,
184
        'NU' => 683,
185
        'NO' => 47,
186
        'OM' => 968,
187
        'PK' => 92,
188
        'PW' => 680,
189
        'PA' => 507,
190
        'PG' => 675,
191
        'PY' => 595,
192
        'PE' => 51,
193
        'PH' => 63,
194
        'PL' => 48,
195
        'PT' => 351,
196
        'QA' => 974,
197
        'RE' => 262,
198
        'RO' => 40,
199
        'RU' => 7,
200
        'RW' => 250,
201
        'SH' => 290,
202
        'SM' => 378,
203
        'ST' => 239,
204
        'SA' => 966,
205
        'SN' => 221,
206
        'SC' => 248,
207
        'SL' => 232,
208
        'SG' => 65,
209
        'SK' => 421,
210
        'SI' => 386,
211
        'SB' => 677,
212
        'SO' => 252,
213
        'ZA' => 27,
214
        'ES' => 34,
215
        'LK' => 94,
216
        'PM' => 508,
217
        'SD' => 249,
218
        'SR' => 597,
219
        'SZ' => 268,
220
        'SE' => 46,
221
        'CH' => 41,
222
        'SY' => 963,
223
        'TW' => 886,
224
        'TJ' => 992364,
225
        'TZ' => 255,
226
        'TH' => 66,
227
        'TG' => 228,
228
        'TK' => 690,
229
        'TO' => 676,
230
        'TN' => 216,
231
        'TR' => 90,
232
        'TM' => 993,
233
        'TV' => 688,
234
        'UG' => 256,
235
        'UA' => 380,
236
        'AE' => 971,
237
        'GB' => 44,
238
        'UR' => 598,
239
        'UZ' => 998,
240
        'VU' => 678,
241
        'VE' => 58,
242
        'VN' => 84,
243
        'WF' => 681,
244
        'WS' => 685,
245
        'YD' => 967,
246
        'YU' => 381,
247
        'ZR' => 243,
248
        'ZM' => 260,
249
        'ZW' => 263
250
    );
251
 
252
    /**
253
     * Load Language
254
     *
255
     * Does nothing.
256
     *
257
     * @access  public
258
     * @return  bool true
259
     * @param   string  $lang
260
     */
261
    function loadLanguage($lang)
262
    {
263
        return true;
264
    }
265
 
266
    /**
267
     * Change Key Case
268
     *
269
     * @access  protected
270
     * @return  string
271
     * @param   string  $key
272
     */
273
    function changeKeyCase($key)
274
    {
275
        return strToUpper($key);
276
    }
277
 
278
    /**
279
     * Merge Country
280
     *
281
     * Merge this list with an I18Nv2_Country list to a new I18Nv2_CommonList,
282
     * where the international area codes map to the full country name.
283
     *
284
     * @access  public
285
     * @return  object  I18Nv2_CommonList
286
     * @param   object  $country I18Nv2_Country
287
     */
288
    function &mergeCountry(&$country)
289
    {
290
        $list = &new I18Nv2_CommonList(
291
            $country->getLanguage(),
292
            $encoding = $country->getEncoding()
293
        );
294
 
295
        $country->setEncoding('UTF-8');
296
        $ctys = $country->getAllCodes();
297
        $acds = $this->getAllCodes();
298
        $country->setEncoding($encoding);
299
 
300
        $uniq = array_intersect(array_keys($acds), array_keys($ctys));
301
 
302
        foreach ($uniq as $code) {
303
            $list->codes[$acds[$code]] = $ctys[$code];
304
        }
305
 
306
        return $list;
307
    }
308
 
309
}
310
?>