File indexing completed on 2025-01-19 05:21:16
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Locale 0017 * @subpackage Data 0018 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0019 * @license http://framework.zend.com/license/new-bsd New BSD License 0020 * @version $Id$ 0021 */ 0022 0023 /** 0024 * include needed classes 0025 */ 0026 // require_once 'Zend/Locale.php'; 0027 0028 /** @see Zend_Xml_Security */ 0029 // require_once 'Zend/Xml/Security.php'; 0030 0031 /** 0032 * Locale data reader, handles the CLDR 0033 * 0034 * @category Zend 0035 * @package Zend_Locale 0036 * @subpackage Data 0037 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0038 * @license http://framework.zend.com/license/new-bsd New BSD License 0039 */ 0040 class Zend_Locale_Data 0041 { 0042 /** 0043 * Locale files 0044 * 0045 * @var array 0046 */ 0047 private static $_ldml = array(); 0048 0049 /** 0050 * List of values which are collected 0051 * 0052 * @var array 0053 */ 0054 private static $_list = array(); 0055 0056 /** 0057 * Internal cache for ldml values 0058 * 0059 * @var Zend_Cache_Core 0060 */ 0061 private static $_cache = null; 0062 0063 /** 0064 * Internal value to remember if cache supports tags 0065 * 0066 * @var boolean 0067 */ 0068 private static $_cacheTags = false; 0069 0070 /** 0071 * Internal option, cache disabled 0072 * 0073 * @var boolean 0074 */ 0075 private static $_cacheDisabled = false; 0076 0077 /** 0078 * Read the content from locale 0079 * 0080 * Can be called like: 0081 * <ldml> 0082 * <delimiter>test</delimiter> 0083 * <second type='myone'>content</second> 0084 * <second type='mysecond'>content2</second> 0085 * <third type='mythird' /> 0086 * </ldml> 0087 * 0088 * Case 1: _readFile('ar','/ldml/delimiter') -> returns [] = test 0089 * Case 1: _readFile('ar','/ldml/second[@type=myone]') -> returns [] = content 0090 * Case 2: _readFile('ar','/ldml/second','type') -> returns [myone] = content; [mysecond] = content2 0091 * Case 3: _readFile('ar','/ldml/delimiter',,'right') -> returns [right] = test 0092 * Case 4: _readFile('ar','/ldml/third','type','myone') -> returns [myone] = mythird 0093 * 0094 * @param string $locale 0095 * @param string $path 0096 * @param string $attribute 0097 * @param string $value 0098 * @access private 0099 * @return array 0100 */ 0101 private static function _readFile($locale, $path, $attribute, $value, $temp) 0102 { 0103 // without attribute - read all values 0104 // with attribute - read only this value 0105 if (!empty(self::$_ldml[(string) $locale])) { 0106 0107 $result = self::$_ldml[(string) $locale]->xpath($path); 0108 if (!empty($result)) { 0109 foreach ($result as &$found) { 0110 0111 if (empty($value)) { 0112 0113 if (empty($attribute)) { 0114 // Case 1 0115 $temp[] = (string) $found; 0116 } else if (empty($temp[(string) $found[$attribute]])){ 0117 // Case 2 0118 $temp[(string) $found[$attribute]] = (string) $found; 0119 } 0120 0121 } else if (empty ($temp[$value])) { 0122 0123 if (empty($attribute)) { 0124 // Case 3 0125 $temp[$value] = (string) $found; 0126 } else { 0127 // Case 4 0128 $temp[$value] = (string) $found[$attribute]; 0129 } 0130 0131 } 0132 } 0133 } 0134 } 0135 return $temp; 0136 } 0137 0138 /** 0139 * Find possible routing to other path or locale 0140 * 0141 * @param string $locale 0142 * @param string $path 0143 * @param string $attribute 0144 * @param string $value 0145 * @param array $temp 0146 * @return bool 0147 * @throws Zend_Locale_Exception 0148 */ 0149 private static function _findRoute($locale, $path, $attribute, $value, &$temp) 0150 { 0151 // load locale file if not already in cache 0152 // needed for alias tag when referring to other locale 0153 if (empty(self::$_ldml[(string) $locale])) { 0154 $filename = dirname(__FILE__) . '/Data/' . $locale . '.xml'; 0155 if (!file_exists($filename)) { 0156 // require_once 'Zend/Locale/Exception.php'; 0157 throw new Zend_Locale_Exception("Missing locale file '$filename' for '$locale' locale."); 0158 } 0159 0160 self::$_ldml[(string) $locale] = Zend_Xml_Security::scanFile($filename); 0161 } 0162 0163 // search for 'alias' tag in the search path for redirection 0164 $search = ''; 0165 $tok = strtok($path, '/'); 0166 0167 // parse the complete path 0168 if (!empty(self::$_ldml[(string) $locale])) { 0169 while ($tok !== false) { 0170 $search .= '/' . $tok; 0171 if (strpos($search, '[@') !== false) { 0172 while (strrpos($search, '[@') > strrpos($search, ']')) { 0173 $tok = strtok('/'); 0174 if (empty($tok)) { 0175 $search .= '/'; 0176 } 0177 $search = $search . '/' . $tok; 0178 } 0179 } 0180 $result = self::$_ldml[(string) $locale]->xpath($search . '/alias'); 0181 0182 // alias found 0183 if (!empty($result)) { 0184 0185 $source = $result[0]['source']; 0186 $newpath = $result[0]['path']; 0187 0188 // new path - path //ldml is to ignore 0189 if ($newpath != '//ldml') { 0190 // other path - parse to make real path 0191 0192 while (substr($newpath,0,3) == '../') { 0193 $newpath = substr($newpath, 3); 0194 $search = substr($search, 0, strrpos($search, '/')); 0195 } 0196 0197 // truncate ../ to realpath otherwise problems with alias 0198 $path = $search . '/' . $newpath; 0199 while (($tok = strtok('/'))!== false) { 0200 $path = $path . '/' . $tok; 0201 } 0202 } 0203 0204 // reroute to other locale 0205 if ($source != 'locale') { 0206 $locale = $source; 0207 } 0208 0209 $temp = self::_getFile($locale, $path, $attribute, $value, $temp); 0210 return false; 0211 } 0212 0213 $tok = strtok('/'); 0214 } 0215 } 0216 return true; 0217 } 0218 0219 /** 0220 * Read the right LDML file 0221 * 0222 * @param string $locale 0223 * @param string $path 0224 * @param string|bool $attribute 0225 * @param string|bool $value 0226 * @param array $temp 0227 * @return array 0228 * @throws Zend_Locale_Exception 0229 */ 0230 private static function _getFile($locale, $path, $attribute = false, $value = false, $temp = array()) 0231 { 0232 $result = self::_findRoute($locale, $path, $attribute, $value, $temp); 0233 if ($result) { 0234 $temp = self::_readFile($locale, $path, $attribute, $value, $temp); 0235 } 0236 0237 // parse required locales reversive 0238 // example: when given zh_Hans_CN 0239 // 1. -> zh_Hans_CN 0240 // 2. -> zh_Hans 0241 // 3. -> zh 0242 // 4. -> root 0243 if (($locale != 'root') && ($result)) { 0244 // Search for parent locale 0245 if (false !== strpos($locale, '_')) { 0246 $parentLocale = self::getContent($locale, 'parentlocale'); 0247 if ($parentLocale) { 0248 $temp = self::_getFile($parentLocale, $path, $attribute, $value, $temp); 0249 } 0250 } 0251 0252 $locale = substr($locale, 0, -strlen(strrchr($locale, '_'))); 0253 if (!empty($locale)) { 0254 $temp = self::_getFile($locale, $path, $attribute, $value, $temp); 0255 } else { 0256 $temp = self::_getFile('root', $path, $attribute, $value, $temp); 0257 } 0258 } 0259 return $temp; 0260 } 0261 0262 /** 0263 * Find the details for supplemental calendar datas 0264 * 0265 * @param string $locale Locale for Detaildata 0266 * @param array $list List to search 0267 * @return string Key for Detaildata 0268 */ 0269 private static function _calendarDetail($locale, $list) 0270 { 0271 $ret = "001"; 0272 foreach ($list as $key => $value) { 0273 if (strpos($locale, '_') !== false) { 0274 $locale = substr($locale, strpos($locale, '_') + 1); 0275 } 0276 if (strpos($key, $locale) !== false) { 0277 $ret = $key; 0278 break; 0279 } 0280 } 0281 return $ret; 0282 } 0283 0284 /** 0285 * Internal function for checking the locale 0286 * 0287 * @param string|Zend_Locale $locale Locale to check 0288 * @return string 0289 * @throws Zend_Locale_Exception 0290 */ 0291 private static function _checkLocale($locale) 0292 { 0293 if (empty($locale)) { 0294 $locale = new Zend_Locale(); 0295 } 0296 0297 if (!(Zend_Locale::isLocale((string) $locale, null, false))) { 0298 // require_once 'Zend/Locale/Exception.php'; 0299 throw new Zend_Locale_Exception("Locale (" . (string) $locale . ") is a unknown locale"); 0300 } 0301 0302 if (Zend_Locale::isAlias($locale)) { 0303 // Return a valid CLDR locale so that the XML file can be loaded. 0304 return Zend_Locale::getAlias($locale); 0305 } 0306 return (string) $locale; 0307 } 0308 0309 /** 0310 * Read the LDML file, get a array of multipath defined value 0311 * 0312 * @param string $locale 0313 * @param string $path 0314 * @param bool|string $value 0315 * @return array 0316 * @throws Zend_Locale_Exception 0317 */ 0318 public static function getList($locale, $path, $value = false) 0319 { 0320 $locale = self::_checkLocale($locale); 0321 0322 if (!isset(self::$_cache) && !self::$_cacheDisabled) { 0323 // require_once 'Zend/Cache.php'; 0324 self::$_cache = Zend_Cache::factory( 0325 'Core', 0326 'File', 0327 array('automatic_serialization' => true), 0328 array()); 0329 } 0330 0331 $val = $value; 0332 if (is_array($value)) { 0333 $val = implode('_' , $value); 0334 } 0335 0336 $val = urlencode($val); 0337 $id = self::_filterCacheId('Zend_LocaleL_' . $locale . '_' . $path . '_' . $val); 0338 if (!self::$_cacheDisabled && ($result = self::$_cache->load($id))) { 0339 return unserialize($result); 0340 } 0341 0342 $temp = array(); 0343 switch(strtolower($path)) { 0344 case 'language': 0345 $temp = self::_getFile($locale, '/ldml/localeDisplayNames/languages/language', 'type'); 0346 break; 0347 0348 case 'script': 0349 $temp = self::_getFile($locale, '/ldml/localeDisplayNames/scripts/script', 'type'); 0350 break; 0351 0352 case 'territory': 0353 $temp = self::_getFile($locale, '/ldml/localeDisplayNames/territories/territory', 'type'); 0354 if ($value === 1) { 0355 foreach($temp as $key => $value) { 0356 if ((is_numeric($key) === false) and ($key != 'QO') and ($key != 'EU')) { 0357 unset($temp[$key]); 0358 } 0359 } 0360 } else if ($value === 2) { 0361 foreach($temp as $key => $value) { 0362 if (is_numeric($key) or ($key == 'QO') or ($key == 'EU')) { 0363 unset($temp[$key]); 0364 } 0365 } 0366 } 0367 break; 0368 0369 case 'variant': 0370 $temp = self::_getFile($locale, '/ldml/localeDisplayNames/variants/variant', 'type'); 0371 break; 0372 0373 case 'key': 0374 $temp = self::_getFile($locale, '/ldml/localeDisplayNames/keys/key', 'type'); 0375 break; 0376 0377 case 'type': 0378 if (empty($value)) { 0379 $temp = self::_getFile($locale, '/ldml/localeDisplayNames/types/type', 'type'); 0380 } else { 0381 if (($value == 'calendar') or 0382 ($value == 'collation') or 0383 ($value == 'currency')) { 0384 $temp = self::_getFile($locale, '/ldml/localeDisplayNames/types/type[@key=\'' . $value . '\']', 'type'); 0385 } else { 0386 $temp = self::_getFile($locale, '/ldml/localeDisplayNames/types/type[@type=\'' . $value . '\']', 'type'); 0387 } 0388 } 0389 break; 0390 0391 case 'layout': 0392 $temp = self::_getFile($locale, '/ldml/layout/orientation/characterOrder', '', 'characterOrder'); 0393 $temp += self::_getFile($locale, '/ldml/layout/orientation/lineOrder', '', 'lineOrder'); 0394 break; 0395 0396 case 'contexttransform': 0397 if (empty($value)) { 0398 $value = 'uiListOrMenu'; 0399 } 0400 $temp = self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'languages\']/contextTransform[@type=\''.$value.'\']', '', 'languages'); 0401 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'day-format-except-narrow\']/contextTransform[@type=\''.$value.'\']', '', 'day-format-except-narrow'); 0402 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'day-standalone-except-narrow\']/contextTransform[@type=\''.$value.'\']', '', 'day-standalone-except-narrow'); 0403 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'day-narrow\']/contextTransform[@type=\''.$value.'\']', '', 'day-narrow'); 0404 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'month-format-except-narrow\']/contextTransform[@type=\''.$value.'\']', '', 'month-format-except-narrow'); 0405 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'month-standalone-except-narrow\']/contextTransform[@type=\''.$value.'\']', '', 'month-standalone-except-narrow'); 0406 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'month-narrow\']/contextTransform[@type=\''.$value.'\']', '', 'month-narrow'); 0407 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'script\']/contextTransform[@type=\''.$value.'\']', '', 'script'); 0408 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'territory\']/contextTransform[@type=\''.$value.'\']', '', 'territory'); 0409 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'variant\']/contextTransform[@type=\''.$value.'\']', '', 'variant'); 0410 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'key\']/contextTransform[@type=\''.$value.'\']', '', 'key'); 0411 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'type\']/contextTransform[@type=\''.$value.'\']', '', 'type'); 0412 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'era-name\']/contextTransform[@type=\''.$value.'\']', '', 'era-name'); 0413 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'era-abbr\']/contextTransform[@type=\''.$value.'\']', '', 'era-abbr'); 0414 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'era-narrow\']/contextTransform[@type=\''.$value.'\']', '', 'era-narrow'); 0415 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'quater-format-wide\']/contextTransform[@type=\''.$value.'\']', '', 'quater-format-wide'); 0416 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'quater-standalone-wide\']/contextTransform[@type=\''.$value.'\']', '', 'quater-standalone-wide'); 0417 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'quater-abbreviated\']/contextTransform[@type=\''.$value.'\']', '', 'quater-abbreviated'); 0418 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'quater-narrow\']/contextTransform[@type=\''.$value.'\']', '', 'quater-narrow'); 0419 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'calendar-field\']/contextTransform[@type=\''.$value.'\']', '', 'calendar-field'); 0420 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'symbol\']/contextTransform[@type=\''.$value.'\']', '', 'symbol'); 0421 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'tense\']/contextTransform[@type=\''.$value.'\']', '', 'tense'); 0422 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'zone-exemplarCity\']/contextTransform[@type=\''.$value.'\']', '', 'zone-exemplarCity'); 0423 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'zone-long\']/contextTransform[@type=\''.$value.'\']', '', 'zone-long'); 0424 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'zone-short\']/contextTransform[@type=\''.$value.'\']', '', 'zone-short'); 0425 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'metazone-long\']/contextTransform[@type=\''.$value.'\']', '', 'metazone-long'); 0426 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'metazone-short\']/contextTransform[@type=\''.$value.'\']', '', 'metazone-short'); 0427 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'displayName-count\']/contextTransform[@type=\''.$value.'\']', '', 'displayName-count'); 0428 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'displayName\']/contextTransform[@type=\''.$value.'\']', '', 'displayName'); 0429 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'unit-pattern\']/contextTransform[@type=\''.$value.'\']', '', 'unit-pattern'); 0430 break; 0431 0432 case 'characters': 0433 $temp = self::_getFile($locale, '/ldml/characters/exemplarCharacters', '', 'characters'); 0434 $temp += self::_getFile($locale, '/ldml/characters/exemplarCharacters[@type=\'auxiliary\']', '', 'auxiliary'); 0435 // $temp += self::_getFile($locale, '/ldml/characters/exemplarCharacters[@type=\'currencySymbol\']', '', 'currencySymbol'); 0436 break; 0437 0438 case 'delimiters': 0439 $temp = self::_getFile($locale, '/ldml/delimiters/quotationStart', '', 'quoteStart'); 0440 $temp += self::_getFile($locale, '/ldml/delimiters/quotationEnd', '', 'quoteEnd'); 0441 $temp += self::_getFile($locale, '/ldml/delimiters/alternateQuotationStart', '', 'quoteStartAlt'); 0442 $temp += self::_getFile($locale, '/ldml/delimiters/alternateQuotationEnd', '', 'quoteEndAlt'); 0443 break; 0444 0445 case 'measurement': 0446 $temp = self::_getFile('supplementalData', '/supplementalData/measurementData/measurementSystem[@type=\'metric\']', 'territories', 'metric'); 0447 $temp += self::_getFile('supplementalData', '/supplementalData/measurementData/measurementSystem[@type=\'US\']', 'territories', 'US'); 0448 $temp += self::_getFile('supplementalData', '/supplementalData/measurementData/paperSize[@type=\'A4\']', 'territories', 'A4'); 0449 $temp += self::_getFile('supplementalData', '/supplementalData/measurementData/paperSize[@type=\'US-Letter\']', 'territories', 'US-Letter'); 0450 break; 0451 0452 case 'months': 0453 if (empty($value)) { 0454 $value = "gregorian"; 0455 } 0456 $temp['context'] = "format"; 0457 $temp['default'] = "wide"; 0458 $temp['format']['abbreviated'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'format\']/monthWidth[@type=\'abbreviated\']/month', 'type'); 0459 $temp['format']['narrow'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'format\']/monthWidth[@type=\'narrow\']/month', 'type'); 0460 $temp['format']['wide'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'format\']/monthWidth[@type=\'wide\']/month', 'type'); 0461 $temp['stand-alone']['abbreviated'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'stand-alone\']/monthWidth[@type=\'abbreviated\']/month', 'type'); 0462 $temp['stand-alone']['narrow'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'stand-alone\']/monthWidth[@type=\'narrow\']/month', 'type'); 0463 $temp['stand-alone']['wide'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'stand-alone\']/monthWidth[@type=\'wide\']/month', 'type'); 0464 break; 0465 0466 case 'month': 0467 if (empty($value)) { 0468 $value = array("gregorian", "format", "wide"); 0469 } 0470 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/months/monthContext[@type=\'' . $value[1] . '\']/monthWidth[@type=\'' . $value[2] . '\']/month', 'type'); 0471 break; 0472 0473 case 'days': 0474 if (empty($value)) { 0475 $value = "gregorian"; 0476 } 0477 $temp['context'] = "format"; 0478 $temp['default'] = "wide"; 0479 $temp['format']['abbreviated'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'format\']/dayWidth[@type=\'abbreviated\']/day', 'type'); 0480 $temp['format']['narrow'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'format\']/dayWidth[@type=\'narrow\']/day', 'type'); 0481 $temp['format']['wide'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'format\']/dayWidth[@type=\'wide\']/day', 'type'); 0482 $temp['stand-alone']['abbreviated'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'stand-alone\']/dayWidth[@type=\'abbreviated\']/day', 'type'); 0483 $temp['stand-alone']['narrow'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'stand-alone\']/dayWidth[@type=\'narrow\']/day', 'type'); 0484 $temp['stand-alone']['wide'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'stand-alone\']/dayWidth[@type=\'wide\']/day', 'type'); 0485 break; 0486 0487 case 'day': 0488 if (empty($value)) { 0489 $value = array("gregorian", "format", "wide"); 0490 } 0491 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/days/dayContext[@type=\'' . $value[1] . '\']/dayWidth[@type=\'' . $value[2] . '\']/day', 'type'); 0492 break; 0493 0494 case 'week': 0495 $minDays = self::_calendarDetail($locale, self::_getFile('supplementalData', '/supplementalData/weekData/minDays', 'territories')); 0496 $firstDay = self::_calendarDetail($locale, self::_getFile('supplementalData', '/supplementalData/weekData/firstDay', 'territories')); 0497 $weekStart = self::_calendarDetail($locale, self::_getFile('supplementalData', '/supplementalData/weekData/weekendStart', 'territories')); 0498 $weekEnd = self::_calendarDetail($locale, self::_getFile('supplementalData', '/supplementalData/weekData/weekendEnd', 'territories')); 0499 0500 $temp = self::_getFile('supplementalData', "/supplementalData/weekData/minDays[@territories='" . $minDays . "']", 'count', 'minDays'); 0501 $temp += self::_getFile('supplementalData', "/supplementalData/weekData/firstDay[@territories='" . $firstDay . "']", 'day', 'firstDay'); 0502 $temp += self::_getFile('supplementalData', "/supplementalData/weekData/weekendStart[@territories='" . $weekStart . "']", 'day', 'weekendStart'); 0503 $temp += self::_getFile('supplementalData', "/supplementalData/weekData/weekendEnd[@territories='" . $weekEnd . "']", 'day', 'weekendEnd'); 0504 break; 0505 0506 case 'quarters': 0507 if (empty($value)) { 0508 $value = "gregorian"; 0509 } 0510 $temp['format']['abbreviated'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/quarters/quarterContext[@type=\'format\']/quarterWidth[@type=\'abbreviated\']/quarter', 'type'); 0511 $temp['format']['narrow'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/quarters/quarterContext[@type=\'format\']/quarterWidth[@type=\'narrow\']/quarter', 'type'); 0512 $temp['format']['wide'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/quarters/quarterContext[@type=\'format\']/quarterWidth[@type=\'wide\']/quarter', 'type'); 0513 $temp['stand-alone']['abbreviated'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/quarters/quarterContext[@type=\'stand-alone\']/quarterWidth[@type=\'abbreviated\']/quarter', 'type'); 0514 $temp['stand-alone']['narrow'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/quarters/quarterContext[@type=\'stand-alone\']/quarterWidth[@type=\'narrow\']/quarter', 'type'); 0515 $temp['stand-alone']['wide'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/quarters/quarterContext[@type=\'stand-alone\']/quarterWidth[@type=\'wide\']/quarter', 'type'); 0516 break; 0517 0518 case 'quarter': 0519 if (empty($value)) { 0520 $value = array("gregorian", "format", "wide"); 0521 } 0522 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/quarters/quarterContext[@type=\'' . $value[1] . '\']/quarterWidth[@type=\'' . $value[2] . '\']/quarter', 'type'); 0523 break; 0524 0525 case 'eras': 0526 if (empty($value)) { 0527 $value = "gregorian"; 0528 } 0529 $temp['names'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/eras/eraNames/era', 'type'); 0530 $temp['abbreviated'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/eras/eraAbbr/era', 'type'); 0531 $temp['narrow'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/eras/eraNarrow/era', 'type'); 0532 break; 0533 0534 case 'era': 0535 if (empty($value)) { 0536 $value = array("gregorian", "Abbr"); 0537 } 0538 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/eras/era' . $value[1] . '/era', 'type'); 0539 break; 0540 0541 case 'date': 0542 if (empty($value)) { 0543 $value = "gregorian"; 0544 } 0545 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateFormats/dateFormatLength[@type=\'full\']/dateFormat/pattern', '', 'full'); 0546 $temp += self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateFormats/dateFormatLength[@type=\'long\']/dateFormat/pattern', '', 'long'); 0547 $temp += self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateFormats/dateFormatLength[@type=\'medium\']/dateFormat/pattern', '', 'medium'); 0548 $temp += self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateFormats/dateFormatLength[@type=\'short\']/dateFormat/pattern', '', 'short'); 0549 break; 0550 0551 case 'time': 0552 if (empty($value)) { 0553 $value = "gregorian"; 0554 } 0555 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/timeFormats/timeFormatLength[@type=\'full\']/timeFormat/pattern', '', 'full'); 0556 $temp += self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/timeFormats/timeFormatLength[@type=\'long\']/timeFormat/pattern', '', 'long'); 0557 $temp += self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/timeFormats/timeFormatLength[@type=\'medium\']/timeFormat/pattern', '', 'medium'); 0558 $temp += self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/timeFormats/timeFormatLength[@type=\'short\']/timeFormat/pattern', '', 'short'); 0559 break; 0560 0561 case 'datetime': 0562 if (empty($value)) { 0563 $value = "gregorian"; 0564 } 0565 0566 $timefull = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/timeFormats/timeFormatLength[@type=\'full\']/timeFormat/pattern', '', 'full'); 0567 $timelong = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/timeFormats/timeFormatLength[@type=\'long\']/timeFormat/pattern', '', 'long'); 0568 $timemedi = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/timeFormats/timeFormatLength[@type=\'medium\']/timeFormat/pattern', '', 'medi'); 0569 $timeshor = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/timeFormats/timeFormatLength[@type=\'short\']/timeFormat/pattern', '', 'shor'); 0570 0571 $datefull = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateFormats/dateFormatLength[@type=\'full\']/dateFormat/pattern', '', 'full'); 0572 $datelong = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateFormats/dateFormatLength[@type=\'long\']/dateFormat/pattern', '', 'long'); 0573 $datemedi = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateFormats/dateFormatLength[@type=\'medium\']/dateFormat/pattern', '', 'medi'); 0574 $dateshor = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateFormats/dateFormatLength[@type=\'short\']/dateFormat/pattern', '', 'shor'); 0575 0576 $full = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateTimeFormats/dateTimeFormatLength[@type=\'full\']/dateTimeFormat/pattern', '', 'full'); 0577 $long = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateTimeFormats/dateTimeFormatLength[@type=\'long\']/dateTimeFormat/pattern', '', 'long'); 0578 $medi = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateTimeFormats/dateTimeFormatLength[@type=\'medium\']/dateTimeFormat/pattern', '', 'medi'); 0579 $shor = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateTimeFormats/dateTimeFormatLength[@type=\'short\']/dateTimeFormat/pattern', '', 'shor'); 0580 0581 $temp['full'] = str_replace(array('{0}', '{1}'), array($timefull['full'], $datefull['full']), $full['full']); 0582 $temp['long'] = str_replace(array('{0}', '{1}'), array($timelong['long'], $datelong['long']), $long['long']); 0583 $temp['medium'] = str_replace(array('{0}', '{1}'), array($timemedi['medi'], $datemedi['medi']), $medi['medi']); 0584 $temp['short'] = str_replace(array('{0}', '{1}'), array($timeshor['shor'], $dateshor['shor']), $shor['shor']); 0585 break; 0586 0587 case 'dateitem': 0588 if (empty($value)) { 0589 $value = "gregorian"; 0590 } 0591 $_temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateTimeFormats/availableFormats/dateFormatItem', 'id'); 0592 foreach($_temp as $key => $found) { 0593 $temp += self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateTimeFormats/availableFormats/dateFormatItem[@id=\'' . $key . '\']', '', $key); 0594 } 0595 break; 0596 0597 case 'dateinterval': 0598 if (empty($value)) { 0599 $value = "gregorian"; 0600 } 0601 $_temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateTimeFormats/intervalFormats/intervalFormatItem', 'id'); 0602 foreach($_temp as $key => $found) { 0603 $temp[$key] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateTimeFormats/intervalFormats/intervalFormatItem[@id=\'' . $key . '\']/greatestDifference', 'id'); 0604 } 0605 break; 0606 0607 case 'field': 0608 if (empty($value)) { 0609 $value = "gregorian"; 0610 } 0611 $temp2 = self::_getFile($locale, '/ldml/dates/fields/field', 'type'); 0612 // $temp2 = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/fields/field', 'type'); 0613 foreach ($temp2 as $key => $keyvalue) { 0614 $temp += self::_getFile($locale, '/ldml/dates/fields/field[@type=\'' . $key . '\']/displayName', '', $key); 0615 // $temp += self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/fields/field[@type=\'' . $key . '\']/displayName', '', $key); 0616 } 0617 break; 0618 0619 case 'relative': 0620 if (empty($value)) { 0621 $value = "day"; 0622 } 0623 $temp = self::_getFile($locale, '/ldml/dates/fields/field[@type=\'' . $value . '\']/relative', 'type'); 0624 break; 0625 0626 case 'symbols': 0627 $temp = self::_getFile($locale, '/ldml/numbers/symbols/decimal', '', 'decimal'); 0628 $temp += self::_getFile($locale, '/ldml/numbers/symbols/group', '', 'group'); 0629 $temp += self::_getFile($locale, '/ldml/numbers/symbols/list', '', 'list'); 0630 $temp += self::_getFile($locale, '/ldml/numbers/symbols/percentSign', '', 'percent'); 0631 $temp += self::_getFile($locale, '/ldml/numbers/symbols/nativeZeroDigit', '', 'zero'); 0632 $temp += self::_getFile($locale, '/ldml/numbers/symbols/patternDigit', '', 'pattern'); 0633 $temp += self::_getFile($locale, '/ldml/numbers/symbols/plusSign', '', 'plus'); 0634 $temp += self::_getFile($locale, '/ldml/numbers/symbols/minusSign', '', 'minus'); 0635 $temp += self::_getFile($locale, '/ldml/numbers/symbols/exponential', '', 'exponent'); 0636 $temp += self::_getFile($locale, '/ldml/numbers/symbols/perMille', '', 'mille'); 0637 $temp += self::_getFile($locale, '/ldml/numbers/symbols/infinity', '', 'infinity'); 0638 $temp += self::_getFile($locale, '/ldml/numbers/symbols/nan', '', 'nan'); 0639 break; 0640 0641 case 'nametocurrency': 0642 $_temp = self::_getFile($locale, '/ldml/numbers/currencies/currency', 'type'); 0643 foreach ($_temp as $key => $found) { 0644 $temp += self::_getFile($locale, '/ldml/numbers/currencies/currency[@type=\'' . $key . '\']/displayName', '', $key); 0645 } 0646 break; 0647 0648 case 'currencytoname': 0649 $_temp = self::_getFile($locale, '/ldml/numbers/currencies/currency', 'type'); 0650 foreach ($_temp as $key => $keyvalue) { 0651 $val = self::_getFile($locale, '/ldml/numbers/currencies/currency[@type=\'' . $key . '\']/displayName', '', $key); 0652 if (!isset($val[$key])) { 0653 continue; 0654 } 0655 if (!isset($temp[$val[$key]])) { 0656 $temp[$val[$key]] = $key; 0657 } else { 0658 $temp[$val[$key]] .= " " . $key; 0659 } 0660 } 0661 break; 0662 0663 case 'currencysymbol': 0664 $_temp = self::_getFile($locale, '/ldml/numbers/currencies/currency', 'type'); 0665 foreach ($_temp as $key => $found) { 0666 $temp += self::_getFile($locale, '/ldml/numbers/currencies/currency[@type=\'' . $key . '\']/symbol', '', $key); 0667 } 0668 break; 0669 0670 case 'question': 0671 $temp = self::_getFile($locale, '/ldml/posix/messages/yesstr', '', 'yes'); 0672 $temp += self::_getFile($locale, '/ldml/posix/messages/nostr', '', 'no'); 0673 break; 0674 0675 case 'currencyfraction': 0676 $_temp = self::_getFile('supplementalData', '/supplementalData/currencyData/fractions/info', 'iso4217'); 0677 foreach ($_temp as $key => $found) { 0678 $temp += self::_getFile('supplementalData', '/supplementalData/currencyData/fractions/info[@iso4217=\'' . $key . '\']', 'digits', $key); 0679 } 0680 break; 0681 0682 case 'currencyrounding': 0683 $_temp = self::_getFile('supplementalData', '/supplementalData/currencyData/fractions/info', 'iso4217'); 0684 foreach ($_temp as $key => $found) { 0685 $temp += self::_getFile('supplementalData', '/supplementalData/currencyData/fractions/info[@iso4217=\'' . $key . '\']', 'rounding', $key); 0686 } 0687 break; 0688 0689 case 'currencytoregion': 0690 $_temp = self::_getFile('supplementalData', '/supplementalData/currencyData/region', 'iso3166'); 0691 foreach ($_temp as $key => $keyvalue) { 0692 $temp += self::_getFile('supplementalData', '/supplementalData/currencyData/region[@iso3166=\'' . $key . '\']/currency', 'iso4217', $key); 0693 } 0694 break; 0695 0696 case 'regiontocurrency': 0697 $_temp = self::_getFile('supplementalData', '/supplementalData/currencyData/region', 'iso3166'); 0698 foreach ($_temp as $key => $keyvalue) { 0699 $val = self::_getFile('supplementalData', '/supplementalData/currencyData/region[@iso3166=\'' . $key . '\']/currency', 'iso4217', $key); 0700 if (!isset($val[$key])) { 0701 continue; 0702 } 0703 if (!isset($temp[$val[$key]])) { 0704 $temp[$val[$key]] = $key; 0705 } else { 0706 $temp[$val[$key]] .= " " . $key; 0707 } 0708 } 0709 break; 0710 0711 case 'regiontoterritory': 0712 $_temp = self::_getFile('supplementalData', '/supplementalData/territoryContainment/group', 'type'); 0713 foreach ($_temp as $key => $found) { 0714 $temp += self::_getFile('supplementalData', '/supplementalData/territoryContainment/group[@type=\'' . $key . '\']', 'contains', $key); 0715 } 0716 break; 0717 0718 case 'territorytoregion': 0719 $_temp2 = self::_getFile('supplementalData', '/supplementalData/territoryContainment/group', 'type'); 0720 $_temp = array(); 0721 foreach ($_temp2 as $key => $found) { 0722 $_temp += self::_getFile('supplementalData', '/supplementalData/territoryContainment/group[@type=\'' . $key . '\']', 'contains', $key); 0723 } 0724 foreach($_temp as $key => $found) { 0725 $_temp3 = explode(" ", $found); 0726 foreach($_temp3 as $found3) { 0727 if (!isset($temp[$found3])) { 0728 $temp[$found3] = (string) $key; 0729 } else { 0730 $temp[$found3] .= " " . $key; 0731 } 0732 } 0733 } 0734 break; 0735 0736 case 'scripttolanguage': 0737 $_temp = self::_getFile('supplementalData', '/supplementalData/languageData/language', 'type'); 0738 foreach ($_temp as $key => $found) { 0739 $temp += self::_getFile('supplementalData', '/supplementalData/languageData/language[@type=\'' . $key . '\']', 'scripts', $key); 0740 if (empty($temp[$key])) { 0741 unset($temp[$key]); 0742 } 0743 } 0744 break; 0745 0746 case 'languagetoscript': 0747 $_temp2 = self::_getFile('supplementalData', '/supplementalData/languageData/language', 'type'); 0748 $_temp = array(); 0749 foreach ($_temp2 as $key => $found) { 0750 $_temp += self::_getFile('supplementalData', '/supplementalData/languageData/language[@type=\'' . $key . '\']', 'scripts', $key); 0751 } 0752 foreach($_temp as $key => $found) { 0753 $_temp3 = explode(" ", $found); 0754 foreach($_temp3 as $found3) { 0755 if (empty($found3)) { 0756 continue; 0757 } 0758 if (!isset($temp[$found3])) { 0759 $temp[$found3] = (string) $key; 0760 } else { 0761 $temp[$found3] .= " " . $key; 0762 } 0763 } 0764 } 0765 break; 0766 0767 case 'territorytolanguage': 0768 $_temp = self::_getFile('supplementalData', '/supplementalData/languageData/language', 'type'); 0769 foreach ($_temp as $key => $found) { 0770 $temp += self::_getFile('supplementalData', '/supplementalData/languageData/language[@type=\'' . $key . '\']', 'territories', $key); 0771 if (empty($temp[$key])) { 0772 unset($temp[$key]); 0773 } 0774 } 0775 break; 0776 0777 case 'languagetoterritory': 0778 $_temp2 = self::_getFile('supplementalData', '/supplementalData/languageData/language', 'type'); 0779 $_temp = array(); 0780 foreach ($_temp2 as $key => $found) { 0781 $_temp += self::_getFile('supplementalData', '/supplementalData/languageData/language[@type=\'' . $key . '\']', 'territories', $key); 0782 } 0783 foreach($_temp as $key => $found) { 0784 $_temp3 = explode(" ", $found); 0785 foreach($_temp3 as $found3) { 0786 if (empty($found3)) { 0787 continue; 0788 } 0789 if (!isset($temp[$found3])) { 0790 $temp[$found3] = (string) $key; 0791 } else { 0792 $temp[$found3] .= " " . $key; 0793 } 0794 } 0795 } 0796 break; 0797 0798 case 'timezonetowindows': 0799 $_temp = self::_getFile('windowsZones', '/supplementalData/windowsZones/mapTimezones/mapZone', 'other'); 0800 foreach ($_temp as $key => $found) { 0801 $temp += self::_getFile('windowsZones', '/supplementalData/windowsZones/mapTimezones/mapZone[@other=\'' . $key . '\']', 'type', $key); 0802 } 0803 break; 0804 0805 case 'windowstotimezone': 0806 $_temp = self::_getFile('windowsZones', '/supplementalData/windowsZones/mapTimezones/mapZone', 'type'); 0807 foreach ($_temp as $key => $found) { 0808 $temp += self::_getFile('windowsZones', '/supplementalData/windowsZones/mapTimezones/mapZone[@type=\'' .$key . '\']', 'other', $key); 0809 } 0810 break; 0811 0812 case 'territorytotimezone': 0813 $_temp = self::_getFile('metaZones', '/supplementalData/metaZones/mapTimezones/mapZone', 'type'); 0814 foreach ($_temp as $key => $found) { 0815 $temp += self::_getFile('metaZones', '/supplementalData/metaZones/mapTimezones/mapZone[@type=\'' . $key . '\']', 'territory', $key); 0816 } 0817 break; 0818 0819 case 'timezonetoterritory': 0820 $_temp = self::_getFile('metaZones', '/supplementalData/metaZones/mapTimezones/mapZone', 'territory'); 0821 foreach ($_temp as $key => $found) { 0822 $temp += self::_getFile('metaZones', '/supplementalData/metaZones/mapTimezones/mapZone[@territory=\'' . $key . '\']', 'type', $key); 0823 } 0824 break; 0825 0826 case 'citytotimezone': 0827 $_temp = self::_getFile($locale, '/ldml/dates/timeZoneNames/zone', 'type'); 0828 foreach($_temp as $key => $found) { 0829 $temp += self::_getFile($locale, '/ldml/dates/timeZoneNames/zone[@type=\'' . $key . '\']/exemplarCity', '', $key); 0830 } 0831 break; 0832 0833 case 'timezonetocity': 0834 $_temp = self::_getFile($locale, '/ldml/dates/timeZoneNames/zone', 'type'); 0835 $temp = array(); 0836 foreach($_temp as $key => $found) { 0837 $temp += self::_getFile($locale, '/ldml/dates/timeZoneNames/zone[@type=\'' . $key . '\']/exemplarCity', '', $key); 0838 if (!empty($temp[$key])) { 0839 $temp[$temp[$key]] = $key; 0840 } 0841 unset($temp[$key]); 0842 } 0843 break; 0844 0845 case 'phonetoterritory': 0846 $_temp = self::_getFile('telephoneCodeData', '/supplementalData/telephoneCodeData/codesByTerritory', 'territory'); 0847 foreach ($_temp as $key => $keyvalue) { 0848 $temp += self::_getFile('telephoneCodeData', '/supplementalData/telephoneCodeData/codesByTerritory[@territory=\'' . $key . '\']/telephoneCountryCode', 'code', $key); 0849 } 0850 break; 0851 0852 case 'territorytophone': 0853 $_temp = self::_getFile('telephoneCodeData', '/supplementalData/telephoneCodeData/codesByTerritory', 'territory'); 0854 foreach ($_temp as $key => $keyvalue) { 0855 $val = self::_getFile('telephoneCodeData', '/supplementalData/telephoneCodeData/codesByTerritory[@territory=\'' . $key . '\']/telephoneCountryCode', 'code', $key); 0856 if (!isset($val[$key])) { 0857 continue; 0858 } 0859 if (!isset($temp[$val[$key]])) { 0860 $temp[$val[$key]] = $key; 0861 } else { 0862 $temp[$val[$key]] .= " " . $key; 0863 } 0864 } 0865 break; 0866 0867 case 'numerictoterritory': 0868 $_temp = self::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes', 'type'); 0869 foreach ($_temp as $key => $keyvalue) { 0870 $temp += self::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes[@type=\'' . $key . '\']', 'numeric', $key); 0871 } 0872 break; 0873 0874 case 'territorytonumeric': 0875 $_temp = self::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes', 'numeric'); 0876 foreach ($_temp as $key => $keyvalue) { 0877 $temp += self::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes[@numeric=\'' . $key . '\']', 'type', $key); 0878 } 0879 break; 0880 0881 case 'alpha3toterritory': 0882 $_temp = self::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes', 'type'); 0883 foreach ($_temp as $key => $keyvalue) { 0884 $temp += self::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes[@type=\'' . $key . '\']', 'alpha3', $key); 0885 } 0886 break; 0887 0888 case 'territorytoalpha3': 0889 $_temp = self::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes', 'alpha3'); 0890 foreach ($_temp as $key => $keyvalue) { 0891 $temp += self::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes[@alpha3=\'' . $key . '\']', 'type', $key); 0892 } 0893 break; 0894 0895 case 'postaltoterritory': 0896 $_temp = self::_getFile('postalCodeData', '/supplementalData/postalCodeData/postCodeRegex', 'territoryId'); 0897 foreach ($_temp as $key => $keyvalue) { 0898 $temp += self::_getFile('postalCodeData', '/supplementalData/postalCodeData/postCodeRegex[@territoryId=\'' . $key . '\']', 'territoryId'); 0899 } 0900 break; 0901 0902 case 'numberingsystem': 0903 $_temp = self::_getFile('numberingSystems', '/supplementalData/numberingSystems/numberingSystem', 'id'); 0904 foreach ($_temp as $key => $keyvalue) { 0905 $temp += self::_getFile('numberingSystems', '/supplementalData/numberingSystems/numberingSystem[@id=\'' . $key . '\']', 'digits', $key); 0906 if (empty($temp[$key])) { 0907 unset($temp[$key]); 0908 } 0909 } 0910 break; 0911 0912 case 'chartofallback': 0913 $_temp = self::_getFile('characters', '/supplementalData/characters/character-fallback/character', 'value'); 0914 foreach ($_temp as $key => $keyvalue) { 0915 $temp2 = self::_getFile('characters', '/supplementalData/characters/character-fallback/character[@value=\'' . $key . '\']/substitute', '', $key); 0916 $temp[current($temp2)] = $key; 0917 } 0918 break; 0919 0920 case 'fallbacktochar': 0921 $_temp = self::_getFile('characters', '/supplementalData/characters/character-fallback/character', 'value'); 0922 foreach ($_temp as $key => $keyvalue) { 0923 $temp += self::_getFile('characters', '/supplementalData/characters/character-fallback/character[@value=\'' . $key . '\']/substitute', '', $key); 0924 } 0925 break; 0926 0927 case 'localeupgrade': 0928 $_temp = self::_getFile('likelySubtags', '/supplementalData/likelySubtags/likelySubtag', 'from'); 0929 foreach ($_temp as $key => $keyvalue) { 0930 $temp += self::_getFile('likelySubtags', '/supplementalData/likelySubtags/likelySubtag[@from=\'' . $key . '\']', 'to', $key); 0931 } 0932 break; 0933 0934 case 'unit': 0935 $_temp = self::_getFile($locale, '/ldml/units/unitLength/unit', 'type'); 0936 foreach($_temp as $key => $keyvalue) { 0937 $_temp2 = self::_getFile($locale, '/ldml/units/unitLength/unit[@type=\'' . $key . '\']/unitPattern', 'count'); 0938 $temp[$key] = $_temp2; 0939 } 0940 break; 0941 0942 default : 0943 // require_once 'Zend/Locale/Exception.php'; 0944 throw new Zend_Locale_Exception("Unknown list ($path) for parsing locale data."); 0945 break; 0946 } 0947 0948 if (isset(self::$_cache)) { 0949 if (self::$_cacheTags) { 0950 self::$_cache->save( serialize($temp), $id, array('Zend_Locale')); 0951 } else { 0952 self::$_cache->save( serialize($temp), $id); 0953 } 0954 } 0955 0956 return $temp; 0957 } 0958 0959 /** 0960 * Read the LDML file, get a single path defined value 0961 * 0962 * @param string $locale 0963 * @param string $path 0964 * @param bool|string $value 0965 * @return string 0966 * @throws Zend_Locale_Exception 0967 */ 0968 public static function getContent($locale, $path, $value = false) 0969 { 0970 $locale = self::_checkLocale($locale); 0971 0972 if (!isset(self::$_cache) && !self::$_cacheDisabled) { 0973 // require_once 'Zend/Cache.php'; 0974 self::$_cache = Zend_Cache::factory( 0975 'Core', 0976 'File', 0977 array('automatic_serialization' => true), 0978 array()); 0979 } 0980 0981 $val = $value; 0982 if (is_array($value)) { 0983 $val = implode('_' , $value); 0984 } 0985 $val = urlencode($val); 0986 $id = self::_filterCacheId('Zend_LocaleC_' . $locale . '_' . $path . '_' . $val); 0987 if (!self::$_cacheDisabled && ($result = self::$_cache->load($id))) { 0988 return unserialize($result); 0989 } 0990 0991 switch(strtolower($path)) { 0992 case 'language': 0993 $temp = self::_getFile($locale, '/ldml/localeDisplayNames/languages/language[@type=\'' . $value . '\']', 'type'); 0994 break; 0995 0996 case 'script': 0997 $temp = self::_getFile($locale, '/ldml/localeDisplayNames/scripts/script[@type=\'' . $value . '\']', 'type'); 0998 break; 0999 1000 case 'country': 1001 case 'territory': 1002 $temp = self::_getFile($locale, '/ldml/localeDisplayNames/territories/territory[@type=\'' . $value . '\']', 'type'); 1003 break; 1004 1005 case 'variant': 1006 $temp = self::_getFile($locale, '/ldml/localeDisplayNames/variants/variant[@type=\'' . $value . '\']', 'type'); 1007 break; 1008 1009 case 'key': 1010 $temp = self::_getFile($locale, '/ldml/localeDisplayNames/keys/key[@type=\'' . $value . '\']', 'type'); 1011 break; 1012 1013 case 'defaultcalendar': 1014 $givenLocale = new Zend_Locale($locale); 1015 $territory = $givenLocale->getRegion(); 1016 unset($givenLocale); 1017 $temp = self::_getFile('supplementalData', '/supplementalData/calendarPreferenceData/calendarPreference[contains(@territories,\'' . $territory . '\')]', 'ordering', 'ordering'); 1018 if (isset($temp['ordering'])) { 1019 list($temp) = explode(' ', $temp['ordering']); 1020 } else { 1021 $temp = 'gregorian'; 1022 } 1023 break; 1024 1025 case 'monthcontext': 1026 /* default context is always 'format' 1027 if (empty ($value)) { 1028 $value = "gregorian"; 1029 } 1030 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/default', 'choice', 'context'); 1031 */ 1032 $temp = 'format'; 1033 break; 1034 1035 case 'defaultmonth': 1036 /* default width is always 'wide' 1037 if (empty ($value)) { 1038 $value = "gregorian"; 1039 } 1040 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'format\']/default', 'choice', 'default'); 1041 */ 1042 $temp = 'wide'; 1043 break; 1044 1045 case 'month': 1046 if (!is_array($value)) { 1047 $temp = $value; 1048 $value = array("gregorian", "format", "wide", $temp); 1049 } 1050 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/months/monthContext[@type=\'' . $value[1] . '\']/monthWidth[@type=\'' . $value[2] . '\']/month[@type=\'' . $value[3] . '\']', 'type'); 1051 break; 1052 1053 case 'daycontext': 1054 /* default context is always 'format' 1055 if (empty($value)) { 1056 $value = "gregorian"; 1057 } 1058 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/default', 'choice', 'context'); 1059 */ 1060 $temp = 'format'; 1061 break; 1062 1063 case 'defaultday': 1064 /* default width is always 'wide' 1065 if (empty($value)) { 1066 $value = "gregorian"; 1067 } 1068 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'format\']/default', 'choice', 'default'); 1069 */ 1070 $temp = 'wide'; 1071 break; 1072 1073 case 'day': 1074 if (!is_array($value)) { 1075 $temp = $value; 1076 $value = array("gregorian", "format", "wide", $temp); 1077 } 1078 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/days/dayContext[@type=\'' . $value[1] . '\']/dayWidth[@type=\'' . $value[2] . '\']/day[@type=\'' . $value[3] . '\']', 'type'); 1079 break; 1080 1081 case 'quarter': 1082 if (!is_array($value)) { 1083 $temp = $value; 1084 $value = array("gregorian", "format", "wide", $temp); 1085 } 1086 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/quarters/quarterContext[@type=\'' . $value[1] . '\']/quarterWidth[@type=\'' . $value[2] . '\']/quarter[@type=\'' . $value[3] . '\']', 'type'); 1087 break; 1088 1089 case 'am': 1090 if (empty($value)) { 1091 $value = array("gregorian", "format", "wide"); 1092 } 1093 if (!is_array($value)) { 1094 $temp = $value; 1095 $value = array($temp, "format", "wide"); 1096 } 1097 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/dayPeriods/dayPeriodContext[@type=\'' . $value[1] . '\']/dayPeriodWidth[@type=\'' . $value[2] . '\']/dayPeriod[@type=\'am\']', '', 'dayPeriod'); 1098 break; 1099 1100 case 'pm': 1101 if (empty($value)) { 1102 $value = array("gregorian", "format", "wide"); 1103 } 1104 if (!is_array($value)) { 1105 $temp = $value; 1106 $value = array($temp, "format", "wide"); 1107 } 1108 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/dayPeriods/dayPeriodContext[@type=\'' . $value[1] . '\']/dayPeriodWidth[@type=\'' . $value[2] . '\']/dayPeriod[@type=\'pm\']', '', 'dayPeriod'); 1109 break; 1110 1111 case 'era': 1112 if (!is_array($value)) { 1113 $temp = $value; 1114 $value = array("gregorian", "Abbr", $temp); 1115 } 1116 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/eras/era' . $value[1] . '/era[@type=\'' . $value[2] . '\']', 'type'); 1117 break; 1118 1119 case 'defaultdate': 1120 /* default choice is deprecated in CDLR - should be always medium here 1121 if (empty($value)) { 1122 $value = "gregorian"; 1123 } 1124 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateFormats/default', 'choice', 'default'); 1125 */ 1126 $temp = 'medium'; 1127 break; 1128 1129 case 'date': 1130 if (empty($value)) { 1131 $value = array("gregorian", "medium"); 1132 } 1133 if (!is_array($value)) { 1134 $temp = $value; 1135 $value = array("gregorian", $temp); 1136 } 1137 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/dateFormats/dateFormatLength[@type=\'' . $value[1] . '\']/dateFormat/pattern', '', 'pattern'); 1138 break; 1139 1140 case 'defaulttime': 1141 /* default choice is deprecated in CDLR - should be always medium here 1142 if (empty($value)) { 1143 $value = "gregorian"; 1144 } 1145 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/timeFormats/default', 'choice', 'default'); 1146 */ 1147 $temp = 'medium'; 1148 break; 1149 1150 case 'time': 1151 if (empty($value)) { 1152 $value = array("gregorian", "medium"); 1153 } 1154 if (!is_array($value)) { 1155 $temp = $value; 1156 $value = array("gregorian", $temp); 1157 } 1158 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/timeFormats/timeFormatLength[@type=\'' . $value[1] . '\']/timeFormat/pattern', '', 'pattern'); 1159 break; 1160 1161 case 'datetime': 1162 if (empty($value)) { 1163 $value = array("gregorian", "medium"); 1164 } 1165 if (!is_array($value)) { 1166 $temp = $value; 1167 $value = array("gregorian", $temp); 1168 } 1169 1170 $date = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/dateFormats/dateFormatLength[@type=\'' . $value[1] . '\']/dateFormat/pattern', '', 'pattern'); 1171 $time = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/timeFormats/timeFormatLength[@type=\'' . $value[1] . '\']/timeFormat/pattern', '', 'pattern'); 1172 $datetime = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/dateTimeFormats/dateTimeFormatLength[@type=\'' . $value[1] . '\']/dateTimeFormat/pattern', '', 'pattern'); 1173 $temp = str_replace(array('{0}', '{1}'), array(current($time), current($date)), current($datetime)); 1174 break; 1175 1176 case 'dateitem': 1177 if (empty($value)) { 1178 $value = array("gregorian", "yyMMdd"); 1179 } 1180 if (!is_array($value)) { 1181 $temp = $value; 1182 $value = array("gregorian", $temp); 1183 } 1184 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/dateTimeFormats/availableFormats/dateFormatItem[@id=\'' . $value[1] . '\']', ''); 1185 break; 1186 1187 case 'dateinterval': 1188 if (empty($value)) { 1189 $value = array("gregorian", "yMd", "y"); 1190 } 1191 if (!is_array($value)) { 1192 $temp = $value; 1193 $value = array("gregorian", $temp, $temp[0]); 1194 } 1195 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/dateTimeFormats/intervalFormats/intervalFormatItem[@id=\'' . $value[1] . '\']/greatestDifference[@id=\'' . $value[2] . '\']', ''); 1196 break; 1197 1198 case 'field': 1199 if (!is_array($value)) { 1200 $temp = $value; 1201 $value = array("gregorian", $temp); 1202 } 1203 $temp = self::_getFile($locale, '/ldml/dates/fields/field[@type=\'' . $value[1] . '\']/displayName', '', $value[1]); 1204 break; 1205 1206 case 'relative': 1207 if (!is_array($value)) { 1208 $temp = $value; 1209 $value = array("gregorian", $temp); 1210 } 1211 $temp = self::_getFile($locale, '/ldml/dates/fields/field[@type=\'day\']/relative[@type=\'' . $value[1] . '\']', '', $value[1]); 1212 // $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/fields/field/relative[@type=\'' . $value[1] . '\']', '', $value[1]); 1213 break; 1214 1215 case 'defaultnumberingsystem': 1216 $temp = self::_getFile($locale, '/ldml/numbers/defaultNumberingSystem', '', 'default'); 1217 break; 1218 1219 case 'decimalnumber': 1220 $temp = self::_getFile($locale, '/ldml/numbers/decimalFormats/decimalFormatLength/decimalFormat/pattern', '', 'default'); 1221 break; 1222 1223 case 'scientificnumber': 1224 $temp = self::_getFile($locale, '/ldml/numbers/scientificFormats/scientificFormatLength/scientificFormat/pattern', '', 'default'); 1225 break; 1226 1227 case 'percentnumber': 1228 $temp = self::_getFile($locale, '/ldml/numbers/percentFormats/percentFormatLength/percentFormat/pattern', '', 'default'); 1229 break; 1230 1231 case 'currencynumber': 1232 $temp = self::_getFile($locale, '/ldml/numbers/currencyFormats/currencyFormatLength/currencyFormat/pattern', '', 'default'); 1233 break; 1234 1235 case 'nametocurrency': 1236 $temp = self::_getFile($locale, '/ldml/numbers/currencies/currency[@type=\'' . $value . '\']/displayName', '', $value); 1237 break; 1238 1239 case 'currencytoname': 1240 $temp = self::_getFile($locale, '/ldml/numbers/currencies/currency[@type=\'' . $value . '\']/displayName', '', $value); 1241 $_temp = self::_getFile($locale, '/ldml/numbers/currencies/currency', 'type'); 1242 $temp = array(); 1243 foreach ($_temp as $key => $keyvalue) { 1244 $val = self::_getFile($locale, '/ldml/numbers/currencies/currency[@type=\'' . $key . '\']/displayName', '', $key); 1245 if (!isset($val[$key]) or ($val[$key] != $value)) { 1246 continue; 1247 } 1248 if (!isset($temp[$val[$key]])) { 1249 $temp[$val[$key]] = $key; 1250 } else { 1251 $temp[$val[$key]] .= " " . $key; 1252 } 1253 } 1254 break; 1255 1256 case 'currencysymbol': 1257 $temp = self::_getFile($locale, '/ldml/numbers/currencies/currency[@type=\'' . $value . '\']/symbol', '', $value); 1258 break; 1259 1260 case 'question': 1261 $temp = self::_getFile($locale, '/ldml/posix/messages/' . $value . 'str', '', $value); 1262 break; 1263 1264 case 'currencyfraction': 1265 if (empty($value)) { 1266 $value = "DEFAULT"; 1267 } 1268 $temp = self::_getFile('supplementalData', '/supplementalData/currencyData/fractions/info[@iso4217=\'' . $value . '\']', 'digits', 'digits'); 1269 break; 1270 1271 case 'currencyrounding': 1272 if (empty($value)) { 1273 $value = "DEFAULT"; 1274 } 1275 $temp = self::_getFile('supplementalData', '/supplementalData/currencyData/fractions/info[@iso4217=\'' . $value . '\']', 'rounding', 'rounding'); 1276 break; 1277 1278 case 'currencytoregion': 1279 $temp = self::_getFile('supplementalData', '/supplementalData/currencyData/region[@iso3166=\'' . $value . '\']/currency', 'iso4217', $value); 1280 break; 1281 1282 case 'regiontocurrency': 1283 $_temp = self::_getFile('supplementalData', '/supplementalData/currencyData/region', 'iso3166'); 1284 $temp = array(); 1285 foreach ($_temp as $key => $keyvalue) { 1286 $val = self::_getFile('supplementalData', '/supplementalData/currencyData/region[@iso3166=\'' . $key . '\']/currency', 'iso4217', $key); 1287 if (!isset($val[$key]) or ($val[$key] != $value)) { 1288 continue; 1289 } 1290 if (!isset($temp[$val[$key]])) { 1291 $temp[$val[$key]] = $key; 1292 } else { 1293 $temp[$val[$key]] .= " " . $key; 1294 } 1295 } 1296 break; 1297 1298 case 'regiontoterritory': 1299 $temp = self::_getFile('supplementalData', '/supplementalData/territoryContainment/group[@type=\'' . $value . '\']', 'contains', $value); 1300 break; 1301 1302 case 'territorytoregion': 1303 $_temp2 = self::_getFile('supplementalData', '/supplementalData/territoryContainment/group', 'type'); 1304 $_temp = array(); 1305 foreach ($_temp2 as $key => $found) { 1306 $_temp += self::_getFile('supplementalData', '/supplementalData/territoryContainment/group[@type=\'' . $key . '\']', 'contains', $key); 1307 } 1308 $temp = array(); 1309 foreach($_temp as $key => $found) { 1310 $_temp3 = explode(" ", $found); 1311 foreach($_temp3 as $found3) { 1312 if ($found3 !== $value) { 1313 continue; 1314 } 1315 if (!isset($temp[$found3])) { 1316 $temp[$found3] = (string) $key; 1317 } else { 1318 $temp[$found3] .= " " . $key; 1319 } 1320 } 1321 } 1322 break; 1323 1324 case 'scripttolanguage': 1325 $temp = self::_getFile('supplementalData', '/supplementalData/languageData/language[@type=\'' . $value . '\']', 'scripts', $value); 1326 break; 1327 1328 case 'languagetoscript': 1329 $_temp2 = self::_getFile('supplementalData', '/supplementalData/languageData/language', 'type'); 1330 $_temp = array(); 1331 foreach ($_temp2 as $key => $found) { 1332 $_temp += self::_getFile('supplementalData', '/supplementalData/languageData/language[@type=\'' . $key . '\']', 'scripts', $key); 1333 } 1334 $temp = array(); 1335 foreach($_temp as $key => $found) { 1336 $_temp3 = explode(" ", $found); 1337 foreach($_temp3 as $found3) { 1338 if ($found3 !== $value) { 1339 continue; 1340 } 1341 if (!isset($temp[$found3])) { 1342 $temp[$found3] = (string) $key; 1343 } else { 1344 $temp[$found3] .= " " . $key; 1345 } 1346 } 1347 } 1348 break; 1349 1350 case 'territorytolanguage': 1351 $temp = self::_getFile('supplementalData', '/supplementalData/languageData/language[@type=\'' . $value . '\']', 'territories', $value); 1352 break; 1353 1354 case 'languagetoterritory': 1355 $_temp2 = self::_getFile('supplementalData', '/supplementalData/languageData/language', 'type'); 1356 $_temp = array(); 1357 foreach ($_temp2 as $key => $found) { 1358 $_temp += self::_getFile('supplementalData', '/supplementalData/languageData/language[@type=\'' . $key . '\']', 'territories', $key); 1359 } 1360 $temp = array(); 1361 foreach($_temp as $key => $found) { 1362 $_temp3 = explode(" ", $found); 1363 foreach($_temp3 as $found3) { 1364 if ($found3 !== $value) { 1365 continue; 1366 } 1367 if (!isset($temp[$found3])) { 1368 $temp[$found3] = (string) $key; 1369 } else { 1370 $temp[$found3] .= " " . $key; 1371 } 1372 } 1373 } 1374 break; 1375 1376 case 'timezonetowindows': 1377 $temp = self::_getFile('windowsZones', '/supplementalData/windowsZones/mapTimezones/mapZone[@other=\''.$value.'\']', 'type', $value); 1378 break; 1379 1380 case 'windowstotimezone': 1381 $temp = self::_getFile('windowsZones', '/supplementalData/windowsZones/mapTimezones/mapZone[@type=\''.$value.'\']', 'other', $value); 1382 break; 1383 1384 case 'territorytotimezone': 1385 $temp = self::_getFile('metaZones', '/supplementalData/metaZones/mapTimezones/mapZone[@type=\'' . $value . '\']', 'territory', $value); 1386 break; 1387 1388 case 'timezonetoterritory': 1389 $temp = self::_getFile('metaZones', '/supplementalData/metaZones/mapTimezones/mapZone[@territory=\'' . $value . '\']', 'type', $value); 1390 break; 1391 1392 case 'citytotimezone': 1393 $temp = self::_getFile($locale, '/ldml/dates/timeZoneNames/zone[@type=\'' . $value . '\']/exemplarCity', '', $value); 1394 break; 1395 1396 case 'timezonetocity': 1397 $_temp = self::_getFile($locale, '/ldml/dates/timeZoneNames/zone', 'type'); 1398 $temp = array(); 1399 foreach($_temp as $key => $found) { 1400 $temp += self::_getFile($locale, '/ldml/dates/timeZoneNames/zone[@type=\'' . $key . '\']/exemplarCity', '', $key); 1401 if (!empty($temp[$key])) { 1402 if ($temp[$key] == $value) { 1403 $temp[$temp[$key]] = $key; 1404 } 1405 } 1406 unset($temp[$key]); 1407 } 1408 break; 1409 1410 case 'phonetoterritory': 1411 $temp = self::_getFile('telephoneCodeData', '/supplementalData/telephoneCodeData/codesByTerritory[@territory=\'' . $value . '\']/telephoneCountryCode', 'code', $value); 1412 break; 1413 1414 case 'territorytophone': 1415 $_temp2 = self::_getFile('telephoneCodeData', '/supplementalData/telephoneCodeData/codesByTerritory', 'territory'); 1416 $_temp = array(); 1417 foreach ($_temp2 as $key => $found) { 1418 $_temp += self::_getFile('telephoneCodeData', '/supplementalData/telephoneCodeData/codesByTerritory[@territory=\'' . $key . '\']/telephoneCountryCode', 'code', $key); 1419 } 1420 $temp = array(); 1421 foreach($_temp as $key => $found) { 1422 $_temp3 = explode(" ", $found); 1423 foreach($_temp3 as $found3) { 1424 if ($found3 !== $value) { 1425 continue; 1426 } 1427 if (!isset($temp[$found3])) { 1428 $temp[$found3] = (string) $key; 1429 } else { 1430 $temp[$found3] .= " " . $key; 1431 } 1432 } 1433 } 1434 break; 1435 1436 case 'numerictoterritory': 1437 $temp = self::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes[@type=\''.$value.'\']', 'numeric', $value); 1438 break; 1439 1440 case 'territorytonumeric': 1441 $temp = self::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes[@numeric=\''.$value.'\']', 'type', $value); 1442 break; 1443 1444 case 'alpha3toterritory': 1445 $temp = self::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes[@type=\''.$value.'\']', 'alpha3', $value); 1446 break; 1447 1448 case 'territorytoalpha3': 1449 $temp = self::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes[@alpha3=\''.$value.'\']', 'type', $value); 1450 break; 1451 1452 case 'postaltoterritory': 1453 $temp = self::_getFile('postalCodeData', '/supplementalData/postalCodeData/postCodeRegex[@territoryId=\'' . $value . '\']', 'territoryId'); 1454 break; 1455 1456 case 'numberingsystem': 1457 $temp = self::_getFile('numberingSystems', '/supplementalData/numberingSystems/numberingSystem[@id=\'' . strtolower($value) . '\']', 'digits', $value); 1458 break; 1459 1460 case 'chartofallback': 1461 $_temp = self::_getFile('characters', '/supplementalData/characters/character-fallback/character', 'value'); 1462 foreach ($_temp as $key => $keyvalue) { 1463 $temp2 = self::_getFile('characters', '/supplementalData/characters/character-fallback/character[@value=\'' . $key . '\']/substitute', '', $key); 1464 if (current($temp2) == $value) { 1465 $temp = $key; 1466 } 1467 } 1468 break; 1469 1470 $temp = self::_getFile('characters', '/supplementalData/characters/character-fallback/character[@value=\'' . $value . '\']/substitute', '', $value); 1471 break; 1472 1473 case 'fallbacktochar': 1474 $temp = self::_getFile('characters', '/supplementalData/characters/character-fallback/character[@value=\'' . $value . '\']/substitute', ''); 1475 break; 1476 1477 case 'localeupgrade': 1478 $temp = self::_getFile('likelySubtags', '/supplementalData/likelySubtags/likelySubtag[@from=\'' . $value . '\']', 'to', $value); 1479 break; 1480 1481 case 'unit': 1482 $temp = self::_getFile($locale, '/ldml/units/unitLength/unit[@type=\'' . $value[0] . '\']/unitPattern[@count=\'' . $value[1] . '\']', ''); 1483 break; 1484 1485 case 'parentlocale': 1486 if (false === $value) { 1487 $value = $locale; 1488 } 1489 $temp = self::_getFile('supplementalData', "/supplementalData/parentLocales/parentLocale[contains(@locales, '" . $value . "')]", 'parent', 'parent'); 1490 break; 1491 1492 default : 1493 // require_once 'Zend/Locale/Exception.php'; 1494 throw new Zend_Locale_Exception("Unknown detail ($path) for parsing locale data."); 1495 break; 1496 } 1497 1498 if (is_array($temp)) { 1499 $temp = current($temp); 1500 } 1501 if (isset(self::$_cache)) { 1502 if (self::$_cacheTags) { 1503 self::$_cache->save( serialize($temp), $id, array('Zend_Locale')); 1504 } else { 1505 self::$_cache->save( serialize($temp), $id); 1506 } 1507 } 1508 1509 return $temp; 1510 } 1511 1512 /** 1513 * Returns the set cache 1514 * 1515 * @return Zend_Cache_Core The set cache 1516 */ 1517 public static function getCache() 1518 { 1519 return self::$_cache; 1520 } 1521 1522 /** 1523 * Set a cache for Zend_Locale_Data 1524 * 1525 * @param Zend_Cache_Core $cache A cache frontend 1526 */ 1527 public static function setCache(Zend_Cache_Core $cache) 1528 { 1529 self::$_cache = $cache; 1530 self::_getTagSupportForCache(); 1531 } 1532 1533 /** 1534 * Returns true when a cache is set 1535 * 1536 * @return boolean 1537 */ 1538 public static function hasCache() 1539 { 1540 if (self::$_cache !== null) { 1541 return true; 1542 } 1543 1544 return false; 1545 } 1546 1547 /** 1548 * Removes any set cache 1549 * 1550 * @return void 1551 */ 1552 public static function removeCache() 1553 { 1554 self::$_cache = null; 1555 } 1556 1557 /** 1558 * Clears all set cache data 1559 * 1560 * @return void 1561 */ 1562 public static function clearCache() 1563 { 1564 if (self::$_cacheTags) { 1565 self::$_cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array('Zend_Locale')); 1566 } else { 1567 self::$_cache->clean(Zend_Cache::CLEANING_MODE_ALL); 1568 } 1569 } 1570 1571 /** 1572 * Disables the cache 1573 * 1574 * @param bool $flag 1575 */ 1576 public static function disableCache($flag) 1577 { 1578 self::$_cacheDisabled = (boolean) $flag; 1579 } 1580 1581 /** 1582 * Internal method to check if the given cache supports tags 1583 * 1584 * @return bool 1585 */ 1586 private static function _getTagSupportForCache() 1587 { 1588 $backend = self::$_cache->getBackend(); 1589 if ($backend instanceof Zend_Cache_Backend_ExtendedInterface) { 1590 $cacheOptions = $backend->getCapabilities(); 1591 self::$_cacheTags = $cacheOptions['tags']; 1592 } else { 1593 self::$_cacheTags = false; 1594 } 1595 1596 return self::$_cacheTags; 1597 } 1598 1599 /** 1600 * Filter an ID to only allow valid variable characters 1601 * 1602 * @param string $value 1603 * @return string 1604 */ 1605 protected static function _filterCacheId($value) 1606 { 1607 return strtr( 1608 $value, 1609 array( 1610 '-' => '_', 1611 '%' => '_', 1612 '+' => '_', 1613 '.' => '_', 1614 ) 1615 ); 1616 } 1617 }