web/lib/Zend/Locale/Data.php
changeset 1230 68c69c656a2c
parent 807 877f952ae2bd
equal deleted inserted replaced
1229:5a6b6e770365 1230:68c69c656a2c
    13  * to license@zend.com so we can send you a copy immediately.
    13  * to license@zend.com so we can send you a copy immediately.
    14  *
    14  *
    15  * @category   Zend
    15  * @category   Zend
    16  * @package    Zend_Locale
    16  * @package    Zend_Locale
    17  * @subpackage Data
    17  * @subpackage Data
    18  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    18  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    20  * @version    $Id: Data.php 24766 2012-05-06 02:51:42Z adamlundrigan $
    20  * @version    $Id$
    21  */
    21  */
    22 
    22 
    23 /**
    23 /**
    24  * include needed classes
    24  * include needed classes
    25  */
    25  */
    26 require_once 'Zend/Locale.php';
    26 require_once 'Zend/Locale.php';
       
    27 
       
    28 /** @see Zend_Xml_Security */
       
    29 require_once 'Zend/Xml/Security.php';
    27 
    30 
    28 /**
    31 /**
    29  * Locale data reader, handles the CLDR
    32  * Locale data reader, handles the CLDR
    30  *
    33  *
    31  * @category   Zend
    34  * @category   Zend
    32  * @package    Zend_Locale
    35  * @package    Zend_Locale
    33  * @subpackage Data
    36  * @subpackage Data
    34  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    37  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
    35  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    38  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    36  */
    39  */
    37 class Zend_Locale_Data
    40 class Zend_Locale_Data
    38 {
    41 {
    39     /**
    42     /**
    40      * Locale files
    43      * Locale files
    41      *
    44      *
    42      * @var ressource
    45      * @var array
    43      * @access private
       
    44      */
    46      */
    45     private static $_ldml = array();
    47     private static $_ldml = array();
    46 
    48 
    47     /**
    49     /**
    48      * List of values which are collected
    50      * List of values which are collected
    49      *
    51      *
    50      * @var array
    52      * @var array
    51      * @access private
       
    52      */
    53      */
    53     private static $_list = array();
    54     private static $_list = array();
    54 
    55 
    55     /**
    56     /**
    56      * Internal cache for ldml values
    57      * Internal cache for ldml values
    57      *
    58      *
    58      * @var Zend_Cache_Core
    59      * @var Zend_Cache_Core
    59      * @access private
       
    60      */
    60      */
    61     private static $_cache = null;
    61     private static $_cache = null;
    62 
    62 
    63     /**
    63     /**
    64      * Internal value to remember if cache supports tags
    64      * Internal value to remember if cache supports tags
    68     private static $_cacheTags = false;
    68     private static $_cacheTags = false;
    69 
    69 
    70     /**
    70     /**
    71      * Internal option, cache disabled
    71      * Internal option, cache disabled
    72      *
    72      *
    73      * @var    boolean
    73      * @var boolean
    74      * @access private
       
    75      */
    74      */
    76     private static $_cacheDisabled = false;
    75     private static $_cacheDisabled = false;
    77 
    76 
    78     /**
    77     /**
    79      * Read the content from locale
    78      * Read the content from locale
   142      * @param  string $locale
   141      * @param  string $locale
   143      * @param  string $path
   142      * @param  string $path
   144      * @param  string $attribute
   143      * @param  string $attribute
   145      * @param  string $value
   144      * @param  string $value
   146      * @param  array  $temp
   145      * @param  array  $temp
       
   146      * @return bool
   147      * @throws Zend_Locale_Exception
   147      * @throws Zend_Locale_Exception
   148      * @access private
       
   149      */
   148      */
   150     private static function _findRoute($locale, $path, $attribute, $value, &$temp)
   149     private static function _findRoute($locale, $path, $attribute, $value, &$temp)
   151     {
   150     {
   152         // load locale file if not already in cache
   151         // load locale file if not already in cache
   153         // needed for alias tag when referring to other locale
   152         // needed for alias tag when referring to other locale
   156             if (!file_exists($filename)) {
   155             if (!file_exists($filename)) {
   157                 require_once 'Zend/Locale/Exception.php';
   156                 require_once 'Zend/Locale/Exception.php';
   158                 throw new Zend_Locale_Exception("Missing locale file '$filename' for '$locale' locale.");
   157                 throw new Zend_Locale_Exception("Missing locale file '$filename' for '$locale' locale.");
   159             }
   158             }
   160 
   159 
   161             self::$_ldml[(string) $locale] = simplexml_load_file($filename);
   160             self::$_ldml[(string) $locale] = Zend_Xml_Security::scanFile($filename);
   162         }
   161         }
   163 
   162 
   164         // search for 'alias' tag in the search path for redirection
   163         // search for 'alias' tag in the search path for redirection
   165         $search = '';
   164         $search = '';
   166         $tok = strtok($path, '/');
   165         $tok = strtok($path, '/');
   218     }
   217     }
   219 
   218 
   220     /**
   219     /**
   221      * Read the right LDML file
   220      * Read the right LDML file
   222      *
   221      *
   223      * @param  string $locale
   222      * @param  string      $locale
   224      * @param  string $path
   223      * @param  string      $path
   225      * @param  string $attribute
   224      * @param  string|bool $attribute
   226      * @param  string $value
   225      * @param  string|bool $value
   227      * @access private
   226      * @param  array       $temp
       
   227      * @return array
       
   228      * @throws Zend_Locale_Exception
   228      */
   229      */
   229     private static function _getFile($locale, $path, $attribute = false, $value = false, $temp = array())
   230     private static function _getFile($locale, $path, $attribute = false, $value = false, $temp = array())
   230     {
   231     {
   231         $result = self::_findRoute($locale, $path, $attribute, $value, $temp);
   232         $result = self::_findRoute($locale, $path, $attribute, $value, $temp);
   232         if ($result) {
   233         if ($result) {
   273     }
   274     }
   274 
   275 
   275     /**
   276     /**
   276      * Internal function for checking the locale
   277      * Internal function for checking the locale
   277      *
   278      *
   278      * @param string|Zend_Locale $locale Locale to check
   279      * @param  string|Zend_Locale $locale Locale to check
   279      * @return string
   280      * @return string
       
   281      * @throws Zend_Locale_Exception
   280      */
   282      */
   281     private static function _checkLocale($locale)
   283     private static function _checkLocale($locale)
   282     {
   284     {
   283         if (empty($locale)) {
   285         if (empty($locale)) {
   284             $locale = new Zend_Locale();
   286             $locale = new Zend_Locale();
   287         if (!(Zend_Locale::isLocale((string) $locale, null, false))) {
   289         if (!(Zend_Locale::isLocale((string) $locale, null, false))) {
   288             require_once 'Zend/Locale/Exception.php';
   290             require_once 'Zend/Locale/Exception.php';
   289             throw new Zend_Locale_Exception("Locale (" . (string) $locale . ") is a unknown locale");
   291             throw new Zend_Locale_Exception("Locale (" . (string) $locale . ") is a unknown locale");
   290         }
   292         }
   291 
   293 
       
   294         if (Zend_Locale::isAlias($locale)) {
       
   295             // Return a valid CLDR locale so that the XML file can be loaded.
       
   296             return Zend_Locale::getAlias($locale);
       
   297         }
   292         return (string) $locale;
   298         return (string) $locale;
   293     }
   299     }
   294 
   300 
   295     /**
   301     /**
   296      * Read the LDML file, get a array of multipath defined value
   302      * Read the LDML file, get a array of multipath defined value
   297      *
   303      *
   298      * @param  string $locale
   304      * @param  string      $locale
   299      * @param  string $path
   305      * @param  string      $path
   300      * @param  string $value
   306      * @param  bool|string $value
   301      * @return array
   307      * @return array
   302      * @access public
   308      * @throws Zend_Locale_Exception
   303      */
   309      */
   304     public static function getList($locale, $path, $value = false)
   310     public static function getList($locale, $path, $value = false)
   305     {
   311     {
   306         $locale = self::_checkLocale($locale);
   312         $locale = self::_checkLocale($locale);
   307 
   313 
   318         if (is_array($value)) {
   324         if (is_array($value)) {
   319             $val = implode('_' , $value);
   325             $val = implode('_' , $value);
   320         }
   326         }
   321 
   327 
   322         $val = urlencode($val);
   328         $val = urlencode($val);
   323         $id = strtr('Zend_LocaleL_' . $locale . '_' . $path . '_' . $val, array('-' => '_', '%' => '_', '+' => '_'));
   329         $id  = self::_filterCacheId('Zend_LocaleL_' . $locale . '_' . $path . '_' . $val);
   324         if (!self::$_cacheDisabled && ($result = self::$_cache->load($id))) {
   330         if (!self::$_cacheDisabled && ($result = self::$_cache->load($id))) {
   325             return unserialize($result);
   331             return unserialize($result);
   326         }
   332         }
   327 
   333 
   328         $temp = array();
   334         $temp = array();
   337 
   343 
   338             case 'territory':
   344             case 'territory':
   339                 $temp = self::_getFile($locale, '/ldml/localeDisplayNames/territories/territory', 'type');
   345                 $temp = self::_getFile($locale, '/ldml/localeDisplayNames/territories/territory', 'type');
   340                 if ($value === 1) {
   346                 if ($value === 1) {
   341                     foreach($temp as $key => $value) {
   347                     foreach($temp as $key => $value) {
   342                         if ((is_numeric($key) === false) and ($key != 'QO') and ($key != 'QU')) {
   348                         if ((is_numeric($key) === false) and ($key != 'QO') and ($key != 'EU')) {
   343                             unset($temp[$key]);
   349                             unset($temp[$key]);
   344                         }
   350                         }
   345                     }
   351                     }
   346                 } else if ($value === 2) {
   352                 } else if ($value === 2) {
   347                     foreach($temp as $key => $value) {
   353                     foreach($temp as $key => $value) {
   348                         if (is_numeric($key) or ($key == 'QO') or ($key == 'QU')) {
   354                         if (is_numeric($key) or ($key == 'QO') or ($key == 'EU')) {
   349                             unset($temp[$key]);
   355                             unset($temp[$key]);
   350                         }
   356                         }
   351                     }
   357                     }
   352                 }
   358                 }
   353                 break;
   359                 break;
   373                     }
   379                     }
   374                 }
   380                 }
   375                 break;
   381                 break;
   376 
   382 
   377             case 'layout':
   383             case 'layout':
   378                 $temp  = self::_getFile($locale, '/ldml/layout/orientation',                 'lines',      'lines');
   384                 $temp  = self::_getFile($locale, '/ldml/layout/orientation/characterOrder', '', 'characterOrder');
   379                 $temp += self::_getFile($locale, '/ldml/layout/orientation',                 'characters', 'characters');
   385                 $temp += self::_getFile($locale, '/ldml/layout/orientation/lineOrder', '', 'lineOrder');
   380                 $temp += self::_getFile($locale, '/ldml/layout/inList',                      '',           'inList');
   386                 break;
   381                 $temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'currency\']',  '',           'currency');
   387 
   382                 $temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'dayWidth\']',  '',           'dayWidth');
   388             case 'contexttransform':
   383                 $temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'fields\']',    '',           'fields');
   389                 if (empty($value)) {
   384                 $temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'keys\']',      '',           'keys');
   390                     $value = 'uiListOrMenu';
   385                 $temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'languages\']', '',           'languages');
   391                 }
   386                 $temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'long\']',      '',           'long');
   392                 $temp = self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'languages\']/contextTransform[@type=\''.$value.'\']', '', 'languages');
   387                 $temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'measurementSystemNames\']', '', 'measurementSystemNames');
   393                 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'day-format-except-narrow\']/contextTransform[@type=\''.$value.'\']', '', 'day-format-except-narrow');
   388                 $temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'monthWidth\']',   '',        'monthWidth');
   394                 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'day-standalone-except-narrow\']/contextTransform[@type=\''.$value.'\']', '', 'day-standalone-except-narrow');
   389                 $temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'quarterWidth\']', '',        'quarterWidth');
   395                 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'day-narrow\']/contextTransform[@type=\''.$value.'\']', '', 'day-narrow');
   390                 $temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'scripts\']',   '',           'scripts');
   396                 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'month-format-except-narrow\']/contextTransform[@type=\''.$value.'\']', '', 'month-format-except-narrow');
   391                 $temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'territories\']',  '',        'territories');
   397                 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'month-standalone-except-narrow\']/contextTransform[@type=\''.$value.'\']', '', 'month-standalone-except-narrow');
   392                 $temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'types\']',     '',           'types');
   398                 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'month-narrow\']/contextTransform[@type=\''.$value.'\']', '', 'month-narrow');
   393                 $temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'variants\']',  '',           'variants');
   399                 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'script\']/contextTransform[@type=\''.$value.'\']', '', 'script');
       
   400                 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'territory\']/contextTransform[@type=\''.$value.'\']', '', 'territory');
       
   401                 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'variant\']/contextTransform[@type=\''.$value.'\']', '', 'variant');
       
   402                 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'key\']/contextTransform[@type=\''.$value.'\']', '', 'key');
       
   403                 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'type\']/contextTransform[@type=\''.$value.'\']', '', 'type');
       
   404                 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'era-name\']/contextTransform[@type=\''.$value.'\']', '', 'era-name');
       
   405                 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'era-abbr\']/contextTransform[@type=\''.$value.'\']', '', 'era-abbr');
       
   406                 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'era-narrow\']/contextTransform[@type=\''.$value.'\']', '', 'era-narrow');
       
   407                 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'quater-format-wide\']/contextTransform[@type=\''.$value.'\']', '', 'quater-format-wide');
       
   408                 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'quater-standalone-wide\']/contextTransform[@type=\''.$value.'\']', '', 'quater-standalone-wide');
       
   409                 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'quater-abbreviated\']/contextTransform[@type=\''.$value.'\']', '', 'quater-abbreviated');
       
   410                 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'quater-narrow\']/contextTransform[@type=\''.$value.'\']', '', 'quater-narrow');
       
   411                 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'calendar-field\']/contextTransform[@type=\''.$value.'\']', '', 'calendar-field');
       
   412                 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'symbol\']/contextTransform[@type=\''.$value.'\']', '', 'symbol');
       
   413                 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'tense\']/contextTransform[@type=\''.$value.'\']', '', 'tense');
       
   414                 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'zone-exemplarCity\']/contextTransform[@type=\''.$value.'\']', '', 'zone-exemplarCity');
       
   415                 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'zone-long\']/contextTransform[@type=\''.$value.'\']', '', 'zone-long');
       
   416                 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'zone-short\']/contextTransform[@type=\''.$value.'\']', '', 'zone-short');
       
   417                 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'metazone-long\']/contextTransform[@type=\''.$value.'\']', '', 'metazone-long');
       
   418                 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'metazone-short\']/contextTransform[@type=\''.$value.'\']', '', 'metazone-short');
       
   419                 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'displayName-count\']/contextTransform[@type=\''.$value.'\']', '', 'displayName-count');
       
   420                 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'displayName\']/contextTransform[@type=\''.$value.'\']', '', 'displayName');
       
   421                 $temp += self::_getFile($locale, '/ldml/contextTransforms/contextTransformUsage[@type=\'unit-pattern\']/contextTransform[@type=\''.$value.'\']', '', 'unit-pattern');
   394                 break;
   422                 break;
   395 
   423 
   396             case 'characters':
   424             case 'characters':
   397                 $temp  = self::_getFile($locale, '/ldml/characters/exemplarCharacters',                           '', 'characters');
   425                 $temp  = self::_getFile($locale, '/ldml/characters/exemplarCharacters',                           '', 'characters');
   398                 $temp += self::_getFile($locale, '/ldml/characters/exemplarCharacters[@type=\'auxiliary\']',      '', 'auxiliary');
   426                 $temp += self::_getFile($locale, '/ldml/characters/exemplarCharacters[@type=\'auxiliary\']',      '', 'auxiliary');
   399                 $temp += self::_getFile($locale, '/ldml/characters/exemplarCharacters[@type=\'currencySymbol\']', '', 'currencySymbol');
   427                 // $temp += self::_getFile($locale, '/ldml/characters/exemplarCharacters[@type=\'currencySymbol\']', '', 'currencySymbol');
   400                 break;
   428                 break;
   401 
   429 
   402             case 'delimiters':
   430             case 'delimiters':
   403                 $temp  = self::_getFile($locale, '/ldml/delimiters/quotationStart',          '', 'quoteStart');
   431                 $temp  = self::_getFile($locale, '/ldml/delimiters/quotationStart',          '', 'quoteStart');
   404                 $temp += self::_getFile($locale, '/ldml/delimiters/quotationEnd',            '', 'quoteEnd');
   432                 $temp += self::_getFile($locale, '/ldml/delimiters/quotationEnd',            '', 'quoteEnd');
   415 
   443 
   416             case 'months':
   444             case 'months':
   417                 if (empty($value)) {
   445                 if (empty($value)) {
   418                     $value = "gregorian";
   446                     $value = "gregorian";
   419                 }
   447                 }
   420                 $temp  = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/default', 'choice', 'context');
   448                 $temp['context'] = "format";
   421                 $temp += self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'format\']/default', 'choice', 'default');
   449                 $temp['default'] = "wide";
   422                 $temp['format']['abbreviated'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'format\']/monthWidth[@type=\'abbreviated\']/month', 'type');
   450                 $temp['format']['abbreviated'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'format\']/monthWidth[@type=\'abbreviated\']/month', 'type');
   423                 $temp['format']['narrow']      = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'format\']/monthWidth[@type=\'narrow\']/month', 'type');
   451                 $temp['format']['narrow']      = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'format\']/monthWidth[@type=\'narrow\']/month', 'type');
   424                 $temp['format']['wide']        = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'format\']/monthWidth[@type=\'wide\']/month', 'type');
   452                 $temp['format']['wide']        = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'format\']/monthWidth[@type=\'wide\']/month', 'type');
   425                 $temp['stand-alone']['abbreviated']  = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'stand-alone\']/monthWidth[@type=\'abbreviated\']/month', 'type');
   453                 $temp['stand-alone']['abbreviated']  = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'stand-alone\']/monthWidth[@type=\'abbreviated\']/month', 'type');
   426                 $temp['stand-alone']['narrow']       = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'stand-alone\']/monthWidth[@type=\'narrow\']/month', 'type');
   454                 $temp['stand-alone']['narrow']       = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'stand-alone\']/monthWidth[@type=\'narrow\']/month', 'type');
   436 
   464 
   437             case 'days':
   465             case 'days':
   438                 if (empty($value)) {
   466                 if (empty($value)) {
   439                     $value = "gregorian";
   467                     $value = "gregorian";
   440                 }
   468                 }
   441                 $temp  = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/default', 'choice', 'context');
   469                 $temp['context'] = "format";
   442                 $temp += self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'format\']/default', 'choice', 'default');
   470                 $temp['default'] = "wide";
   443                 $temp['format']['abbreviated'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'format\']/dayWidth[@type=\'abbreviated\']/day', 'type');
   471                 $temp['format']['abbreviated'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'format\']/dayWidth[@type=\'abbreviated\']/day', 'type');
   444                 $temp['format']['narrow']      = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'format\']/dayWidth[@type=\'narrow\']/day', 'type');
   472                 $temp['format']['narrow']      = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'format\']/dayWidth[@type=\'narrow\']/day', 'type');
   445                 $temp['format']['wide']        = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'format\']/dayWidth[@type=\'wide\']/day', 'type');
   473                 $temp['format']['wide']        = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'format\']/dayWidth[@type=\'wide\']/day', 'type');
   446                 $temp['stand-alone']['abbreviated']  = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'stand-alone\']/dayWidth[@type=\'abbreviated\']/day', 'type');
   474                 $temp['stand-alone']['abbreviated']  = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'stand-alone\']/dayWidth[@type=\'abbreviated\']/day', 'type');
   447                 $temp['stand-alone']['narrow']       = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'stand-alone\']/dayWidth[@type=\'narrow\']/day', 'type');
   475                 $temp['stand-alone']['narrow']       = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'stand-alone\']/dayWidth[@type=\'narrow\']/day', 'type');
   570 
   598 
   571             case 'field':
   599             case 'field':
   572                 if (empty($value)) {
   600                 if (empty($value)) {
   573                     $value = "gregorian";
   601                     $value = "gregorian";
   574                 }
   602                 }
   575                 $temp2 = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/fields/field', 'type');
   603                 $temp2 = self::_getFile($locale, '/ldml/dates/fields/field', 'type');
       
   604                 // $temp2 = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/fields/field', 'type');
   576                 foreach ($temp2 as $key => $keyvalue) {
   605                 foreach ($temp2 as $key => $keyvalue) {
   577                     $temp += self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/fields/field[@type=\'' . $key . '\']/displayName', '', $key);
   606                     $temp += self::_getFile($locale, '/ldml/dates/fields/field[@type=\'' . $key . '\']/displayName', '', $key);
       
   607                     // $temp += self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/fields/field[@type=\'' . $key . '\']/displayName', '', $key);
   578                 }
   608                 }
   579                 break;
   609                 break;
   580 
   610 
   581             case 'relative':
   611             case 'relative':
   582                 if (empty($value)) {
   612                 if (empty($value)) {
   583                     $value = "gregorian";
   613                     $value = "day";
   584                 }
   614                 }
   585                 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/fields/field/relative', 'type');
   615                 $temp = self::_getFile($locale, '/ldml/dates/fields/field[@type=\'' . $value . '\']/relative', 'type');
   586                 break;
   616                 break;
   587 
   617 
   588             case 'symbols':
   618             case 'symbols':
   589                 $temp  = self::_getFile($locale, '/ldml/numbers/symbols/decimal',         '', 'decimal');
   619                 $temp  = self::_getFile($locale, '/ldml/numbers/symbols/decimal',         '', 'decimal');
   590                 $temp += self::_getFile($locale, '/ldml/numbers/symbols/group',           '', 'group');
   620                 $temp += self::_getFile($locale, '/ldml/numbers/symbols/group',           '', 'group');
   756                     }
   786                     }
   757                 }
   787                 }
   758                 break;
   788                 break;
   759 
   789 
   760             case 'timezonetowindows':
   790             case 'timezonetowindows':
   761                 $_temp = self::_getFile('supplementalData', '/supplementalData/timezoneData/mapTimezones[@type=\'windows\']/mapZone', 'other');
   791                 $_temp = self::_getFile('windowsZones', '/supplementalData/windowsZones/mapTimezones/mapZone', 'other');
   762                 foreach ($_temp as $key => $found) {
   792                 foreach ($_temp as $key => $found) {
   763                     $temp += self::_getFile('supplementalData', '/supplementalData/timezoneData/mapTimezones[@type=\'windows\']/mapZone[@other=\'' . $key . '\']', 'type', $key);
   793                     $temp += self::_getFile('windowsZones', '/supplementalData/windowsZones/mapTimezones/mapZone[@other=\'' . $key . '\']', 'type', $key);
   764                 }
   794                 }
   765                 break;
   795                 break;
   766 
   796 
   767             case 'windowstotimezone':
   797             case 'windowstotimezone':
   768                 $_temp = self::_getFile('supplementalData', '/supplementalData/timezoneData/mapTimezones[@type=\'windows\']/mapZone', 'type');
   798                 $_temp = self::_getFile('windowsZones', '/supplementalData/windowsZones/mapTimezones/mapZone', 'type');
   769                 foreach ($_temp as $key => $found) {
   799                 foreach ($_temp as $key => $found) {
   770                     $temp += self::_getFile('supplementalData', '/supplementalData/timezoneData/mapTimezones[@type=\'windows\']/mapZone[@type=\'' .$key . '\']', 'other', $key);
   800                     $temp += self::_getFile('windowsZones', '/supplementalData/windowsZones/mapTimezones/mapZone[@type=\'' .$key . '\']', 'other', $key);
   771                 }
   801                 }
   772                 break;
   802                 break;
   773 
   803 
   774             case 'territorytotimezone':
   804             case 'territorytotimezone':
   775                 $_temp = self::_getFile('supplementalData', '/supplementalData/timezoneData/zoneFormatting/zoneItem', 'type');
   805                 $_temp = self::_getFile('metaZones', '/supplementalData/metaZones/mapTimezones/mapZone', 'type');
   776                 foreach ($_temp as $key => $found) {
   806                 foreach ($_temp as $key => $found) {
   777                     $temp += self::_getFile('supplementalData', '/supplementalData/timezoneData/zoneFormatting/zoneItem[@type=\'' . $key . '\']', 'territory', $key);
   807                     $temp += self::_getFile('metaZones', '/supplementalData/metaZones/mapTimezones/mapZone[@type=\'' . $key . '\']', 'territory', $key);
   778                 }
   808                 }
   779                 break;
   809                 break;
   780 
   810 
   781             case 'timezonetoterritory':
   811             case 'timezonetoterritory':
   782                 $_temp = self::_getFile('supplementalData', '/supplementalData/timezoneData/zoneFormatting/zoneItem', 'territory');
   812                 $_temp = self::_getFile('metaZones', '/supplementalData/metaZones/mapTimezones/mapZone', 'territory');
   783                 foreach ($_temp as $key => $found) {
   813                 foreach ($_temp as $key => $found) {
   784                     $temp += self::_getFile('supplementalData', '/supplementalData/timezoneData/zoneFormatting/zoneItem[@territory=\'' . $key . '\']', 'type', $key);
   814                     $temp += self::_getFile('metaZones', '/supplementalData/metaZones/mapTimezones/mapZone[@territory=\'' . $key . '\']', 'type', $key);
   785                 }
   815                 }
   786                 break;
   816                 break;
   787 
   817 
   788             case 'citytotimezone':
   818             case 'citytotimezone':
   789                 $_temp = self::_getFile($locale, '/ldml/dates/timeZoneNames/zone', 'type');
   819                 $_temp = self::_getFile($locale, '/ldml/dates/timeZoneNames/zone', 'type');
   892                     $temp += self::_getFile('likelySubtags', '/supplementalData/likelySubtags/likelySubtag[@from=\'' . $key . '\']', 'to', $key);
   922                     $temp += self::_getFile('likelySubtags', '/supplementalData/likelySubtags/likelySubtag[@from=\'' . $key . '\']', 'to', $key);
   893                 }
   923                 }
   894                 break;
   924                 break;
   895 
   925 
   896             case 'unit':
   926             case 'unit':
   897                 $_temp = self::_getFile($locale, '/ldml/units/unit', 'type');
   927                 $_temp = self::_getFile($locale, '/ldml/units/unitLength/unit', 'type');
   898                 foreach($_temp as $key => $keyvalue) {
   928                 foreach($_temp as $key => $keyvalue) {
   899                     $_temp2 = self::_getFile($locale, '/ldml/units/unit[@type=\'' . $key . '\']/unitPattern', 'count');
   929                     $_temp2 = self::_getFile($locale, '/ldml/units/unitLength/unit[@type=\'' . $key . '\']/unitPattern', 'count');
   900                     $temp[$key] = $_temp2;
   930                     $temp[$key] = $_temp2;
   901                 }
   931                 }
   902                 break;
   932                 break;
   903 
   933 
   904             default :
   934             default :
   919     }
   949     }
   920 
   950 
   921     /**
   951     /**
   922      * Read the LDML file, get a single path defined value
   952      * Read the LDML file, get a single path defined value
   923      *
   953      *
   924      * @param  string $locale
   954      * @param  string      $locale
   925      * @param  string $path
   955      * @param  string      $path
   926      * @param  string $value
   956      * @param  bool|string $value
   927      * @return string
   957      * @return string
   928      * @access public
   958      * @throws Zend_Locale_Exception
   929      */
   959      */
   930     public static function getContent($locale, $path, $value = false)
   960     public static function getContent($locale, $path, $value = false)
   931     {
   961     {
   932         $locale = self::_checkLocale($locale);
   962         $locale = self::_checkLocale($locale);
   933 
   963 
   943         $val = $value;
   973         $val = $value;
   944         if (is_array($value)) {
   974         if (is_array($value)) {
   945             $val = implode('_' , $value);
   975             $val = implode('_' , $value);
   946         }
   976         }
   947         $val = urlencode($val);
   977         $val = urlencode($val);
   948         $id = strtr('Zend_LocaleC_' . $locale . '_' . $path . '_' . $val, array('-' => '_', '%' => '_', '+' => '_'));
   978         $id  = self::_filterCacheId('Zend_LocaleC_' . $locale . '_' . $path . '_' . $val);
   949         if (!self::$_cacheDisabled && ($result = self::$_cache->load($id))) {
   979         if (!self::$_cacheDisabled && ($result = self::$_cache->load($id))) {
   950             return unserialize($result);
   980             return unserialize($result);
   951         }
   981         }
   952 
   982 
   953         switch(strtolower($path)) {
   983         switch(strtolower($path)) {
   971             case 'key':
  1001             case 'key':
   972                 $temp = self::_getFile($locale, '/ldml/localeDisplayNames/keys/key[@type=\'' . $value . '\']', 'type');
  1002                 $temp = self::_getFile($locale, '/ldml/localeDisplayNames/keys/key[@type=\'' . $value . '\']', 'type');
   973                 break;
  1003                 break;
   974 
  1004 
   975             case 'defaultcalendar':
  1005             case 'defaultcalendar':
   976                 $temp = self::_getFile($locale, '/ldml/dates/calendars/default', 'choice', 'default');
  1006                 $givenLocale = new Zend_Locale($locale);
       
  1007                 $territory = $givenLocale->getRegion();
       
  1008                 unset($givenLocale);
       
  1009                 $temp = self::_getFile('supplementalData', '/supplementalData/calendarPreferenceData/calendarPreference[contains(@territories,\'' . $territory . '\')]', 'ordering', 'ordering');
       
  1010                 if (isset($temp['ordering'])) {
       
  1011                     list($temp) = explode(' ', $temp['ordering']);
       
  1012                 } else {
       
  1013                     $temp = 'gregorian';
       
  1014                 }
   977                 break;
  1015                 break;
   978 
  1016 
   979             case 'monthcontext':
  1017             case 'monthcontext':
       
  1018                 /* default context is always 'format'
   980                 if (empty ($value)) {
  1019                 if (empty ($value)) {
   981                     $value = "gregorian";
  1020                     $value = "gregorian";
   982                 }
  1021                 }
   983                 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/default', 'choice', 'context');
  1022                 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/default', 'choice', 'context');
       
  1023                 */
       
  1024                 $temp = 'format';
   984                 break;
  1025                 break;
   985 
  1026 
   986             case 'defaultmonth':
  1027             case 'defaultmonth':
       
  1028                 /* default width is always 'wide'
   987                 if (empty ($value)) {
  1029                 if (empty ($value)) {
   988                     $value = "gregorian";
  1030                     $value = "gregorian";
   989                 }
  1031                 }
   990                 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'format\']/default', 'choice', 'default');
  1032                 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'format\']/default', 'choice', 'default');
       
  1033                 */
       
  1034                 $temp = 'wide';
   991                 break;
  1035                 break;
   992 
  1036 
   993             case 'month':
  1037             case 'month':
   994                 if (!is_array($value)) {
  1038                 if (!is_array($value)) {
   995                     $temp = $value;
  1039                     $temp = $value;
   997                 }
  1041                 }
   998                 $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');
  1042                 $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');
   999                 break;
  1043                 break;
  1000 
  1044 
  1001             case 'daycontext':
  1045             case 'daycontext':
       
  1046                 /* default context is always 'format'
  1002                 if (empty($value)) {
  1047                 if (empty($value)) {
  1003                     $value = "gregorian";
  1048                     $value = "gregorian";
  1004                 }
  1049                 }
  1005                 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/default', 'choice', 'context');
  1050                 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/default', 'choice', 'context');
       
  1051                 */
       
  1052                 $temp = 'format';
  1006                 break;
  1053                 break;
  1007 
  1054 
  1008             case 'defaultday':
  1055             case 'defaultday':
       
  1056                 /* default width is always 'wide'
  1009                 if (empty($value)) {
  1057                 if (empty($value)) {
  1010                     $value = "gregorian";
  1058                     $value = "gregorian";
  1011                 }
  1059                 }
  1012                 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'format\']/default', 'choice', 'default');
  1060                 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'format\']/default', 'choice', 'default');
       
  1061                 */
       
  1062                 $temp = 'wide';
  1013                 break;
  1063                 break;
  1014 
  1064 
  1015             case 'day':
  1065             case 'day':
  1016                 if (!is_array($value)) {
  1066                 if (!is_array($value)) {
  1017                     $temp = $value;
  1067                     $temp = $value;
  1028                 $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');
  1078                 $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');
  1029                 break;
  1079                 break;
  1030 
  1080 
  1031             case 'am':
  1081             case 'am':
  1032                 if (empty($value)) {
  1082                 if (empty($value)) {
  1033                     $value = "gregorian";
  1083                     $value = array("gregorian", "format", "wide");
  1034                 }
  1084                 }
  1035                 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/am', '', 'am');
  1085                 if (!is_array($value)) {
       
  1086                     $temp = $value;
       
  1087                     $value = array($temp, "format", "wide");
       
  1088                 }
       
  1089                 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/dayPeriods/dayPeriodContext[@type=\'' . $value[1] . '\']/dayPeriodWidth[@type=\'' . $value[2] . '\']/dayPeriod[@type=\'am\']', '', 'dayPeriod');
  1036                 break;
  1090                 break;
  1037 
  1091 
  1038             case 'pm':
  1092             case 'pm':
  1039                 if (empty($value)) {
  1093                 if (empty($value)) {
  1040                     $value = "gregorian";
  1094                     $value = array("gregorian", "format", "wide");
  1041                 }
  1095                 }
  1042                 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/pm', '', 'pm');
  1096                 if (!is_array($value)) {
       
  1097                     $temp = $value;
       
  1098                     $value = array($temp, "format", "wide");
       
  1099                 }
       
  1100                 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/dayPeriods/dayPeriodContext[@type=\'' . $value[1] . '\']/dayPeriodWidth[@type=\'' . $value[2] . '\']/dayPeriod[@type=\'pm\']', '', 'dayPeriod');
  1043                 break;
  1101                 break;
  1044 
  1102 
  1045             case 'era':
  1103             case 'era':
  1046                 if (!is_array($value)) {
  1104                 if (!is_array($value)) {
  1047                     $temp = $value;
  1105                     $temp = $value;
  1049                 }
  1107                 }
  1050                 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/eras/era' . $value[1] . '/era[@type=\'' . $value[2] . '\']', 'type');
  1108                 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/eras/era' . $value[1] . '/era[@type=\'' . $value[2] . '\']', 'type');
  1051                 break;
  1109                 break;
  1052 
  1110 
  1053             case 'defaultdate':
  1111             case 'defaultdate':
       
  1112                 /* default choice is deprecated in CDLR - should be always medium here
  1054                 if (empty($value)) {
  1113                 if (empty($value)) {
  1055                     $value = "gregorian";
  1114                     $value = "gregorian";
  1056                 }
  1115                 }
  1057                 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateFormats/default', 'choice', 'default');
  1116                 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateFormats/default', 'choice', 'default');
       
  1117                 */
       
  1118                 $temp = 'medium';
  1058                 break;
  1119                 break;
  1059 
  1120 
  1060             case 'date':
  1121             case 'date':
  1061                 if (empty($value)) {
  1122                 if (empty($value)) {
  1062                     $value = array("gregorian", "medium");
  1123                     $value = array("gregorian", "medium");
  1067                 }
  1128                 }
  1068                 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/dateFormats/dateFormatLength[@type=\'' . $value[1] . '\']/dateFormat/pattern', '', 'pattern');
  1129                 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/dateFormats/dateFormatLength[@type=\'' . $value[1] . '\']/dateFormat/pattern', '', 'pattern');
  1069                 break;
  1130                 break;
  1070 
  1131 
  1071             case 'defaulttime':
  1132             case 'defaulttime':
       
  1133                 /* default choice is deprecated in CDLR - should be always medium here
  1072                 if (empty($value)) {
  1134                 if (empty($value)) {
  1073                     $value = "gregorian";
  1135                     $value = "gregorian";
  1074                 }
  1136                 }
  1075                 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/timeFormats/default', 'choice', 'default');
  1137                 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/timeFormats/default', 'choice', 'default');
       
  1138                 */
       
  1139                 $temp = 'medium';
  1076                 break;
  1140                 break;
  1077 
  1141 
  1078             case 'time':
  1142             case 'time':
  1079                 if (empty($value)) {
  1143                 if (empty($value)) {
  1080                     $value = array("gregorian", "medium");
  1144                     $value = array("gregorian", "medium");
  1126             case 'field':
  1190             case 'field':
  1127                 if (!is_array($value)) {
  1191                 if (!is_array($value)) {
  1128                     $temp = $value;
  1192                     $temp = $value;
  1129                     $value = array("gregorian", $temp);
  1193                     $value = array("gregorian", $temp);
  1130                 }
  1194                 }
  1131                 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/fields/field[@type=\'' . $value[1] . '\']/displayName', '', $value[1]);
  1195                 $temp = self::_getFile($locale, '/ldml/dates/fields/field[@type=\'' . $value[1] . '\']/displayName', '', $value[1]);
  1132                 break;
  1196                 break;
  1133 
  1197 
  1134             case 'relative':
  1198             case 'relative':
  1135                 if (!is_array($value)) {
  1199                 if (!is_array($value)) {
  1136                     $temp = $value;
  1200                     $temp = $value;
  1137                     $value = array("gregorian", $temp);
  1201                     $value = array("gregorian", $temp);
  1138                 }
  1202                 }
  1139                 $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/fields/field/relative[@type=\'' . $value[1] . '\']', '', $value[1]);
  1203                 $temp = self::_getFile($locale, '/ldml/dates/fields/field[@type=\'day\']/relative[@type=\'' . $value[1] . '\']', '', $value[1]);
       
  1204                 // $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/fields/field/relative[@type=\'' . $value[1] . '\']', '', $value[1]);
  1140                 break;
  1205                 break;
  1141 
  1206 
  1142             case 'defaultnumberingsystem':
  1207             case 'defaultnumberingsystem':
  1143                 $temp = self::_getFile($locale, '/ldml/numbers/defaultNumberingSystem', '', 'default');
  1208                 $temp = self::_getFile($locale, '/ldml/numbers/defaultNumberingSystem', '', 'default');
  1144                 break;
  1209                 break;
  1299                     }
  1364                     }
  1300                 }
  1365                 }
  1301                 break;
  1366                 break;
  1302 
  1367 
  1303             case 'timezonetowindows':
  1368             case 'timezonetowindows':
  1304                 $temp = self::_getFile('supplementalData', '/supplementalData/timezoneData/mapTimezones[@type=\'windows\']/mapZone[@other=\''.$value.'\']', 'type', $value);
  1369                 $temp = self::_getFile('windowsZones', '/supplementalData/windowsZones/mapTimezones/mapZone[@other=\''.$value.'\']', 'type', $value);
  1305                 break;
  1370                 break;
  1306 
  1371 
  1307             case 'windowstotimezone':
  1372             case 'windowstotimezone':
  1308                 $temp = self::_getFile('supplementalData', '/supplementalData/timezoneData/mapTimezones[@type=\'windows\']/mapZone[@type=\''.$value.'\']', 'other', $value);
  1373                 $temp = self::_getFile('windowsZones', '/supplementalData/windowsZones/mapTimezones/mapZone[@type=\''.$value.'\']', 'other', $value);
  1309                 break;
  1374                 break;
  1310 
  1375 
  1311             case 'territorytotimezone':
  1376             case 'territorytotimezone':
  1312                 $temp = self::_getFile('supplementalData', '/supplementalData/timezoneData/zoneFormatting/zoneItem[@type=\'' . $value . '\']', 'territory', $value);
  1377                 $temp = self::_getFile('metaZones', '/supplementalData/metaZones/mapTimezones/mapZone[@type=\'' . $value . '\']', 'territory', $value);
  1313                 break;
  1378                 break;
  1314 
  1379 
  1315             case 'timezonetoterritory':
  1380             case 'timezonetoterritory':
  1316                 $temp = self::_getFile('supplementalData', '/supplementalData/timezoneData/zoneFormatting/zoneItem[@territory=\'' . $value . '\']', 'type', $value);
  1381                 $temp = self::_getFile('metaZones', '/supplementalData/metaZones/mapTimezones/mapZone[@territory=\'' . $value . '\']', 'type', $value);
  1317                 break;
  1382                 break;
  1318 
  1383 
  1319             case 'citytotimezone':
  1384             case 'citytotimezone':
  1320                 $temp = self::_getFile($locale, '/ldml/dates/timeZoneNames/zone[@type=\'' . $value . '\']/exemplarCity', '', $value);
  1385                 $temp = self::_getFile($locale, '/ldml/dates/timeZoneNames/zone[@type=\'' . $value . '\']/exemplarCity', '', $value);
  1321                 break;
  1386                 break;
  1404             case 'localeupgrade':
  1469             case 'localeupgrade':
  1405                 $temp = self::_getFile('likelySubtags', '/supplementalData/likelySubtags/likelySubtag[@from=\'' . $value . '\']', 'to', $value);
  1470                 $temp = self::_getFile('likelySubtags', '/supplementalData/likelySubtags/likelySubtag[@from=\'' . $value . '\']', 'to', $value);
  1406                 break;
  1471                 break;
  1407 
  1472 
  1408             case 'unit':
  1473             case 'unit':
  1409                 $temp = self::_getFile($locale, '/ldml/units/unit[@type=\'' . $value[0] . '\']/unitPattern[@count=\'' . $value[1] . '\']', '');
  1474                 $temp = self::_getFile($locale, '/ldml/units/unitLength/unit[@type=\'' . $value[0] . '\']/unitPattern[@count=\'' . $value[1] . '\']', '');
  1410                 break;
  1475                 break;
  1411 
  1476 
  1412             default :
  1477             default :
  1413                 require_once 'Zend/Locale/Exception.php';
  1478                 require_once 'Zend/Locale/Exception.php';
  1414                 throw new Zend_Locale_Exception("Unknown detail ($path) for parsing locale data.");
  1479                 throw new Zend_Locale_Exception("Unknown detail ($path) for parsing locale data.");
  1489     }
  1554     }
  1490 
  1555 
  1491     /**
  1556     /**
  1492      * Disables the cache
  1557      * Disables the cache
  1493      *
  1558      *
  1494      * @param unknown_type $flag
  1559      * @param bool $flag
  1495      */
  1560      */
  1496     public static function disableCache($flag)
  1561     public static function disableCache($flag)
  1497     {
  1562     {
  1498         self::$_cacheDisabled = (boolean) $flag;
  1563         self::$_cacheDisabled = (boolean) $flag;
  1499     }
  1564     }
  1500 
  1565 
  1501     /**
  1566     /**
  1502      * Internal method to check if the given cache supports tags
  1567      * Internal method to check if the given cache supports tags
  1503      *
  1568      *
  1504      * @param Zend_Cache $cache
  1569      * @return bool
  1505      */
  1570      */
  1506     private static function _getTagSupportForCache()
  1571     private static function _getTagSupportForCache()
  1507     {
  1572     {
  1508         $backend = self::$_cache->getBackend();
  1573         $backend = self::$_cache->getBackend();
  1509         if ($backend instanceof Zend_Cache_Backend_ExtendedInterface) {
  1574         if ($backend instanceof Zend_Cache_Backend_ExtendedInterface) {
  1513             self::$_cacheTags = false;
  1578             self::$_cacheTags = false;
  1514         }
  1579         }
  1515 
  1580 
  1516         return self::$_cacheTags;
  1581         return self::$_cacheTags;
  1517     }
  1582     }
       
  1583 
       
  1584     /**
       
  1585      * Filter an ID to only allow valid variable characters
       
  1586      *
       
  1587      * @param  string $value
       
  1588      * @return string
       
  1589      */
       
  1590     protected static function _filterCacheId($value)
       
  1591     {
       
  1592         return strtr(
       
  1593             $value,
       
  1594             array(
       
  1595                 '-' => '_',
       
  1596                 '%' => '_',
       
  1597                 '+' => '_',
       
  1598                 '.' => '_',
       
  1599             )
       
  1600         );
       
  1601     }
  1518 }
  1602 }