当前位置: 首页>>代码示例>>PHP>>正文


PHP Environment::pathComponentsResource方法代码示例

本文整理汇总了PHP中Environment::pathComponentsResource方法的典型用法代码示例。如果您正苦于以下问题:PHP Environment::pathComponentsResource方法的具体用法?PHP Environment::pathComponentsResource怎么用?PHP Environment::pathComponentsResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Environment的用法示例。


在下文中一共展示了Environment::pathComponentsResource方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: load

 private static function load()
 {
     if (!($map = Cache::get(self::CACHE_KEY . '_map'))) {
         $path = Environment::pathComponentsResource('i18n', 'resource', 'i18n', 'script', 'hans.json');
         $map = json_decode(Io_File::valueOf($path)->getContent(), true);
         Cache::set(self::CACHE_KEY . '_map', $map);
     }
     self::$m_unicode =& $map['unicode'];
     self::$m_transformLatn =& $map['transform']['latin'];
 }
开发者ID:evalcodenet,项目名称:net.evalcode.components.i18n,代码行数:10,代码来源:hans.php

示例2: style

 /**
  * @param string $name_
  * @param string $media_
  *
  * @return boolean
  */
 public function style($name_, $media_ = 'all')
 {
     if (0 === strpos($name_, '/')) {
         return false;
     }
     $chunks = explode('/', $name_);
     $ns = array_shift($chunks);
     $path = Environment::pathComponentsResource($ns, 'resource', 'css', implode('/', $chunks) . '.css');
     $uri = Environment::uriComponentsResource($ns . '/css/' . implode('/', $chunks) . '.css');
     $options = [];
     $options['href'] = $uri;
     $options['media'] = $media_;
     $this->styles[$path] = $options;
     return true;
 }
开发者ID:evalcodenet,项目名称:net.evalcode.components.ui,代码行数:21,代码来源:embedded.php

示例3: importScript

 private function importScript($script_)
 {
     $target = Environment::pathComponentsResource('i18n', 'resource', 'i18n', 'script', "{$script_}.json");
     $ranges = array_chunk(self::$m_unicodeRanges[$script_], 2);
     $range = [];
     foreach ($ranges as $r) {
         $range = array_merge($range, range(reset($r), end($r)));
     }
     $range = array_flip($range);
     $mapScript = [];
     $mapScriptUnicode =& $mapScript['unicode'];
     $mapScriptTransformations =& $mapScript['transform'];
     foreach (self::$m_scripts[$script_] as $transformation) {
         $mapScriptTransformations[$transformation] = [];
         $mapScriptTransformationsCurrent =& $mapScriptTransformations[$transformation];
         $source = self::$m_sources[$script_][$transformation];
         $source = Environment::pathComponentsResource('i18n', 'resource', 'cldr', $source);
         // TODO Implement Io_File_Xml
         $xml = new \SimpleXMLElement(Io_File::valueOf($source)->getContent());
         /* @var $node \SimpleXMLElement */
         foreach ($xml->xpath('//supplementalData/transforms/transform/tRule') as $node) {
             $string = (string) $node;
             $chars = '';
             $trans = '';
             if (91 === ord($string[0])) {
                 $chars = mb_substr($string, 1, mb_strpos($string, chr(93)) - 1);
                 $ldim = mb_strrpos($string, chr(226));
                 $trans = mb_substr($string, $ldim + 1, mb_strrpos($string, chr(59)) - $ldim - 1);
             }
             $len = mb_strlen($chars);
             for ($i = 0; $i < $len; $i++) {
                 $char = mb_substr($chars, $i, 1);
                 $dec = Character::unicodeDecimal($char);
                 if (isset($range[$dec])) {
                     $mapScriptUnicode[$dec] = "    \"{$dec}\": \"{$char}\"";
                     $mapScriptTransformationsCurrent[$dec] = "      \"{$dec}\": \"{$trans}\"";
                 }
             }
         }
         $string = implode(",\n", $mapScriptUnicode);
     }
     $transform = [];
     foreach ($mapScript['transform'] as $script => $transformations) {
         $transform[] = sprintf('    "%1$s":%3$s    {%3$s%2$s%3$s    }%3$s', $script, implode(",\n", $transformations), Io::LINE_SEPARATOR_DEFAULT);
     }
     $file = new Io_File($target, Io_File::CREATE | Io_File::WRITE | Io_File::TRUNCATE);
     if (false === $file->exists()) {
         $file->create();
     }
     $file->open();
     // XXX json_encode converts to unicode - which we dont want here - yet maybe implement an alternative Object_Marshaller_Json or Io_File_Json...
     $file->writeLine('{');
     $file->writeLine('  "unicode":');
     $file->writeLine('  {');
     $file->writeLine(implode(",\n", $mapScript['unicode']));
     $file->writeLine('  },');
     $file->writeLine('  "transform":');
     $file->writeLine('  {');
     $file->write(implode(",\n", $transform));
     $file->writeLine('  }');
     $file->writeLine('}');
     $file->close();
 }
开发者ID:evalcodenet,项目名称:net.evalcode.components.i18n,代码行数:63,代码来源:script.php

示例4: get

 public function get()
 {
     $locale = $this->request->getParams()->get('locale');
     $source = Environment::pathComponentsResource('i18n', 'resource', 'cldr', 'common', 'main', "{$locale}.xml");
     // FIXME "Upgrade" to JSON.
     $target = Environment::pathComponentsResource('i18n', 'resource', 'i18n', 'common', "{$locale}.xml");
     $document = new \DOMDocument('1.0', 'utf-8');
     $document->standalone = true;
     $document->formatOutput = true;
     $document->preserveWhiteSpace = true;
     $xml = new \SimpleXMLElement(file_get_contents($source));
     $values = [];
     foreach ($xml->localeDisplayNames->languages->language as $node) {
         if (2 === strlen($code = (string) $node['type'])) {
             $values[(string) $node['type']] = (string) $node;
         }
     }
     asort($values);
     $this->append($document, 'common/language', $values);
     $values = [];
     foreach ($xml->localeDisplayNames->territories->territory as $node) {
         if (2 === strlen($code = (string) $node['type'])) {
             $values[$code] = (string) $node;
         }
     }
     asort($values);
     $this->append($document, 'common/country', $values);
     $values = [];
     foreach ($xml->localeDisplayNames->scripts->script as $node) {
         $values[(string) $node['type']] = (string) $node;
     }
     asort($values);
     $this->append($document, 'common/script', $values);
     $values = [];
     foreach ($xml->numbers->currencies->currency as $node) {
         $values[(string) $node['type']] = (string) $node->displayName[0];
     }
     asort($values);
     $this->append($document, 'common/currency', $values);
     $values = [];
     foreach ($xml->xpath('//dates/calendars/calendar[@type="gregorian"]/months/monthContext[@type="format"]/monthWidth[@type="abbreviated"]/month') as $node) {
         $values[(string) $node['type']] = (string) $node;
     }
     $this->append($document, 'common/date/month/long', $values, self::$m_months);
     $values = [];
     foreach ($xml->xpath('//dates/calendars/calendar[@type="gregorian"]/months/monthContext[@type="format"]/monthWidth[@type="wide"]/month') as $node) {
         $values[(string) $node['type']] = (string) $node;
     }
     $this->append($document, 'common/date/month/short', $values, self::$m_months);
     $values = [];
     foreach ($xml->xpath('//dates/calendars/calendar[@type="gregorian"]/days/dayContext[@type="format"]/dayWidth[@type="short"]/day') as $node) {
         $values[(string) $node['type']] = (string) $node;
     }
     $this->append($document, 'common/date/day/short', $values, self::$m_days);
     $values = [];
     foreach ($xml->xpath('//dates/calendars/calendar[@type="gregorian"]/days/dayContext[@type="format"]/dayWidth[@type="abbreviated"]/day') as $node) {
         $values[(string) $node['type']] = (string) $node;
     }
     $this->append($document, 'common/date/day/abbreviated', $values, self::$m_days);
     $values = [];
     foreach ($xml->xpath('//dates/calendars/calendar[@type="gregorian"]/days/dayContext[@type="format"]/dayWidth[@type="wide"]/day') as $node) {
         $values[(string) $node['type']] = (string) $node;
     }
     $this->append($document, 'common/date/day/long', $values, self::$m_days);
     $values = [];
     foreach ($xml->xpath('//dates/calendars/calendar[@type="gregorian"]/dateFormats/*') as $node) {
         $values[(string) $node['type']] = str_replace(array('EEEE', 'dd', 'MMMM', 'MMM', 'MM', 'M', 'yyyy', 'yy', 'y'), array('l', 'd', 'F', 'M', 'm', 'm', 'Y', 'y', 'Y'), (string) $node->dateFormat->pattern);
     }
     $this->append($document, 'common/date/pattern', $values);
     $values = [];
     foreach ($xml->xpath('//dates/calendars/calendar[@type="gregorian"]/timeFormats/*') as $node) {
         $values[(string) $node['type']] = str_replace(array('HH', 'mm', 'ss', 'zzzz', 'z'), array('H', 'i', 's', 'O', 'T'), (string) $node->timeFormat->pattern);
     }
     $this->append($document, 'common/time/pattern', $values);
     file_put_contents($target, $document->saveXML());
 }
开发者ID:evalcodenet,项目名称:net.evalcode.components.i18n,代码行数:76,代码来源:common.php

示例5: initialized

 /**
  * @return \Components\I18n_Location
  */
 protected function initialized()
 {
     if (null === $this->m_data) {
         if (false === ($this->m_data = Cache::get("i18n/location/{$this->m_name}"))) {
             if (null === self::$m_pathResource) {
                 self::$m_pathResource = Io::path(Environment::pathComponentsResource('i18n', 'resource', 'i18n', 'location'));
             }
             $file = null;
             $sub = [];
             $chunks = explode('_', strtolower($this->m_name));
             while (count($chunks)) {
                 $file = self::$m_pathResource->getFile(implode('/', $chunks) . '.json');
                 if ($file->exists()) {
                     break;
                 }
                 array_unshift($sub, array_pop($chunks));
             }
             if (false === $file->exists()) {
                 Cache::set("i18n/location/{$this->m_name}", []);
                 return $this;
             }
             $json = $file->getContent();
             $this->m_data = json_decode($json, true);
             if (0 < count($sub)) {
                 while ($next = array_shift($sub)) {
                     $this->m_data =& $this->m_data['children'][$next];
                 }
             }
             Cache::set("i18n/location/{$this->m_name}", $this->m_data);
         }
     }
     return $this;
 }
开发者ID:evalcodenet,项目名称:net.evalcode.components.i18n,代码行数:36,代码来源:location.php


注:本文中的Environment::pathComponentsResource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。