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


PHP Smarty_Template_Source类代码示例

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


在下文中一共展示了Smarty_Template_Source类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 ($source->smarty->getTemplateDir() as $key => $directory) {
         try {
             $s = Smarty_Template_Source::load(null, $source->smarty, 'file:[' . $key . ']' . $source->name);
             if (!$s->exists) {
                 continue;
             }
             $sources[$s->uid] = $s;
             $uid .= $s->filepath;
         } 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);
     $source->exists = $exists;
     if ($_template && $_template->smarty->compile_check) {
         $source->timestamp = $s->getTimeStamp();
     }
 }
开发者ID:dayday0769,项目名称:smarty,代码行数:39,代码来源:resource.extendsall.php

示例2: load

 /**
  * get a Compiled Object of this source
  *
  * @param  Smarty_Internal_Template $_template template object
  *
  * @return Smarty_Template_Compiled compiled object
  */
 static function load($_template)
 {
     if (!isset($_template->source)) {
         $_template->source = Smarty_Template_Source::load($_template);
     }
     $src = $_template->source;
     $_cache_key = null;
     // check runtime cache
     if ($crc = !$src->recompiled && $_template->smarty->resource_caching) {
         $_cache_key = $src->unique_resource . '#';
         if ($_template->caching) {
             $_cache_key .= 'caching#';
         }
         $_cache_key .= $_template->compile_id;
         if (isset($src->compileds[$_cache_key])) {
             return $src->compileds[$_cache_key];
         }
     }
     $compiled = new Smarty_Template_Compiled($_cache_key);
     if (method_exists($src->handler, 'populateCompiledFilepath')) {
         $src->handler->populateCompiledFilepath($compiled, $_template);
     } else {
         $compiled->populateCompiledFilepath($_template);
     }
     // runtime cache
     if ($crc) {
         $src->compileds[$_cache_key] = $compiled;
     }
     return $compiled;
 }
开发者ID:uwetews,项目名称:smarty-hhvm,代码行数:37,代码来源:smarty_template_compiled.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
  *
  * @throws SmartyException
  */
 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) {
         /* @var \Smarty_Template_Source $_s */
         $_s = Smarty_Template_Source::load(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) {
             $exists = $exists && $_s->exists;
         }
     }
     $source->components = $sources;
     $source->filepath = $_s->filepath;
     $source->uid = sha1($uid);
     $source->exists = $exists;
     if ($_template) {
         $source->timestamp = $_s->timestamp;
     }
 }
开发者ID:smart-com,项目名称:bike-cms,代码行数:34,代码来源:smarty_internal_resource_extends.php

示例4: compileAll

 /**
  * Compile all template or config files
  *
  * @param \Smarty $smarty
  * @param  string $extension     template file name extension
  * @param  bool   $force_compile force all to recompile
  * @param  int    $time_limit    set maximum execution time
  * @param  int    $max_errors    set maximum allowed errors
  * @param bool    $isConfig      flag true if called for config files
  *
  * @return int number of template files compiled
  */
 protected function compileAll(Smarty $smarty, $extension, $force_compile, $time_limit, $max_errors, $isConfig = false)
 {
     // switch off time limit
     if (function_exists('set_time_limit')) {
         @set_time_limit($time_limit);
     }
     $_count = 0;
     $_error_count = 0;
     $sourceDir = $isConfig ? $smarty->getConfigDir() : $smarty->getTemplateDir();
     // loop over array of source directories
     foreach ($sourceDir as $_dir) {
         $_dir_1 = new RecursiveDirectoryIterator($_dir);
         $_dir_2 = new RecursiveIteratorIterator($_dir_1);
         foreach ($_dir_2 as $_fileinfo) {
             $_file = $_fileinfo->getFilename();
             if (substr(basename($_fileinfo->getPathname()), 0, 1) == '.' || strpos($_file, '.svn') !== false) {
                 continue;
             }
             if (!substr_compare($_file, $extension, -strlen($extension)) == 0) {
                 continue;
             }
             if ($_fileinfo->getPath() !== substr($_dir, 0, -1)) {
                 $_file = substr($_fileinfo->getPath(), strlen($_dir)) . DS . $_file;
             }
             echo "\n<br>", $_dir, '---', $_file;
             flush();
             $_start_time = microtime(true);
             $_smarty = clone $smarty;
             $_smarty->force_compile = $force_compile;
             try {
                 /* @var Smarty_Internal_Template $_tpl */
                 $_tpl = new $smarty->template_class($_file, $_smarty);
                 $_tpl->caching = Smarty::CACHING_OFF;
                 $_tpl->source = $isConfig ? Smarty_Template_Config::load($_tpl) : Smarty_Template_Source::load($_tpl);
                 if ($_tpl->mustCompile()) {
                     $_tpl->compileTemplateSource();
                     $_count++;
                     echo ' compiled in  ', microtime(true) - $_start_time, ' seconds';
                     flush();
                 } else {
                     echo ' is up to date';
                     flush();
                 }
             } catch (Exception $e) {
                 echo "\n<br>        ------>Error: ", $e->getMessage(), "<br><br>\n";
                 $_error_count++;
             }
             // free memory
             unset($_tpl);
             $_smarty->_clearTemplateCache();
             if ($max_errors !== null && $_error_count == $max_errors) {
                 echo "\n<br><br>too many errors\n";
                 exit;
             }
         }
     }
     echo "\n<br>";
     return $_count;
 }
开发者ID:yanlyan,项目名称:si_ibuhamil,代码行数:71,代码来源:smarty_internal_method_compilealltemplates.php

示例5: 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(Smarty_Internal_Template $tpl, $properties, $cache = false)
 {
     $is_valid = true;
     if (Smarty::SMARTY_VERSION != $properties['version']) {
         // new version must rebuild
         $is_valid = false;
     } elseif ($is_valid && !empty($properties['file_dependency']) && (!$cache && $tpl->smarty->compile_check || $tpl->smarty->compile_check == 1)) {
         // check file dependencies at compiled code
         foreach ($properties['file_dependency'] as $_file_to_check) {
             if ($_file_to_check[2] == 'file' || $_file_to_check[2] == 'extends' || $_file_to_check[2] == 'php') {
                 if ($tpl->source->filepath == $_file_to_check[0]) {
                     // do not recheck current template
                     continue;
                     //$mtime = $tpl->source->getTimeStamp();
                 } 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 {
                 $handler = Smarty_Resource::load($tpl->smarty, $_file_to_check[2]);
                 if ($handler->checkTimestamps()) {
                     $source = Smarty_Template_Source::load($tpl, $tpl->smarty, $_file_to_check[0]);
                     $mtime = $source->getTimeStamp();
                 } else {
                     continue;
                 }
             }
             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 ($tpl->caching === Smarty::CACHING_LIFETIME_SAVED && $properties['cache_lifetime'] >= 0 && time() > $tpl->cached->timestamp + $properties['cache_lifetime']) {
             $is_valid = false;
         }
         $tpl->cached->cache_lifetime = $properties['cache_lifetime'];
         $tpl->cached->valid = $is_valid;
         $resource = $tpl->cached;
     } else {
         $tpl->mustCompile = !$is_valid;
         $resource = $tpl->compiled;
         $resource->includes = isset($properties['includes']) ? $properties['includes'] : array();
     }
     if ($is_valid) {
         $resource->unifunc = $properties['unifunc'];
         $resource->has_nocache_code = $properties['has_nocache_code'];
         //            $tpl->compiled->nocache_hash = $properties['nocache_hash'];
         $resource->file_dependency = $properties['file_dependency'];
         if (isset($properties['tpl_function'])) {
             $tpl->tpl_function = $properties['tpl_function'];
         }
     }
     return $is_valid && !function_exists($properties['unifunc']);
 }
开发者ID:cywymch,项目名称:testMvc,代码行数:69,代码来源:smarty_internal_runtime_validatecompiled.php

示例6: compile

 /**
  * Compiles code for the {extends} tag
  *
  * @param array                                        $args     array with attributes from parser
  * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
  *
  * @return string compiled code
  * @throws \SmartyCompilerException
  * @throws \SmartyException
  */
 public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
 {
     // check and get attributes
     $_attr = $this->getAttributes($compiler, $args);
     if ($_attr['nocache'] === true) {
         $compiler->trigger_template_error('nocache option not allowed', null, true);
     }
     if (strpos($_attr['file'], '$_tmp') !== false) {
         $compiler->trigger_template_error('illegal value for file attribute', null, true);
     }
     $name = $_attr['file'];
     if ($compiler->has_variable_string || !(substr_count($name, '"') == 2 || substr_count($name, "'") == 2) || substr_count($name, '(') != 0 || substr_count($name, '$_smarty_tpl->') != 0) {
         /** @var Smarty_Internal_Template $_smarty_tpl
          * used in evaluated code
          */
         $_smarty_tpl = $compiler->template;
         eval("\$tpl_name = @{$name};");
     } else {
         $tpl_name = trim($name, '\'"');
     }
     // create source object
     $_source = Smarty_Template_Source::load(null, $compiler->smarty, $tpl_name);
     // check for recursion
     $uid = $_source->uid;
     if (isset($compiler->extends_uid[$uid])) {
         $compiler->trigger_template_error("illegal recursive call of \"{$_source->filepath}\"", $compiler->parser->lex->line - 1);
     }
     $compiler->extends_uid[$uid] = true;
     if (empty($_source->components)) {
         array_unshift($compiler->sources, $_source);
     } else {
         foreach ($_source->components as $source) {
             array_unshift($compiler->sources, $source);
             $uid = $source->uid;
             if (isset($compiler->extends_uid[$uid])) {
                 $compiler->trigger_template_error("illegal recursive call of \"{$source->filepath}\"", $compiler->parser->lex->line - 1);
             }
             $compiler->extends_uid[$uid] = true;
         }
     }
     $compiler->inheritance_child = true;
     $compiler->parser->lex->yypushstate(Smarty_Internal_Templatelexer::CHILDBODY);
     return '';
 }
开发者ID:dower-d,项目名称:shop,代码行数:54,代码来源:smarty_internal_compile_extends.php

示例7: setSource

 /**
  * Set source object of inline template by $uid
  *
  * @param \Smarty_Internal_Template $tpl
  * @param  string                   $uid
  *
  * @throws \SmartyException
  */
 public function setSource(Smarty_Internal_Template $tpl, $uid = null)
 {
     // $uid is set if template is inline
     if (isset($uid)) {
         // inline templates have same compiled resource
         $tpl->compiled = $tpl->parent->compiled;
         if (isset($tpl->compiled->file_dependency[$uid])) {
             list($filepath, $timestamp, $resource) = $tpl->compiled->file_dependency[$uid];
             $tpl->source = new Smarty_Template_Source(isset($tpl->smarty->_cache['resource_handlers'][$resource]) ? $tpl->smarty->_cache['resource_handlers'][$resource] : Smarty_Resource::load($tpl->smarty, $resource), $tpl->smarty, $filepath, $resource, $filepath);
             $tpl->source->filepath = $filepath;
             $tpl->source->timestamp = $timestamp;
             $tpl->source->exists = true;
             $tpl->source->uid = $uid;
         } else {
             $tpl->source = null;
         }
     } else {
         $tpl->source = null;
         unset($tpl->compiled);
     }
     if (!isset($tpl->source)) {
         $tpl->source = Smarty_Template_Source::load($tpl);
     }
 }
开发者ID:visense,项目名称:smarty,代码行数:32,代码来源:smarty_internal_runtime_inline.php

示例8: clear

 /**
  * Empty cache for a specific template
  *
  * @param  Smarty  $smarty        Smarty object
  * @param  string  $resource_name template name
  * @param  string  $cache_id      cache id
  * @param  string  $compile_id    compile id
  * @param  integer $exp_time      expiration time (number of seconds, not timestamp)
  *
  * @return integer number of cache files deleted
  */
 public function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time)
 {
     $cache_name = null;
     if (isset($resource_name)) {
         $source = Smarty_Template_Source::load(null, $smarty, $resource_name);
         if ($source->exists) {
             $cache_name = $source->name;
         } else {
             return 0;
         }
         // remove from template cache
         if (isset($smarty->_cache['template_objects'])) {
             foreach ($smarty->_cache['template_objects'] as $key => $_tpl) {
                 if (isset($_tpl->cached) && $_tpl->source->uid == $source->uid) {
                     unset($smarty->_cache['template_objects'][$key]);
                 }
             }
         }
     }
     return $this->delete($cache_name, $cache_id, $compile_id, $exp_time);
 }
开发者ID:smart-com,项目名称:bike-cms,代码行数:32,代码来源:smarty_cacheresource_custom.php

示例9: setupSubtemplate

 /**
  * Template code runtime function to set up an inline subtemplate
  *
  * @param \Smarty_Internal_Template $callerTpl
  * @param string                    $template       template name
  * @param mixed                     $cache_id       cache id
  * @param mixed                     $compile_id     compile id
  * @param integer                   $caching        cache mode
  * @param integer                   $cache_lifetime life time of cache data
  * @param array                     $data           passed parameter template variables
  * @param int                       $parent_scope   scope in which {include} should execute
  * @param bool                      $cache_tpl_obj  cache template object
  * @param string|null               $uid            source uid
  *
  * @return \Smarty_Internal_Template template object
  * @throws \SmartyException
  */
 public function setupSubtemplate(Smarty_Internal_Template $callerTpl, $template, $cache_id, $compile_id, $caching, $cache_lifetime, $data, $parent_scope, $cache_tpl_obj, $uid = null)
 {
     $_templateId = isset($callerTpl->smarty->_cache['template_objects']) ? $callerTpl->smarty->_getTemplateId($template, $cache_id, $compile_id) : null;
     // already in template cache?
     /* @var Smarty_Internal_Template $tpl */
     if (isset($callerTpl->smarty->_cache['template_objects'][$_templateId])) {
         // clone cached template object because of possible recursive call
         $tpl = clone $callerTpl->smarty->_cache['template_objects'][$_templateId];
         $tpl->parent = $callerTpl;
         if ((bool) $tpl->caching !== (bool) $caching) {
             unset($tpl->compiled);
         }
         // get variables from calling scope
         if ($parent_scope == Smarty::SCOPE_LOCAL) {
             $tpl->tpl_vars = $callerTpl->tpl_vars;
             $tpl->config_vars = $callerTpl->config_vars;
         }
         $tpl->tpl_function = $callerTpl->tpl_function;
         //if (isset($callerTpl->_cache['inheritanceBlocks'])) {
         //    $tpl->_cache['inheritanceBlocks'] = $callerTpl->_cache['inheritanceBlocks'];
         //}
     } else {
         $tpl = clone $callerTpl;
         $tpl->parent = $callerTpl;
         $tpl->isChild = false;
         if (!isset($tpl->templateId) || $tpl->templateId !== $_templateId) {
             $tpl->templateId = $_templateId;
             $tpl->template_resource = $template;
             $tpl->cache_id = $cache_id;
             $tpl->compile_id = $compile_id;
             if (isset($uid)) {
                 $tpl->compiled = $callerTpl->compiled;
                 if (isset($tpl->compiled->includes["{$tpl->source->type}:{$tpl->source->name}"]) && $tpl->compiled->includes["{$tpl->source->type}:{$tpl->source->name}"] > 1) {
                     $cache_tpl_obj = true;
                 }
                 if (isset($tpl->compiled->file_dependency[$uid])) {
                     $info = $tpl->compiled->file_dependency[$uid];
                     $tpl->source = new Smarty_Template_Source(isset($tpl->smarty->_cache['resource_handlers'][$info[2]]) ? $tpl->smarty->_cache['resource_handlers'][$info[2]] : Smarty_Resource::load($tpl->smarty, $info[2]), $tpl->smarty, $info[0], $info[2], $info[0]);
                     $tpl->source->filepath = $info[0];
                     $tpl->source->timestamp = $info[1];
                     $tpl->source->exist = true;
                     $tpl->source->uid = $uid;
                 } else {
                     $tpl->source = null;
                 }
             } else {
                 $tpl->source = null;
                 unset($tpl->compiled);
             }
             if (!isset($tpl->source)) {
                 $tpl->source = Smarty_Template_Source::load($tpl);
             }
             unset($tpl->cached);
             // check if template object should be cached
             if (!$tpl->source->handler->recompiled && (isset($tpl->parent->templateId) && isset($tpl->smarty->_cache['template_objects'][$tpl->parent->templateId]) || $cache_tpl_obj && $tpl->smarty->resource_cache_mode & Smarty::RESOURCE_CACHE_AUTOMATIC || $tpl->smarty->resource_cache_mode & Smarty::RESOURCE_CACHE_ON)) {
                 $tpl->smarty->_cache['template_objects'][$tpl->_getTemplateId()] = $tpl;
             }
         }
     }
     $tpl->caching = $caching;
     $tpl->cache_lifetime = $cache_lifetime;
     if ($caching == 9999) {
         $tpl->cached = $callerTpl->cached;
     }
     // get variables from calling scope
     if ($parent_scope != Smarty::SCOPE_LOCAL) {
         if ($parent_scope == Smarty::SCOPE_PARENT) {
             $tpl->tpl_vars =& $callerTpl->tpl_vars;
             $tpl->config_vars =& $callerTpl->config_vars;
         } elseif ($parent_scope == Smarty::SCOPE_GLOBAL) {
             $tpl->tpl_vars =& Smarty::$global_tpl_vars;
             $tpl->config_vars = $callerTpl->config_vars;
         } elseif ($parent_scope == Smarty::SCOPE_ROOT) {
             $ptr = $tpl->parent;
             while (!empty($ptr->parent)) {
                 $ptr = $ptr->parent;
             }
             $tpl->tpl_vars =& $ptr->tpl_vars;
             $tpl->config_vars =& $ptr->config_vars;
         } else {
             $tpl->tpl_vars = $callerTpl->tpl_vars;
             $tpl->config_vars = $callerTpl->config_vars;
         }
//.........这里部分代码省略.........
开发者ID:xuanhoang90,项目名称:XHFramework_2016,代码行数:101,代码来源:smarty_internal_runtime_subtemplate.php

示例10: compile


//.........这里部分代码省略.........
     } else {
         $_cache_id = '$_smarty_tpl->cache_id';
     }
     if (isset($_attr['compile_id'])) {
         $_compile_id = $_attr['compile_id'];
     } else {
         $_compile_id = '$_smarty_tpl->compile_id';
     }
     // if subtemplate will be called in nocache mode do not merge
     if ($compiler->template->caching && $call_nocache) {
         $merge_compiled_includes = false;
     }
     $has_compiled_template = false;
     if ($merge_compiled_includes) {
         if ($compiler->template->caching && ($compiler->tag_nocache || $compiler->nocache) && $_caching != self::CACHING_NOCACHE_CODE) {
             //                $merge_compiled_includes = false;
             if ($compiler->inheritance && $compiler->smarty->inheritance_merge_compiled_includes) {
                 $compiler->trigger_template_error(' invalid caching mode of subtemplate within {block} tags');
             }
         }
         $c_id = isset($_attr['compile_id']) ? $_attr['compile_id'] : $compiler->template->compile_id;
         // we must observe different compile_id and caching
         $uid = sha1($c_id . ($_caching ? '--caching' : '--nocaching'));
         $tpl_name = null;
         /** @var Smarty_Internal_Template $_smarty_tpl
          * used in evaluated code
          */
         $_smarty_tpl = $compiler->template;
         eval("\$tpl_name = {$include_file};");
         if (!isset($compiler->parent_compiler->mergedSubTemplatesData[$tpl_name][$uid])) {
             $compiler->smarty->allow_ambiguous_resources = true;
             $tpl = new $compiler->smarty->template_class($tpl_name, $compiler->smarty, $compiler->template, $compiler->template->cache_id, $c_id, $_caching);
             if (!isset($tpl->source)) {
                 $tpl->source = Smarty_Template_Source::load($tpl);
             }
             $tpl->loadCompiler();
             // save unique function name
             $compiler->parent_compiler->mergedSubTemplatesData[$tpl_name][$uid]['func'] = $renderName = 'render_' . str_replace(array('.', ','), '_', uniqid('', true));
             if ($compiler->inheritance) {
                 $tpl->compiler->inheritance = true;
             }
             $tpl->source->isChild = $parameter['isChild'];
             // make sure whole chain gets compiled
             $tpl->mustCompile = true;
             if (!$tpl->source->uncompiled && $tpl->source->exists) {
                 $tpl->compiler->suppressTemplatePropertyHeader = true;
                 $compiled_code = "\n/*  Merged included template \"" . $tpl_name . "\" */\n";
                 // get compiled code
                 $compiled_code .= "public function {$renderName} (\$_smarty_tpl) {\n";
                 //$compiled_code .= "\$_smarty_tpl->context->initTemplate(\$this, \$_smarty_tpl);\n";
                 $compiled_code .= $tpl->compiler->compileTemplate($tpl, null, $compiler->parent_compiler);
                 $compiled_code .= "}\n";
                 unset($tpl->compiler);
                 $compiler->parent_compiler->mergedSubTemplatesCode[$renderName] = $compiled_code;
                 $has_compiled_template = true;
                 unset($tpl);
             }
         } else {
             $has_compiled_template = true;
         }
     }
     // delete {include} standard attributes
     unset($_attr['file'], $_attr['assign'], $_attr['cache_id'], $_attr['compile_id'], $_attr['cache_lifetime'], $_attr['nocache'], $_attr['caching'], $_attr['scope'], $_attr['inline']);
     // remaining attributes must be assigned as smarty variable
     $_vars_nc = '';
     if (!empty($_attr)) {
开发者ID:uwetews,项目名称:smarty-hhvm,代码行数:67,代码来源:smarty_internal_compile_include.php

示例11: templateExists

 /**
  * Check if a template resource exists
  *
  * @param  string $resource_name template name
  *
  * @return boolean status
  */
 public function templateExists($resource_name)
 {
     // create source object
     $source = Smarty_Template_Source::load(null, $this, $resource_name);
     return $source->exists;
 }
开发者ID:lclblack,项目名称:myPHP,代码行数:13,代码来源:Smarty.class.php

示例12: setSource

 /**
  * Set source object of inline template by $uid
  *
  * @param \Smarty_Internal_Template $tpl
  * @param  string                   $uid
  *
  * @throws \SmartyException
  */
 public function setSource(Smarty_Internal_Template $tpl, $uid = null)
 {
     //load source
     $tpl->source = null;
     unset($tpl->compiled);
     if (!isset($tpl->source)) {
         $tpl->source = Smarty_Template_Source::load($tpl);
     }
 }
开发者ID:visense,项目名称:smarty,代码行数:17,代码来源:smarty_internal_runtime_subtemplate.php

示例13: getTemplateUid

 /**
  * Get template's unique ID
  *
  * @param  Smarty $smarty        Smarty object
  * @param  string $resource_name template name
  *
  * @return string filepath of cache file
  * @throws \SmartyException
  *
  */
 protected function getTemplateUid(Smarty $smarty, $resource_name)
 {
     if (isset($resource_name)) {
         $source = Smarty_Template_Source::load(null, $smarty, $resource_name);
         if ($source->exists) {
             return $source->uid;
         }
     }
     return '';
 }
开发者ID:smart-com,项目名称:bike-cms,代码行数:20,代码来源:smarty_cacheresource_keyvaluestore.php

示例14: loadSource

 /**
  * Load source object
  *
  * @throws SmartyException
  */
 public function loadSource()
 {
     if (!isset($this->source)) {
         $this->source = Smarty_Template_Source::load($this);
     }
 }
开发者ID:uwetews,项目名称:smarty-hhvm,代码行数:11,代码来源:smarty_internal_template.php

示例15: render

 /**
  * Runtime function to render subtemplate
  *
  * @param \Smarty_Internal_Template $parent
  * @param string                    $template       template name
  * @param mixed                     $cache_id       cache id
  * @param mixed                     $compile_id     compile id
  * @param integer                   $caching        cache mode
  * @param integer                   $cache_lifetime life time of cache data
  * @param array                     $data           passed parameter template variables
  * @param int                       $scope          scope in which {include_test} should execute
  * @param bool                      $forceTplCache  cache template object
  * @param string                    $uid            file dependency uid
  * @param string                    $content_func   function name
  *
  */
 public function render(Smarty_Internal_Template $parent, $template, $cache_id, $compile_id, $caching, $cache_lifetime, $data, $scope, $forceTplCache, $uid = null, $content_func = null)
 {
     // if there are cached template objects calculate $templateID
     $_templateId = !empty($this->tplObjects) ? $parent->smarty->_getTemplateId($template, $cache_id, $compile_id, $caching) : null;
     // already in template cache?
     /* @var Smarty_Internal_Template $tpl */
     if (isset($_templateId) && isset($this->tplObjects[$_templateId])) {
         // clone cached template object because of possible recursive call
         $tpl = clone $this->tplObjects[$_templateId];
         $tpl->parent = $parent;
         // if $caching mode changed the compiled resource is invalid
         if ((bool) $tpl->caching !== (bool) $caching) {
             unset($tpl->compiled);
         }
         // get variables from calling scope
         $tpl->tpl_vars = $parent->tpl_vars;
         $tpl->config_vars = $parent->config_vars;
         // get template functions
         $tpl->tpl_function = $parent->tpl_function;
         // copy inheritance object?
         if (isset($parent->ext->_inheritance)) {
             $tpl->ext->_inheritance = $parent->ext->_inheritance;
         } else {
             unset($tpl->ext->_inheritance);
         }
     } else {
         $tpl = clone $parent;
         $tpl->parent = $parent;
         if (!isset($tpl->templateId) || $tpl->templateId !== $_templateId) {
             $tpl->templateId = $_templateId;
             $tpl->template_resource = $template;
             $tpl->cache_id = $cache_id;
             $tpl->compile_id = $compile_id;
             if (isset($uid)) {
                 // for inline templates we can get all resource information from file dependency
                 if (isset($tpl->compiled->file_dependency[$uid])) {
                     list($filepath, $timestamp, $resource) = $tpl->compiled->file_dependency[$uid];
                     $tpl->source = new Smarty_Template_Source(isset($tpl->smarty->_cache['resource_handlers'][$resource]) ? $tpl->smarty->_cache['resource_handlers'][$resource] : Smarty_Resource::load($tpl->smarty, $resource), $tpl->smarty, $filepath, $resource, $filepath);
                     $tpl->source->filepath = $filepath;
                     $tpl->source->timestamp = $timestamp;
                     $tpl->source->exists = true;
                     $tpl->source->uid = $uid;
                 } else {
                     $tpl->source = null;
                 }
             } else {
                 $tpl->source = null;
             }
             if (!isset($tpl->source)) {
                 $tpl->source = Smarty_Template_Source::load($tpl);
                 unset($tpl->compiled);
             }
             unset($tpl->cached);
         }
     }
     $tpl->caching = $caching;
     $tpl->cache_lifetime = $cache_lifetime;
     if ($caching == 9999) {
         $tpl->cached = $parent->cached;
     }
     // set template scope
     $tpl->scope = $scope;
     $scopePtr = false;
     if ($scope & ~Smarty::SCOPE_BUBBLE_UP) {
         if ($scope == Smarty::SCOPE_GLOBAL) {
             $tpl->tpl_vars = Smarty::$global_tpl_vars;
             $tpl->config_vars = $tpl->smarty->config_vars;
             $scopePtr = true;
         } else {
             if ($scope == Smarty::SCOPE_PARENT) {
                 $scopePtr = $parent;
             } elseif ($scope == Smarty::SCOPE_SMARTY) {
                 $scopePtr = $tpl->smarty;
             } else {
                 $scopePtr = $tpl;
                 while (isset($scopePtr->parent)) {
                     if ($scopePtr->parent->_objType != 2 && $scope & Smarty::SCOPE_TPL_ROOT) {
                         break;
                     }
                     $scopePtr = $scopePtr->parent;
                 }
             }
             $tpl->tpl_vars = $scopePtr->tpl_vars;
             $tpl->config_vars = $scopePtr->config_vars;
//.........这里部分代码省略.........
开发者ID:Hjsmallfly,项目名称:musex_old,代码行数:101,代码来源:smarty_internal_runtime_subtemplate.php


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