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


PHP Smarty_Resource::source方法代码示例

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


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

示例1: populate

 /**
  * populate Source Object with meta data from Resource
  *
  * @param  Smarty_Template_Source   $source    source object
  * @param  Smarty_Internal_Template $_template template object
  *
  * @return void
  */
 public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null)
 {
     $uid = '';
     $sources = array();
     $exists = true;
     foreach ($_template->smarty->getTemplateDir() as $key => $directory) {
         try {
             $s = Smarty_Resource::source(null, $source->smarty, '[' . $key . ']' . $source->name);
             if (!$s->exists) {
                 continue;
             }
             $sources[$s->uid] = $s;
             $uid .= $s->filepath;
         } catch (SmartyException $e) {
         }
     }
     if (!$sources) {
         $source->exists = false;
         $source->template = $_template;
         return;
     }
     $sources = array_reverse($sources, true);
     reset($sources);
     $s = current($sources);
     $source->components = $sources;
     $source->filepath = $s->filepath;
     $source->uid = sha1($uid);
     $source->exists = $exists;
     if ($_template && $_template->smarty->compile_check) {
         $source->timestamp = $s->timestamp;
     }
     // need the template at getContent()
     $source->template = $_template;
 }
开发者ID:gelcaas,项目名称:newpi,代码行数:42,代码来源:resource.extendsall.php

示例2: populate

 /**
  * populate Source Object with meta data from Resource
  *
  * @param Smarty_Template_Source   $source    source object
  * @param Smarty_Internal_Template $_template template object
  */
 public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null)
 {
     $uid = '';
     $sources = array();
     $components = explode('|', $source->name);
     $exists = true;
     foreach ($components as $component) {
         $s = Smarty_Resource::source(null, $source->smarty, $component);
         if ($s->type == 'php') {
             throw new SmartyException("Resource type {$s->type} cannot be used with the extends resource type");
         }
         $sources[$s->uid] = $s;
         $uid .= $s->filepath;
         if ($_template && $_template->smarty->compile_check) {
             $exists = $exists && $s->exists;
         }
     }
     $source->components = $sources;
     $source->filepath = $s->filepath;
     $source->uid = sha1($uid);
     if ($_template && $_template->smarty->compile_check) {
         $source->timestamp = $s->timestamp;
         $source->exists = $exists;
     }
     // need the template at getContent()
     $source->template = $_template;
 }
开发者ID:Setrino,项目名称:collabtive,代码行数:33,代码来源:smarty_internal_resource_extends.php

示例3: populate

 /**
  * populate Source Object with meta data from Resource
  *
  * @param  Smarty_Template_Source   $source    source object
  * @param  Smarty_Internal_Template $_template template object
  *
  * @return void
  */
 public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null)
 {
     $uid = '';
     $sources = array();
     $timestamp = 0;
     foreach ($_template->smarty->getTemplateDir() as $key => $directory) {
         try {
             $s = Smarty_Resource::source(null, $source->smarty, 'file:' . '[' . $key . ']' . $source->name);
             if (!$s->exists) {
                 continue;
             }
             $sources[$s->uid] = $s;
             $uid .= $s->filepath;
             $timestamp = $s->timestamp > $timestamp ? $s->timestamp : $timestamp;
         } catch (SmartyException $e) {
         }
     }
     if (!$sources) {
         $source->exists = false;
         return;
     }
     $sources = array_reverse($sources, true);
     reset($sources);
     $s = current($sources);
     $source->components = $sources;
     $source->filepath = $s->filepath;
     $source->uid = sha1($uid . $_template->smarty->_joined_template_dir);
     $source->exists = true;
     $source->timestamp = $timestamp;
 }
开发者ID:Wicloz,项目名称:UniversityWebsite,代码行数:38,代码来源:resource.extendsall.php

示例4: populate

 /**
  * populate Source Object with meta data from Resource
  *
  * @param Smarty_Template_Source   $source    source object
  * @param Smarty_Internal_Template $_template template object
  */
 public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null)
 {
     $filePath = $this->buildFilepath($source, $_template);
     $s = Smarty_Resource::source(null, $source->smarty, $filePath);
     $source->components = $s;
     $source->filepath = $s->filepath;
     $source->uid = $s->uid;
     if ($_template && $_template->smarty->compile_check) {
         $source->timestamp = $s->timestamp;
         $source->exists = $s->exists;
     }
     $source->template = $_template;
 }
开发者ID:ClaudioThomas,项目名称:shopware-4,代码行数:19,代码来源:resource.parent.php

示例5: __get

 /**
  * get Smarty property in template context
  *
  * @param string $property_name property name
  */
 public function __get($property_name)
 {
     switch ($property_name) {
         case 'source':
             if (empty($this->template_resource)) {
                 throw new SmartyException("Unable to parse resource name \"{$this->template_resource}\"");
             }
             $this->source = Smarty_Resource::source($this);
             // cache template object under a unique ID
             // do not cache eval resources
             if ($this->source->type != 'eval') {
                 if ($this->smarty->allow_ambiguous_resources) {
                     $_templateId = $this->source->unique_resource . $this->cache_id . $this->compile_id;
                 } else {
                     $_templateId = $this->smarty->joined_template_dir . '#' . $this->template_resource . $this->cache_id . $this->compile_id;
                 }
                 if (isset($_templateId[150])) {
                     $_templateId = sha1($_templateId);
                 }
                 $this->smarty->template_objects[$_templateId] = $this;
             }
             return $this->source;
         case 'compiled':
             $this->compiled = $this->source->getCompiled($this);
             return $this->compiled;
         case 'cached':
             if (!class_exists('Smarty_Template_Cached')) {
                 include SMARTY_SYSPLUGINS_DIR . 'smarty_cacheresource.php';
             }
             $this->cached = new Smarty_Template_Cached($this);
             return $this->cached;
         case 'compiler':
             $this->smarty->loadPlugin($this->source->compiler_class);
             $this->compiler = new $this->source->compiler_class($this->source->template_lexer_class, $this->source->template_parser_class, $this->smarty);
             return $this->compiler;
             // FIXME: routing of template -> smarty attributes
         // FIXME: routing of template -> smarty attributes
         default:
             if (property_exists($this->smarty, $property_name)) {
                 return $this->smarty->{$property_name};
             }
     }
     throw new SmartyException("template property '{$property_name}' does not exist.");
 }
开发者ID:Tipkin-Commons,项目名称:tipkin,代码行数:49,代码来源:smarty_internal_template.php

示例6: decodeProperties

 /**
  * This function is executed automatically when a compiled or cached template file is included
  * - Decode saved properties from compiled template and cache files
  * - Check if compiled or cache file is valid
  *
  * @param  array $properties special template properties
  * @param  bool  $cache flag if called from cache file
  *
  * @return bool  flag if compiled or cache file is valid
  */
 public function decodeProperties($properties, $cache = false)
 {
     $properties['version'] = isset($properties['version']) ? $properties['version'] : '';
     $is_valid = true;
     if (Smarty::SMARTY_VERSION != $properties['version']) {
         // new version must rebuild
         $is_valid = false;
     } elseif ((!$cache && $this->smarty->compile_check || $cache && ($this->smarty->compile_check === true || $this->smarty->compile_check === Smarty::COMPILECHECK_ON)) && !empty($properties['file_dependency'])) {
         // check file dependencies at compiled code
         foreach ($properties['file_dependency'] as $_file_to_check) {
             if ($_file_to_check[2] == 'file' || $_file_to_check[2] == 'php') {
                 if ($this->source->filepath == $_file_to_check[0] && isset($this->source->timestamp)) {
                     // do not recheck current template
                     $mtime = $this->source->timestamp;
                 } else {
                     // file and php types can be checked without loading the respective resource handlers
                     $mtime = is_file($_file_to_check[0]) ? @filemtime($_file_to_check[0]) : false;
                 }
             } elseif ($_file_to_check[2] == 'string') {
                 continue;
             } else {
                 $source = Smarty_Resource::source(null, $this->smarty, $_file_to_check[0]);
                 $mtime = $source->timestamp;
             }
             if (!$mtime || $mtime > $_file_to_check[1]) {
                 $is_valid = false;
                 break;
             }
         }
     }
     if ($cache) {
         // CACHING_LIFETIME_SAVED cache expiry has to be validated here since otherwise we'd define the unifunc
         if ($this->caching === Smarty::CACHING_LIFETIME_SAVED && $properties['cache_lifetime'] >= 0 && time() > $this->cached->timestamp + $properties['cache_lifetime']) {
             $is_valid = false;
         }
         $this->cached->valid = $is_valid;
     } else {
         $this->mustCompile = !$is_valid;
     }
     if ($is_valid) {
         $this->has_nocache_code = $properties['has_nocache_code'];
         //            $this->properties['nocache_hash'] = $properties['nocache_hash'];
         if (isset($properties['cache_lifetime'])) {
             $this->properties['cache_lifetime'] = $properties['cache_lifetime'];
         }
         if (isset($properties['file_dependency'])) {
             $this->properties['file_dependency'] = array_merge($this->properties['file_dependency'], $properties['file_dependency']);
         }
         if (isset($properties['tpl_function'])) {
             $this->properties['tpl_function'] = array_merge($this->properties['tpl_function'], $properties['tpl_function']);
         }
         $this->properties['version'] = $properties['version'];
         $this->properties['unifunc'] = $properties['unifunc'];
     }
     return $is_valid;
 }
开发者ID:hejxing,项目名称:jt,代码行数:66,代码来源:smarty_internal_template.php

示例7: __get

 public function __get($property_name)
 {
     switch ($property_name) {
         case 'source':
             if (strlen($this->template_resource) == 0) {
                 throw new SmartyException('Missing template name');
             }
             $this->source = Smarty_Resource::source($this);
             if ($this->source->type != 'eval') {
                 if ($this->smarty->allow_ambiguous_resources) {
                     $_templateId = $this->source->unique_resource . $this->cache_id . $this->compile_id;
                 } else {
                     $_templateId = $this->smarty->joined_template_dir . '#' . $this->template_resource . $this->cache_id . $this->compile_id;
                 }
                 if (isset($_templateId[150])) {
                     $_templateId = sha1($_templateId);
                 }
                 $this->smarty->template_objects[$_templateId] = $this;
             }
             return $this->source;
         case 'compiled':
             $this->compiled = $this->source->getCompiled($this);
             return $this->compiled;
         case 'cached':
             if (!class_exists('Smarty_Template_Cached')) {
                 include SMARTY_SYSPLUGINS_DIR . 'smarty_cacheresource.php';
             }
             $this->cached = new Smarty_Template_Cached($this);
             return $this->cached;
         case 'compiler':
             $this->smarty->loadPlugin($this->source->compiler_class);
             $this->compiler = new $this->source->compiler_class($this->source->template_lexer_class, $this->source->template_parser_class, $this->smarty);
             return $this->compiler;
         default:
             if (property_exists($this->smarty, $property_name)) {
                 return $this->smarty->{$property_name};
             }
     }
     throw new SmartyException("template property '{$property_name}' does not exist.");
 }
开发者ID:admpub,项目名称:MicroPHP,代码行数:40,代码来源:~Runtime.php

示例8: __construct

 /**
  * Constructor
  *
  * @param \Smarty_Internal_Template $template
  */
 public function __construct(Smarty_Internal_Template $template)
 {
     $valid = true;
     if (!$template->source->recompiled) {
         if (Smarty::SMARTY_VERSION != $this->version) {
             // new version must rebuild
             $valid = false;
         } elseif ((int) $template->smarty->compile_check == 1 || $this->isCache && $template->smarty->compile_check === Smarty::COMPILECHECK_ON) {
             // check file dependencies at compiled code
             foreach ($this->resourceInfo as $r) {
                 if ($r[2] == 'file' || $r[2] == 'php') {
                     if ($template->source->filepath == $r[0]) {
                         // do not recheck current template
                         $mtime = $template->source->timestamp;
                     } else {
                         // file and php types can be checked without loading the respective resource handlers
                         if (is_file($r[0])) {
                             $mtime = filemtime($r[0]);
                         } else {
                             $valid = false;
                             break;
                         }
                     }
                 } else {
                     $source = Smarty_Resource::source(null, $template->smarty, $r[0]);
                     if ($source->exists) {
                         $mtime = $source->timestamp;
                     } else {
                         $valid = false;
                         break;
                     }
                 }
                 if (!$mtime || $mtime > $r[1]) {
                     $valid = false;
                     break;
                 }
             }
         }
         if ($this->isCache) {
             // CACHING_LIFETIME_SAVED cache expiry has to be validated here since otherwise we'd define the unifunc
             if ($this->cacheLifetime > 0 && ($template->caching === Smarty::CACHING_LIFETIME_SAVED || $this->caching === Smarty::CACHING_LIFETIME_SAVED) && time() > $template->cached->timestamp + $this->cacheLifetime) {
                 $valid = false;
             }
             $template->cached->valid = $valid;
         } else {
             $template->mustCompile = !$valid;
         }
     }
     if ($valid && !empty($this->plugins)) {
         $this->loadPlugins($this->plugins);
     }
 }
开发者ID:uwetews,项目名称:smarty-hhvm,代码行数:57,代码来源:smarty_internal_runtime.php


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