芝麻web文件管理V1.00
编辑当前文件:/home/pulsehostuk9/public_html/portal.pulsehost.co.uk/vendor/punic/punic/src/Data.php
$language, 'script' => $script, 'territory' => $territory, 'parentLocale' => $parentLocale, ); } } } } return $result; } /** * Get value from nested array. * * @param array $data the nested array to descend into * @param array $path Path of array keys. Each part of the path may be a string or an array of alternative strings. * * @return mixed|null */ public static function getArrayValue(array $data, array $path) { $alternatives = array_shift($path); if ($alternatives === null) { return $data; } foreach ((array) $alternatives as $alternative) { if (array_key_exists($alternative, $data)) { $data = $data[$alternative]; return is_array($data) ? self::getArrayValue($data, $path) : ($path ? null : $data); } } return null; } /** * @deprecated * * @param string $territory * * @return string */ protected static function getParentTerritory($territory) { return Territory::getParentTerritoryCode($territory); } /** * @deprecated * * @param string $parentTerritory * * @return array */ protected static function expandTerritoryGroup($parentTerritory) { return Territory::getChildTerritoryCodes($parentTerritory, true); } /** * Returns the path of the locale-specific data, looking also for the fallback locale. * * @param string $locale The locale for which you want the data folder * * @return string Returns an empty string if the folder is not found, the absolute path to the folder otherwise */ protected static function getLocaleFolder($locale) { static $cache = array(); $result = ''; if (is_string($locale)) { $key = $locale.'/'.static::$fallbackLocale; if (!isset($cache[$key])) { $dir = static::getDataDirectory(); foreach (static::getLocaleAlternatives($locale) as $alternative) { if (is_dir($dir.DIRECTORY_SEPARATOR.$alternative)) { $result = $alternative; break; } } $cache[$key] = $result; } $result = $cache[$key]; } return $result; } /** * Returns a list of locale identifiers associated to a locale. * * @param string $locale The locale for which you want the alternatives * @param bool $addFallback Set to true to add the fallback locale to the result, false otherwise * * @return array */ protected static function getLocaleAlternatives($locale, $addFallback = true) { $result = array(); $localeInfo = static::explodeLocale($locale); if (!is_array($localeInfo)) { throw new Exception\InvalidLocale($locale); } $language = $localeInfo['language']; $script = $localeInfo['script']; $territory = $localeInfo['territory']; $parentLocale = $localeInfo['parentLocale']; if ($territory === '') { $fullLocale = static::guessFullLocale($language, $script); if ($fullLocale !== '') { $localeInfo = static::explodeLocale($fullLocale); $language = $localeInfo['language']; $script = $localeInfo['script']; $territory = $localeInfo['territory']; $parentLocale = $localeInfo['parentLocale']; } } $territories = array(); while ($territory !== '') { $territories[] = $territory; $territory = Territory::getParentTerritoryCode($territory); } if ($script !== '') { foreach ($territories as $territory) { $result[] = "{$language}-{$script}-{$territory}"; } } if ($script !== '') { $result[] = "{$language}-{$script}"; } foreach ($territories as $territory) { $result[] = "{$language}-{$territory}"; if ("{$language}-{$territory}" === 'en-US') { $result[] = 'root'; } } if ($parentLocale !== '') { $result = array_merge($result, static::getLocaleAlternatives($parentLocale, false)); } $result[] = $language; if ($addFallback && ($locale !== static::$fallbackLocale)) { $result = array_merge($result, static::getLocaleAlternatives(static::$fallbackLocale, false)); } for ($i = count($result) - 1; $i > 1; --$i) { for ($j = 0; $j < $i; ++$j) { if ($result[$i] === $result[$j]) { array_splice($result, $i, 1); break; } } } if ($locale !== 'root') { $i = array_search('root', $result, true); if ($i !== false) { array_splice($result, $i, 1); $result[] = 'root'; } } return $result; } protected static function merge(array $data, array $overrides) { foreach ($overrides as $key => $override) { if (isset($data[$key])) { if (gettype($override) !== gettype($data[$key])) { throw new Exception\InvalidOverride($data[$key], $override); } if (is_array($data[$key])) { $data[$key] = static::merge($data[$key], $override); } else { $data[$key] = $override; } } else { $data[$key] = $override; } } return $data; } }