Current File : /home/k/a/r/karenpetzb/www/items/category/Data.php.tar |
home/karenpetzb/library/Zend/Dojo/Data.php 0000604 00000031606 15071273473 0014475 0 ustar 00 <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Dojo
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Data.php 11282 2008-09-08 16:05:59Z matthew $
*/
/**
* dojo.data support for Zend Framework
*
* @uses ArrayAccess
* @uses Iterator
* @uses Countable
* @package Zend_Dojo
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Dojo_Data implements ArrayAccess,Iterator,Countable
{
/**
* Identifier field of item
* @var string|int
*/
protected $_identifier;
/**
* Collected items
* @var array
*/
protected $_items = array();
/**
* Label field of item
* @var string
*/
protected $_label;
/**
* Data container metadata
* @var array
*/
protected $_metadata = array();
/**
* Constructor
*
* @param string|null $identifier
* @param array|Traversable|null $items
* @param string|null $label
* @return void
*/
public function __construct($identifier = null, $items = null, $label = null)
{
if (null !== $identifier) {
$this->setIdentifier($identifier);
}
if (null !== $items) {
$this->setItems($items);
}
if (null !== $label) {
$this->setLabel($label);
}
}
/**
* Set the items to collect
*
* @param array|Traversable $items
* @return Zend_Dojo_Data
*/
public function setItems($items)
{
$this->clearItems();
return $this->addItems($items);
}
/**
* Set an individual item, optionally by identifier (overwrites)
*
* @param array|object $item
* @param string|null $identifier
* @return Zend_Dojo_Data
*/
public function setItem($item, $id = null)
{
$item = $this->_normalizeItem($item, $id);
$this->_items[$item['id']] = $item['data'];
return $this;
}
/**
* Add an individual item, optionally by identifier
*
* @param array|object $item
* @param string|null $id
* @return Zend_Dojo_Data
*/
public function addItem($item, $id = null)
{
$item = $this->_normalizeItem($item, $id);
if ($this->hasItem($item['id'])) {
require_once 'Zend/Dojo/Exception.php';
throw new Zend_Dojo_Exception('Overwriting items using addItem() is not allowed');
}
$this->_items[$item['id']] = $item['data'];
return $this;
}
/**
* Add multiple items at once
*
* @param array|Traversable $items
* @return Zend_Dojo_Data
*/
public function addItems($items)
{
if (!is_array($items) && (!is_object($items) || !($items instanceof Traversable))) {
require_once 'Zend/Dojo/Exception.php';
throw new Zend_Dojo_Exception('Only arrays and Traversable objects may be added to ' . __CLASS__);
}
foreach ($items as $item) {
$this->addItem($item);
}
return $this;
}
/**
* Get all items as an array
*
* Serializes items to arrays.
*
* @return array
*/
public function getItems()
{
return $this->_items;
}
/**
* Does an item with the given identifier exist?
*
* @param string|int $id
* @return bool
*/
public function hasItem($id)
{
return array_key_exists($id, $this->_items);
}
/**
* Retrieve an item by identifier
*
* Item retrieved will be flattened to an array.
*
* @param string $id
* @return array
*/
public function getItem($id)
{
if (!$this->hasItem($id)) {
return null;
}
return $this->_items[$id];
}
/**
* Remove item by identifier
*
* @param string $id
* @return Zend_Dojo_Data
*/
public function removeItem($id)
{
if ($this->hasItem($id)) {
unset($this->_items[$id]);
}
return $this;
}
/**
* Remove all items at once
*
* @return Zend_Dojo_Data
*/
public function clearItems()
{
$this->_items = array();
return $this;
}
/**
* Set identifier for item lookups
*
* @param string|int|null $identifier
* @return Zend_Dojo_Data
*/
public function setIdentifier($identifier)
{
if (null === $identifier) {
$this->_identifier = null;
} elseif (is_string($identifier)) {
$this->_identifier = $identifier;
} elseif (is_numeric($identifier)) {
$this->_identifier = (int) $identifier;
} else {
require_once 'Zend/Dojo/Exception.php';
throw new Zend_Dojo_Exception('Invalid identifier; please use a string or integer');
}
return $this;
}
/**
* Retrieve current item identifier
*
* @return string|int|null
*/
public function getIdentifier()
{
return $this->_identifier;
}
/**
* Set label to use for displaying item associations
*
* @param string|null $label
* @return Zend_Dojo_Data
*/
public function setLabel($label)
{
if (null === $label) {
$this->_label = null;
} else {
$this->_label = (string) $label;
}
return $this;
}
/**
* Retrieve item association label
*
* @return string|null
*/
public function getLabel()
{
return $this->_label;
}
/**
* Set metadata by key or en masse
*
* @param string|array $spec
* @param mixed $value
* @return Zend_Dojo_Data
*/
public function setMetadata($spec, $value = null)
{
if (is_string($spec) && (null !== $value)) {
$this->_metadata[$spec] = $value;
} elseif (is_array($spec)) {
foreach ($spec as $key => $value) {
$this->setMetadata($key, $value);
}
}
return $this;
}
/**
* Get metadata item or all metadata
*
* @param null|string $key Metadata key when pulling single metadata item
* @return mixed
*/
public function getMetadata($key = null)
{
if (null === $key) {
return $this->_metadata;
}
if (array_key_exists($key, $this->_metadata)) {
return $this->_metadata[$key];
}
return null;
}
/**
* Clear individual or all metadata item(s)
*
* @param null|string $key
* @return Zend_Dojo_Data
*/
public function clearMetadata($key = null)
{
if (null === $key) {
$this->_metadata = array();
} elseif (array_key_exists($key, $this->_metadata)) {
unset($this->_metadata[$key]);
}
return $this;
}
/**
* Load object from array
*
* @param array $data
* @return Zend_Dojo_Data
*/
public function fromArray(array $data)
{
if (array_key_exists('identifier', $data)) {
$this->setIdentifier($data['identifier']);
}
if (array_key_exists('label', $data)) {
$this->setLabel($data['label']);
}
if (array_key_exists('items', $data) && is_array($data['items'])) {
$this->setItems($data['items']);
} else {
$this->clearItems();
}
return $this;
}
/**
* Load object from JSON
*
* @param string $json
* @return Zend_Dojo_Data
*/
public function fromJson($json)
{
if (!is_string($json)) {
require_once 'Zend/Dojo/Exception.php';
throw new Zend_Dojo_Exception('fromJson() expects JSON input');
}
require_once 'Zend/Json.php';
$data = Zend_Json::decode($json);
return $this->fromArray($data);
}
/**
* Seralize entire data structure, including identifier and label, to array
*
* @return array
*/
public function toArray()
{
if (null === ($identifier = $this->getIdentifier())) {
require_once 'Zend/Dojo/Exception.php';
throw new Zend_Dojo_Exception('Serialization requires that an identifier be present in the object; first call setIdentifier()');
}
$array = array(
'identifier' => $identifier,
'items' => array_values($this->getItems()),
);
$metadata = $this->getMetadata();
if (!empty($metadata)) {
foreach ($metadata as $key => $value) {
$array[$key] = $value;
}
}
if (null !== ($label = $this->getLabel())) {
$array['label'] = $label;
}
return $array;
}
/**
* Serialize to JSON (dojo.data format)
*
* @return string
*/
public function toJson()
{
require_once 'Zend/Json.php';
return Zend_Json::encode($this->toArray());
}
/**
* Serialize to string (proxy to {@link toJson()})
*
* @return string
*/
public function __toString()
{
return $this->toJson();
}
/**
* ArrayAccess: does offset exist?
*
* @param string|int $offset
* @return bool
*/
public function offsetExists($offset)
{
return (null !== $this->getItem($offset));
}
/**
* ArrayAccess: retrieve by offset
*
* @param string|int $offset
* @return array
*/
public function offsetGet($offset)
{
return $this->getItem($offset);
}
/**
* ArrayAccess: set value by offset
*
* @param string $offset
* @param array|object|null $value
* @return void
*/
public function offsetSet($offset, $value)
{
$this->setItem($value, $offset);
}
/**
* ArrayAccess: unset value by offset
*
* @param string $offset
* @return void
*/
public function offsetUnset($offset)
{
$this->removeItem($offset);
}
/**
* Iterator: get current value
*
* @return array
*/
public function current()
{
return current($this->_items);
}
/**
* Iterator: get current key
*
* @return string|int
*/
public function key()
{
return key($this->_items);
}
/**
* Iterator: get next item
*
* @return void
*/
public function next()
{
return next($this->_items);
}
/**
* Iterator: rewind to first value in collection
*
* @return void
*/
public function rewind()
{
return reset($this->_items);
}
/**
* Iterator: is item valid?
*
* @return bool
*/
public function valid()
{
return (bool) $this->current();
}
/**
* Countable: how many items are present
*
* @return int
*/
public function count()
{
return count($this->_items);
}
/**
* Normalize an item to attach to the collection
*
* @param array|object $item
* @param string|int|null $id
* @return array
*/
protected function _normalizeItem($item, $id)
{
if (null === ($identifier = $this->getIdentifier())) {
require_once 'Zend/Dojo/Exception.php';
throw new Zend_Dojo_Exception('You must set an identifier prior to adding items');
}
if (!is_object($item) && !is_array($item)) {
require_once 'Zend/Dojo/Exception.php';
throw new Zend_Dojo_Exception('Only arrays and objects may be attached');
}
if (is_object($item)) {
if (method_exists($item, 'toArray')) {
$item = $item->toArray();
} else {
$item = get_object_vars($item);
}
}
if ((null === $id) && !array_key_exists($identifier, $item)) {
require_once 'Zend/Dojo/Exception.php';
throw new Zend_Dojo_Exception('Item must contain a column matching the currently set identifier');
} elseif (null === $id) {
$id = $item[$identifier];
} else {
$item[$identifier] = $id;
}
return array(
'id' => $id,
'data' => $item,
);
}
}
home/karenpetzb/library/Zend/Locale/Data.php 0000604 00000161236 15071410615 0014773 0 ustar 00 <?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Locale
* @subpackage Data
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Data.php 12057 2008-10-21 17:19:43Z thomas $
*/
/**
* include needed classes
*/
require_once 'Zend/Locale.php';
/**
* Locale data reader, handles the CLDR
*
* @category Zend
* @package Zend_Locale
* @subpackage Data
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Locale_Data
{
/**
* Locale files
*
* @var ressource
* @access private
*/
private static $_ldml = array();
/**
* List of values which are collected
*
* @var array
* @access private
*/
private static $_list = array();
/**
* Internal cache for ldml values
*
* @var Zend_Cache_Core
* @access private
*/
private static $_cache = null;
/**
* Read the content from locale
*
* Can be called like:
* <ldml>
* <delimiter>test</delimiter>
* <second type='myone'>content</second>
* <second type='mysecond'>content2</second>
* <third type='mythird' />
* </ldml>
*
* Case 1: _readFile('ar','/ldml/delimiter') -> returns [] = test
* Case 1: _readFile('ar','/ldml/second[@type=myone]') -> returns [] = content
* Case 2: _readFile('ar','/ldml/second','type') -> returns [myone] = content; [mysecond] = content2
* Case 3: _readFile('ar','/ldml/delimiter',,'right') -> returns [right] = test
* Case 4: _readFile('ar','/ldml/third','type','myone') -> returns [myone] = mythird
*
* @param string $locale
* @param string $path
* @param string $attribute
* @param string $value
* @access private
* @return array
*/
private static function _readFile($locale, $path, $attribute, $value, $temp)
{
// without attribute - read all values
// with attribute - read only this value
if (!empty(self::$_ldml[(string) $locale])) {
$result = self::$_ldml[(string) $locale]->xpath($path);
if (!empty($result)) {
foreach ($result as &$found) {
if (empty($value)) {
if (empty($attribute)) {
// Case 1
$temp[] = (string) $found;
} else if (empty($temp[(string) $found[$attribute]])){
// Case 2
$temp[(string) $found[$attribute]] = (string) $found;
}
} else if (empty ($temp[$value])) {
if (empty($attribute)) {
// Case 3
$temp[$value] = (string) $found;
} else {
// Case 4
$temp[$value] = (string) $found[$attribute];
}
}
}
}
}
return $temp;
}
/**
* Find possible routing to other path or locale
*
* @param string $locale
* @param string $path
* @param string $attribute
* @param string $value
* @param array $temp
* @throws Zend_Locale_Exception
* @access private
*/
private static function _findRoute($locale, $path, $attribute, $value, &$temp)
{
// load locale file if not already in cache
// needed for alias tag when referring to other locale
if (empty(self::$_ldml[(string) $locale])) {
$filename = dirname(__FILE__) . '/Data/' . $locale . '.xml';
if (!file_exists($filename)) {
require_once 'Zend/Locale/Exception.php';
throw new Zend_Locale_Exception("Missing locale file '$filename' for '$locale' locale.");
}
self::$_ldml[(string) $locale] = simplexml_load_file($filename);
}
// search for 'alias' tag in the search path for redirection
$search = '';
$tok = strtok($path, '/');
// parse the complete path
if (!empty(self::$_ldml[(string) $locale])) {
while ($tok !== false) {
$search .= '/' . $tok;
if (strpos($search, '[@') !== false) {
while (strrpos($search, '[@') > strrpos($search, ']')) {
$tok = strtok('/');
if (empty($tok)) {
$search .= '/';
}
$search = $search . '/' . $tok;
}
}
$result = self::$_ldml[(string) $locale]->xpath($search . '/alias');
// alias found
if (!empty($result)) {
$source = $result[0]['source'];
$newpath = $result[0]['path'];
// new path - path //ldml is to ignore
if ($newpath != '//ldml') {
// other path - parse to make real path
while (substr($newpath,0,3) == '../') {
$newpath = substr($newpath, 3);
$search = substr($search, 0, strrpos($search, '/'));
}
// truncate ../ to realpath otherwise problems with alias
$path = $search . '/' . $newpath;
while (($tok = strtok('/'))!== false) {
$path = $path . '/' . $tok;
}
}
// reroute to other locale
if ($source != 'locale') {
$locale = $source;
}
$temp = self::_getFile($locale, $path, $attribute, $value, $temp);
return false;
}
$tok = strtok('/');
}
}
return true;
}
/**
* Read the right LDML file
*
* @param string $locale
* @param string $path
* @param string $attribute
* @param string $value
* @access private
*/
private static function _getFile($locale, $path, $attribute = false, $value = false, $temp = array())
{
$result = self::_findRoute($locale, $path, $attribute, $value, $temp);
if ($result) {
$temp = self::_readFile($locale, $path, $attribute, $value, $temp);
}
// parse required locales reversive
// example: when given zh_Hans_CN
// 1. -> zh_Hans_CN
// 2. -> zh_Hans
// 3. -> zh
// 4. -> root
if (($locale != 'root') && ($result)) {
$locale = substr($locale, 0, -strlen(strrchr($locale, '_')));
if (!empty($locale)) {
$temp = self::_getFile($locale, $path, $attribute, $value, $temp);
} else {
$temp = self::_getFile('root', $path, $attribute, $value, $temp);
}
}
return $temp;
}
/**
* Find the details for supplemental calendar datas
*
* @param string $locale Locale for Detaildata
* @param array $list List to search
* @return string Key for Detaildata
*/
private static function _calendarDetail($locale, $list)
{
$ret = "001";
foreach ($list as $key => $value) {
if (strpos($locale, '_') !== false) {
$locale = substr($locale, strpos($locale, '_') + 1);
}
if (strpos($key, $locale) !== false) {
$ret = $key;
break;
}
}
return $ret;
}
/**
* Internal function for checking the locale
*
* @param string|Zend_Locale $locale Locale to check
* @return string
*/
private static function _checkLocale($locale)
{
if (empty($locale)) {
$locale = new Zend_Locale();
}
if (!(Zend_Locale::isLocale((string) $locale, null, false))) {
require_once 'Zend/Locale/Exception.php';
throw new Zend_Locale_Exception("Locale (" . (string) $locale . ") is a unknown locale");
}
return (string) $locale;
}
/**
* Read the LDML file, get a array of multipath defined value
*
* @param string $locale
* @param string $path
* @param string $value
* @return array
* @access public
*/
public static function getList($locale, $path, $value = false)
{
$locale = self::_checkLocale($locale);
if (isset(self::$_cache)) {
$val = $value;
if (is_array($value)) {
$val = implode('_' , $value);
}
$val = urlencode($val);
$id = strtr('Zend_LocaleL_' . $locale . '_' . $path . '_' . $val, array('-' => '_', '%' => '_', '+' => '_'));
if ($result = self::$_cache->load($id)) {
return unserialize($result);
}
}
$temp = array();
switch(strtolower($path)) {
case 'language':
$temp = self::_getFile($locale, '/ldml/localeDisplayNames/languages/language', 'type');
break;
case 'script':
$temp = self::_getFile($locale, '/ldml/localeDisplayNames/scripts/script', 'type');
break;
case 'territory':
$temp = self::_getFile($locale, '/ldml/localeDisplayNames/territories/territory', 'type');
if ($value === 1) {
foreach($temp as $key => $value) {
if ((is_numeric($key) === false) and ($key != 'QO') and ($key != 'QU')) {
unset($temp[$key]);
}
}
} else if ($value === 2) {
foreach($temp as $key => $value) {
if (is_numeric($key) or ($key == 'QO') or ($key == 'QU')) {
unset($temp[$key]);
}
}
}
break;
case 'variant':
$temp = self::_getFile($locale, '/ldml/localeDisplayNames/variants/variant', 'type');
break;
case 'key':
$temp = self::_getFile($locale, '/ldml/localeDisplayNames/keys/key', 'type');
break;
case 'type':
if (empty($type)) {
$temp = self::_getFile($locale, '/ldml/localeDisplayNames/types/type', 'type');
} else {
if (($value == 'calendar') or
($value == 'collation') or
($value == 'currency')) {
$temp = self::_getFile($locale, '/ldml/localeDisplayNames/types/type[@key=\'' . $value . '\']', 'type');
} else {
$temp = self::_getFile($locale, '/ldml/localeDisplayNames/types/type[@type=\'' . $value . '\']', 'type');
}
}
break;
case 'layout':
$temp = self::_getFile($locale, '/ldml/layout/orientation', 'lines', 'lines');
$temp += self::_getFile($locale, '/ldml/layout/orientation', 'characters', 'characters');
$temp += self::_getFile($locale, '/ldml/layout/inList', '', 'inList');
$temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'currency\']', '', 'currency');
$temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'dayWidth\']', '', 'dayWidth');
$temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'fields\']', '', 'fields');
$temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'keys\']', '', 'keys');
$temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'languages\']', '', 'languages');
$temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'long\']', '', 'long');
$temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'measurementSystemNames\']', '', 'measurementSystemNames');
$temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'monthWidth\']', '', 'monthWidth');
$temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'quarterWidth\']', '', 'quarterWidth');
$temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'scripts\']', '', 'scripts');
$temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'territories\']', '', 'territories');
$temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'types\']', '', 'types');
$temp += self::_getFile($locale, '/ldml/layout/inText[@type=\'variants\']', '', 'variants');
break;
case 'characters':
$temp = self::_getFile($locale, '/ldml/characters/exemplarCharacters', '', 'characters');
$temp += self::_getFile($locale, '/ldml/characters/exemplarCharacters[@type=\'auxiliary\']', '', 'auxiliary');
$temp += self::_getFile($locale, '/ldml/characters/exemplarCharacters[@type=\'currencySymbol\']', '', 'currencySymbol');
break;
case 'delimiters':
$temp = self::_getFile($locale, '/ldml/delimiters/quotationStart', '', 'quoteStart');
$temp += self::_getFile($locale, '/ldml/delimiters/quotationEnd', '', 'quoteEnd');
$temp += self::_getFile($locale, '/ldml/delimiters/alternateQuotationStart', '', 'quoteStartAlt');
$temp += self::_getFile($locale, '/ldml/delimiters/alternateQuotationEnd', '', 'quoteEndAlt');
break;
case 'measurement':
$temp = self::_getFile('supplementalData', '/supplementalData/measurementData/measurementSystem[@type=\'metric\']', 'territories', 'metric');
$temp += self::_getFile('supplementalData', '/supplementalData/measurementData/measurementSystem[@type=\'US\']', 'territories', 'US');
$temp += self::_getFile('supplementalData', '/supplementalData/measurementData/paperSize[@type=\'A4\']', 'territories', 'A4');
$temp += self::_getFile('supplementalData', '/supplementalData/measurementData/paperSize[@type=\'US-Letter\']', 'territories', 'US-Letter');
break;
case 'months':
if (empty($value)) {
$value = "gregorian";
}
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/default', 'choice', 'context');
$temp += self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'format\']/default', 'choice', 'default');
$temp['format']['abbreviated'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'format\']/monthWidth[@type=\'abbreviated\']/month', 'type');
$temp['format']['narrow'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'format\']/monthWidth[@type=\'narrow\']/month', 'type');
$temp['format']['wide'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'format\']/monthWidth[@type=\'wide\']/month', 'type');
$temp['stand-alone']['abbreviated'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'stand-alone\']/monthWidth[@type=\'abbreviated\']/month', 'type');
$temp['stand-alone']['narrow'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'stand-alone\']/monthWidth[@type=\'narrow\']/month', 'type');
$temp['stand-alone']['wide'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'stand-alone\']/monthWidth[@type=\'wide\']/month', 'type');
break;
case 'month':
if (empty($value)) {
$value = array("gregorian", "format", "wide");
}
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/months/monthContext[@type=\'' . $value[1] . '\']/monthWidth[@type=\'' . $value[2] . '\']/month', 'type');
break;
case 'days':
if (empty($value)) {
$value = "gregorian";
}
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/default', 'choice', 'context');
$temp += self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'format\']/default', 'choice', 'default');
$temp['format']['abbreviated'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'format\']/dayWidth[@type=\'abbreviated\']/day', 'type');
$temp['format']['narrow'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'format\']/dayWidth[@type=\'narrow\']/day', 'type');
$temp['format']['wide'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'format\']/dayWidth[@type=\'wide\']/day', 'type');
$temp['stand-alone']['abbreviated'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'stand-alone\']/dayWidth[@type=\'abbreviated\']/day', 'type');
$temp['stand-alone']['narrow'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'stand-alone\']/dayWidth[@type=\'narrow\']/day', 'type');
$temp['stand-alone']['wide'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'stand-alone\']/dayWidth[@type=\'wide\']/day', 'type');
break;
case 'day':
if (empty($value)) {
$value = array("gregorian", "format", "wide");
}
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/days/dayContext[@type=\'' . $value[1] . '\']/dayWidth[@type=\'' . $value[2] . '\']/day', 'type');
break;
case 'week':
$minDays = self::_calendarDetail($locale, self::_getFile('supplementalData', '/supplementalData/weekData/minDays', 'territories'));
$firstDay = self::_calendarDetail($locale, self::_getFile('supplementalData', '/supplementalData/weekData/firstDay', 'territories'));
$weekStart = self::_calendarDetail($locale, self::_getFile('supplementalData', '/supplementalData/weekData/weekendStart', 'territories'));
$weekEnd = self::_calendarDetail($locale, self::_getFile('supplementalData', '/supplementalData/weekData/weekendEnd', 'territories'));
$temp = self::_getFile('supplementalData', "/supplementalData/weekData/minDays[@territories='" . $minDays . "']", 'count', 'minDays');
$temp += self::_getFile('supplementalData', "/supplementalData/weekData/firstDay[@territories='" . $firstDay . "']", 'day', 'firstDay');
$temp += self::_getFile('supplementalData', "/supplementalData/weekData/weekendStart[@territories='" . $weekStart . "']", 'day', 'weekendStart');
$temp += self::_getFile('supplementalData', "/supplementalData/weekData/weekendEnd[@territories='" . $weekEnd . "']", 'day', 'weekendEnd');
break;
case 'quarters':
if (empty($value)) {
$value = "gregorian";
}
$temp['format']['abbreviated'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/quarters/quarterContext[@type=\'format\']/quarterWidth[@type=\'abbreviated\']/quarter', 'type');
$temp['format']['narrow'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/quarters/quarterContext[@type=\'format\']/quarterWidth[@type=\'narrow\']/quarter', 'type');
$temp['format']['wide'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/quarters/quarterContext[@type=\'format\']/quarterWidth[@type=\'wide\']/quarter', 'type');
$temp['stand-alone']['abbreviated'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/quarters/quarterContext[@type=\'stand-alone\']/quarterWidth[@type=\'abbreviated\']/quarter', 'type');
$temp['stand-alone']['narrow'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/quarters/quarterContext[@type=\'stand-alone\']/quarterWidth[@type=\'narrow\']/quarter', 'type');
$temp['stand-alone']['wide'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/quarters/quarterContext[@type=\'stand-alone\']/quarterWidth[@type=\'wide\']/quarter', 'type');
break;
case 'quarter':
if (empty($value)) {
$value = array("gregorian", "format", "wide");
}
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/quarters/quarterContext[@type=\'' . $value[1] . '\']/quarterWidth[@type=\'' . $value[2] . '\']/quarter', 'type');
break;
case 'eras':
if (empty($value)) {
$value = "gregorian";
}
$temp['names'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/eras/eraNames/era', 'type');
$temp['abbreviated'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/eras/eraAbbr/era', 'type');
$temp['narrow'] = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/eras/eraNarrow/era', 'type');
break;
case 'era':
if (empty($value)) {
$value = array("gregorian", "Abbr");
}
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/eras/era' . $value[1] . '/era', 'type');
break;
case 'date':
if (empty($value)) {
$value = "gregorian";
}
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateFormats/dateFormatLength[@type=\'full\']/dateFormat/pattern', '', 'full');
$temp += self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateFormats/dateFormatLength[@type=\'long\']/dateFormat/pattern', '', 'long');
$temp += self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateFormats/dateFormatLength[@type=\'medium\']/dateFormat/pattern', '', 'medium');
$temp += self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateFormats/dateFormatLength[@type=\'short\']/dateFormat/pattern', '', 'short');
break;
case 'time':
if (empty($value)) {
$value = "gregorian";
}
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/timeFormats/timeFormatLength[@type=\'full\']/timeFormat/pattern', '', 'full');
$temp += self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/timeFormats/timeFormatLength[@type=\'long\']/timeFormat/pattern', '', 'long');
$temp += self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/timeFormats/timeFormatLength[@type=\'medium\']/timeFormat/pattern', '', 'medium');
$temp += self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/timeFormats/timeFormatLength[@type=\'short\']/timeFormat/pattern', '', 'short');
break;
case 'datetime':
if (empty($value)) {
$value = "gregorian";
}
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateTimeFormats/availableFormats/dateFormatItem', 'id');
break;
case 'field':
if (empty($value)) {
$value = "gregorian";
}
$temp2 = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/fields/field', 'type');
foreach ($temp2 as $key => $keyvalue) {
$temp += self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/fields/field[@type=\'' . $key . '\']/displayName', '', $key);
}
break;
case 'relative':
if (empty($value)) {
$value = "gregorian";
}
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/fields/field/relative', 'type');
break;
case 'symbols':
$temp = self::_getFile($locale, '/ldml/numbers/symbols/decimal', '', 'decimal');
$temp += self::_getFile($locale, '/ldml/numbers/symbols/group', '', 'group');
$temp += self::_getFile($locale, '/ldml/numbers/symbols/list', '', 'list');
$temp += self::_getFile($locale, '/ldml/numbers/symbols/percentSign', '', 'percent');
$temp += self::_getFile($locale, '/ldml/numbers/symbols/nativeZeroDigit', '', 'zero');
$temp += self::_getFile($locale, '/ldml/numbers/symbols/patternDigit', '', 'pattern');
$temp += self::_getFile($locale, '/ldml/numbers/symbols/plusSign', '', 'plus');
$temp += self::_getFile($locale, '/ldml/numbers/symbols/minusSign', '', 'minus');
$temp += self::_getFile($locale, '/ldml/numbers/symbols/exponential', '', 'exponent');
$temp += self::_getFile($locale, '/ldml/numbers/symbols/perMille', '', 'mille');
$temp += self::_getFile($locale, '/ldml/numbers/symbols/infinity', '', 'infinity');
$temp += self::_getFile($locale, '/ldml/numbers/symbols/nan', '', 'nan');
break;
case 'nametocurrency':
$_temp = self::_getFile($locale, '/ldml/numbers/currencies/currency', 'type');
foreach ($_temp as $key => $found) {
$temp += self::_getFile($locale, '/ldml/numbers/currencies/currency[@type=\'' . $key . '\']/displayName', '', $key);
}
break;
case 'currencytoname':
$_temp = self::_getFile($locale, '/ldml/numbers/currencies/currency', 'type');
foreach ($_temp as $key => $keyvalue) {
$val = self::_getFile($locale, '/ldml/numbers/currencies/currency[@type=\'' . $key . '\']/displayName', '', $key);
if (!isset($val[$key])) {
continue;
}
if (!isset($temp[$val[$key]])) {
$temp[$val[$key]] = $key;
} else {
$temp[$val[$key]] .= " " . $key;
}
}
break;
case 'currencysymbol':
$_temp = self::_getFile($locale, '/ldml/numbers/currencies/currency', 'type');
foreach ($_temp as $key => $found) {
$temp += self::_getFile($locale, '/ldml/numbers/currencies/currency[@type=\'' . $key . '\']/symbol', '', $key);
}
break;
case 'question':
$temp = self::_getFile($locale, '/ldml/posix/messages/yesstr', '', 'yes');
$temp += self::_getFile($locale, '/ldml/posix/messages/nostr', '', 'no');
break;
case 'currencyfraction':
$_temp = self::_getFile('supplementalData', '/supplementalData/currencyData/fractions/info', 'iso4217');
foreach ($_temp as $key => $found) {
$temp += self::_getFile('supplementalData', '/supplementalData/currencyData/fractions/info[@iso4217=\'' . $key . '\']', 'digits', $key);
}
break;
case 'currencyrounding':
$_temp = self::_getFile('supplementalData', '/supplementalData/currencyData/fractions/info', 'iso4217');
foreach ($_temp as $key => $found) {
$temp += self::_getFile('supplementalData', '/supplementalData/currencyData/fractions/info[@iso4217=\'' . $key . '\']', 'rounding', $key);
}
break;
case 'currencytoregion':
$_temp = self::_getFile('supplementalData', '/supplementalData/currencyData/region', 'iso3166');
foreach ($_temp as $key => $keyvalue) {
$temp += self::_getFile('supplementalData', '/supplementalData/currencyData/region[@iso3166=\'' . $key . '\']/currency', 'iso4217', $key);
}
break;
case 'regiontocurrency':
$_temp = self::_getFile('supplementalData', '/supplementalData/currencyData/region', 'iso3166');
foreach ($_temp as $key => $keyvalue) {
$val = self::_getFile('supplementalData', '/supplementalData/currencyData/region[@iso3166=\'' . $key . '\']/currency', 'iso4217', $key);
if (!isset($val[$key])) {
continue;
}
if (!isset($temp[$val[$key]])) {
$temp[$val[$key]] = $key;
} else {
$temp[$val[$key]] .= " " . $key;
}
}
break;
case 'regiontoterritory':
$_temp = self::_getFile('supplementalData', '/supplementalData/territoryContainment/group', 'type');
foreach ($_temp as $key => $found) {
$temp += self::_getFile('supplementalData', '/supplementalData/territoryContainment/group[@type=\'' . $key . '\']', 'contains', $key);
}
break;
case 'territorytoregion':
$_temp2 = self::_getFile('supplementalData', '/supplementalData/territoryContainment/group', 'type');
$_temp = array();
foreach ($_temp2 as $key => $found) {
$_temp += self::_getFile('supplementalData', '/supplementalData/territoryContainment/group[@type=\'' . $key . '\']', 'contains', $key);
}
foreach($_temp as $key => $found) {
$_temp3 = explode(" ", $found);
foreach($_temp3 as $found3) {
if (!isset($temp[$found3])) {
$temp[$found3] = (string) $key;
} else {
$temp[$found3] .= " " . $key;
}
}
}
break;
case 'scripttolanguage':
$_temp = self::_getFile('supplementalData', '/supplementalData/languageData/language', 'type');
foreach ($_temp as $key => $found) {
$temp += self::_getFile('supplementalData', '/supplementalData/languageData/language[@type=\'' . $key . '\']', 'scripts', $key);
if (empty($temp[$key])) {
unset($temp[$key]);
}
}
break;
case 'languagetoscript':
$_temp2 = self::_getFile('supplementalData', '/supplementalData/languageData/language', 'type');
$_temp = array();
foreach ($_temp2 as $key => $found) {
$_temp += self::_getFile('supplementalData', '/supplementalData/languageData/language[@type=\'' . $key . '\']', 'scripts', $key);
}
foreach($_temp as $key => $found) {
$_temp3 = explode(" ", $found);
foreach($_temp3 as $found3) {
if (empty($found3)) {
continue;
}
if (!isset($temp[$found3])) {
$temp[$found3] = (string) $key;
} else {
$temp[$found3] .= " " . $key;
}
}
}
break;
case 'territorytolanguage':
$_temp = self::_getFile('supplementalData', '/supplementalData/languageData/language', 'type');
foreach ($_temp as $key => $found) {
$temp += self::_getFile('supplementalData', '/supplementalData/languageData/language[@type=\'' . $key . '\']', 'territories', $key);
if (empty($temp[$key])) {
unset($temp[$key]);
}
}
break;
case 'languagetoterritory':
$_temp2 = self::_getFile('supplementalData', '/supplementalData/languageData/language', 'type');
$_temp = array();
foreach ($_temp2 as $key => $found) {
$_temp += self::_getFile('supplementalData', '/supplementalData/languageData/language[@type=\'' . $key . '\']', 'territories', $key);
}
foreach($_temp as $key => $found) {
$_temp3 = explode(" ", $found);
foreach($_temp3 as $found3) {
if (empty($found3)) {
continue;
}
if (!isset($temp[$found3])) {
$temp[$found3] = (string) $key;
} else {
$temp[$found3] .= " " . $key;
}
}
}
break;
case 'timezonetowindows':
$_temp = self::_getFile('supplementalData', '/supplementalData/timezoneData/mapTimezones[@type=\'windows\']/mapZone', 'other');
foreach ($_temp as $key => $found) {
$temp += self::_getFile('supplementalData', '/supplementalData/timezoneData/mapTimezones[@type=\'windows\']/mapZone[@other=\'' . $key . '\']', 'type', $key);
}
break;
case 'windowstotimezone':
$_temp = self::_getFile('supplementalData', '/supplementalData/timezoneData/mapTimezones[@type=\'windows\']/mapZone', 'type');
foreach ($_temp as $key => $found) {
$temp += self::_getFile('supplementalData', '/supplementalData/timezoneData/mapTimezones[@type=\'windows\']/mapZone[@type=\'' .$key . '\']', 'other', $key);
}
break;
case 'territorytotimezone':
$_temp = self::_getFile('supplementalData', '/supplementalData/timezoneData/zoneFormatting/zoneItem', 'type');
foreach ($_temp as $key => $found) {
$temp += self::_getFile('supplementalData', '/supplementalData/timezoneData/zoneFormatting/zoneItem[@type=\'' . $key . '\']', 'territory', $key);
}
break;
case 'timezonetoterritory':
$_temp = self::_getFile('supplementalData', '/supplementalData/timezoneData/zoneFormatting/zoneItem', 'territory');
foreach ($_temp as $key => $found) {
$temp += self::_getFile('supplementalData', '/supplementalData/timezoneData/zoneFormatting/zoneItem[@territory=\'' . $key . '\']', 'type', $key);
}
break;
case 'citytotimezone':
$_temp = self::_getFile($locale, '/ldml/dates/timeZoneNames/zone', 'type');
foreach($_temp as $key => $found) {
$temp += self::_getFile($locale, '/ldml/dates/timeZoneNames/zone[@type=\'' . $key . '\']/exemplarCity', '', $key);
}
break;
case 'timezonetocity':
$_temp = self::_getFile($locale, '/ldml/dates/timeZoneNames/zone', 'type');
$temp = array();
foreach($_temp as $key => $found) {
$temp += self::_getFile($locale, '/ldml/dates/timeZoneNames/zone[@type=\'' . $key . '\']/exemplarCity', '', $key);
if (!empty($temp[$key])) {
$temp[$temp[$key]] = $key;
}
unset($temp[$key]);
}
break;
default :
require_once 'Zend/Locale/Exception.php';
throw new Zend_Locale_Exception("Unknown list ($path) for parsing locale data.");
break;
}
if (isset(self::$_cache)) {
self::$_cache->save( serialize($temp), $id);
}
return $temp;
}
/**
* Read the LDML file, get a single path defined value
*
* @param string $locale
* @param string $path
* @param string $value
* @return string
* @access public
*/
public static function getContent($locale, $path, $value = false)
{
$locale = self::_checkLocale($locale);
if (isset(self::$_cache)) {
$val = $value;
if (is_array($value)) {
$val = implode('_' , $value);
}
$val = urlencode($val);
$id = strtr('Zend_LocaleC_' . $locale . '_' . $path . '_' . $val, array('-' => '_', '%' => '_', '+' => '_'));
if ($result = self::$_cache->load($id)) {
return unserialize($result);
}
}
switch(strtolower($path)) {
case 'language':
$temp = self::_getFile($locale, '/ldml/localeDisplayNames/languages/language[@type=\'' . $value . '\']', 'type');
break;
case 'script':
$temp = self::_getFile($locale, '/ldml/localeDisplayNames/scripts/script[@type=\'' . $value . '\']', 'type');
break;
case 'country':
case 'territory':
$temp = self::_getFile($locale, '/ldml/localeDisplayNames/territories/territory[@type=\'' . $value . '\']', 'type');
break;
case 'variant':
$temp = self::_getFile($locale, '/ldml/localeDisplayNames/variants/variant[@type=\'' . $value . '\']', 'type');
break;
case 'key':
$temp = self::_getFile($locale, '/ldml/localeDisplayNames/keys/key[@type=\'' . $value . '\']', 'type');
break;
case 'datechars':
$temp = self::_getFile($locale, '/ldml/dates/localizedPatternChars', '', 'chars');
break;
case 'defaultcalendar':
$temp = self::_getFile($locale, '/ldml/dates/calendars/default', 'choice', 'default');
break;
case 'monthcontext':
if (empty ($value)) {
$value = "gregorian";
}
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/default', 'choice', 'context');
break;
case 'defaultmonth':
if (empty ($value)) {
$value = "gregorian";
}
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'format\']/default', 'choice', 'default');
break;
case 'month':
if (!is_array($value)) {
$temp = $value;
$value = array("gregorian", "format", "wide", $temp);
}
$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');
break;
case 'daycontext':
if (empty($value)) {
$value = "gregorian";
}
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/default', 'choice', 'context');
break;
case 'defaultday':
if (empty($value)) {
$value = "gregorian";
}
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'format\']/default', 'choice', 'default');
break;
case 'day':
if (!is_array($value)) {
$temp = $value;
$value = array("gregorian", "format", "wide", $temp);
}
$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');
break;
case 'quarter':
if (!is_array($value)) {
$temp = $value;
$value = array("gregorian", "format", "wide", $temp);
}
$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');
break;
case 'am':
if (empty($value)) {
$value = "gregorian";
}
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/am', '', 'am');
break;
case 'pm':
if (empty($value)) {
$value = "gregorian";
}
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/pm', '', 'pm');
break;
case 'era':
if (!is_array($value)) {
$temp = $value;
$value = array("gregorian", "Abbr", $temp);
}
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/eras/era' . $value[1] . '/era[@type=\'' . $value[2] . '\']', 'type');
break;
case 'defaultdate':
if (empty($value)) {
$value = "gregorian";
}
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateFormats/default', 'choice', 'default');
break;
case 'date':
if (empty($value)) {
$value = array("gregorian", "medium");
}
if (!is_array($value)) {
$temp = $value;
$value = array("gregorian", $temp);
}
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/dateFormats/dateFormatLength[@type=\'' . $value[1] . '\']/dateFormat/pattern', '', 'pattern');
break;
case 'defaulttime':
if (empty($value)) {
$value = "gregorian";
}
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/timeFormats/default', 'choice', 'default');
break;
case 'time':
if (empty($value)) {
$value = array("gregorian", "medium");
}
if (!is_array($value)) {
$temp = $value;
$value = array("gregorian", $temp);
}
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/timeFormats/timeFormatLength[@type=\'' . $value[1] . '\']/timeFormat/pattern', '', 'pattern');
break;
case 'datetime':
if (empty($value)) {
$value = "gregorian";
}
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateTimeFormats/dateTimeFormatLength/dateTimeFormat/pattern', '', 'pattern');
break;
case 'field':
if (!is_array($value)) {
$temp = $value;
$value = array("gregorian", $temp);
}
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/fields/field[@type=\'' . $value[1] . '\']/displayName', '', $value[1]);
break;
case 'relative':
if (!is_array($value)) {
$temp = $value;
$value = array("gregorian", $temp);
}
$temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/fields/field/relative[@type=\'' . $value[1] . '\']', '', $value[1]);
break;
case 'decimalnumber':
$temp = self::_getFile($locale, '/ldml/numbers/decimalFormats/decimalFormatLength/decimalFormat/pattern', '', 'default');
break;
case 'scientificnumber':
$temp = self::_getFile($locale, '/ldml/numbers/scientificFormats/scientificFormatLength/scientificFormat/pattern', '', 'default');
break;
case 'percentnumber':
$temp = self::_getFile($locale, '/ldml/numbers/percentFormats/percentFormatLength/percentFormat/pattern', '', 'default');
break;
case 'currencynumber':
$temp = self::_getFile($locale, '/ldml/numbers/currencyFormats/currencyFormatLength/currencyFormat/pattern', '', 'default');
break;
case 'nametocurrency':
$temp = self::_getFile($locale, '/ldml/numbers/currencies/currency[@type=\'' . $value . '\']/displayName', '', $value);
break;
case 'currencytoname':
$temp = self::_getFile($locale, '/ldml/numbers/currencies/currency[@type=\'' . $value . '\']/displayName', '', $value);
$_temp = self::_getFile($locale, '/ldml/numbers/currencies/currency', 'type');
$temp = array();
foreach ($_temp as $key => $keyvalue) {
$val = self::_getFile($locale, '/ldml/numbers/currencies/currency[@type=\'' . $key . '\']/displayName', '', $key);
if (!isset($val[$key]) or ($val[$key] != $value)) {
continue;
}
if (!isset($temp[$val[$key]])) {
$temp[$val[$key]] = $key;
} else {
$temp[$val[$key]] .= " " . $key;
}
}
break;
case 'currencysymbol':
$temp = self::_getFile($locale, '/ldml/numbers/currencies/currency[@type=\'' . $value . '\']/symbol', '', $value);
break;
case 'question':
$temp = self::_getFile($locale, '/ldml/posix/messages/' . $value . 'str', '', $value);
break;
case 'currencyfraction':
if (empty($value)) {
$value = "DEFAULT";
}
$temp = self::_getFile('supplementalData', '/supplementalData/currencyData/fractions/info[@iso4217=\'' . $value . '\']', 'digits', 'digits');
break;
case 'currencyrounding':
if (empty($value)) {
$value = "DEFAULT";
}
$temp = self::_getFile('supplementalData', '/supplementalData/currencyData/fractions/info[@iso4217=\'' . $value . '\']', 'rounding', 'rounding');
break;
case 'currencytoregion':
$temp = self::_getFile('supplementalData', '/supplementalData/currencyData/region[@iso3166=\'' . $value . '\']/currency', 'iso4217', $value);
break;
case 'regiontocurrency':
$_temp = self::_getFile('supplementalData', '/supplementalData/currencyData/region', 'iso3166');
$temp = array();
foreach ($_temp as $key => $keyvalue) {
$val = self::_getFile('supplementalData', '/supplementalData/currencyData/region[@iso3166=\'' . $key . '\']/currency', 'iso4217', $key);
if (!isset($val[$key]) or ($val[$key] != $value)) {
continue;
}
if (!isset($temp[$val[$key]])) {
$temp[$val[$key]] = $key;
} else {
$temp[$val[$key]] .= " " . $key;
}
}
break;
case 'regiontoterritory':
$temp = self::_getFile('supplementalData', '/supplementalData/territoryContainment/group[@type=\'' . $value . '\']', 'contains', $value);
break;
case 'territorytoregion':
$_temp2 = self::_getFile('supplementalData', '/supplementalData/territoryContainment/group', 'type');
$_temp = array();
foreach ($_temp2 as $key => $found) {
$_temp += self::_getFile('supplementalData', '/supplementalData/territoryContainment/group[@type=\'' . $key . '\']', 'contains', $key);
}
$temp = array();
foreach($_temp as $key => $found) {
$_temp3 = explode(" ", $found);
foreach($_temp3 as $found3) {
if ($found3 !== $value) {
continue;
}
if (!isset($temp[$found3])) {
$temp[$found3] = (string) $key;
} else {
$temp[$found3] .= " " . $key;
}
}
}
break;
case 'scripttolanguage':
$temp = self::_getFile('supplementalData', '/supplementalData/languageData/language[@type=\'' . $value . '\']', 'scripts', $value);
break;
case 'languagetoscript':
$_temp2 = self::_getFile('supplementalData', '/supplementalData/languageData/language', 'type');
$_temp = array();
foreach ($_temp2 as $key => $found) {
$_temp += self::_getFile('supplementalData', '/supplementalData/languageData/language[@type=\'' . $key . '\']', 'scripts', $key);
}
$temp = array();
foreach($_temp as $key => $found) {
$_temp3 = explode(" ", $found);
foreach($_temp3 as $found3) {
if ($found3 !== $value) {
continue;
}
if (!isset($temp[$found3])) {
$temp[$found3] = (string) $key;
} else {
$temp[$found3] .= " " . $key;
}
}
}
break;
case 'territorytolanguage':
$temp = self::_getFile('supplementalData', '/supplementalData/languageData/language[@type=\'' . $value . '\']', 'territories', $value);
break;
case 'languagetoterritory':
$_temp2 = self::_getFile('supplementalData', '/supplementalData/languageData/language', 'type');
$_temp = array();
foreach ($_temp2 as $key => $found) {
$_temp += self::_getFile('supplementalData', '/supplementalData/languageData/language[@type=\'' . $key . '\']', 'territories', $key);
}
$temp = array();
foreach($_temp as $key => $found) {
$_temp3 = explode(" ", $found);
foreach($_temp3 as $found3) {
if ($found3 !== $value) {
continue;
}
if (!isset($temp[$found3])) {
$temp[$found3] = (string) $key;
} else {
$temp[$found3] .= " " . $key;
}
}
}
break;
case 'timezonetowindows':
$temp = self::_getFile('supplementalData', '/supplementalData/timezoneData/mapTimezones[@type=\'windows\']/mapZone[@other=\''.$value.'\']', 'type', $value);
break;
case 'windowstotimezone':
$temp = self::_getFile('supplementalData', '/supplementalData/timezoneData/mapTimezones[@type=\'windows\']/mapZone[@type=\''.$value.'\']', 'other', $value);
break;
case 'territorytotimezone':
$temp = self::_getFile('supplementalData', '/supplementalData/timezoneData/zoneFormatting/zoneItem[@type=\'' . $value . '\']', 'territory', $value);
break;
case 'timezonetoterritory':
$temp = self::_getFile('supplementalData', '/supplementalData/timezoneData/zoneFormatting/zoneItem[@territory=\'' . $value . '\']', 'type', $value);
break;
case 'citytotimezone':
$temp = self::_getFile($locale, '/ldml/dates/timeZoneNames/zone[@type=\'' . $value . '\']/exemplarCity', '', $value);
break;
case 'timezonetocity':
$_temp = self::_getFile($locale, '/ldml/dates/timeZoneNames/zone', 'type');
$temp = array();
foreach($_temp as $key => $found) {
$temp += self::_getFile($locale, '/ldml/dates/timeZoneNames/zone[@type=\'' . $key . '\']/exemplarCity', '', $key);
if (!empty($temp[$key])) {
if ($temp[$key] == $value) {
$temp[$temp[$key]] = $key;
}
}
unset($temp[$key]);
}
break;
default :
require_once 'Zend/Locale/Exception.php';
throw new Zend_Locale_Exception("Unknown detail ($path) for parsing locale data.");
break;
}
if (is_array($temp)) {
$temp = current($temp);
}
if (isset(self::$_cache)) {
self::$_cache->save( serialize($temp), $id);
}
return $temp;
}
/**
* Returns the set cache
*
* @return Zend_Cache_Core The set cache
*/
public static function getCache()
{
return self::$_cache;
}
/**
* Set a cache for Zend_Locale_Data
*
* @param Zend_Cache_Core $cache A cache frontend
*/
public static function setCache(Zend_Cache_Core $cache)
{
self::$_cache = $cache;
}
/**
* Returns true when a cache is set
*
* @return boolean
*/
public static function hasCache()
{
if (self::$_cache !== null) {
return true;
}
return false;
}
/**
* Removes any set cache
*
* @return void
*/
public static function removeCache()
{
self::$_cache = null;
}
/**
* Clears all set cache data
*
* @return void
*/
public static function clearCache()
{
self::$_cache->clean();
}
}