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


PHP SPLoader::translateDirPath方法代码示例

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


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

示例1: cachedView

 public function cachedView($xml, $template, $cacheId, $config = array())
 {
     $this->_xml = $xml;
     Sobi::Trigger('Start', ucfirst(__FUNCTION__), array(&$this->_xml));
     $templatePackage = SPLoader::translateDirPath(Sobi::Cfg('section.template'), 'templates');
     $templateOverride = SPRequest::cmd('sptpl');
     if ($templateOverride) {
         if (strstr($templateOverride, '.')) {
             $templateOverride = str_replace('.', '/', $templateOverride);
         }
         $template = $templateOverride . '.xsl';
     }
     if (file_exists(Sobi::FixPath($templatePackage . '/' . $template))) {
         $template = Sobi::FixPath($templatePackage . '/' . $template);
     } else {
         $type = SPFactory::db()->select('oType', 'spdb_object', array('id' => SPRequest::sid()))->loadResult();
         $template = $templatePackage . '/' . $type . '/' . $template;
     }
     SPFactory::registry()->set('current_template', $templatePackage);
     $this->_templatePath = $templatePackage;
     $this->_template = str_replace('.xsl', null, $template);
     $ini = array();
     if (count($config)) {
         foreach ($config as $file) {
             $file = parse_ini_file($file, true);
             foreach ($file as $section => $keys) {
                 if (isset($ini[$section])) {
                     $ini[$section] = array_merge($ini[$section], $keys);
                 } else {
                     $ini[$section] = $keys;
                 }
             }
         }
     }
     $this->setConfig($ini, SPRequest::task('get'));
     $this->parseXml();
     $this->validateData($cacheId);
     Sobi::Trigger('After', ucfirst(__FUNCTION__), array(&$this->_xml));
 }
开发者ID:kishoreweblabs,项目名称:SobiPro,代码行数:39,代码来源:cache.php

示例2: storeView

 /**
  */
 public function storeView($head)
 {
     if (!Sobi::Cfg('cache.xml_enabled') || $this->_cachedView || Sobi::My('id') && Sobi::Cfg('cache.xml_no_reg')) {
         return false;
     }
     if ($this->view['xml']) {
         $xml = $this->view['xml'];
         $template = Sobi::Reg('cache_view_template');
         if (!$template) {
             $template = $this->view['template'];
             $template = str_replace(SPLoader::translateDirPath(Sobi::Cfg('section.template'), 'templates'), null, $template);
         }
         $root = $xml->documentElement;
         $root->removeChild($root->getElementsByTagName('visitor')->item(0));
         if ($root->getElementsByTagName('messages')->length) {
             $root->removeChild($root->getElementsByTagName('messages')->item(0));
         }
         /** @var $header DOMDocument */
         $header = SPFactory::Instance('types.array')->toXML($head, 'header', true);
         $root->appendChild($xml->importNode($header->documentElement, true));
         if ($this->view['data'] && count($this->view['data'])) {
             $data = SPFactory::Instance('types.array')->toXML($this->view['data'], 'cache-data', true);
             $root->appendChild($xml->importNode($data->documentElement, true));
         }
         $request = $this->viewRequest();
         $request['template'] = $template;
         $configFiles = SPFactory::registry()->get('template_config');
         $request['configFile'] = str_replace('"', "'", json_encode($configFiles));
         $request['cid'] = 'NULL';
         $request['created'] = 'FUNCTION:NOW()';
         $fileName = md5(serialize($request));
         $request['fileName'] = $fileName;
         $filePath = SPLoader::path('var.xml.' . $fileName, 'front', false, 'xml');
         $content = $xml->saveXML();
         $content = str_replace(' ', ' ', $content);
         $content = preg_replace('/[^\\x{0009}\\x{000a}\\x{000d}\\x{0020}-\\x{D7FF}\\x{E000}-\\x{FFFD}]+/u', null, $content);
         $matches = array();
         preg_match_all('/<(category|entry|subcategory)[^>]*id="(\\d{1,})"/', $content, $matches);
         try {
             $cid = SPFactory::db()->insert('spdb_view_cache', $request, false, true)->insertid();
             $relations = array(SPRequest::sid() => array('cid' => $cid, 'sid' => SPRequest::sid()));
             if (isset($matches[2])) {
                 $ids = array_unique($matches[2]);
                 foreach ($ids as $sid) {
                     $relations[$sid] = array('cid' => $cid, 'sid' => $sid);
                 }
             }
             SPFactory::db()->insertArray('spdb_view_cache_relation', $relations);
             SPFs::write($filePath, $content);
         } catch (SPException $x) {
             Sobi::Error('XML-Cache', $x->getMessage());
         }
     }
 }
开发者ID:pelloq1,项目名称:SobiPro,代码行数:56,代码来源:cache.php

示例3: tplCfg

 /**
  */
 protected function tplCfg($path, $task = null)
 {
     $file = explode('.', $path);
     $files = array();
     if (strstr($file[0], 'cms:')) {
         $file[0] = str_replace('cms:', null, $file[0]);
         $file = SPFactory::mainframe()->path(implode('.', $file));
         $path = SPLoader::dirPath($file, 'root', true);
         $this->_tCfg = SPLoader::loadIniFile("{$path}.config", true, false, false, true);
         $files[] = SPLoader::iniStorage();
     } else {
         $this->_tCfg = SPLoader::loadIniFile("usr.templates.{$path}.config");
         $files[] = SPLoader::iniStorage();
         $path = SPLoader::dirPath('usr.templates.' . $path, 'front', true);
     }
     if (!$task) {
         $task = $this->_task == 'add' || $this->_task == 'submit' ? 'edit' : $this->template;
     }
     if (SPLoader::translatePath("{$path}.{$this->templateType}.{$task}", 'absolute', true, 'ini')) {
         $taskCfg = SPLoader::loadIniFile("{$path}.{$this->templateType}.{$task}", true, false, false, true);
         $files[] = SPLoader::iniStorage();
         foreach ($taskCfg as $section => $keys) {
             if (isset($this->_tCfg[$section])) {
                 $this->_tCfg[$section] = array_merge($this->_tCfg[$section], $keys);
             } else {
                 $this->_tCfg[$section] = $keys;
             }
         }
     }
     if (count($files)) {
         foreach ($files as $i => $file) {
             $files[$i] = array('file' => str_replace(SPLoader::translateDirPath(Sobi::Cfg('section.template'), 'templates'), null, $file), 'checksum' => md5_file($file));
         }
         SPFactory::registry()->set('template_config', $files);
     }
     if (SPLoader::translatePath("{$path}.config", 'absolute', true, 'json')) {
         $config = json_decode(SPFs::read(SPLoader::translatePath("{$path}.config", 'absolute', true, 'json')), true);
         $settings = array();
         foreach ($config as $section => $setting) {
             $settings[str_replace('-', '.', $section)] = $setting;
         }
         if (SPLoader::translatePath("{$path}.{$this->templateType}.{$task}", 'absolute', true, 'json')) {
             $subConfig = json_decode(SPFs::read(SPLoader::translatePath("{$path}.{$this->templateType}.{$task}", 'absolute', true, 'json')), true);
             if (count($subConfig)) {
                 foreach ($subConfig as $section => $subSettings) {
                     foreach ($subSettings as $k => $v) {
                         $settings[str_replace('-', '.', $section)][$k] = $v;
                     }
                 }
             }
         }
         if (isset($settings['general'])) {
             foreach ($settings['general'] as $k => $v) {
                 $this->_tCfg['general'][$k] = $v;
             }
         }
         $task = SPRequest::task() == 'entry.add' ? 'entry.edit' : SPRequest::task();
         if (isset($settings[$task])) {
             foreach ($settings[$task] as $k => $v) {
                 $this->_tCfg['general'][$k] = $v;
             }
         }
     }
     Sobi::Trigger($this->name(), __FUNCTION__, array(&$this->_tCfg));
     SPFactory::registry()->set('current_template', $path);
 }
开发者ID:pelloq1,项目名称:SobiPro,代码行数:68,代码来源:controller.php


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