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


PHP Smarty_Internal_Debug::end_cache方法代码示例

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


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

示例1: render


//.........这里部分代码省略.........
                 $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']);
             //$this->parent->properties['tpl_function'] = array_merge($this->parent->properties['tpl_function'], $this->properties['tpl_function']);
         }
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::end_render($this);
         }
         // write to cache when necessary
         if (!$this->source->recompiled && $isCacheTpl) {
             if ($this->smarty->debugging) {
                 Smarty_Internal_Debug::start_cache($this);
             }
             $this->cached->updateCache($this, $content, $no_output_filter);
             $compile_check = $this->smarty->compile_check;
             $this->smarty->compile_check = false;
             if ($parentIsTpl) {
                 $this->properties['tpl_function'] = $this->parent->properties['tpl_function'];
             }
             if (!$this->cached->processed) {
                 $this->cached->process($this);
             }
             $this->smarty->compile_check = $compile_check;
             $content = $this->getRenderedTemplateCode();
             if ($this->smarty->debugging) {
                 Smarty_Internal_Debug::end_cache($this);
             }
         } else {
             if (!empty($this->properties['nocache_hash']) && !empty($this->parent->properties['nocache_hash'])) {
                 // replace nocache_hash
                 $content = str_replace("{$this->properties['nocache_hash']}", $this->parent->properties['nocache_hash'], $content);
                 $this->parent->has_nocache_code = $this->parent->has_nocache_code || $this->has_nocache_code;
             }
         }
     } else {
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::start_cache($this);
         }
         $content = $this->cached->render($this);
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::end_cache($this);
         }
     }
     if ((!$this->caching || $this->has_nocache_code || $this->source->recompiled) && !$no_output_filter && (isset($this->smarty->autoload_filters['output']) || isset($this->smarty->registered_filters['output']))) {
         $content = Smarty_Internal_Filter_Handler::runFilter('output', $content, $this);
     }
     if (isset($_smarty_old_error_level)) {
         error_reporting($_smarty_old_error_level);
     }
     // display or fetch
     if ($display) {
         if ($this->caching && $this->smarty->cache_modified_check) {
             $this->cached->cacheModifiedCheck($this, $content);
         } else {
             echo $content;
         }
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::end_template($this);
开发者ID:hejxing,项目名称:jt,代码行数:67,代码来源:smarty_internal_template.php

示例2: getRenderedTemplate

 /**
  * Returns the rendered HTML output 
  * 
  * If the cache is valid the cached content is used, otherwise
  * the output is rendered from the compiled template or PHP template source
  * 
  * @return string rendered HTML output
  */
 public function getRenderedTemplate()
 {
     // disable caching for evaluated code
     if ($this->resource_object->isEvaluated) {
         $this->caching = false;
     }
     // checks if template exists
     $this->isExisting(true);
     // read from cache or render
     if ($this->rendered_content === null) {
         if ($this->isCached) {
             if ($this->smarty->debugging) {
                 Smarty_Internal_Debug::start_cache($this);
             }
             $this->rendered_content = $this->cache_resource_object->getCachedContents($this, false);
             if ($this->smarty->debugging) {
                 Smarty_Internal_Debug::end_cache($this);
             }
         }
         if ($this->isCached === null) {
             $this->isCached(false);
         }
         if (!$this->isCached) {
             // render template (not loaded and not in cache)
             $this->renderTemplate();
         }
     }
     $this->updateParentVariables();
     $this->isCached = null;
     return $this->rendered_content;
 }
开发者ID:jiatower,项目名称:php,代码行数:39,代码来源:smarty_internal_template.php

示例3: fetch


//.........这里部分代码省略.........
             }
             $_template->properties['has_nocache_code'] = false;
             // get text between non-cached items
             $cache_split = preg_split("!/\\*%%SmartyNocache:{$_template->properties['nocache_hash']}%%\\*\\/(.+?)/\\*/%%SmartyNocache:{$_template->properties['nocache_hash']}%%\\*/!s", $_output);
             // get non-cached items
             preg_match_all("!/\\*%%SmartyNocache:{$_template->properties['nocache_hash']}%%\\*\\/(.+?)/\\*/%%SmartyNocache:{$_template->properties['nocache_hash']}%%\\*/!s", $_output, $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])) {
                     $_template->properties['has_nocache_code'] = true;
                     // remove nocache tags from cache output
                     $output .= preg_replace("!/\\*/?%%SmartyNocache:{$_template->properties['nocache_hash']}%%\\*/!", '', $cache_parts[0][$curr_idx]);
                 }
             }
             if (!$no_output_filter && (isset($this->smarty->autoload_filters['output']) || isset($this->smarty->registered_filters['output']))) {
                 $output = Smarty_Internal_Filter_Handler::runFilter('output', $output, $_template);
             }
             // rendering (must be done before writing cache file because of {function} nocache handling)
             $_smarty_tpl = $_template;
             try {
                 ob_start();
                 eval("?>" . $output);
                 $_output = ob_get_clean();
             } catch (Exception $e) {
                 ob_get_clean();
                 throw $e;
             }
             // write cache file content
             $_template->writeCachedContent($output);
             if ($this->smarty->debugging) {
                 Smarty_Internal_Debug::end_cache($_template);
             }
         } else {
             // var_dump('renderTemplate', $_template->has_nocache_code, $_template->template_resource, $_template->properties['nocache_hash'], $_template->parent->properties['nocache_hash'], $_output);
             if (!empty($_template->properties['nocache_hash']) && !empty($_template->parent->properties['nocache_hash'])) {
                 // replace nocache_hash
                 $_output = preg_replace("/{$_template->properties['nocache_hash']}/", $_template->parent->properties['nocache_hash'], $_output);
                 $_template->parent->has_nocache_code = $_template->parent->has_nocache_code || $_template->has_nocache_code;
             }
         }
     } else {
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::start_cache($_template);
         }
         try {
             ob_start();
             array_unshift($_template->_capture_stack, array());
             //
             // render cached template
             //
             $_template->properties['unifunc']($_template);
             // any unclosed {capture} tags ?
             if (isset($_template->_capture_stack[0][0])) {
                 $_template->capture_error();
             }
             array_shift($_template->_capture_stack);
             $_output = ob_get_clean();
         } catch (Exception $e) {
             ob_get_clean();
             throw $e;
         }
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::end_cache($_template);
开发者ID:Tipkin-Commons,项目名称:tipkin,代码行数:67,代码来源:smarty_internal_templatebase.php

示例4: __construct

 /**
  * create Cached Object container
  *
  * @param Smarty_Internal_Template $_template template object
  */
 public function __construct(Smarty_Internal_Template $_template)
 {
     $this->compile_id = $_template->compile_id;
     $this->cache_id = $_template->cache_id;
     $this->source = $_template->source;
     $_template->cached = $this;
     $smarty = $_template->smarty;
     //
     // load resource handler
     //
     $this->handler = $handler = Smarty_CacheResource::load($smarty);
     // Note: prone to circular references
     //
     //    check if cache is valid
     //
     if (!($_template->caching == Smarty::CACHING_LIFETIME_CURRENT || $_template->caching == Smarty::CACHING_LIFETIME_SAVED) || $_template->source->recompiled) {
         $handler->populate($this, $_template);
         return;
     }
     while (true) {
         while (true) {
             $handler->populate($this, $_template);
             if ($this->timestamp === false || $smarty->force_compile || $smarty->force_cache) {
                 $this->valid = false;
             } else {
                 $this->valid = true;
             }
             if ($this->valid && $_template->caching == Smarty::CACHING_LIFETIME_CURRENT && $_template->cache_lifetime >= 0 && time() > $this->timestamp + $_template->cache_lifetime) {
                 // lifetime expired
                 $this->valid = false;
             }
             if ($this->valid || !$_template->smarty->cache_locking) {
                 break;
             }
             if (!$this->handler->locked($_template->smarty, $this)) {
                 $this->handler->acquireLock($_template->smarty, $this);
                 break 2;
             }
         }
         if ($this->valid) {
             if (!$_template->smarty->cache_locking || $this->handler->locked($_template->smarty, $this) === null) {
                 // load cache file for the following checks
                 if ($smarty->debugging) {
                     Smarty_Internal_Debug::start_cache($_template);
                 }
                 if ($handler->process($_template, $this) === false) {
                     $this->valid = false;
                 } else {
                     $this->processed = true;
                 }
                 if ($smarty->debugging) {
                     Smarty_Internal_Debug::end_cache($_template);
                 }
             } else {
                 continue;
             }
         } else {
             return;
         }
         if ($this->valid && $_template->caching === Smarty::CACHING_LIFETIME_SAVED && $_template->properties['cache_lifetime'] >= 0 && time() > $_template->cached->timestamp + $_template->properties['cache_lifetime']) {
             $this->valid = false;
         }
         if (!$this->valid && $_template->smarty->cache_locking) {
             $this->handler->acquireLock($_template->smarty, $this);
             return;
         } else {
             return;
         }
     }
 }
开发者ID:rezarahimi4861,项目名称:icmf,代码行数:75,代码来源:smarty_cacheresource.php

示例5: isCached

 /**
  * Check if cache is valid, lock cache if required
  *
  * @param \Smarty_Internal_Template $_template
  *
  * @return bool flag true if cache is valid
  */
 public function isCached(Smarty_Internal_Template $_template)
 {
     if ($this->valid !== null) {
         return $this->valid;
     }
     while (true) {
         while (true) {
             if ($this->exists === false || $_template->smarty->force_compile || $_template->smarty->force_cache) {
                 $this->valid = false;
             } else {
                 $this->valid = true;
             }
             if ($this->valid && $_template->caching == Smarty::CACHING_LIFETIME_CURRENT && $_template->cache_lifetime >= 0 && time() > $this->timestamp + $_template->cache_lifetime) {
                 // lifetime expired
                 $this->valid = false;
             }
             if ($this->valid && $_template->source->timestamp > $this->timestamp) {
                 $this->valid = false;
             }
             if ($this->valid || !$_template->smarty->cache_locking) {
                 break;
             }
             if (!$this->handler->locked($_template->smarty, $this)) {
                 $this->handler->acquireLock($_template->smarty, $this);
                 break 2;
             }
             $this->handler->populate($this, $_template);
         }
         if ($this->valid) {
             if (!$_template->smarty->cache_locking || $this->handler->locked($_template->smarty, $this) === null) {
                 // load cache file for the following checks
                 if ($_template->smarty->debugging) {
                     Smarty_Internal_Debug::start_cache($_template);
                 }
                 if ($this->handler->process($_template, $this) === false) {
                     $this->valid = false;
                 } else {
                     $this->processed = true;
                 }
                 if ($_template->smarty->debugging) {
                     Smarty_Internal_Debug::end_cache($_template);
                 }
             } else {
                 $this->is_locked = true;
                 continue;
             }
         } else {
             return $this->valid;
         }
         if ($this->valid && $_template->caching === Smarty::CACHING_LIFETIME_SAVED && $_template->properties['cache_lifetime'] >= 0 && time() > $_template->cached->timestamp + $_template->properties['cache_lifetime']) {
             $this->valid = false;
         }
         if ($_template->smarty->cache_locking) {
             if (!$this->valid) {
                 $this->handler->acquireLock($_template->smarty, $this);
             } elseif ($this->is_locked) {
                 $this->handler->releaseLock($_template->smarty, $this);
             }
         }
         return $this->valid;
     }
     return $this->valid;
 }
开发者ID:hejxing,项目名称:jt,代码行数:70,代码来源:smarty_template_cached.php

示例6: fetch


//.........这里部分代码省略.........
             $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'; ?>\n", $curr_split);
                 if (isset($cache_parts[0][$curr_idx])) {
                     $_template->properties['has_nocache_code'] = true;
                     // remove nocache tags from cache output
                     $output .= preg_replace("!/\\*/?%%SmartyNocache:{$_template->properties['nocache_hash']}%%\\*/!", '', $cache_parts[0][$curr_idx]);
                 }
             }
             if (!$no_output_filter && !$_template->has_nocache_code && (isset($this->smarty->autoload_filters['output']) || isset($this->smarty->registered_filters['output']))) {
                 $output = Smarty_Internal_Filter_Handler::runFilter('output', $output, $_template);
             }
             // rendering (must be done before writing cache file because of {function} nocache handling)
             /** @var Smarty_Internal_Template $_smarty_tpl
              * used in evaluated code
              */
             $_smarty_tpl = $_template;
             try {
                 ob_start();
                 /// dark edit
                 \Dark\SmartyView\SmartyEngine::integrateViewComposers($_template);
                 /// end edit
                 eval("?>" . $output);
                 $_output = ob_get_clean();
             } catch (Exception $e) {
                 ob_get_clean();
                 throw $e;
             }
             // write cache file content
             $_template->writeCachedContent($output);
             if ($this->smarty->debugging) {
                 Smarty_Internal_Debug::end_cache($_template);
             }
         } else {
             // var_dump('renderTemplate', $_template->has_nocache_code, $_template->template_resource, $_template->properties['nocache_hash'], $_template->parent->properties['nocache_hash'], $_output);
             if (!empty($_template->properties['nocache_hash']) && !empty($_template->parent->properties['nocache_hash'])) {
                 // replace nocache_hash
                 $_output = str_replace("{$_template->properties['nocache_hash']}", $_template->parent->properties['nocache_hash'], $_output);
                 $_template->parent->has_nocache_code = $_template->parent->has_nocache_code || $_template->has_nocache_code;
             }
         }
     } else {
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::start_cache($_template);
         }
         try {
             ob_start();
             /// dark edit
             \Dark\SmartyView\SmartyEngine::integrateViewComposers($_template);
             /// end edit
             array_unshift($_template->_capture_stack, array());
             //
             // render cached template
             //
             $_template->properties['unifunc']($_template);
             // any unclosed {capture} tags ?
             if (isset($_template->_capture_stack[0][0])) {
                 $_template->capture_error();
             }
             array_shift($_template->_capture_stack);
             $_output = ob_get_clean();
         } catch (Exception $e) {
             ob_get_clean();
             throw $e;
开发者ID:baiduXM,项目名称:gbpen,代码行数:67,代码来源:smarty_internal_templatebase.php

示例7: fetch


//.........这里部分代码省略.........
         }
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::end_render($_template);
         }
         if (!$_template->source->recompiled && ($_template->caching == Smarty::CACHING_LIFETIME_SAVED || $_template->caching == Smarty::CACHING_LIFETIME_CURRENT)) {
             if ($this->smarty->debugging) {
                 Smarty_Internal_Debug::start_cache($_template);
             }
             $_template->properties['has_nocache_code'] = false;
             $cache_split = preg_split("!/\\*%%SmartyNocache:{$_template->properties['nocache_hash']}%%\\*\\/(.+?)/\\*/%%SmartyNocache:{$_template->properties['nocache_hash']}%%\\*/!s", $_output);
             preg_match_all("!/\\*%%SmartyNocache:{$_template->properties['nocache_hash']}%%\\*\\/(.+?)/\\*/%%SmartyNocache:{$_template->properties['nocache_hash']}%%\\*/!s", $_output, $cache_parts);
             $output = '';
             foreach ($cache_split as $curr_idx => $curr_split) {
                 $output .= preg_replace('/(<%|%>|<\\?php|<\\?|\\?>)/', '<?php echo \'$1\'; ?>', $curr_split);
                 if (isset($cache_parts[0][$curr_idx])) {
                     $_template->properties['has_nocache_code'] = true;
                     $output .= preg_replace("!/\\*/?%%SmartyNocache:{$_template->properties['nocache_hash']}%%\\*/!", '', $cache_parts[0][$curr_idx]);
                 }
             }
             if (!$no_output_filter && !$_template->has_nocache_code && (isset($this->smarty->autoload_filters['output']) || isset($this->smarty->registered_filters['output']))) {
                 $output = Smarty_Internal_Filter_Handler::runFilter('output', $output, $_template);
             }
             $_smarty_tpl = $_template;
             try {
                 ob_start();
                 eval("?>" . $output);
                 $_output = ob_get_clean();
             } catch (Exception $e) {
                 ob_get_clean();
                 throw $e;
             }
             $_template->writeCachedContent($output);
             if ($this->smarty->debugging) {
                 Smarty_Internal_Debug::end_cache($_template);
             }
         } else {
             if (!empty($_template->properties['nocache_hash']) && !empty($_template->parent->properties['nocache_hash'])) {
                 $_output = str_replace("{$_template->properties['nocache_hash']}", $_template->parent->properties['nocache_hash'], $_output);
                 $_template->parent->has_nocache_code = $_template->parent->has_nocache_code || $_template->has_nocache_code;
             }
         }
     } else {
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::start_cache($_template);
         }
         try {
             ob_start();
             array_unshift($_template->_capture_stack, array());
             $_template->properties['unifunc']($_template);
             if (isset($_template->_capture_stack[0][0])) {
                 $_template->capture_error();
             }
             array_shift($_template->_capture_stack);
             $_output = ob_get_clean();
         } catch (Exception $e) {
             ob_get_clean();
             throw $e;
         }
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::end_cache($_template);
         }
     }
     if ((!$this->caching || $_template->has_nocache_code || $_template->source->recompiled) && !$no_output_filter && (isset($this->smarty->autoload_filters['output']) || isset($this->smarty->registered_filters['output']))) {
         $_output = Smarty_Internal_Filter_Handler::runFilter('output', $_output, $_template);
     }
     if (isset($this->error_reporting)) {
开发者ID:EfncoPlugins,项目名称:web-portal-lite-client-portal-secure-file-sharing-private-messaging,代码行数:67,代码来源:smarty_internal_templatebase.php

示例8: render


//.........这里部分代码省略.........
         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) {
                 if ($this->smarty->debugging) {
                     Smarty_Internal_Debug::start_cache($this);
                 }
                 // write cache file content
                 if ($runOutputFilter && !$this->context->hasNocacheCode && (isset($this->smarty->autoload_filters['output']) || isset($this->smarty->registered_filters['output']))) {
                     $this->cached->writeCachedContent($this, $this->context, Smarty_Internal_Filter_Handler::runFilter('output', $this->context->getContent(), $this));
                 } else {
                     $this->cached->writeCachedContent($this, $this->context);
                 }
                 $this->context = $_savedContext;
                 $compile_check = $this->smarty->compile_check;
                 $this->smarty->compile_check = false;
                 if (!$this->cached->processed) {
                     $this->cached->process($this);
                 }
                 $this->smarty->compile_check = $compile_check;
                 $this->cached->compiledTplObj->getRenderedTemplateCode($this);
                 if ($this->smarty->debugging) {
                     Smarty_Internal_Debug::end_cache($this);
                 }
             }
         } else {
             if ($this->smarty->debugging) {
                 Smarty_Internal_Debug::start_cache($this);
             }
             $this->cached->render($this);
             if ($this->smarty->debugging) {
                 Smarty_Internal_Debug::end_cache($this);
             }
         }
         if ($runOutputFilter && (!$this->caching || $this->context->hasNocacheCode || $this->source->recompiled) && (isset($this->smarty->autoload_filters['output']) || isset($this->smarty->registered_filters['output']))) {
             $this->context->flushBuffer();
             $this->context->content = Smarty_Internal_Filter_Handler::runFilter('output', $this->context->content, $this);
         }
         // display or fetch
         if ($display) {
             $this->context->endBuffer();
             if ($this->caching && $this->smarty->cache_modified_check) {
                 $this->cached->cacheModifiedCheck($this, $this->context->content);
             } else {
                 echo $this->context->content;
             }
             $this->context = null;
         }
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::end_template($this);
         }
         if ($display) {
             // debug output
             if ($this->smarty->debugging) {
                 Smarty_Internal_Debug::display_debug($this, true);
             }
         }
         if (!$isSubTemplate) {
             // restore local variables
             $this->tpl_vars = $savedTplVars;
             $this->config_vars = $savedConfigVars;
             if (isset($savedErrorLevel)) {
                 error_reporting($savedErrorLevel);
             }
         }
     } catch (Exception $e) {
         while (ob_get_level() > $level) {
             ob_end_clean();
         }
         throw $e;
     }
     if (!$display && $_contextObjIn === null) {
         // return fetched content
         $this->context->endBuffer();
         $output = $this->context->content;
         $this->context = null;
         return $output;
     }
     $this->context = null;
     return '';
 }
开发者ID:uwetews,项目名称:smarty-hhvm,代码行数:101,代码来源:smarty_internal_template.php

示例9: renderTemplate


//.........这里部分代码省略.........
         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;
                     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->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->resource_object->isEvaluated && empty($this->properties['file_dependency'][$this->templateUid])) {
         $this->properties['file_dependency'][$this->templateUid] = array($this->getTemplateFilepath(), $this->getTemplateTimestamp());
     }
     if ($this->parent instanceof Smarty_Template or $this->parent instanceof Smarty_Internal_Template) {
         $this->parent->properties['file_dependency'] = array_merge($this->parent->properties['file_dependency'], $this->properties['file_dependency']);
         $this->parent->required_plugins['compiled'] = array_merge($this->parent->required_plugins['compiled'], $this->required_plugins['compiled']);
         $this->parent->required_plugins['cache'] = array_merge($this->parent->required_plugins['cache'], $this->required_plugins['cache']);
     }
     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]);
             }
         }
         // rendering (must be done before writing cache file because of {function} nocache handling)
         $_smarty_tpl = $this;
         ob_start();
         eval("?>" . $output);
         $this->rendered_content = ob_get_clean();
         // write cache file content
         $this->writeCachedContent($output);
         if ($this->smarty->debugging) {
             Smarty_Internal_Debug::end_cache($this);
         }
     } else {
         // var_dump('renderTemplate', $this->has_nocache_code, $this->template_resource, $this->properties['nocache_hash'], $this->parent->properties['nocache_hash'], $this->rendered_content);
         if ($this->has_nocache_code && !empty($this->properties['nocache_hash']) && !empty($this->parent->properties['nocache_hash'])) {
             // replace nocache_hash
             $this->rendered_content = preg_replace("/{$this->properties['nocache_hash']}/", $this->parent->properties['nocache_hash'], $this->rendered_content);
             $this->parent->has_nocache_code = $this->has_nocache_code;
         }
     }
 }
开发者ID:purna89,项目名称:TrellisDesk,代码行数:101,代码来源:smarty_internal_template.php

示例10: load

 /**
  * @param Smarty_Internal_Template $_template
  *
  * @return Smarty_Template_Cached
  */
 static function load(Smarty_Internal_Template $_template)
 {
     $_template->cached = $cached = new Smarty_Template_Cached($_template);
     //
     //    check if cache is valid
     //
     if (!($_template->caching == Smarty::CACHING_LIFETIME_CURRENT || $_template->caching == Smarty::CACHING_LIFETIME_SAVED) || $_template->source->recompiled) {
         $cached->handler->populate($cached, $_template);
         return $cached;
     }
     while (true) {
         while (true) {
             $cached->handler->populate($cached, $_template);
             if ($cached->timestamp === false || $_template->smarty->force_compile || $_template->smarty->force_cache) {
                 $cached->valid = false;
             } else {
                 $cached->valid = true;
             }
             if ($cached->valid && $_template->caching == Smarty::CACHING_LIFETIME_CURRENT && $_template->cache_lifetime >= 0 && time() > $cached->timestamp + $_template->cache_lifetime) {
                 // lifetime expired
                 $cached->valid = false;
             }
             if ($cached->valid || !$_template->smarty->cache_locking) {
                 break;
             }
             if (!$cached->handler->locked($_template->smarty, $cached)) {
                 $cached->handler->acquireLock($_template->smarty, $cached);
                 break 2;
             }
         }
         if ($cached->valid) {
             if (!$_template->smarty->cache_locking || $cached->handler->locked($_template->smarty, $cached) === null) {
                 // load cache file for the following checks
                 if ($_template->smarty->debugging) {
                     Smarty_Internal_Debug::start_cache($_template);
                 }
                 $cached->process($_template);
                 if ($_template->smarty->debugging) {
                     Smarty_Internal_Debug::end_cache($_template);
                 }
             } else {
                 continue;
             }
         } else {
             return $cached;
         }
         if ($cached->valid && $_template->caching === Smarty::CACHING_LIFETIME_SAVED && $_template->properties['cache_lifetime'] >= 0 && time() > $_template->cached->timestamp + $_template->properties['cache_lifetime']) {
             $cached->valid = false;
         }
         if (!$cached->valid && $_template->smarty->cache_locking) {
             $cached->handler->acquireLock($_template->smarty, $cached);
             return $cached;
         } else {
             return $cached;
         }
     }
 }
开发者ID:Tramp1357,项目名称:wood,代码行数:62,代码来源:smarty_template_cached.php

示例11: 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


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