本文整理汇总了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;
}
示例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;
}