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


PHP Smarty_Internal_Debug::start_render方法代码示例

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


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

示例1: configLoad

 /**
  * @param        $obj
  * @param        $config_file
  * @param null   $sections
  * @param string $scope
  */
 static function configLoad($obj, $config_file, $sections = null, $scope = 'local')
 {
     $smarty = isset($obj->smarty) ? $obj->smarty : $obj;
     $confObj = new $smarty->template_class($config_file, $smarty, $obj);
     $confObj->caching = Smarty::CACHING_OFF;
     $confObj->source = Smarty_Template_Config::load($confObj);
     $confObj->source->config_sections = $sections;
     $confObj->source->scope = $scope;
     $confObj->compiled = Smarty_Template_Compiled::load($confObj);
     if ($confObj->smarty->debugging) {
         Smarty_Internal_Debug::start_render($confObj);
     }
     $confObj->compiled->render($confObj);
     if ($confObj->smarty->debugging) {
         Smarty_Internal_Debug::end_render($confObj);
     }
     if ($obj instanceof Smarty_Internal_Template) {
         $obj->properties['file_dependency'][$confObj->source->uid] = array($confObj->source->filepath, $confObj->source->timestamp, $confObj->source->type);
     }
 }
开发者ID:nstungxd,项目名称:F2CA5,代码行数:26,代码来源:smarty_internal_extension_config.php

示例2: configLoad

 /**
  * @param                         $obj
  * @param                         $config_file
  * @param null                    $sections
  * @param string                  $scope
  *
  * @throws \SmartyException
  */
 static function configLoad($obj, $config_file, $sections = null, $scope = 'local')
 {
     $smarty = isset($obj->smarty) ? $obj->smarty : $obj;
     $confObj = new $smarty->template_class($config_file, $smarty, $obj);
     $confObj->context = new Smarty_Internal_Context();
     $confObj->caching = Smarty::CACHING_OFF;
     $confObj->source = Smarty_Template_Config::load($confObj);
     $confObj->source->config_sections = $sections;
     $confObj->source->scope = $scope;
     $confObj->compiled = Smarty_Template_Compiled::load($confObj);
     if ($confObj->smarty->debugging) {
         Smarty_Internal_Debug::start_render($confObj);
     }
     $confObj->compiled->render($confObj);
     $confObj->context = null;
     if ($confObj->smarty->debugging) {
         Smarty_Internal_Debug::end_render($confObj);
     }
     if ($obj instanceof Smarty_Internal_Template && isset($obj->context)) {
         $obj->context->resourceInfo[$confObj->source->uid] = array($confObj->source->filepath, $confObj->source->timestamp, $confObj->source->type);
     } else {
         // TODO   config file dependency if loaded in Smarty, Data or Template object
     }
 }
开发者ID:uwetews,项目名称:smarty-hhvm,代码行数:32,代码来源:smarty_internal_extension_config.php

示例3: renderTemplate

 /**
  * Render the output using the compiled template or the PHP template source
  * 
  * The rendering process is accomplished by just including the PHP files.
  * The only exceptions are evaluated templates (string template). Their code has 
  * to be evaluated
  */
 public function renderTemplate()
 {
     if ($this->resource_object->usesCompiler) {
         if ($this->mustCompile() && $this->compiled_template === null) {
             $this->compileTemplateSource();
         }
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::start_render($this);
         }
         $_smarty_tpl = $this;
         ob_start();
         if ($this->resource_object->isEvaluated) {
             eval("?>" . $this->compiled_template);
         } else {
             include $this->getCompiledFilepath();
             // check file dependencies at compiled code
             if ($this->smarty->compile_check) {
                 if (!empty($this->properties['file_dependency'])) {
                     $this->mustCompile = false;
                     $resource_type = null;
                     $resource_name = null;
                     foreach ($this->properties['file_dependency'] as $_file_to_check) {
                         if ($_file_to_check[2] == 'file' || $_file_to_check[2] == 'extends' || $_file_to_check[2] == 'php') {
                             $mtime = filemtime($_file_to_check[0]);
                         } else {
                             $this->getResourceTypeName($_file_to_check[0], $resource_type, $resource_name);
                             $resource_handler = $this->loadTemplateResourceHandler($resource_type);
                             $mtime = $resource_handler->getTemplateTimestampTypeName($resource_type, $resource_name);
                         }
                         // If ($mtime != $_file_to_check[1]) {
                         if ($mtime > $_file_to_check[1]) {
                             $this->mustCompile = true;
                             break;
                         }
                     }
                     if ($this->mustCompile) {
                         // recompile and render again
                         ob_GET_clean();
                         $this->compileTemplateSource();
                         ob_start();
                         include $this->getCompiledFilepath();
                     }
                 }
             }
         }
     } else {
         if (is_callable(array($this->resource_object, 'renderUncompiled'))) {
             if ($this->smarty->debugging) {
                 Smarty_Internal_Debug::start_render($this);
             }
             ob_start();
             $this->resource_object->renderUncompiled($this);
         } else {
             throw new SmartyException("Resource '{$this->resource_type}' must have 'renderUncompiled' methode");
         }
     }
     $this->rendered_content = ob_GET_clean();
     if (!$this->resource_object->isEvaluated && empty($this->properties['file_dependency'][$this->templateUid])) {
         $this->properties['file_dependency'][$this->templateUid] = array($this->getTemplateFilepath(), $this->getTemplateTimestamp(), $this->resource_type);
     }
     if ($this->parent instanceof Smarty_Internal_Template) {
         $this->parent->properties['file_dependency'] = array_merge($this->parent->properties['file_dependency'], $this->properties['file_dependency']);
         foreach ($this->required_plugins as $code => $tmp1) {
             foreach ($tmp1 as $name => $tmp) {
                 foreach ($tmp as $type => $data) {
                     $this->parent->required_plugins[$code][$name][$type] = $data;
                 }
             }
         }
     }
     if ($this->smarty->debugging) {
         Smarty_Internal_Debug::end_render($this);
     }
     // write to cache when nessecary
     if (!$this->resource_object->isEvaluated && ($this->caching == Smarty::CACHING_LIFETIME_SAVED || $this->caching == Smarty::CACHING_LIFETIME_CURRENT)) {
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::start_cache($this);
         }
         $this->properties['has_nocache_code'] = false;
         // get text between non-cached items
         $cache_split = preg_split("!/\\*%%SmartyNocache:{$this->properties['nocache_hash']}%%\\*\\/(.+?)/\\*/%%SmartyNocache:{$this->properties['nocache_hash']}%%\\*/!s", $this->rendered_content);
         // get non-cached items
         preg_match_all("!/\\*%%SmartyNocache:{$this->properties['nocache_hash']}%%\\*\\/(.+?)/\\*/%%SmartyNocache:{$this->properties['nocache_hash']}%%\\*/!s", $this->rendered_content, $cache_parts);
         $output = '';
         // loop over items, stitch back together
         foreach ($cache_split as $curr_idx => $curr_split) {
             // escape PHP tags in template content
             $output .= preg_replace('/(<%|%>|<\\?php|<\\?|\\?>)/', '<?php echo \'$1\'; ?>', $curr_split);
             if (isset($cache_parts[0][$curr_idx])) {
                 $this->properties['has_nocache_code'] = true;
                 // remove nocache tags from cache output
                 $output .= preg_replace("!/\\*/?%%SmartyNocache:{$this->properties['nocache_hash']}%%\\*/!", '', $cache_parts[0][$curr_idx]);
             }
//.........这里部分代码省略.........
开发者ID:jiatower,项目名称:php,代码行数:101,代码来源:smarty_internal_template.php

示例4: getInlineSubTemplate

 /**
  * Template code runtime function to set up an inline subtemplate
  *
  * @param string  $template the resource handle of the template file
  * @param mixed   $cache_id cache id to be used with this template
  * @param mixed   $compile_id compile id to be used with this template
  * @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 string  $hash nocache hash code
  * @param string  $content_func name of content function
  *
  * @returns object template content
  */
 public function getInlineSubTemplate($template, $cache_id, $compile_id, $caching, $cache_lifetime, $data, $parent_scope, $hash, $content_func)
 {
     $tpl = $this->setupSubTemplate($template, $cache_id, $compile_id, $caching, $cache_lifetime, $data, $parent_scope);
     $tpl->properties['nocache_hash'] = $hash;
     if (!isset($this->smarty->template_objects[$tpl->templateId])) {
         $this->smarty->template_objects[$tpl->templateId] = $tpl;
     }
     if ($this->smarty->debugging) {
         Smarty_Internal_Debug::start_template($tpl);
         Smarty_Internal_Debug::start_render($tpl);
     }
     $tpl->properties['unifunc'] = $content_func;
     $output = $tpl->getRenderedTemplateCode();
     if ($this->smarty->debugging) {
         Smarty_Internal_Debug::end_template($tpl);
         Smarty_Internal_Debug::end_render($tpl);
     }
     if (!empty($tpl->properties['file_dependency'])) {
         $this->properties['file_dependency'] = array_merge($this->properties['file_dependency'], $tpl->properties['file_dependency']);
     }
     $this->properties['tpl_function'] = $tpl->properties['tpl_function'];
     return str_replace($tpl->properties['nocache_hash'], $this->properties['nocache_hash'], $output);
 }
开发者ID:hejxing,项目名称:jt,代码行数:38,代码来源:smarty_internal_template.php

示例5: fetch


//.........这里部分代码省略.........
             }
         }
     }
     // must reset merge template date
     $_template->smarty->merged_templates_func = array();
     // get rendered template
     // disable caching for evaluated code
     if ($_template->source->recompiled) {
         $_template->caching = false;
     }
     // checks if template exists
     if (!$_template->source->exists) {
         if ($_template->parent instanceof Smarty_Internal_Template) {
             $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}");
     }
     // read from cache or render
     if (!($_template->caching == Smarty::CACHING_LIFETIME_CURRENT || $_template->caching == Smarty::CACHING_LIFETIME_SAVED) || !$_template->cached->valid) {
         // render template (not loaded and not in cache)
         if (!$_template->source->uncompiled) {
             $_smarty_tpl = $_template;
             if ($_template->source->recompiled) {
                 if ($this->smarty->debugging) {
                     Smarty_Internal_Debug::start_compile($_template);
                 }
                 $code = $_template->compiler->compileTemplate($_template);
                 if ($this->smarty->debugging) {
                     Smarty_Internal_Debug::end_compile($_template);
                 }
                 if ($this->smarty->debugging) {
                     Smarty_Internal_Debug::start_render($_template);
                 }
                 try {
                     ob_start();
                     eval("?>" . $code);
                     unset($code);
                 } catch (Exception $e) {
                     ob_get_clean();
                     throw $e;
                 }
             } else {
                 if (!$_template->compiled->exists || $_template->smarty->force_compile && !$_template->compiled->isCompiled) {
                     $_template->compileTemplateSource();
                 }
                 if ($this->smarty->debugging) {
                     Smarty_Internal_Debug::start_render($_template);
                 }
                 if (!$_template->compiled->loaded) {
                     include $_template->compiled->filepath;
                     if ($_template->mustCompile) {
                         // recompile and load again
                         $_template->compileTemplateSource();
                         include $_template->compiled->filepath;
                     }
                     $_template->compiled->loaded = true;
                 } else {
                     $_template->decodeProperties($_template->compiled->_properties, false);
                 }
                 try {
                     ob_start();
                     if (empty($_template->properties['unifunc']) || !is_callable($_template->properties['unifunc'])) {
                         throw new SmartyException("Invalid compiled template for '{$_template->template_resource}'");
                     }
开发者ID:Tipkin-Commons,项目名称:tipkin,代码行数:67,代码来源:smarty_internal_templatebase.php

示例6: fetch

 public function fetch($template = null, $cache_id = null, $compile_id = null, $parent = null, $display = false, $merge_tpl_vars = true, $no_output_filter = false)
 {
     if ($template === null && $this instanceof $this->template_class) {
         $template = $this;
     }
     if ($cache_id !== null && is_object($cache_id)) {
         $parent = $cache_id;
         $cache_id = null;
     }
     if ($parent === null && ($this instanceof Smarty || is_string($template))) {
         $parent = $this;
     }
     $_template = $template instanceof $this->template_class ? $template : $this->smarty->createTemplate($template, $cache_id, $compile_id, $parent, false);
     if ($this instanceof Smarty) {
         $_template->caching = $this->caching;
     }
     if ($merge_tpl_vars) {
         $save_tpl_vars = $_template->tpl_vars;
         $save_config_vars = $_template->config_vars;
         $ptr_array = array($_template);
         $ptr = $_template;
         while (isset($ptr->parent)) {
             $ptr_array[] = $ptr = $ptr->parent;
         }
         $ptr_array = array_reverse($ptr_array);
         $parent_ptr = reset($ptr_array);
         $tpl_vars = $parent_ptr->tpl_vars;
         $config_vars = $parent_ptr->config_vars;
         while ($parent_ptr = next($ptr_array)) {
             if (!empty($parent_ptr->tpl_vars)) {
                 $tpl_vars = array_merge($tpl_vars, $parent_ptr->tpl_vars);
             }
             if (!empty($parent_ptr->config_vars)) {
                 $config_vars = array_merge($config_vars, $parent_ptr->config_vars);
             }
         }
         if (!empty(Smarty::$global_tpl_vars)) {
             $tpl_vars = array_merge(Smarty::$global_tpl_vars, $tpl_vars);
         }
         $_template->tpl_vars = $tpl_vars;
         $_template->config_vars = $config_vars;
     }
     if (!isset($_template->tpl_vars['smarty'])) {
         $_template->tpl_vars['smarty'] = new Smarty_Variable();
     }
     if (isset($this->smarty->error_reporting)) {
         $_smarty_old_error_level = error_reporting($this->smarty->error_reporting);
     }
     if (!$this->smarty->debugging && $this->smarty->debugging_ctrl == 'URL') {
         if (isset($_SERVER['QUERY_STRING'])) {
             $_query_string = $_SERVER['QUERY_STRING'];
         } else {
             $_query_string = '';
         }
         if (false !== strpos($_query_string, $this->smarty->smarty_debug_id)) {
             if (false !== strpos($_query_string, $this->smarty->smarty_debug_id . '=on')) {
                 setcookie('SMARTY_DEBUG', true);
                 $this->smarty->debugging = true;
             } elseif (false !== strpos($_query_string, $this->smarty->smarty_debug_id . '=off')) {
                 setcookie('SMARTY_DEBUG', false);
                 $this->smarty->debugging = false;
             } else {
                 $this->smarty->debugging = true;
             }
         } else {
             if (isset($_COOKIE['SMARTY_DEBUG'])) {
                 $this->smarty->debugging = true;
             }
         }
     }
     $_template->smarty->merged_templates_func = array();
     if ($_template->source->recompiled) {
         $_template->caching = false;
     }
     if (!$_template->source->exists) {
         if ($_template->parent instanceof Smarty_Internal_Template) {
             $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->caching == Smarty::CACHING_LIFETIME_CURRENT || $_template->caching == Smarty::CACHING_LIFETIME_SAVED) || !$_template->cached->valid) {
         if (!$_template->source->uncompiled) {
             $_smarty_tpl = $_template;
             if ($_template->source->recompiled) {
                 $code = $_template->compiler->compileTemplate($_template);
                 if ($this->smarty->debugging) {
                     Smarty_Internal_Debug::start_render($_template);
                 }
                 try {
                     ob_start();
                     eval('?>' . $code);
                     unset($code);
                 } catch (Exception $e) {
                     ob_get_clean();
                     throw $e;
                 }
             } else {
                 if (!$_template->compiled->exists || $_template->smarty->force_compile && !$_template->compiled->isCompiled) {
//.........这里部分代码省略.........
开发者ID:admpub,项目名称:MicroPHP,代码行数:101,代码来源:~Runtime.php

示例7: fetch


//.........这里部分代码省略.........
         } else {
             if (isset($_COOKIE['SMARTY_DEBUG'])) {
                 $this->smarty->debugging = true;
             }
         }
     }
     // must reset merge template date
     $_template->smarty->merged_templates_func = array();
     // get rendered template
     // disable caching for evaluated code
     if ($_template->source->recompiled) {
         $_template->caching = false;
     }
     // checks if template exists
     if (!$_template->source->exists) {
         if ($_template->parent instanceof Smarty_Internal_Template) {
             $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}");
     }
     // read from cache or render
     if (!($_template->caching == Smarty::CACHING_LIFETIME_CURRENT || $_template->caching == Smarty::CACHING_LIFETIME_SAVED) || !$_template->cached->valid) {
         // render template (not loaded and not in cache)
         if (!$_template->source->uncompiled) {
             /** @var Smarty_Internal_Template $_smarty_tpl
              * used in evaluated code
              */
             $_smarty_tpl = $_template;
             if ($_template->source->recompiled) {
                 $code = $_template->compiler->compileTemplate($_template);
                 if ($this->smarty->debugging) {
                     Smarty_Internal_Debug::start_render($_template);
                 }
                 try {
                     ob_start();
                     /// dark edit
                     \Dark\SmartyView\SmartyEngine::integrateViewComposers($_template);
                     /// end edit
                     eval("?>" . $code);
                     unset($code);
                 } catch (Exception $e) {
                     ob_get_clean();
                     throw $e;
                 }
             } else {
                 if (!$_template->compiled->exists || $_template->smarty->force_compile && !$_template->compiled->isCompiled) {
                     $_template->compileTemplateSource();
                     $code = file_get_contents($_template->compiled->filepath);
                     eval("?>" . $code);
                     unset($code);
                     $_template->compiled->loaded = true;
                     $_template->compiled->isCompiled = true;
                 }
                 if ($this->smarty->debugging) {
                     Smarty_Internal_Debug::start_render($_template);
                 }
                 if (!$_template->compiled->loaded) {
                     include $_template->compiled->filepath;
                     if ($_template->mustCompile) {
                         // recompile and load again
                         $_template->compileTemplateSource();
                         $code = file_get_contents($_template->compiled->filepath);
                         eval("?>" . $code);
                         unset($code);
开发者ID:baiduXM,项目名称:gbpen,代码行数:67,代码来源:smarty_internal_templatebase.php

示例8: getInlineSubTemplate

 /**
  * Template code runtime function to set up an inline subtemplate
  *
  * @param string  $template       the resource handle of the template file
  * @param mixed   $cache_id       cache id to be used with this template
  * @param mixed   $compile_id     compile id to be used with this template
  * @param integer $caching        cache mode
  * @param integer $cache_lifetime life time of cache data
  * @param array   $data           passed parameter template variables
  * @param         $_scope
  * @param         $parent
  * @param string  $content_func   name of content function
  *
  * @param bool    $newBuffer
  *
  * @return object template content
  */
 public function getInlineSubTemplate($template, $cache_id, $compile_id, $caching, $cache_lifetime, $data, $_scope, $parent, $params, $newBuffer = false)
 {
     $tpl = $parent->smarty->setupTemplate($template, $cache_id, $compile_id, $caching, $cache_lifetime, $data, $_scope, $parent);
     $tpl->context = $newBuffer ? new Smarty_Internal_Context() : $parent->context;
     if ($tpl->smarty->debugging) {
         Smarty_Internal_Debug::start_template($tpl);
         Smarty_Internal_Debug::start_render($tpl);
     }
     $this->getRenderedTemplateCode($tpl, $params['func']);
     if ($tpl->smarty->debugging) {
         Smarty_Internal_Debug::end_template($tpl);
         Smarty_Internal_Debug::end_render($tpl);
     }
     if ($newBuffer) {
         $output = $tpl->context->getContent();
         $tpl->context = null;
         return $output;
     }
     $tpl->context = null;
     return '';
 }
开发者ID:uwetews,项目名称:smarty-hhvm,代码行数:38,代码来源:smarty_internal_runtime.php

示例9: render

 /**
  * render template
  *
  * @param  bool                         $display       true: display, false: fetch
  * @param bool                          $isSubTemplate
  * @param bool                          $runOutputFilter
  * @param null|\Smarty_Internal_Context $_contextObjIn optional buffer object
  *
  * @return string
  * @throws \SmartyException
  */
 public function render($display = false, $isSubTemplate = false, $runOutputFilter = true, Smarty_Internal_Context $_contextObjIn = null)
 {
     $level = ob_get_level();
     try {
         if (!isset($this->source)) {
             $this->source = Smarty_Template_Source::load($this);
         }
         // checks if template exists
         if (!$this->source->exists) {
             if ($this->parent instanceof Smarty_Internal_Template) {
                 $parent_resource = " in '{$this->parent->template_resource}'";
             } else {
                 $parent_resource = '';
             }
             throw new SmartyException("Unable to load template {$this->source->type} '{$this->source->name}'{$parent_resource}");
         }
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::start_template($this);
         }
         $this->context = $_contextObjIn === null ? new Smarty_Internal_Context() : $_contextObjIn;
         // merge all variable scopes into template
         if (!$isSubTemplate) {
             $savedErrorLevel = isset($this->smarty->error_reporting) ? error_reporting($this->smarty->error_reporting) : null;
             // save local variables
             $savedTplVars = $this->tpl_vars;
             $savedConfigVars = $this->config_vars;
             $ptr_array = array($this);
             $ptr = $this;
             while (isset($ptr->parent)) {
                 $ptr_array[] = $ptr = $ptr->parent;
             }
             $ptr_array = array_reverse($ptr_array);
             $parent_ptr = reset($ptr_array);
             $tpl_vars = $parent_ptr->tpl_vars;
             $config_vars = $parent_ptr->config_vars;
             while ($parent_ptr = next($ptr_array)) {
                 if (!empty($parent_ptr->tpl_vars)) {
                     $tpl_vars = array_merge($tpl_vars, $parent_ptr->tpl_vars);
                 }
                 if (!empty($parent_ptr->config_vars)) {
                     $config_vars = array_merge($config_vars, $parent_ptr->config_vars);
                 }
             }
             if (!empty(Smarty::$global_tpl_vars)) {
                 $tpl_vars = array_merge(Smarty::$global_tpl_vars, $tpl_vars);
             }
             $this->tpl_vars = $tpl_vars;
             $this->config_vars = $config_vars;
         } else {
             $savedTplVars = null;
             $savedConfigVars = null;
             $savedErrorLevel = null;
         }
         // dummy local smarty variable
         if (!isset($this->tpl_vars['smarty'])) {
             $this->tpl_vars['smarty'] = new Smarty_Variable();
         }
         // disable caching for evaluated code
         if ($this->source->recompiled) {
             $this->caching = false;
         }
         $_caching = $this->caching == Smarty::CACHING_LIFETIME_CURRENT || $this->caching == Smarty::CACHING_LIFETIME_SAVED;
         // read from cache or render
         if ($_caching && !isset($this->cached)) {
             $this->cached = Smarty_Template_Cached::load($this);
         }
         if (!$_caching || !$this->cached->valid) {
             // render template (not loaded and not in cache)
             if ($this->smarty->debugging) {
                 Smarty_Internal_Debug::start_render($this, null);
             }
             if (isset($this->cached)) {
                 $_savedContext = $this->context;
                 $this->context = new Smarty_Internal_Context(true);
             }
             if (!$this->source->uncompiled) {
                 // render compiled code
                 if (!isset($this->compiled)) {
                     $this->compiled = Smarty_Template_Compiled::load($this);
                 }
                 $this->compiled->render($this);
             } else {
                 $this->source->renderUncompiled($this);
             }
             if ($this->smarty->debugging) {
                 Smarty_Internal_Debug::end_render($this, null);
             }
             // write to cache when necessary
             if ($_caching && !$this->source->recompiled) {
//.........这里部分代码省略.........
开发者ID:uwetews,项目名称:smarty-hhvm,代码行数:101,代码来源:smarty_internal_template.php

示例10: renderTemplate

 /**
  * Render the output using the compiled template or the PHP template source
  * 
  * The rendering process is accomplished by just including the PHP files.
  * The only exceptions are evaluated templates (string template). Their code has 
  * to be evaluated
  */
 public function renderTemplate()
 {
     if ($this->usesCompiler()) {
         if ($this->mustCompile() && $this->compiled_template === null) {
             $this->compileTemplateSource();
         }
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::start_render($this);
         }
         $_smarty_tpl = $this;
         ob_start();
         if ($this->isEvaluated()) {
             eval("?>" . $this->compiled_template);
         } else {
             include $this->getCompiledFilepath();
             // check file dependencies at compiled code
             if ($this->smarty->compile_check) {
                 if (!empty($this->properties['file_dependency'])) {
                     $this->mustCompile = false;
                     foreach ($this->properties['file_dependency'] as $_file_to_check) {
                         $this->getResourceTypeName($_file_to_check[0], $resource_type, $resource_name);
                         if ($resource_type == 'file') {
                             $mtime = filemtime($_file_to_check[0]);
                         } else {
                             $resource_handler = $this->loadTemplateResourceHandler($resource_type);
                             $mtime = $resource_handler->getTemplateTimestampTypeName($resource_type, $resource_name);
                         }
                         //                            If ($mtime != $_file_to_check[1]) {
                         if ($mtime > $_file_to_check[1]) {
                             $this->properties['file_dependency'] = array();
                             $this->mustCompile = true;
                             break;
                         }
                     }
                     if ($this->mustCompile) {
                         // recompile and render again
                         ob_get_clean();
                         $this->compileTemplateSource();
                         ob_start();
                         include $this->getCompiledFilepath();
                     }
                 }
             }
         }
     } else {
         if (is_callable(array($this->resource_object, 'renderUncompiled'))) {
             if ($this->smarty->debugging) {
                 Smarty_Internal_Debug::start_render($this);
             }
             ob_start();
             $this->resource_object->renderUncompiled($this);
         } else {
             throw new Exception("Resource '{$this->resource_type}' must have 'renderUncompiled' methode");
         }
     }
     $this->rendered_content = ob_get_clean();
     if (!$this->isEvaluated) {
         $this->properties['file_dependency']['F' . abs(crc32($this->getTemplateFilepath()))] = array($this->getTemplateFilepath(), $this->getTemplateTimestamp());
     }
     if ($this->parent instanceof Smarty_Template or $this->parent instanceof Smarty_Internal_Template) {
         // var_dump('merge ', $this->parent->getTemplateFilepath(), $this->parent->properties['file_dependency'], $this->getTemplateFilepath(), $this->properties['file_dependency']);
         $this->parent->properties['file_dependency'] = array_merge($this->parent->properties['file_dependency'], $this->properties['file_dependency']);
     }
     if ($this->smarty->debugging) {
         Smarty_Internal_Debug::end_render($this);
     }
     // write to cache when nessecary
     if (!$this->isEvaluated() && ($this->caching == SMARTY_CACHING_LIFETIME_SAVED || $this->caching == SMARTY_CACHING_LIFETIME_CURRENT)) {
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::start_cache($this);
         }
         // write rendered template
         $this->writeCachedContent($this);
         // cache file may contain nocache code. read it back for processing
         $this->rendered_content = $this->cache_resource_object->getCachedContents($this);
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::end_cache($this);
         }
     }
 }
开发者ID:k9lis,项目名称:cms,代码行数:87,代码来源:smarty_internal_template.php

示例11: render

 /**
  * render template
  * @param  bool $merge_tpl_vars if true parent template variables merged in to local scope
  * @param  bool $no_output_filter if true do not run output filter
  * @param  bool $display true: display, false: fetch null: subtemplate
  * @throws Exception
  * @throws SmartyException
  * @return string rendered template output
  */
 public function render($merge_tpl_vars = FALSE, $no_output_filter = TRUE, $display = NULL)
 {
     $parentIsTpl = $this->parent instanceof Smarty_Internal_Template;
     if ($this->smarty->debugging) {
         Smarty_Internal_Debug::start_template($this, $display);
     }
     $save_tpl_vars = NULL;
     $save_config_vars = NULL;
     // merge all variable scopes into template
     if ($merge_tpl_vars) {
         // save local variables
         $save_tpl_vars = $this->tpl_vars;
         $save_config_vars = $this->config_vars;
         $ptr_array = [$this];
         $ptr = $this;
         while (isset($ptr->parent)) {
             $ptr_array[] = $ptr = $ptr->parent;
         }
         $ptr_array = array_reverse($ptr_array);
         $parent_ptr = reset($ptr_array);
         $tpl_vars = $parent_ptr->tpl_vars;
         $config_vars = $parent_ptr->config_vars;
         while ($parent_ptr = next($ptr_array)) {
             if (!empty($parent_ptr->tpl_vars)) {
                 $tpl_vars = array_merge($tpl_vars, $parent_ptr->tpl_vars);
             }
             if (!empty($parent_ptr->config_vars)) {
                 $config_vars = array_merge($config_vars, $parent_ptr->config_vars);
             }
         }
         if (!empty(Smarty::$global_tpl_vars)) {
             $tpl_vars = array_merge(Smarty::$global_tpl_vars, $tpl_vars);
         }
         $this->tpl_vars = $tpl_vars;
         $this->config_vars = $config_vars;
     }
     // dummy local smarty variable
     if (!isset($this->tpl_vars['smarty'])) {
         $this->tpl_vars['smarty'] = new Smarty_Variable();
     }
     $_smarty_old_error_level = isset($this->smarty->error_reporting) ? error_reporting($this->smarty->error_reporting) : NULL;
     // check URL debugging control
     if (!$this->smarty->debugging && $this->smarty->debugging_ctrl == 'URL') {
         Smarty_Internal_Debug::debugUrl($this);
     }
     if (!isset($this->source)) {
         $this->loadSource();
     }
     // checks if template exists
     if (!$this->source->exists) {
         if ($parentIsTpl) {
             $parent_resource = " in '{$this->parent->template_resource}'";
         } else {
             $parent_resource = '';
         }
         throw new SmartyException("Unable to load template {$this->source->type} '{$this->source->name}'{$parent_resource}");
     }
     // disable caching for evaluated code
     if ($this->source->recompiled) {
         $this->caching = FALSE;
     }
     // read from cache or render
     $isCacheTpl = $this->caching == Smarty::CACHING_LIFETIME_CURRENT || $this->caching == Smarty::CACHING_LIFETIME_SAVED;
     if ($isCacheTpl) {
         if (!isset($this->cached)) {
             $this->loadCached();
         }
         $this->cached->isCached($this);
     }
     if (!$isCacheTpl || !$this->cached->valid) {
         if ($isCacheTpl) {
             $this->properties['tpl_function'] = [];
         }
         // render template (not loaded and not in cache)
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::start_render($this);
         }
         if (!$this->source->uncompiled) {
             // render compiled code
             if (!isset($this->compiled)) {
                 $this->loadCompiled();
             }
             $content = $this->compiled->render($this);
         } else {
             $content = $this->source->renderUncompiled($this);
         }
         if (!$this->source->recompiled && empty($this->properties['file_dependency'][$this->source->uid])) {
             $this->properties['file_dependency'][$this->source->uid] = [$this->source->filepath, $this->source->timestamp, $this->source->type];
         }
         if ($parentIsTpl) {
             $this->parent->properties['file_dependency'] = array_merge($this->parent->properties['file_dependency'], $this->properties['file_dependency']);
//.........这里部分代码省略.........
开发者ID:rendix2,项目名称:QW_MVS,代码行数:101,代码来源:smarty_internal_template.php


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