You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
112 lines
3.5 KiB
PHTML
112 lines
3.5 KiB
PHTML
14 years ago
|
<?php
|
||
|
|
||
|
/**
|
||
|
* Smarty Internal Plugin Resource PHP
|
||
|
* Implements the file system as resource for PHP templates
|
||
13 years ago
|
*
|
||
10 years ago
|
* @package Smarty
|
||
14 years ago
|
* @subpackage TemplateResources
|
||
10 years ago
|
* @author Uwe Tews
|
||
|
* @author Rodney Rehm
|
||
14 years ago
|
*/
|
||
9 years ago
|
class Smarty_Internal_Resource_Php extends Smarty_Internal_Resource_File
|
||
11 years ago
|
{
|
||
9 years ago
|
/**
|
||
|
* Flag that it's an uncompiled resource
|
||
|
*
|
||
|
* @var bool
|
||
|
*/
|
||
|
public $uncompiled = true;
|
||
7 years ago
|
|
||
14 years ago
|
/**
|
||
7 years ago
|
* Resource does implement populateCompiledFilepath() method
|
||
10 years ago
|
*
|
||
7 years ago
|
* @var bool
|
||
14 years ago
|
*/
|
||
7 years ago
|
public $hasCompiledHandler = true;
|
||
14 years ago
|
|
||
|
/**
|
||
7 years ago
|
* container for short_open_tag directive's value before executing PHP templates
|
||
13 years ago
|
*
|
||
7 years ago
|
* @var string
|
||
14 years ago
|
*/
|
||
7 years ago
|
protected $short_open_tag;
|
||
14 years ago
|
|
||
|
/**
|
||
9 years ago
|
* Create a new PHP Resource
|
||
14 years ago
|
*/
|
||
9 years ago
|
public function __construct()
|
||
14 years ago
|
{
|
||
7 years ago
|
$this->short_open_tag = function_exists('ini_get') ? ini_get('short_open_tag') : 1;
|
||
13 years ago
|
}
|
||
14 years ago
|
|
||
|
/**
|
||
13 years ago
|
* Load template's source from file into current template object
|
||
|
*
|
||
11 years ago
|
* @param Smarty_Template_Source $source source object
|
||
10 years ago
|
*
|
||
11 years ago
|
* @return string template source
|
||
|
* @throws SmartyException if source cannot be loaded
|
||
14 years ago
|
*/
|
||
13 years ago
|
public function getContent(Smarty_Template_Source $source)
|
||
|
{
|
||
9 years ago
|
if ($source->exists) {
|
||
13 years ago
|
return '';
|
||
|
}
|
||
|
throw new SmartyException("Unable to read template {$source->type} '{$source->name}'");
|
||
|
}
|
||
14 years ago
|
|
||
7 years ago
|
/**
|
||
|
* populate compiled object with compiled filepath
|
||
|
*
|
||
|
* @param Smarty_Template_Compiled $compiled compiled object
|
||
|
* @param Smarty_Internal_Template $_template template object (is ignored)
|
||
|
*/
|
||
|
public function populateCompiledFilepath(Smarty_Template_Compiled $compiled, Smarty_Internal_Template $_template)
|
||
|
{
|
||
|
$compiled->filepath = $_template->source->filepath;
|
||
|
$compiled->timestamp = $_template->source->timestamp;
|
||
|
$compiled->exists = $_template->source->exists;
|
||
|
$compiled->file_dependency[ $_template->source->uid ] =
|
||
|
array($compiled->filepath,
|
||
|
$compiled->timestamp,
|
||
|
$_template->source->type,);
|
||
|
}
|
||
|
|
||
14 years ago
|
/**
|
||
13 years ago
|
* Render and output the template (without using the compiler)
|
||
|
*
|
||
11 years ago
|
* @param Smarty_Template_Source $source source object
|
||
|
* @param Smarty_Internal_Template $_template template object
|
||
10 years ago
|
*
|
||
13 years ago
|
* @return void
|
||
11 years ago
|
* @throws SmartyException if template cannot be loaded or allow_php_templates is disabled
|
||
14 years ago
|
*/
|
||
13 years ago
|
public function renderUncompiled(Smarty_Template_Source $source, Smarty_Internal_Template $_template)
|
||
14 years ago
|
{
|
||
13 years ago
|
if (!$source->smarty->allow_php_templates) {
|
||
7 years ago
|
throw new SmartyException('PHP templates are disabled');
|
||
13 years ago
|
}
|
||
|
if (!$source->exists) {
|
||
7 years ago
|
throw new SmartyException("Unable to load template '{$source->type}:{$source->name}'" .
|
||
7 years ago
|
($_template->_isSubTpl() ? " in '{$_template->parent->template_resource}'" : ''));
|
||
13 years ago
|
}
|
||
|
|
||
14 years ago
|
// prepare variables
|
||
13 years ago
|
extract($_template->getTemplateVars());
|
||
|
|
||
|
// include PHP template with short open tags enabled
|
||
7 years ago
|
if (function_exists('ini_set')) {
|
||
|
ini_set('short_open_tag', '1');
|
||
|
}
|
||
10 years ago
|
/** @var Smarty_Internal_Template $_smarty_template
|
||
|
* used in included file
|
||
|
*/
|
||
|
$_smarty_template = $_template;
|
||
13 years ago
|
include($source->filepath);
|
||
7 years ago
|
if (function_exists('ini_set')) {
|
||
|
ini_set('short_open_tag', $this->short_open_tag);
|
||
|
}
|
||
9 years ago
|
}
|
||
13 years ago
|
}
|