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


PHP TemplateHandler::rootTpl方法代码示例

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


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

示例1: compile

 /**
  * compiles specified tpl file and execution result in Context into resultant content
  * @param string $tpl_path path of the directory containing target template file
  * @param string $tpl_filename target template file's name
  * @param string $tpl_file if specified use it as template file's full path
  * @return string Returns compiled result in case of success, NULL otherwise
  */
 public function compile($tpl_path, $tpl_filename, $tpl_file = '')
 {
     // store the starting time for debug information
     $start = microtime(true);
     // initiation
     $this->init($tpl_path, $tpl_filename, $tpl_file);
     // if target file does not exist exit
     if (!$this->file || !file_exists($this->file)) {
         $error_message = "Template not found: {$tpl_path}{$tpl_filename}" . ($tpl_file ? " ({$tpl_file})" : '');
         trigger_error($error_message, \E_USER_WARNING);
         return escape($error_message);
     }
     // for backward compatibility
     if (is_null(self::$rootTpl)) {
         self::$rootTpl = $this->file;
     }
     $latest_mtime = max(filemtime($this->file), $this->handler_mtime);
     // make compiled file
     if (!file_exists($this->compiled_file) || filemtime($this->compiled_file) < $latest_mtime) {
         $buff = $this->parse();
         if (Rhymix\Framework\Storage::write($this->compiled_file, $buff) === false) {
             $tmpfilename = tempnam(sys_get_temp_dir(), 'rx-compiled');
             if ($tmpfilename === false || Rhymix\Framework\Storage::write($tmpfilename, $buff) === false) {
                 return 'Fatal Error : Cannot create temporary file. Please check permissions.';
             }
             $this->compiled_file = $tmpfilename;
         }
     }
     Rhymix\Framework\Debug::addFilenameAlias($this->file, $this->compiled_file);
     $output = $this->_fetch($this->compiled_file);
     // delete tmpfile
     if (isset($tmpfilename)) {
         Rhymix\Framework\Storage::delete($tmpfilename);
     }
     if ($__templatehandler_root_tpl == $this->file) {
         $__templatehandler_root_tpl = null;
     }
     // store the ending time for debug information
     $GLOBALS['__template_elapsed__'] += microtime(true) - $start;
     return $output;
 }
开发者ID:rhymix,项目名称:rhymix,代码行数:48,代码来源:TemplateHandler.class.php

示例2: compile

 /**
  * compiles specified tpl file and execution result in Context into resultant content
  * @param string $tpl_path path of the directory containing target template file
  * @param string $tpl_filename target template file's name
  * @param string $tpl_file if specified use it as template file's full path
  * @return string Returns compiled result in case of success, NULL otherwise
  */
 public function compile($tpl_path, $tpl_filename, $tpl_file = '')
 {
     $buff = false;
     // store the starting time for debug information
     if (__DEBUG__ == 3) {
         $start = getMicroTime();
     }
     // initiation
     $this->init($tpl_path, $tpl_filename, $tpl_file);
     // if target file does not exist exit
     if (!$this->file || !file_exists($this->file)) {
         return "Err : '{$this->file}' template file does not exists.";
     }
     // for backward compatibility
     if (is_null(self::$rootTpl)) {
         self::$rootTpl = $this->file;
     }
     $source_template_mtime = filemtime($this->file);
     $latest_mtime = $source_template_mtime > $this->handler_mtime ? $source_template_mtime : $this->handler_mtime;
     // cache control
     $oCacheHandler = CacheHandler::getInstance('template');
     // get cached buff
     if ($oCacheHandler->isSupport()) {
         $cache_key = 'template:' . $this->file;
         $buff = $oCacheHandler->get($cache_key, $latest_mtime);
     } else {
         if (is_readable($this->compiled_file) && filemtime($this->compiled_file) > $latest_mtime && filesize($this->compiled_file)) {
             $buff = 'file://' . $this->compiled_file;
         }
     }
     if ($buff === FALSE) {
         $buff = $this->parse();
         if ($oCacheHandler->isSupport()) {
             $oCacheHandler->put($cache_key, $buff);
         } else {
             FileHandler::writeFile($this->compiled_file, $buff);
         }
     }
     $output = $this->_fetch($buff);
     if ($__templatehandler_root_tpl == $this->file) {
         $__templatehandler_root_tpl = null;
     }
     // store the ending time for debug information
     if (__DEBUG__ == 3) {
         $GLOBALS['__template_elapsed__'] += getMicroTime() - $start;
     }
     return $output;
 }
开发者ID:perzona420,项目名称:xe-core,代码行数:55,代码来源:TemplateHandler.class.php


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