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


PHP Smarty_Internal_Template::_isSubTpl方法代码示例

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


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

示例1: start_template

 /**
  * Start logging template
  *
  * @param \Smarty_Internal_Template $template template
  * @param null                      $mode     true: display   false: fetch  null: subtemplate
  */
 public function start_template(Smarty_Internal_Template $template, $mode = null)
 {
     if (isset($mode) && !$template->_isSubTpl()) {
         $this->index++;
         $this->offset++;
         $this->template_data[$this->index] = null;
     }
     $key = $this->get_key($template);
     $this->template_data[$this->index][$key]['start_template_time'] = microtime(true);
 }
开发者ID:jimjag,项目名称:smarty,代码行数:16,代码来源:smarty_internal_debug.php

示例2: mustCompile

 /**
  * Returns if the current template must be compiled by the Smarty compiler
  * It does compare the timestamps of template source and the compiled templates and checks the force compile
  * configuration
  *
  * @param \Smarty_Internal_Template $_template
  *
  * @return bool
  * @throws \SmartyException
  */
 public function mustCompile(Smarty_Internal_Template $_template)
 {
     if (!$_template->source->exists) {
         if ($_template->_isSubTpl()) {
             $parent_resource = " in '{$_template->parent}->template_resource}'";
         } else {
             $parent_resource = '';
         }
         throw new SmartyException("Unable to load template {$_template->source->type} '{$_template->source->name}'{$parent_resource}");
     }
     if ($_template->mustCompile === null) {
         $_template->mustCompile = !$_template->source->handler->uncompiled && ($_template->smarty->force_compile || $_template->source->handler->recompiled || !$_template->compiled->exists || $_template->smarty->compile_check && $_template->compiled->getTimeStamp() < $_template->source->getTimeStamp());
     }
     return $_template->mustCompile;
 }
开发者ID:jimjag,项目名称:smarty,代码行数:25,代码来源:smarty_internal_method_mustcompile.php

示例3: renderUncompiled

 /**
  * Render and output the template (without using the compiler)
  *
  * @param  Smarty_Template_Source   $source    source object
  * @param  Smarty_Internal_Template $_template template object
  *
  * @return void
  * @throws SmartyException          if template cannot be loaded or allow_php_templates is disabled
  */
 public function renderUncompiled(Smarty_Template_Source $source, Smarty_Internal_Template $_template)
 {
     if (!$source->smarty->allow_php_templates) {
         throw new SmartyException("PHP templates are disabled");
     }
     if (!$source->exists) {
         throw new SmartyException("Unable to load template {$source->type} '{$source->name}'" . ($_template->_isSubTpl() ? " in '{$_template->parent->template_resource}'" : ''));
     }
     // prepare variables
     extract($_template->getTemplateVars());
     // include PHP template with short open tags enabled
     ini_set('short_open_tag', '1');
     /** @var Smarty_Internal_Template $_smarty_template
      * used in included file
      */
     $_smarty_template = $_template;
     include $source->filepath;
     ini_set('short_open_tag', $this->short_open_tag);
 }
开发者ID:jimjag,项目名称:smarty,代码行数:28,代码来源:smarty_internal_resource_php.php

示例4: buildFilepath

 /**
  * build template filepath by traversing the template_dir array
  *
  * @param Smarty_Template_Source    $source    source object
  * @param  Smarty_Internal_Template $_template template object
  *
  * @return string fully qualified filepath
  * @throws SmartyException
  */
 protected function buildFilepath(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null)
 {
     $file = $source->name;
     // absolute file ?
     if ($file[0] == '/' || $file[1] == ':') {
         $file = $source->smarty->_realpath($file, true);
         return is_file($file) ? $file : false;
     }
     // go relative to a given template?
     if ($file[0] == '.' && $_template && $_template->_isSubTpl() && preg_match('#^[.]{1,2}[\\\\/]#', $file)) {
         if ($_template->parent->source->type != 'file' && $_template->parent->source->type != 'extends' && !isset($_template->parent->_cache['allow_relative_path'])) {
             throw new SmartyException("Template '{$file}' cannot be relative to template of resource type '{$_template->parent->source->type}'");
         }
         // normalize path
         $path = $source->smarty->_realpath(dirname($_template->parent->source->filepath) . $source->smarty->ds . $file);
         // files relative to a template only get one shot
         return is_file($path) ? $path : false;
     }
     // normalize $source->smarty->ds
     if (strpos($file, $source->smarty->ds == '/' ? '\\' : '/') !== false) {
         $file = str_replace($source->smarty->ds == '/' ? '\\' : '/', $source->smarty->ds, $file);
     }
     $_directories = $source->smarty->getTemplateDir(null, $source->isConfig);
     // template_dir index?
     if ($file[0] == '[' && preg_match('#^\\[([^\\]]+)\\](.+)$#', $file, $fileMatch)) {
         $file = $fileMatch[2];
         $_indices = explode(',', $fileMatch[1]);
         $_index_dirs = array();
         foreach ($_indices as $index) {
             $index = trim($index);
             // try string indexes
             if (isset($_directories[$index])) {
                 $_index_dirs[] = $_directories[$index];
             } elseif (is_numeric($index)) {
                 // try numeric index
                 $index = (int) $index;
                 if (isset($_directories[$index])) {
                     $_index_dirs[] = $_directories[$index];
                 } else {
                     // try at location index
                     $keys = array_keys($_directories);
                     if (isset($_directories[$keys[$index]])) {
                         $_index_dirs[] = $_directories[$keys[$index]];
                     }
                 }
             }
         }
         if (empty($_index_dirs)) {
             // index not found
             return false;
         } else {
             $_directories = $_index_dirs;
         }
     }
     // relative file name?
     foreach ($_directories as $_directory) {
         $path = $_directory . $file;
         if (is_file($path)) {
             return strpos($path, '.' . $source->smarty->ds) !== false ? $source->smarty->_realpath($path) : $path;
         }
     }
     if (!isset($_index_dirs)) {
         // Could be relative to cwd
         $path = $source->smarty->_realpath($file, true);
         if (is_file($path)) {
             return $path;
         }
     }
     // Use include path ?
     if ($source->smarty->use_include_path) {
         return $source->smarty->ext->_getIncludePath->getIncludePath($_directories, $file, $source->smarty);
     }
     return false;
 }
开发者ID:jimjag,项目名称:smarty,代码行数:83,代码来源:smarty_internal_resource_file.php


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