本文整理汇总了PHP中Typeframe::FindTemplate方法的典型用法代码示例。如果您正苦于以下问题:PHP Typeframe::FindTemplate方法的具体用法?PHP Typeframe::FindTemplate怎么用?PHP Typeframe::FindTemplate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Typeframe
的用法示例。
在下文中一共展示了Typeframe::FindTemplate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute()
{
static $executed = false;
if (!$executed) {
$executed = true;
$this->_executeApplicationCode();
Typeframe::Timestamp('Controller and triggers executed');
$selectedTemplate = $this->_template;
if (!$selectedTemplate && $this->_application->name()) {
$pathinfo = pathinfo($this->_controller);
$selectedTemplate = substr($pathinfo['dirname'], strlen(TYPEF_SOURCE_DIR . '/controllers')) . '/' . $pathinfo['filename'] . '.html';
$finalTemplate = Typeframe::FindTemplate($selectedTemplate);
if (is_null($finalTemplate)) {
$selectedTemplate = null;
}
} else {
$finalTemplate = Typeframe::FindTemplate($selectedTemplate);
}
// $selectedTemplate tells us if a template was selected (either explicitly or automatically).
// $finalTemplate tells us if the template is valid.
if ($selectedTemplate) {
if ($finalTemplate) {
Typeframe::Timestamp('Starting page render');
if ($this->_redirectLocation) {
// If there were errors sent to the browser (i.e., output has already started), don't use meta redirect
//if ( (headers_sent()) || (ob_get_length()) ) {
// Typeframe::Pagemill()->setVariable("time", 0);
//}
if (Typeframe::Pagemill()->getVariable('time') == 0 && $_SERVER['REQUEST_METHOD'] == 'POST' && !headers_sent() && !requestIsAjax()) {
$_SESSION['typef_redirect_message'] = Typeframe::Pagemill()->getVariable('message');
}
}
$this->_executedTemplate = $finalTemplate;
if ($this->_redirectHeader) {
if (!headers_sent() && !requestIsAjax()) {
header('Location: ' . $this->_redirectLocation, true, $this->_redirectResponseCode);
}
}
Typeframe::Pagemill()->writeFile($finalTemplate);
// TODO: Another quick and dirty hack to make JavaScript templates work.
/*$pathinfo = pathinfo($selectedTemplate);
switch ($pathinfo['extension']) {
case 'js':
$output = str_replace('<', '<', $output);
$output = str_replace('>', '>', $output);
$output = str_replace('&', '&', $output);
}
echo $output;*/
} else {
trigger_error("Template {$selectedTemplate} not found");
}
}
} else {
trigger_error("Page controller was already executed");
}
if (!$this->_redirectLocation && !requestIsAjax()) {
unset($_SESSION['typef_redirect_message']);
}
session_write_close();
}