本文整理汇总了PHP中ViewFactory::get_template_type方法的典型用法代码示例。如果您正苦于以下问题:PHP ViewFactory::get_template_type方法的具体用法?PHP ViewFactory::get_template_type怎么用?PHP ViewFactory::get_template_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ViewFactory
的用法示例。
在下文中一共展示了ViewFactory::get_template_type方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: make_view
static function make_view($template, $layout = false)
{
# get the template type
$template = PROJECT_VIEWS . '/' . $template;
$type = ViewFactory::get_template_type($template);
if ($type === false) {
throw new MissingTemplate("No recognizable template was found at {$template}.");
}
# return the right view depending on the extension of the template
switch ($type) {
case 'phtml':
$the_view = new PHTMLView("{$template}.{$type}");
break;
case 'pxml':
$the_view = new PXMLView("{$template}.{$type}");
break;
case 'pjs':
$the_view = new PJSView("{$template}.{$type}");
break;
case 'xsl':
$the_view = new XSLTView("{$template}.{$type}");
break;
default:
throw new UnknownViewType("ViewFactory doesn't know how to use a {$type} file.");
}
return $the_view;
}
示例2: parse
function parse($layout_template = false)
{
parent::parse($layout_template);
# unpack the props
#extract($this->props);
# trap the buffer
ob_start();
# include the template
include $this->template;
# get the buffer contents
$parsed = ob_get_contents();
# clean the buffer
ob_clean();
# if there is a layout
if ($this->layout) {
# find the type
$type = ViewFactory::get_template_type($layout_template);
if ($type) {
# push the content into the layout
$content_for_layout = $parsed;
# include the template
include $this->layout . ".{$type}";
# get the buffer contents
$parsed = ob_get_contents();
}
}
# close the output buffer
ob_end_clean();
# save the result
$this->parsed = $parsed;
return $parsed;
}