mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
- new extension handler to load functions when called
This commit is contained in:
@@ -903,19 +903,19 @@ variable(res) ::= object(o). {
|
||||
|
||||
// config variable
|
||||
variable(res) ::= HATCH ID(i) HATCH. {
|
||||
res = '$_smarty_tpl->_getConfigVariable( \''. i .'\')';
|
||||
res = '$_smarty_tpl->smarty->ext->_config->_getConfigVariable($_smarty_tpl, \''. i .'\')';
|
||||
}
|
||||
|
||||
variable(res) ::= HATCH ID(i) HATCH arrayindex(a). {
|
||||
res = '(is_array($tmp = $_smarty_tpl->_getConfigVariable( \''. i .'\')) ? $tmp'.a.' :null)';
|
||||
res = '(is_array($tmp = $_smarty_tpl->smarty->ext->_config->_getConfigVariable($_smarty_tpl, \''. i .'\')) ? $tmp'.a.' :null)';
|
||||
}
|
||||
|
||||
variable(res) ::= HATCH variable(v) HATCH. {
|
||||
res = '$_smarty_tpl->_getConfigVariable( '. v .')';
|
||||
res = '$_smarty_tpl->smarty->ext->_config->_getConfigVariable($_smarty_tpl, '. v .')';
|
||||
}
|
||||
|
||||
variable(res) ::= HATCH variable(v) HATCH arrayindex(a). {
|
||||
res = '(is_array($tmp = $_smarty_tpl->_getConfigVariable( '. v .')) ? $tmp'.a.' : null)';
|
||||
res = '(is_array($tmp = $_smarty_tpl->smarty->ext->_config->_getConfigVariable($_smarty_tpl, '. v .')) ? $tmp'.a.' : null)';
|
||||
}
|
||||
|
||||
varindexed(res) ::= DOLLARID(i) arrayindex(a). {
|
||||
@@ -1106,7 +1106,7 @@ function(res) ::= ns1(f) OPENP params(p) CLOSEP. {
|
||||
$this->compiler->trigger_template_error ('Illegal number of paramer in "isset()"');
|
||||
}
|
||||
$par = implode(',',p);
|
||||
if (strncasecmp($par,'$_smarty_tpl->_getConfigVariable',strlen('$_smarty_tpl->_getConfigVariable')) === 0) {
|
||||
if (strncasecmp($par,'$_smarty_tpl->smarty->ext->_config->_getConfigVariable',strlen('$_smarty_tpl->smarty->ext->_config->_getConfigVariable')) === 0) {
|
||||
self::$prefix_number++;
|
||||
$this->compiler->prefix_code[] = '<?php $_tmp'.self::$prefix_number.'='.str_replace(')',', false)',$par).';?>';
|
||||
$isset_par = '$_tmp'.self::$prefix_number;
|
||||
|
@@ -91,6 +91,7 @@ if (!class_exists('Smarty_Autoloader', false)) {
|
||||
if (!class_exists('Smarty_Internal_Data', false)) {
|
||||
require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_data.php';
|
||||
}
|
||||
require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_extension_handler.php';
|
||||
require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_templatebase.php';
|
||||
require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_template.php';
|
||||
require_once SMARTY_SYSPLUGINS_DIR . 'smarty_resource.php';
|
||||
@@ -119,7 +120,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
/**
|
||||
* smarty version
|
||||
*/
|
||||
const SMARTY_VERSION = '3.1.28-dev/68';
|
||||
const SMARTY_VERSION = '3.1.28-dev/70';
|
||||
|
||||
/**
|
||||
* define variable scopes
|
||||
@@ -689,6 +690,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
if (is_callable('mb_internal_encoding')) {
|
||||
mb_internal_encoding(Smarty::$_CHARSET);
|
||||
}
|
||||
@@ -1105,7 +1107,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
*/
|
||||
public function loadPlugin($plugin_name, $check = true)
|
||||
{
|
||||
return Smarty_Internal_Extension_LoadPlugin::loadPlugin($this, $plugin_name, $check);
|
||||
return $this->ext->loadPlugin->loadPlugin($this, $plugin_name, $check);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -56,6 +56,7 @@ class Smarty_Data extends Smarty_Internal_Data
|
||||
*/
|
||||
public function __construct($_parent = null, $smarty = null, $name = null)
|
||||
{
|
||||
parent::__construct();
|
||||
self::$count ++;
|
||||
$this->dataObjectName = 'Data_object ' . (isset($name) ? "'{$name}'" : self::$count);
|
||||
$this->smarty = $smarty;
|
||||
|
@@ -96,8 +96,9 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
|
||||
* used in included file
|
||||
*/
|
||||
$_smarty_tpl = $_template;
|
||||
$_template->cached->valid = false;
|
||||
if ($update && strpos(phpversion(), 'hhvm') !== false) {
|
||||
return Smarty_Internal_Extension_Hhvm::includeHhvm($_template, $_template->cached->filepath);
|
||||
return $_template->smarty->ext->_hhvm->includeHhvm($_template, $_template->cached->filepath);
|
||||
} else {
|
||||
return @include $_template->cached->filepath;
|
||||
}
|
||||
@@ -113,8 +114,7 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
|
||||
*/
|
||||
public function writeCachedContent(Smarty_Internal_Template $_template, $content)
|
||||
{
|
||||
$obj = new Smarty_Internal_Write_File();
|
||||
if ($obj->writeFile($_template->cached->filepath, $content, $_template->smarty) === true) {
|
||||
if ($_template->smarty->ext->_writeFile->writeFile($_template->cached->filepath, $content, $_template->smarty) === true) {
|
||||
if (function_exists('opcache_invalidate')) {
|
||||
opcache_invalidate($_template->cached->filepath);
|
||||
}
|
||||
|
@@ -61,7 +61,7 @@ class Smarty_Internal_Compile_Assign extends Smarty_Internal_CompileBase
|
||||
}
|
||||
// compiled output
|
||||
if (isset($parameter['smarty_internal_index'])) {
|
||||
$output = "<?php \$_smarty_tpl->_var->createLocalArrayVariable(\$_smarty_tpl, $_attr[var], $_nocache, $_scope);\n\$_smarty_tpl->tpl_vars[$_attr[var]]->value$parameter[smarty_internal_index] = $_attr[value];";
|
||||
$output = "<?php \$_smarty_tpl->smarty->ext->_var->createLocalArrayVariable(\$_smarty_tpl, $_attr[var], $_nocache, $_scope);\n\$_smarty_tpl->tpl_vars[$_attr[var]]->value$parameter[smarty_internal_index] = $_attr[value];";
|
||||
} else {
|
||||
// implement Smarty2's behaviour of variables assigned by reference
|
||||
if ($compiler->template->smarty instanceof SmartyBC) {
|
||||
|
@@ -122,7 +122,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_Compile_Shared_Inher
|
||||
$compiler->has_code = true;
|
||||
$compiler->suppressNocacheProcessing = true;
|
||||
$compiler->_cache['blockParams'][$compiler->_cache['blockNesting']][1] = true;
|
||||
$output = "<?php \n\$_smarty_tpl->_inheritance->processBlock(\$_smarty_tpl, 2, {$compiler->_cache['blockName'][$compiler->_cache['blockNesting']]}, null, \$_blockParentStack);\n?>\n";
|
||||
$output = "<?php \n\$_smarty_tpl->ext->_inheritance->processBlock(\$_smarty_tpl, 2, {$compiler->_cache['blockName'][$compiler->_cache['blockNesting']]}, null, \$_blockParentStack);\n?>\n";
|
||||
return $output;
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_Compile_Shared_Inher
|
||||
}
|
||||
$compiler->suppressNocacheProcessing = true;
|
||||
$compiler->has_code = true;
|
||||
$output = "<?php \n\$_smarty_tpl->_inheritance->processBlock(\$_smarty_tpl, 3, {$compiler->_cache['blockName'][$compiler->_cache['blockNesting']]}, null, \$_blockParentStack);\n?>\n";
|
||||
$output = "<?php \n\$_smarty_tpl->ext->_inheritance->processBlock(\$_smarty_tpl, 3, {$compiler->_cache['blockName'][$compiler->_cache['blockNesting']]}, null, \$_blockParentStack);\n?>\n";
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
@@ -259,10 +259,10 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_
|
||||
$compiler->parser->current_buffer = $_buffer;
|
||||
$output = "<?php \n";
|
||||
if ($compiler->_cache['blockNesting'] == 1) {
|
||||
$output .= "\$_smarty_tpl->_inheritance->processBlock(\$_smarty_tpl, 0, {$compiler->_cache['blockName'][$compiler->_cache['blockNesting']]}, " .
|
||||
$output .= "\$_smarty_tpl->ext->_inheritance->processBlock(\$_smarty_tpl, 0, {$compiler->_cache['blockName'][$compiler->_cache['blockNesting']]}, " .
|
||||
var_export($_block, true) . ");\n";
|
||||
} else {
|
||||
$output .= "\$_smarty_tpl->_inheritance->processBlock(\$_smarty_tpl, 0, {$compiler->_cache['blockName'][$compiler->_cache['blockNesting']]}, " .
|
||||
$output .= "\$_smarty_tpl->ext->_inheritance->processBlock(\$_smarty_tpl, 0, {$compiler->_cache['blockName'][$compiler->_cache['blockNesting']]}, " .
|
||||
var_export($_block, true) . ", \$_blockParentStack);\n";
|
||||
|
||||
}
|
||||
|
@@ -79,10 +79,10 @@ class Smarty_Internal_Compile_Call extends Smarty_Internal_CompileBase
|
||||
// was there an assign attribute
|
||||
if (isset($_assign)) {
|
||||
$_output =
|
||||
"<?php ob_start();\n\$_smarty_tpl->_tplfunc->callTemplateFunction(\$_smarty_tpl, {$_name}, {$_params}, {$_nocache});\n\$_smarty_tpl->assign({$_assign}, ob_get_clean());?>\n";
|
||||
"<?php ob_start();\n\$_smarty_tpl->smarty->ext->_tplFunction->callTemplateFunction(\$_smarty_tpl, {$_name}, {$_params}, {$_nocache});\n\$_smarty_tpl->assign({$_assign}, ob_get_clean());?>\n";
|
||||
} else {
|
||||
$_output =
|
||||
"<?php \$_smarty_tpl->_tplfunc->callTemplateFunction(\$_smarty_tpl, {$_name}, {$_params}, {$_nocache});?>\n";
|
||||
"<?php \$_smarty_tpl->smarty->ext->_tplFunction->callTemplateFunction(\$_smarty_tpl, {$_name}, {$_params}, {$_nocache});?>\n";
|
||||
}
|
||||
return $_output;
|
||||
}
|
||||
|
@@ -99,7 +99,7 @@ class Smarty_Internal_Compile_Extends extends Smarty_Internal_Compile_Shared_Inh
|
||||
private function compileEndChild(Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
{
|
||||
$compiler->parser->template_postfix[] = new Smarty_Internal_ParseTree_Tag($compiler->parser,
|
||||
"<?php \$_smarty_tpl->_inheritance->endChild(\$_smarty_tpl);\n?>\n");
|
||||
"<?php \$_smarty_tpl->ext->_inheritance->endChild(\$_smarty_tpl);\n?>\n");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -184,7 +184,7 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo
|
||||
$output .= "{$local}{$k} = {$code}\n";
|
||||
}
|
||||
$output .= "{$itemVar} = new Smarty_Variable();\n";
|
||||
$output .= "{$local}total = \$_smarty_tpl->_foreach->count(\$_from);\n";
|
||||
$output .= "{$local}total = \$_smarty_tpl->smarty->ext->_foreach->count(\$_from);\n";
|
||||
if (isset($itemAttr['show'])) {
|
||||
$output .= "{$itemVar}->show = ({$local}total > 0);\n";
|
||||
}
|
||||
|
@@ -58,7 +58,7 @@ class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase
|
||||
if (is_array($parameter['if condition']['var'])) {
|
||||
$_output = "<?php if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] .
|
||||
"]) || !is_array(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] .
|
||||
"]->value)) \$_smarty_tpl->_var->createLocalArrayVariable(\$_smarty_tpl, " . $parameter['if condition']['var']['var'] .
|
||||
"]->value)) \$_smarty_tpl->smarty->ext->_var->createLocalArrayVariable(\$_smarty_tpl, " . $parameter['if condition']['var']['var'] .
|
||||
"$_nocache);\n";
|
||||
$_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value" .
|
||||
$parameter['if condition']['var']['smarty_internal_index'] . " = " .
|
||||
@@ -162,7 +162,7 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase
|
||||
$_output = "<?php } else { if (!isset(\$_smarty_tpl->tpl_vars[" .
|
||||
$parameter['if condition']['var']['var'] . "]) || !is_array(\$_smarty_tpl->tpl_vars[" .
|
||||
$parameter['if condition']['var']['var'] .
|
||||
"]->value)) \$_smarty_tpl->_var->createLocalArrayVariable(\$_smarty_tpl, " .
|
||||
"]->value)) \$_smarty_tpl->smarty->ext->_var->createLocalArrayVariable(\$_smarty_tpl, " .
|
||||
$parameter['if condition']['var']['var'] . "$_nocache);\n";
|
||||
$_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value" .
|
||||
$parameter['if condition']['var']['smarty_internal_index'] . " = " .
|
||||
@@ -195,7 +195,7 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase
|
||||
$parameter['if condition']['var']['var'] .
|
||||
"]) || !is_array(\$_smarty_tpl->tpl_vars[" .
|
||||
$parameter['if condition']['var']['var'] .
|
||||
"]->value)) \$_smarty_tpl->_var->createLocalArrayVariable(\$_smarty_tpl, " .
|
||||
"]->value)) \$_smarty_tpl->smarty->ext->_var->createLocalArrayVariable(\$_smarty_tpl, " .
|
||||
$parameter['if condition']['var']['var'] . "$_nocache);\n");
|
||||
$_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value" .
|
||||
$parameter['if condition']['var']['smarty_internal_index'] . " = " .
|
||||
|
@@ -176,7 +176,7 @@ class Smarty_Internal_Compile_Private_ForeachSection extends Smarty_Internal_Com
|
||||
// run pre filter if required
|
||||
if ((isset($nextCompiler->smarty->autoload_filters['pre']) ||
|
||||
isset($nextCompiler->smarty->registered_filters['pre']))) {
|
||||
$_content = Smarty_Internal_Filter_Handler::runFilter('pre', $_content, $nextCompiler->template);
|
||||
$_content = $nextCompiler->smarty->ext->_filter_Handler->runFilter('pre', $_content, $nextCompiler->template);
|
||||
}
|
||||
$this->matchProperty($_content);
|
||||
}
|
||||
|
@@ -99,9 +99,9 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
|
||||
|
||||
case 'config':
|
||||
if (isset($_index[2])) {
|
||||
return "(is_array(\$tmp = \$_smarty_tpl->_getConfigVariable($_index[1])) ? \$tmp[$_index[2]] : null)";
|
||||
return "(is_array(\$tmp = \$_smarty_tpl->smarty->ext->_config->_getConfigVariable(\$_smarty_tpl, $_index[1])) ? \$tmp[$_index[2]] : null)";
|
||||
} else {
|
||||
return "\$_smarty_tpl->_getConfigVariable($_index[1])";
|
||||
return "\$_smarty_tpl->smarty->ext->_config->_getConfigVariable(\$_smarty_tpl, $_index[1])";
|
||||
}
|
||||
case 'ldelim':
|
||||
$_ldelim = $compiler->smarty->left_delimiter;
|
||||
|
@@ -40,7 +40,7 @@ class Smarty_Internal_Compile_Shared_Inheritance extends Smarty_Internal_Compile
|
||||
*/
|
||||
static function postCompile(Smarty_Internal_TemplateCompilerBase $compiler, $initChildSequence = false)
|
||||
{
|
||||
$compiler->prefixCompiledCode .= "<?php \$_smarty_tpl->_inheritance->init(\$_smarty_tpl, " .
|
||||
$compiler->prefixCompiledCode .= "<?php \$_smarty_tpl->ext->_inheritance->init(\$_smarty_tpl, " .
|
||||
var_export($initChildSequence, true) . ");\n?>\n";
|
||||
}
|
||||
}
|
@@ -60,7 +60,7 @@ class Smarty_Internal_Compile_While extends Smarty_Internal_CompileBase
|
||||
if (is_array($parameter['if condition']['var'])) {
|
||||
$_output .= "if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] .
|
||||
"]) || !is_array(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] .
|
||||
"]->value)) \$_smarty_tpl->_var->createLocalArrayVariable(\$_smarty_tpl, " . $parameter['if condition']['var']['var'] .
|
||||
"]->value)) \$_smarty_tpl->smarty->ext->_var->createLocalArrayVariable(\$_smarty_tpl, " . $parameter['if condition']['var']['var'] .
|
||||
"$_nocache);\n";
|
||||
$_output .= "while (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value" .
|
||||
$parameter['if condition']['var']['smarty_internal_index'] . " = " .
|
||||
|
@@ -145,7 +145,7 @@ class Smarty_Internal_Config_File_Compiler
|
||||
|
||||
$code = '<?php Smarty_Internal_Method_ConfigLoad::_loadConfigVars($_smarty_tpl, ' .
|
||||
var_export($this->config_data, true) . '); ?>';
|
||||
return $template_header . Smarty_Internal_Extension_CodeFrame::create($this->template, $code);
|
||||
return $template_header . $this->template->smarty->ext->_codeFrame->create($this->template, $code);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -14,12 +14,11 @@
|
||||
* @package Smarty
|
||||
* @subpackage Template
|
||||
*
|
||||
* @method mixed getConfigVars(string $varname = null, bool $search_parents = true)
|
||||
* @method mixed getConfigVars(string $varName = null, bool $searchParents = true)
|
||||
* @method mixed getStreamVariable(string $variable)
|
||||
* @local_method mixed getTemplateVars(string $varname = null, Smarty_Internal_Data $_ptr = null, bool $search_parents = true)
|
||||
* @method Smarty_Internal_Data clearAssign(mixed $tpl_var)
|
||||
* @method Smarty_Internal_Data clearAllAssign()
|
||||
* @method Smarty_Internal_Data clearConfig(string $varname = null)
|
||||
* @method Smarty_Internal_Data clearConfig(string $varName = null)
|
||||
* @method Smarty_Internal_Data configLoad(string $config_file, mixed $sections = null, string $scope = 'local')
|
||||
* @property int $_objType
|
||||
*/
|
||||
@@ -54,14 +53,21 @@ class Smarty_Internal_Data
|
||||
public $config_vars = array();
|
||||
|
||||
/**
|
||||
* Cache for property information from generic getter/setter
|
||||
* Preloaded with names which should not use with generic getter/setter
|
||||
* extension handler
|
||||
*
|
||||
* @var array
|
||||
* @var Smarty_Internal_Extension_Handler
|
||||
*/
|
||||
private $_property_info = array('AutoloadFilters' => 0, 'DefaultModifiers' => 0, 'ConfigVars' => 0,
|
||||
'DebugTemplate' => 0, 'RegisteredObject' => 0, 'StreamVariable' => 0,
|
||||
'TemplateVars' => 0,);
|
||||
public $ext = null;
|
||||
|
||||
/**
|
||||
* Smarty_Internal_Data constructor.
|
||||
*
|
||||
* Install extension handler
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->ext = new Smarty_Internal_Extension_Handler();
|
||||
}
|
||||
|
||||
/**
|
||||
* assigns a Smarty variable
|
||||
@@ -106,63 +112,22 @@ class Smarty_Internal_Data
|
||||
*/
|
||||
public function append($tpl_var, $value = null, $merge = false, $nocache = false)
|
||||
{
|
||||
if (is_array($tpl_var)) {
|
||||
// $tpl_var is an array, ignore $value
|
||||
foreach ($tpl_var as $_key => $_val) {
|
||||
if ($_key != '') {
|
||||
$this->append($_key, $_val, $merge, $nocache);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($tpl_var != '' && isset($value)) {
|
||||
if (!isset($this->tpl_vars[$tpl_var])) {
|
||||
$tpl_var_inst = $this->_getVariable($tpl_var, null, true, false);
|
||||
if ($tpl_var_inst instanceof Smarty_Undefined_Variable) {
|
||||
$this->tpl_vars[$tpl_var] = new Smarty_Variable(null, $nocache);
|
||||
} else {
|
||||
$this->tpl_vars[$tpl_var] = clone $tpl_var_inst;
|
||||
}
|
||||
}
|
||||
if (!(is_array($this->tpl_vars[$tpl_var]->value) ||
|
||||
$this->tpl_vars[$tpl_var]->value instanceof ArrayAccess)
|
||||
) {
|
||||
settype($this->tpl_vars[$tpl_var]->value, 'array');
|
||||
}
|
||||
if ($merge && is_array($value)) {
|
||||
foreach ($value as $_mkey => $_mval) {
|
||||
$this->tpl_vars[$tpl_var]->value[$_mkey] = $_mval;
|
||||
}
|
||||
} else {
|
||||
$this->tpl_vars[$tpl_var]->value[] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
return $this->ext->append->append($this, $tpl_var, $value, $merge, $nocache);
|
||||
}
|
||||
|
||||
/**
|
||||
* assigns a global Smarty variable
|
||||
*
|
||||
* @param string $varname the global variable name
|
||||
* @param string $varName the global variable name
|
||||
* @param mixed $value the value to assign
|
||||
* @param boolean $nocache if true any output of this variable will be not cached
|
||||
*
|
||||
* @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for
|
||||
* chaining
|
||||
* @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty
|
||||
*/
|
||||
public function assignGlobal($varname, $value = null, $nocache = false)
|
||||
public function assignGlobal($varName, $value = null, $nocache = false)
|
||||
{
|
||||
if ($varname != '') {
|
||||
Smarty::$global_tpl_vars[$varname] = new Smarty_Variable($value, $nocache);
|
||||
$ptr = $this;
|
||||
while ($ptr->_objType == 2) {
|
||||
$ptr->tpl_vars[$varname] = clone Smarty::$global_tpl_vars[$varname];
|
||||
$ptr = $ptr->parent;
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
return $this->ext->assignGlobal->assignGlobal($this, $varName, $value, $nocache);
|
||||
}
|
||||
|
||||
/**
|
||||
* appends values to template variables by reference
|
||||
@@ -171,13 +136,11 @@ class Smarty_Internal_Data
|
||||
* @param mixed &$value the referenced value to append
|
||||
* @param boolean $merge flag if array elements shall be merged
|
||||
*
|
||||
* @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for
|
||||
* chaining
|
||||
* @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty
|
||||
*/
|
||||
public function appendByRef($tpl_var, &$value, $merge = false)
|
||||
{
|
||||
Smarty_Internal_Method_AppendByRef::appendByRef($this, $tpl_var, $value, $merge);
|
||||
return $this;
|
||||
return $this->ext->appendByRef->appendByRef($this, $tpl_var, $value, $merge);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -187,17 +150,11 @@ class Smarty_Internal_Data
|
||||
* @param $value
|
||||
* @param boolean $nocache if true any output of this variable will be not cached
|
||||
*
|
||||
* @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for
|
||||
* chaining
|
||||
* @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty
|
||||
*/
|
||||
public function assignByRef($tpl_var, &$value, $nocache = false)
|
||||
{
|
||||
if ($tpl_var != '') {
|
||||
$this->tpl_vars[$tpl_var] = new Smarty_Variable(null, $nocache);
|
||||
$this->tpl_vars[$tpl_var]->value = &$value;
|
||||
}
|
||||
|
||||
return $this;
|
||||
return $this->ext->assignByRef->assignByRef($this, $tpl_var, $value, $nocache);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -206,116 +163,15 @@ class Smarty_Internal_Data
|
||||
* @api Smarty::getTemplateVars()
|
||||
* @link http://www.smarty.net/docs/en/api.get.template.vars.tpl
|
||||
*
|
||||
* @param string $varname variable name or null
|
||||
* @param string $varName variable name or null
|
||||
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $_ptr optional pointer to data object
|
||||
* @param bool $search_parents include parent templates?
|
||||
* @param bool $searchParents include parent templates?
|
||||
*
|
||||
* @return mixed variable value or or array of variables
|
||||
*/
|
||||
public function getTemplateVars($varname = null, Smarty_Internal_Data $_ptr = null, $search_parents = true)
|
||||
public function getTemplateVars($varName = null, Smarty_Internal_Data $_ptr = null, $searchParents = true)
|
||||
{
|
||||
if (isset($varname)) {
|
||||
$_var = $this->_getVariable($varname, $_ptr, $search_parents, false);
|
||||
if (is_object($_var)) {
|
||||
return $_var->value;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
$_result = array();
|
||||
if ($_ptr === null) {
|
||||
$_ptr = $this;
|
||||
}
|
||||
while ($_ptr !== null) {
|
||||
foreach ($_ptr->tpl_vars AS $key => $var) {
|
||||
if (!array_key_exists($key, $_result)) {
|
||||
$_result[$key] = $var->value;
|
||||
}
|
||||
}
|
||||
// not found, try at parent
|
||||
if ($search_parents) {
|
||||
$_ptr = $_ptr->parent;
|
||||
} else {
|
||||
$_ptr = null;
|
||||
}
|
||||
}
|
||||
if ($search_parents && isset(Smarty::$global_tpl_vars)) {
|
||||
foreach (Smarty::$global_tpl_vars AS $key => $var) {
|
||||
if (!array_key_exists($key, $_result)) {
|
||||
$_result[$key] = $var->value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $_result;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* gets the object of a Smarty variable
|
||||
*
|
||||
* @param string $variable the name of the Smarty variable
|
||||
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $_ptr optional pointer to data object
|
||||
* @param bool $search_parents search also in parent data
|
||||
* @param bool $error_enable
|
||||
*
|
||||
* @return \Smarty_Variable
|
||||
*/
|
||||
public function _getVariable($variable, Smarty_Internal_Data $_ptr = null, $search_parents = true, $error_enable = true)
|
||||
{
|
||||
if ($_ptr === null) {
|
||||
$_ptr = $this;
|
||||
}
|
||||
while ($_ptr !== null) {
|
||||
if (isset($_ptr->tpl_vars[$variable])) {
|
||||
// found it, return it
|
||||
return $_ptr->tpl_vars[$variable];
|
||||
}
|
||||
// not found, try at parent
|
||||
if ($search_parents) {
|
||||
$_ptr = $_ptr->parent;
|
||||
} else {
|
||||
$_ptr = null;
|
||||
}
|
||||
}
|
||||
if (isset(Smarty::$global_tpl_vars[$variable])) {
|
||||
// found it, return it
|
||||
return Smarty::$global_tpl_vars[$variable];
|
||||
}
|
||||
/* @var \Smarty $smarty */
|
||||
$smarty = isset($this->smarty) ? $this->smarty : $this;
|
||||
if ($smarty->error_unassigned && $error_enable) {
|
||||
// force a notice
|
||||
$x = $$variable;
|
||||
}
|
||||
|
||||
return new Smarty_Undefined_Variable;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets a config variable value
|
||||
*
|
||||
* @param string $variable the name of the config variable
|
||||
* @param bool $error_enable
|
||||
*
|
||||
* @return mixed the value of the config variable
|
||||
*/
|
||||
public function _getConfigVariable($variable, $error_enable = true)
|
||||
{
|
||||
$_ptr = $this;
|
||||
while ($_ptr !== null) {
|
||||
if (isset($_ptr->config_vars[$variable])) {
|
||||
// found it, return it
|
||||
return $_ptr->config_vars[$variable];
|
||||
}
|
||||
// not found, try at parent
|
||||
$_ptr = $_ptr->parent;
|
||||
}
|
||||
/* @var \Smarty $smarty */
|
||||
$smarty = isset($this->smarty) ? $this->smarty : $this;
|
||||
if ($smarty->error_unassigned && $error_enable) {
|
||||
// force a notice
|
||||
$x = $$variable;
|
||||
}
|
||||
return null;
|
||||
return $this->ext->getTemplateVars->getTemplateVars($this, $varName, $_ptr, $searchParents);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -329,42 +185,6 @@ class Smarty_Internal_Data
|
||||
*/
|
||||
public function __call($name, $args)
|
||||
{
|
||||
$smarty = $this->_objType == 1 ? $this : $this->smarty;
|
||||
if (!isset($smarty->_cache['extObjCache'][$name])) {
|
||||
|
||||
$class = 'Smarty_Internal_Method_' . ucfirst($name);
|
||||
if (preg_match('/^(set|get)([A-Z].*)$/', $name, $match)) {
|
||||
if (!isset($this->_property_info[$prop = $match[2]])) {
|
||||
if (!isset($this->_property_info[$prop])) {
|
||||
// convert camel case to underscored name
|
||||
$smarty->_cache['resolvedProp'][$prop] = $pn = strtolower(join('_', preg_split('/([A-Z][^A-Z]*)/', $prop, - 1, PREG_SPLIT_NO_EMPTY |
|
||||
PREG_SPLIT_DELIM_CAPTURE)));
|
||||
$this->_property_info[$prop] = property_exists($this, $pn) ? 1 : ($this->_objType == 2 &&
|
||||
property_exists($smarty, $pn) ? 2 : 0);
|
||||
}
|
||||
}
|
||||
if ($this->_property_info[$prop]) {
|
||||
$pn = $smarty->_cache['resolvedProp'][$prop];
|
||||
if ($match[1] == 'get') {
|
||||
return $this->_property_info[$prop] == 1 ? $this->$pn : $this->smarty->$pn;
|
||||
} else {
|
||||
return $this->_property_info[$prop] ==
|
||||
1 ? $this->$pn = $args[0] : $this->smarty->$pn = $args[0];
|
||||
}
|
||||
} elseif (!class_exists($class)) {
|
||||
throw new SmartyException("property '$pn' does not exist.");
|
||||
}
|
||||
}
|
||||
if (class_exists($class)) {
|
||||
$callback = array($smarty->_cache['extObjCache'][$name] = new $class(), $name);
|
||||
}
|
||||
} else {
|
||||
$callback = array($smarty->_cache['extObjCache'][$name], $name);
|
||||
}
|
||||
if (isset($callback) && $callback[0]->objMap | $this->_objType) {
|
||||
array_unshift($args, $this);
|
||||
return call_user_func_array($callback, $args);
|
||||
}
|
||||
throw new SmartyException("method '$name' does not exist.");
|
||||
return $this->ext->_callExternalMethod($this, $name, $args);
|
||||
}
|
||||
}
|
||||
|
151
libs/sysplugins/smarty_internal_extension_handler.php
Normal file
151
libs/sysplugins/smarty_internal_extension_handler.php
Normal file
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty Extension handler
|
||||
*
|
||||
* Load extensions dynamically
|
||||
*
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsInternal
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @property Smarty_Internal_Runtime_Inheritance $_inheritance
|
||||
* @property Smarty_Internal_Runtime_SubTemplate $_subTemplate
|
||||
* @property Smarty_Internal_Runtime_Inline $_inline
|
||||
* @property Smarty_Internal_Runtime_TplFunction $_tplFunction
|
||||
* @property Smarty_Internal_Runtime_Var $_var
|
||||
* @property Smarty_Internal_Runtime_Config $_config
|
||||
* @property Smarty_Internal_Runtime_Foreach $_foreach
|
||||
* @property Smarty_Internal_Runtime_Hhvm $_hhvm
|
||||
* @property Smarty_Internal_Runtime_WriteFile $_writeFile
|
||||
* @property Smarty_Internal_Runtime_ValidateCompiled $_validateCompiled
|
||||
* @property Smarty_Internal_Runtime_CodeFrame $_codeFrame
|
||||
* @property Smarty_Internal_Runtime_FilterHandler $_filterHandler
|
||||
* @property Smarty_Internal_Runtime_GetIncludePath $_getIncludePath
|
||||
* @property Smarty_Internal_Method_GetTemplateVars $getTemplateVars
|
||||
* @property Smarty_Internal_Method_Append $append
|
||||
* @property Smarty_Internal_Method_AppendByRef $appendByRef
|
||||
* @property Smarty_Internal_Method_AssignGlobal $assignGlobal
|
||||
* @property Smarty_Internal_Method_AssignByRef $assignByRef
|
||||
* @property Smarty_Internal_Method_LoadFilter $loadFilter
|
||||
* @property Smarty_Internal_Method_RegisterFilter $registerFilter
|
||||
* @property Smarty_Internal_Method_RegisterObject $registerObject
|
||||
* @property Smarty_Internal_Method_RegisterPlugin $registerPlugin
|
||||
*/
|
||||
class Smarty_Internal_Extension_Handler
|
||||
{
|
||||
|
||||
/**
|
||||
* Cache for property information from generic getter/setter
|
||||
* Preloaded with names which should not use with generic getter/setter
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_property_info = array('AutoloadFilters' => 0, 'DefaultModifiers' => 0, 'ConfigVars' => 0,
|
||||
'DebugTemplate' => 0, 'RegisteredObject' => 0, 'StreamVariable' => 0,
|
||||
'TemplateVars' => 0,);#
|
||||
|
||||
private $resolvedProperties = array();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Call external Method
|
||||
*
|
||||
* @param \Smarty_Internal_Data $data
|
||||
* @param string $name external method names
|
||||
* @param array $args argument array
|
||||
*
|
||||
* @return mixed
|
||||
* @throws SmartyException
|
||||
*/
|
||||
public function _callExternalMethod(Smarty_Internal_Data $data, $name, $args) {
|
||||
/* @var Smarty $data->smarty */
|
||||
$smarty = isset($data->smarty) ? $data->smarty : $data;
|
||||
if (!isset($smarty->ext->$name)) {
|
||||
$class = 'Smarty_Internal_Method_' . ucfirst($name);
|
||||
if (preg_match('/^(set|get)([A-Z].*)$/', $name, $match)) {
|
||||
if (!isset($this->_property_info[$prop = $match[2]])) {
|
||||
// convert camel case to underscored name
|
||||
$this->resolvedProperties[$prop] = $pn = strtolower(join('_', preg_split('/([A-Z][^A-Z]*)/', $prop, - 1, PREG_SPLIT_NO_EMPTY |
|
||||
PREG_SPLIT_DELIM_CAPTURE)));
|
||||
$this->_property_info[$prop] = property_exists($data, $pn) ? 1 : ($data->_objType == 2 &&
|
||||
property_exists($smarty, $pn) ? 2 : 0);
|
||||
}
|
||||
if ($this->_property_info[$prop]) {
|
||||
$pn = $this->resolvedProperties[$prop];
|
||||
if ($match[1] == 'get') {
|
||||
return $this->_property_info[$prop] == 1 ? $data->$pn : $data->smarty->$pn;
|
||||
} else {
|
||||
return $this->_property_info[$prop] ==
|
||||
1 ? $data->$pn = $args[0] : $data->smarty->$pn = $args[0];
|
||||
}
|
||||
} elseif (!class_exists($class)) {
|
||||
throw new SmartyException("property '$pn' does not exist.");
|
||||
}
|
||||
}
|
||||
if (class_exists($class)) {
|
||||
$callback = array($smarty->ext->$name = new $class(), $name);
|
||||
}
|
||||
} else {
|
||||
$callback = array($smarty->ext->$name, $name);
|
||||
}
|
||||
array_unshift($args, $data);
|
||||
if (isset($callback) && $callback[0]->objMap | $data->_objType) {
|
||||
return call_user_func_array($callback, $args);
|
||||
}
|
||||
return call_user_func_array(array(new Smarty_Internal_Undefined(), $name), $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* set extension property
|
||||
*
|
||||
* @param string $property_name property name
|
||||
* @param mixed $value value
|
||||
*
|
||||
* @throws SmartyException
|
||||
*/
|
||||
public function __set($property_name, $value)
|
||||
{
|
||||
$this->$property_name = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* get extension object
|
||||
*
|
||||
* @param string $property_name property name
|
||||
*
|
||||
* @return mixed|Smarty_Template_Cached
|
||||
* @throws SmartyException
|
||||
*/
|
||||
public function __get($property_name)
|
||||
{
|
||||
// object properties of runtime template extensions will start with '_'
|
||||
if ($property_name[0] == '_') {
|
||||
$class = 'Smarty_Internal_Runtime_' . ucfirst(substr($property_name, 1));
|
||||
} else {
|
||||
$class = 'Smarty_Internal_Method_' . ucfirst($property_name);
|
||||
|
||||
}
|
||||
if (class_exists($class)) {
|
||||
return $this->$property_name = new $class();
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call error handler for undefined method
|
||||
*
|
||||
* @param string $name unknown method-name
|
||||
* @param array $args argument array
|
||||
*
|
||||
* @return mixed
|
||||
* @throws SmartyException
|
||||
*/
|
||||
public function __call($name, $args)
|
||||
{
|
||||
return call_user_func_array(array(new Smarty_Internal_Undefined(), $name), $args);
|
||||
}
|
||||
|
||||
}
|
@@ -45,7 +45,7 @@ class Smarty_Internal_Method_Append
|
||||
} else {
|
||||
if ($tpl_var != '' && isset($value)) {
|
||||
if (!isset($data->tpl_vars[$tpl_var])) {
|
||||
$tpl_var_inst = $data->_getVariable($tpl_var, null, true, false);
|
||||
$tpl_var_inst = $data->ext->getTemplateVars->_getVariable($data, $tpl_var, null, true, false);
|
||||
if ($tpl_var_inst instanceof Smarty_Undefined_Variable) {
|
||||
$data->tpl_vars[$tpl_var] = new Smarty_Variable(null, $nocache);
|
||||
} else {
|
||||
@@ -66,7 +66,6 @@ class Smarty_Internal_Method_Append
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
@@ -42,7 +42,6 @@ class Smarty_Internal_Method_AppendByRef
|
||||
$data->tpl_vars[$tpl_var]->value[] = &$value;
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
34
libs/sysplugins/smarty_internal_method_assignbyref.php
Normal file
34
libs/sysplugins/smarty_internal_method_assignbyref.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty Method AssignByRef
|
||||
*
|
||||
* Smarty::assignByRef() method
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsInternal
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
class Smarty_Internal_Method_AssignByRef
|
||||
{
|
||||
|
||||
/**
|
||||
* assigns values to template variables by reference
|
||||
*
|
||||
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
||||
* @param string $tpl_var the template variable name
|
||||
* @param $value
|
||||
* @param boolean $nocache if true any output of this variable will be not cached
|
||||
*
|
||||
* @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty
|
||||
*/
|
||||
public function assignByRef(Smarty_Internal_Data $data, $tpl_var, &$value, $nocache)
|
||||
{
|
||||
if ($tpl_var != '') {
|
||||
$data->tpl_vars[$tpl_var] = new Smarty_Variable(null, $nocache);
|
||||
$data->tpl_vars[$tpl_var]->value = &$value;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
43
libs/sysplugins/smarty_internal_method_assignglobal.php
Normal file
43
libs/sysplugins/smarty_internal_method_assignglobal.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty Method AssignGlobal
|
||||
*
|
||||
* Smarty::assignGlobal() method
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsInternal
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
class Smarty_Internal_Method_AssignGlobal
|
||||
{
|
||||
/**
|
||||
* Valid for all objects
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $objMap = 7;
|
||||
|
||||
/**
|
||||
* assigns a global Smarty variable
|
||||
*
|
||||
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
||||
* @param string $varName the global variable name
|
||||
* @param mixed $value the value to assign
|
||||
* @param boolean $nocache if true any output of this variable will be not cached
|
||||
*
|
||||
* @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty
|
||||
*/
|
||||
public function assignGlobal(Smarty_Internal_Data $data, $varName, $value = null, $nocache = false)
|
||||
{
|
||||
if ($varName != '') {
|
||||
Smarty::$global_tpl_vars[$varName] = new Smarty_Variable($value, $nocache);
|
||||
$ptr = $data;
|
||||
while ($ptr->_objType == 2) {
|
||||
$ptr->tpl_vars[$varName] = clone Smarty::$global_tpl_vars[$varName];
|
||||
$ptr = $ptr->parent;
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
@@ -25,16 +25,16 @@ class Smarty_Internal_Method_GetTemplateVars
|
||||
* @link http://www.smarty.net/docs/en/api.get.template.vars.tpl
|
||||
*
|
||||
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
||||
* @param string $varname variable name or null
|
||||
* @param string $varName variable name or null
|
||||
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $_ptr optional pointer to data object
|
||||
* @param bool $search_parents include parent templates?
|
||||
* @param bool $searchParents include parent templates?
|
||||
*
|
||||
* @return mixed variable value or or array of variables
|
||||
*/
|
||||
public function getTemplateVars(Smarty_Internal_Data $data, $varname = null, Smarty_Internal_Data $_ptr = null, $search_parents = true)
|
||||
public function getTemplateVars(Smarty_Internal_Data $data, $varName = null, Smarty_Internal_Data $_ptr = null, $searchParents = true)
|
||||
{
|
||||
if (isset($varname)) {
|
||||
$_var = $data->_getVariable($varname, $_ptr, $search_parents, false);
|
||||
if (isset($varName)) {
|
||||
$_var = $this->_getVariable($data, $varName, $_ptr, $searchParents, false);
|
||||
if (is_object($_var)) {
|
||||
return $_var->value;
|
||||
} else {
|
||||
@@ -52,13 +52,13 @@ class Smarty_Internal_Method_GetTemplateVars
|
||||
}
|
||||
}
|
||||
// not found, try at parent
|
||||
if ($search_parents) {
|
||||
if ($searchParents) {
|
||||
$_ptr = $_ptr->parent;
|
||||
} else {
|
||||
$_ptr = null;
|
||||
}
|
||||
}
|
||||
if ($search_parents && isset(Smarty::$global_tpl_vars)) {
|
||||
if ($searchParents && isset(Smarty::$global_tpl_vars)) {
|
||||
foreach (Smarty::$global_tpl_vars AS $key => $var) {
|
||||
if (!array_key_exists($key, $_result)) {
|
||||
$_result[$key] = $var->value;
|
||||
@@ -68,4 +68,47 @@ class Smarty_Internal_Method_GetTemplateVars
|
||||
return $_result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the object of a Smarty variable
|
||||
*
|
||||
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
||||
* @param string $varName the name of the Smarty variable
|
||||
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $_ptr optional pointer to data object
|
||||
* @param bool $searchParents search also in parent data
|
||||
* @param bool $errorEnable
|
||||
*
|
||||
* @return \Smarty_Variable
|
||||
*/
|
||||
public function _getVariable(Smarty_Internal_Data $data, $varName, Smarty_Internal_Data $_ptr = null, $searchParents = true, $errorEnable = true)
|
||||
{
|
||||
if ($_ptr === null) {
|
||||
$_ptr = $data;
|
||||
}
|
||||
while ($_ptr !== null) {
|
||||
if (isset($_ptr->tpl_vars[$varName])) {
|
||||
// found it, return it
|
||||
return $_ptr->tpl_vars[$varName];
|
||||
}
|
||||
// not found, try at parent
|
||||
if ($searchParents) {
|
||||
$_ptr = $_ptr->parent;
|
||||
} else {
|
||||
$_ptr = null;
|
||||
}
|
||||
}
|
||||
if (isset(Smarty::$global_tpl_vars[$varName])) {
|
||||
// found it, return it
|
||||
return Smarty::$global_tpl_vars[$varName];
|
||||
}
|
||||
/* @var \Smarty $smarty */
|
||||
$smarty = isset($data->smarty) ? $data->smarty : $data;
|
||||
if ($smarty->error_unassigned && $errorEnable) {
|
||||
// force a notice
|
||||
$x = $$varName;
|
||||
}
|
||||
|
||||
return new Smarty_Undefined_Variable;
|
||||
}
|
||||
|
||||
}
|
111
libs/sysplugins/smarty_internal_method_loadplugin.php
Normal file
111
libs/sysplugins/smarty_internal_method_loadplugin.php
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty Extension Loadplugin
|
||||
*
|
||||
* $smarty->loadPlugin() method
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsInternal
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
class Smarty_Internal_Method_LoadPlugin
|
||||
{
|
||||
/**
|
||||
* Cache of searched plugin files
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $plugin_files = array();
|
||||
|
||||
/**
|
||||
* Takes unknown classes and loads plugin files for them
|
||||
* class name format: Smarty_PluginType_PluginName
|
||||
* plugin filename format: plugintype.pluginname.php
|
||||
*
|
||||
* @param \Smarty $smarty
|
||||
* @param string $plugin_name class plugin name to load
|
||||
* @param bool $check check if already loaded
|
||||
*
|
||||
* @return bool|string
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function loadPlugin(Smarty $smarty, $plugin_name, $check)
|
||||
{
|
||||
// if function or class exists, exit silently (already loaded)
|
||||
if ($check && (is_callable($plugin_name) || class_exists($plugin_name, false))) {
|
||||
return true;
|
||||
}
|
||||
if (!preg_match('#^smarty_((internal)|([^_]+))_(.+)$#i', $plugin_name, $match)) {
|
||||
throw new SmartyException("plugin {$plugin_name} is not a valid name format");
|
||||
}
|
||||
if (!empty($match[2])) {
|
||||
$file = SMARTY_SYSPLUGINS_DIR . strtolower($plugin_name) . '.php';
|
||||
if (isset($this->plugin_files[$file])) {
|
||||
if ($this->plugin_files[$file] !== false) {
|
||||
return $this->plugin_files[$file];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (is_file($file)) {
|
||||
$this->plugin_files[$file] = $file;
|
||||
require_once($file);
|
||||
return $file;
|
||||
} else {
|
||||
$this->plugin_files[$file] = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
// plugin filename is expected to be: [type].[name].php
|
||||
$_plugin_filename = "{$match[1]}.{$match[4]}.php";
|
||||
$_lower_filename = strtolower($_plugin_filename);
|
||||
if (isset($this->plugin_files)) {
|
||||
if (isset($this->plugin_files['plugins_dir'][$_lower_filename])) {
|
||||
if (!$smarty->use_include_path || $this->plugin_files['plugins_dir'][$_lower_filename] !== false) {
|
||||
return $this->plugin_files['plugins_dir'][$_lower_filename];
|
||||
}
|
||||
}
|
||||
if (!$smarty->use_include_path || $smarty->ext->_getIncludePath->isNewIncludePath($smarty)) {
|
||||
unset($this->plugin_files['include_path']);
|
||||
} else {
|
||||
if (isset($this->plugin_files['include_path'][$_lower_filename])) {
|
||||
return $this->plugin_files['include_path'][$_lower_filename];
|
||||
}
|
||||
}
|
||||
}
|
||||
$_file_names = array($_plugin_filename);
|
||||
if ($_lower_filename != $_plugin_filename) {
|
||||
$_file_names[] = $_lower_filename;
|
||||
}
|
||||
$_p_dirs = $smarty->getPluginsDir();
|
||||
if (!isset($this->plugin_files['plugins_dir'][$_lower_filename])) {
|
||||
// loop through plugin dirs and find the plugin
|
||||
foreach ($_p_dirs as $_plugin_dir) {
|
||||
foreach ($_file_names as $name) {
|
||||
$file = $_plugin_dir . $name;
|
||||
if (is_file($file)) {
|
||||
$this->plugin_files['plugins_dir'][$_lower_filename] = $file;
|
||||
require_once($file);
|
||||
return $file;
|
||||
}
|
||||
$this->plugin_files['plugins_dir'][$_lower_filename] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($smarty->use_include_path) {
|
||||
foreach ($_file_names as $_file_name) {
|
||||
// try PHP include_path
|
||||
$file = $smarty->ext->_getIncludePath->getIncludePath($_p_dirs, $_file_name, $smarty);
|
||||
$this->plugin_files['include_path'][$_lower_filename] = $file;
|
||||
if ($file !== false) {
|
||||
require_once($file);
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
// no plugin loaded
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -103,7 +103,7 @@ class Smarty_Internal_Resource_File extends Smarty_Resource
|
||||
}
|
||||
// Use include path ?
|
||||
if ($source->smarty->use_include_path) {
|
||||
return Smarty_Internal_Get_Include_Path::getIncludePath($_directories, $file, $source->smarty);
|
||||
return $source->smarty->ext->_getIncludePath->getIncludePath($_directories, $file, $source->smarty);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
88
libs/sysplugins/smarty_internal_runtime_codeframe.php
Normal file
88
libs/sysplugins/smarty_internal_runtime_codeframe.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Extension
|
||||
* This file contains the Smarty template extension to create a code frame
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Template
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class Smarty_Internal_Extension_CodeFrame
|
||||
* Create code frame for compiled and cached templates
|
||||
*/
|
||||
class Smarty_Internal_Runtime_CodeFrame
|
||||
{
|
||||
/**
|
||||
* Create code frame for compiled and cached templates
|
||||
*
|
||||
* @param Smarty_Internal_Template $_template
|
||||
* @param string $content optional template content
|
||||
* @param bool $cache flag for cache file
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function create(Smarty_Internal_Template $_template, $content = '', $functions = '', $cache = false)
|
||||
{
|
||||
// build property code
|
||||
$properties['has_nocache_code'] = $_template->compiled->has_nocache_code;
|
||||
$properties['version'] = Smarty::SMARTY_VERSION;
|
||||
$properties['unifunc'] = 'content_' . str_replace(array('.', ','), '_', uniqid('', true));
|
||||
if (!empty($_template->tpl_function)) {
|
||||
$properties['tpl_function'] = $_template->tpl_function;
|
||||
}
|
||||
if (!$cache) {
|
||||
$properties['file_dependency'] = $_template->compiled->file_dependency;
|
||||
$properties['includes'] = $_template->compiled->includes;
|
||||
} else {
|
||||
$properties['file_dependency'] = $_template->cached->file_dependency;
|
||||
$properties['cache_lifetime'] = $_template->cache_lifetime;
|
||||
}
|
||||
$output = "<?php\n";
|
||||
$output .= "/* Smarty version " . Smarty::SMARTY_VERSION . ", created on " . strftime("%Y-%m-%d %H:%M:%S") .
|
||||
"\n from \"" . $_template->source->filepath . "\" */\n\n";
|
||||
|
||||
$dec = "\$_smarty_tpl->smarty->ext->_validateCompiled->decodeProperties(\$_smarty_tpl, " . var_export($properties, true) . ',' .
|
||||
($cache ? 'true' : 'false') . ")";
|
||||
$output .= "if ({$dec}) {\n";
|
||||
$output .= "function {$properties['unifunc']} (\$_smarty_tpl) {\n";
|
||||
// include code for plugins
|
||||
if (!$cache) {
|
||||
if (!empty($_template->compiled->required_plugins['compiled'])) {
|
||||
foreach ($_template->compiled->required_plugins['compiled'] as $tmp) {
|
||||
foreach ($tmp as $data) {
|
||||
$file = addslashes($data['file']);
|
||||
if (is_array($data['function'])) {
|
||||
$output .= "if (!is_callable(array('{$data['function'][0]}','{$data['function'][1]}'))) require_once '{$file}';\n";
|
||||
} else {
|
||||
$output .= "if (!is_callable('{$data['function']}')) require_once '{$file}';\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($_template->caching && !empty($_template->compiled->required_plugins['nocache'])) {
|
||||
$_template->compiled->has_nocache_code = true;
|
||||
$output .= "echo '/*%%SmartyNocache:{$_template->compiled->nocache_hash}%%*/<?php \$_smarty = \$_smarty_tpl->smarty; ";
|
||||
foreach ($_template->compiled->required_plugins['nocache'] as $tmp) {
|
||||
foreach ($tmp as $data) {
|
||||
$file = addslashes($data['file']);
|
||||
if (is_Array($data['function'])) {
|
||||
$output .= addslashes("if (!is_callable(array('{$data['function'][0]}','{$data['function'][1]}'))) require_once '{$file}';\n");
|
||||
} else {
|
||||
$output .= addslashes("if (!is_callable('{$data['function']}')) require_once '{$file}';\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
$output .= "?>/*/%%SmartyNocache:{$_template->compiled->nocache_hash}%%*/';\n";
|
||||
}
|
||||
}
|
||||
$output .= "?>\n";
|
||||
$output .= $content;
|
||||
$output .= "<?php }\n?>";
|
||||
$output .= $functions;
|
||||
$output .= "<?php }\n";
|
||||
// remove unneeded PHP tags
|
||||
return preg_replace('/\s*\?>[\n]?<\?php\s*/', "\n", $output);
|
||||
}
|
||||
}
|
39
libs/sysplugins/smarty_internal_runtime_config.php
Normal file
39
libs/sysplugins/smarty_internal_runtime_config.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Runtime Methods _getConfigVariable
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsInternal
|
||||
* @author Uwe Tews
|
||||
*
|
||||
**/
|
||||
class Smarty_Internal_Runtime_Config
|
||||
{
|
||||
/**
|
||||
* gets a config variable value
|
||||
*
|
||||
* @param \Smarty_Internal_Template $tpl template object
|
||||
* @param string $varName the name of the config variable
|
||||
* @param bool $errorEnable
|
||||
*
|
||||
* @return mixed the value of the config variable
|
||||
*/
|
||||
public function _getConfigVariable(\Smarty_Internal_Template $tpl, $varName, $errorEnable = true)
|
||||
{
|
||||
$_ptr = $tpl;
|
||||
while ($_ptr !== null) {
|
||||
if (isset($_ptr->config_vars[$varName])) {
|
||||
// found it, return it
|
||||
return $_ptr->config_vars[$varName];
|
||||
}
|
||||
// not found, try at parent
|
||||
$_ptr = $_ptr->parent;
|
||||
}
|
||||
if ($tpl->smarty->error_unassigned && $errorEnable) {
|
||||
// force a notice
|
||||
$x = $$varName;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
69
libs/sysplugins/smarty_internal_runtime_filterhandler.php
Normal file
69
libs/sysplugins/smarty_internal_runtime_filterhandler.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Filter Handler
|
||||
* Smarty filter handler class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsInternal
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class for filter processing
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsInternal
|
||||
*/
|
||||
class Smarty_Internal_Runtime_FilterHandler
|
||||
{
|
||||
/**
|
||||
* Run filters over content
|
||||
* The filters will be lazy loaded if required
|
||||
* class name format: Smarty_FilterType_FilterName
|
||||
* plugin filename format: filtertype.filtername.php
|
||||
* Smarty2 filter plugins could be used
|
||||
*
|
||||
* @param string $type the type of filter ('pre','post','output') which shall run
|
||||
* @param string $content the content which shall be processed by the filters
|
||||
* @param Smarty_Internal_Template $template template object
|
||||
*
|
||||
* @throws SmartyException
|
||||
* @return string the filtered content
|
||||
*/
|
||||
public function runFilter($type, $content, Smarty_Internal_Template $template)
|
||||
{
|
||||
// loop over autoload filters of specified type
|
||||
if (!empty($template->smarty->autoload_filters[$type])) {
|
||||
foreach ((array) $template->smarty->autoload_filters[$type] as $name) {
|
||||
$plugin_name = "Smarty_{$type}filter_{$name}";
|
||||
if (function_exists($plugin_name)) {
|
||||
$callback = $plugin_name;
|
||||
} elseif (class_exists($plugin_name, false) && is_callable(array($plugin_name, 'execute'))) {
|
||||
$callback = array($plugin_name, 'execute');
|
||||
} elseif ($template->smarty->loadPlugin($plugin_name, false)) {
|
||||
if (function_exists($plugin_name)) {
|
||||
// use loaded Smarty2 style plugin
|
||||
$callback = $plugin_name;
|
||||
} elseif (class_exists($plugin_name, false) && is_callable(array($plugin_name, 'execute'))) {
|
||||
// loaded class of filter plugin
|
||||
$callback = array($plugin_name, 'execute');
|
||||
} else {
|
||||
throw new SmartyException("Auto load {$type}-filter plugin method \"{$plugin_name}::execute\" not callable");
|
||||
}
|
||||
} else {
|
||||
// nothing found, throw exception
|
||||
throw new SmartyException("Unable to auto load {$type}-filter plugin \"{$plugin_name}\"");
|
||||
}
|
||||
$content = call_user_func($callback, $content, $template);
|
||||
}
|
||||
}
|
||||
// loop over registered filters of specified type
|
||||
if (!empty($template->smarty->registered_filters[$type])) {
|
||||
foreach ($template->smarty->registered_filters[$type] as $key => $name) {
|
||||
$content = call_user_func($template->smarty->registered_filters[$type][$key], $content, $template);
|
||||
}
|
||||
}
|
||||
// return filtered output
|
||||
return $content;
|
||||
}
|
||||
}
|
183
libs/sysplugins/smarty_internal_runtime_getincludepath.php
Normal file
183
libs/sysplugins/smarty_internal_runtime_getincludepath.php
Normal file
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty read include path plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsInternal
|
||||
* @author Monte Ohrt
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Read Include Path Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsInternal
|
||||
*/
|
||||
class Smarty_Internal_Runtime_GetIncludePath
|
||||
{
|
||||
/**
|
||||
* include path cache
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $_include_path = '';
|
||||
|
||||
/**
|
||||
* include path directory cache
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $_include_dirs = array();
|
||||
|
||||
/**
|
||||
* include path directory cache
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $_user_dirs = array();
|
||||
|
||||
/**
|
||||
* stream cache
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
public $isFile = array();
|
||||
|
||||
/**
|
||||
* stream cache
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
public $isPath = array();
|
||||
|
||||
/**
|
||||
* stream cache
|
||||
*
|
||||
* @var int[]
|
||||
*/
|
||||
public $number = array();
|
||||
|
||||
/**
|
||||
* status cache
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $_has_stream_include = null;
|
||||
|
||||
/**
|
||||
* Number for array index
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $counter = 0;
|
||||
|
||||
/**
|
||||
* Check if include path was updated
|
||||
*
|
||||
* @param \Smarty $smarty
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isNewIncludePath(Smarty $smarty)
|
||||
{
|
||||
$_i_path = get_include_path();
|
||||
if ($this->_include_path != $_i_path) {
|
||||
$this->_include_dirs = array();
|
||||
$this->_include_path = $_i_path;
|
||||
$_dirs = (array) explode(PATH_SEPARATOR, $_i_path);
|
||||
foreach ($_dirs as $_path) {
|
||||
if ($_path[0] != '/' && isset($dir[1]) && $dir[1] != ':') {
|
||||
$_path = $smarty->_realpath($_path . DS, true);
|
||||
}
|
||||
if (is_dir($_path)) {
|
||||
$this->_include_dirs[] = $smarty->_realpath($_path . DS, true);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* return array with include path directories
|
||||
*
|
||||
* @param \Smarty $smarty
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getIncludePathDirs(Smarty $smarty)
|
||||
{
|
||||
$this->isNewIncludePath($smarty);
|
||||
return $this->_include_dirs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return full file path from PHP include_path
|
||||
*
|
||||
* @param string[] $dirs
|
||||
* @param string $file
|
||||
* @param \Smarty $smarty
|
||||
*
|
||||
* @return bool|string full filepath or false
|
||||
*
|
||||
*/
|
||||
public function getIncludePath($dirs, $file, Smarty $smarty)
|
||||
{
|
||||
//if (!(isset($this->_has_stream_include) ? $this->_has_stream_include : $this->_has_stream_include = false)) {
|
||||
if (!(isset($this->_has_stream_include) ? $this->_has_stream_include : $this->_has_stream_include = function_exists('stream_resolve_include_path'))) {
|
||||
$this->isNewIncludePath($smarty);
|
||||
}
|
||||
// try PHP include_path
|
||||
foreach ($dirs as $dir) {
|
||||
$dir_n = isset($this->number[$dir]) ? $this->number[$dir] : $this->number[$dir] = $this->counter ++;
|
||||
if (isset($this->isFile[$dir_n][$file])) {
|
||||
if ($this->isFile[$dir_n][$file]) {
|
||||
return $this->isFile[$dir_n][$file];
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (isset($this->_user_dirs[$dir_n])) {
|
||||
if (false === $this->_user_dirs[$dir_n]) {
|
||||
continue;
|
||||
} else {
|
||||
$dir = $this->_user_dirs[$dir_n];
|
||||
}
|
||||
} else {
|
||||
if ($dir[0] == '/' || $dir[1] == ':') {
|
||||
$dir = str_ireplace(getcwd(), '.', $dir);
|
||||
if ($dir[0] == '/' || $dir[1] == ':') {
|
||||
$this->_user_dirs[$dir_n] = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$dir = substr($dir, 2);
|
||||
$this->_user_dirs[$dir_n] = $dir;
|
||||
}
|
||||
if ($this->_has_stream_include) {
|
||||
$path = stream_resolve_include_path($dir . (isset($file) ? $file : ''));
|
||||
if ($path) {
|
||||
return $this->isFile[$dir_n][$file] = $path;
|
||||
}
|
||||
} else {
|
||||
foreach ($this->_include_dirs as $key => $_i_path) {
|
||||
$path = isset($this->isPath[$key][$dir_n]) ? $this->isPath[$key][$dir_n] : $this->isPath[$key][$dir_n] = is_dir($_dir_path = $_i_path .
|
||||
$dir) ? $_dir_path : false;
|
||||
if ($path === false) {
|
||||
continue;
|
||||
}
|
||||
if (isset($file)) {
|
||||
$_file = $this->isFile[$dir_n][$file] = (is_file($path . $file)) ? $path . $file : false;
|
||||
if ($_file) {
|
||||
return $_file;
|
||||
}
|
||||
} else {
|
||||
// no file was given return directory path
|
||||
return $path;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
30
libs/sysplugins/smarty_internal_runtime_hhvm.php
Normal file
30
libs/sysplugins/smarty_internal_runtime_hhvm.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Runtime Extension Hhvm
|
||||
*
|
||||
* include patch for modified compiled or cached templates
|
||||
* HHVM does not check if file was modified when including same file multiple times
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsInternal
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
class Smarty_Internal_Runtime_Hhvm
|
||||
{
|
||||
/**
|
||||
* @param \Smarty_Internal_Template $_template
|
||||
* @param string $file file name
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
static function includeHhvm(Smarty_Internal_Template $_template, $file)
|
||||
{
|
||||
$_smarty_tpl = $_template;
|
||||
$tmp_file = $file . preg_replace('![^\w]+!', '_', uniqid(rand(), true)) . '.php';
|
||||
file_put_contents($tmp_file, file_get_contents($file));
|
||||
$result = @include $tmp_file;
|
||||
@unlink($tmp_file);
|
||||
return $result;
|
||||
}
|
||||
}
|
@@ -72,8 +72,8 @@ class Smarty_Internal_Runtime_Inheritance
|
||||
{
|
||||
// if template was from an inner block or template is a parent template create new inheritance root
|
||||
if ($initChild && ($this->blockNesting || $this->state == 3)) {
|
||||
$tpl->_inheritance = new Smarty_Internal_Runtime_Inheritance();
|
||||
$tpl->_inheritance->init($tpl, $initChild, $blockNames);
|
||||
$tpl->ext->_inheritance = new Smarty_Internal_Runtime_Inheritance();
|
||||
$tpl->ext->_inheritance->init($tpl, $initChild, $blockNames);
|
||||
return;
|
||||
}
|
||||
// start of child sub template(s)
|
||||
@@ -118,11 +118,16 @@ class Smarty_Internal_Runtime_Inheritance
|
||||
* if found call it, otherwise call current block
|
||||
* - ignored for outer level blocks in child templates
|
||||
*
|
||||
* $type 1 = {$smarty.block.child}:
|
||||
* $type 1 = {block}:
|
||||
* - nested {block}
|
||||
* - search in inheritance template hierarchy for child blocks
|
||||
* if found call it, otherwise call current block
|
||||
*
|
||||
* $type 2 = {$smarty.block.child}:
|
||||
* - search in inheritance template hierarchy for child blocks
|
||||
* if found call it, otherwise ignore
|
||||
*
|
||||
* $type 2 = {$smarty.block.parent}:
|
||||
* $type 3 = {$smarty.block.parent}:
|
||||
* - get block id from parent stack and call parent block
|
||||
*
|
||||
* @param \Smarty_Internal_Template $tpl template object of caller
|
||||
|
97
libs/sysplugins/smarty_internal_runtime_tplfunction.php
Normal file
97
libs/sysplugins/smarty_internal_runtime_tplfunction.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Tplfunc Runtime Methods callTemplateFunction
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsInternal
|
||||
* @author Uwe Tews
|
||||
*
|
||||
**/
|
||||
class Smarty_Internal_Runtime_TplFunction
|
||||
{
|
||||
/**
|
||||
* Call template function
|
||||
*
|
||||
* @param \Smarty_Internal_Template $tpl template object
|
||||
* @param string $name template function name
|
||||
* @param array $params parameter array
|
||||
* @param bool $nocache true if called nocache
|
||||
*
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function callTemplateFunction(\Smarty_Internal_Template $tpl, $name, $params, $nocache)
|
||||
{
|
||||
if (isset($tpl->tpl_function[$name])) {
|
||||
if (!$tpl->caching || ($tpl->caching && $nocache)) {
|
||||
$function = $tpl->tpl_function[$name]['call_name'];
|
||||
} else {
|
||||
if (isset($tpl->tpl_function[$name]['call_name_caching'])) {
|
||||
$function = $tpl->tpl_function[$name]['call_name_caching'];
|
||||
} else {
|
||||
$function = $tpl->tpl_function[$name]['call_name'];
|
||||
}
|
||||
}
|
||||
if (function_exists($function)) {
|
||||
$function ($tpl, $params);
|
||||
return;
|
||||
}
|
||||
// try to load template function dynamically
|
||||
if ($this->addTplFuncToCache($tpl, $name, $function)) {
|
||||
$function ($tpl, $params);
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new SmartyException("Unable to find template function '{$name}'");
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Add template function to cache file for nocache calls
|
||||
*
|
||||
* @param Smarty_Internal_Template $tpl
|
||||
* @param string $_name template function name
|
||||
* @param string $_function PHP function name
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function addTplFuncToCache(Smarty_Internal_Template $tpl, $_name, $_function)
|
||||
{
|
||||
$funcParam = $tpl->tpl_function[$_name];
|
||||
if (is_file($funcParam['compiled_filepath'])) {
|
||||
// read compiled file
|
||||
$code = file_get_contents($funcParam['compiled_filepath']);
|
||||
// grab template function
|
||||
if (preg_match("/\/\* {$_function} \*\/([\S\s]*?)\/\*\/ {$_function} \*\//", $code, $match)) {
|
||||
// grab source info from file dependency
|
||||
preg_match("/\s*'{$funcParam['uid']}'([\S\s]*?)\),/", $code, $match1);
|
||||
unset($code);
|
||||
// make PHP function known
|
||||
eval($match[0]);
|
||||
if (function_exists($_function)) {
|
||||
// search cache file template
|
||||
$tplPtr = $tpl;
|
||||
while (!isset($tplPtr->cached) && isset($tplPtr->parent)) {
|
||||
$tplPtr = $tplPtr->parent;
|
||||
}
|
||||
// add template function code to cache file
|
||||
if (isset($tplPtr->cached)) {
|
||||
$cache = $tplPtr->cached;
|
||||
$content = $cache->read($tplPtr);
|
||||
if ($content) {
|
||||
// check if we must update file dependency
|
||||
if (!preg_match("/'{$funcParam['uid']}'(.*?)'nocache_hash'/", $content, $match2)) {
|
||||
$content = preg_replace("/('file_dependency'(.*?)\()/", "\\1{$match1[0]}", $content);
|
||||
}
|
||||
$cache->write($tplPtr, preg_replace('/\s*\?>\s*$/', "\n", $content) . "\n" .
|
||||
preg_replace(array('/^\s*<\?php\s+/', '/\s*\?>\s*$/'), "\n",
|
||||
$match[0]));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
81
libs/sysplugins/smarty_internal_runtime_validatecompiled.php
Normal file
81
libs/sysplugins/smarty_internal_runtime_validatecompiled.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Runtime Methods decodeProperties
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsInternal
|
||||
* @author Uwe Tews
|
||||
*
|
||||
**/
|
||||
class Smarty_Internal_Runtime_ValidateCompiled
|
||||
{
|
||||
/**
|
||||
* This function is executed automatically when a compiled or cached template file is included
|
||||
* - Decode saved properties from compiled template and cache files
|
||||
* - Check if compiled or cache file is valid
|
||||
*
|
||||
* @param array $properties special template properties
|
||||
* @param bool $cache flag if called from cache file
|
||||
*
|
||||
* @return bool flag if compiled or cache file is valid
|
||||
*/
|
||||
public function decodeProperties(Smarty_Internal_Template $tpl, $properties, $cache = false)
|
||||
{
|
||||
$is_valid = true;
|
||||
if (Smarty::SMARTY_VERSION != $properties['version']) {
|
||||
// new version must rebuild
|
||||
$is_valid = false;
|
||||
} elseif ($is_valid && !empty($properties['file_dependency']) &&
|
||||
((!$cache && $tpl->smarty->compile_check) || $tpl->smarty->compile_check == 1)
|
||||
) {
|
||||
// check file dependencies at compiled code
|
||||
foreach ($properties['file_dependency'] as $_file_to_check) {
|
||||
if ($_file_to_check[2] == 'file' || $_file_to_check[2] == 'extends' || $_file_to_check[2] == 'php') {
|
||||
if ($tpl->source->filepath == $_file_to_check[0]) {
|
||||
// do not recheck current template
|
||||
continue;
|
||||
//$mtime = $tpl->source->getTimeStamp();
|
||||
} else {
|
||||
// file and php types can be checked without loading the respective resource handlers
|
||||
$mtime = is_file($_file_to_check[0]) ? filemtime($_file_to_check[0]) : false;
|
||||
}
|
||||
} elseif ($_file_to_check[2] == 'string') {
|
||||
continue;
|
||||
} else {
|
||||
$source = Smarty_Template_Source::load(null, $tpl->smarty, $_file_to_check[0]);
|
||||
$mtime = $source->getTimeStamp();
|
||||
}
|
||||
if (!$mtime || $mtime > $_file_to_check[1]) {
|
||||
$is_valid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($cache) {
|
||||
// CACHING_LIFETIME_SAVED cache expiry has to be validated here since otherwise we'd define the unifunc
|
||||
if ($tpl->caching === Smarty::CACHING_LIFETIME_SAVED && $properties['cache_lifetime'] >= 0 &&
|
||||
(time() > ($tpl->cached->timestamp + $properties['cache_lifetime']))
|
||||
) {
|
||||
$is_valid = false;
|
||||
}
|
||||
$tpl->cached->cache_lifetime = $properties['cache_lifetime'];
|
||||
$tpl->cached->valid = $is_valid;
|
||||
$resource = $tpl->cached;
|
||||
} else {
|
||||
$tpl->mustCompile = !$is_valid;
|
||||
$resource = $tpl->compiled;
|
||||
$resource->includes = isset($properties['includes']) ? $properties['includes'] : array();
|
||||
}
|
||||
if ($is_valid) {
|
||||
$resource->unifunc = $properties['unifunc'];
|
||||
$resource->has_nocache_code = $properties['has_nocache_code'];
|
||||
// $tpl->compiled->nocache_hash = $properties['nocache_hash'];
|
||||
$resource->file_dependency = $properties['file_dependency'];
|
||||
if (isset($properties['tpl_function'])) {
|
||||
$tpl->tpl_function = $properties['tpl_function'];
|
||||
}
|
||||
}
|
||||
return $is_valid && !function_exists($properties['unifunc']);
|
||||
}
|
||||
}
|
@@ -14,24 +14,24 @@ class Smarty_Internal_Runtime_Var
|
||||
* Template code runtime function to create a local Smarty variable for array assignments
|
||||
*
|
||||
* @param \Smarty_Internal_Template $tpl template object
|
||||
* @param string $tpl_var template variable name
|
||||
* @param string $varName template variable name
|
||||
* @param bool $nocache cache mode of variable
|
||||
* @param int $scope scope of variable
|
||||
*/
|
||||
public function createLocalArrayVariable(\Smarty_Internal_Template $tpl, $tpl_var, $nocache = false,
|
||||
public function createLocalArrayVariable(\Smarty_Internal_Template $tpl, $varName, $nocache = false,
|
||||
$scope = Smarty::SCOPE_LOCAL)
|
||||
{
|
||||
if (!isset($tpl->tpl_vars[$tpl_var])) {
|
||||
$tpl->tpl_vars[$tpl_var] = new Smarty_Variable(array(), $nocache, $scope);
|
||||
if (!isset($tpl->tpl_vars[$varName])) {
|
||||
$tpl->tpl_vars[$varName] = new Smarty_Variable(array(), $nocache, $scope);
|
||||
} else {
|
||||
$tpl->tpl_vars[$tpl_var] = clone $tpl->tpl_vars[$tpl_var];
|
||||
$tpl->tpl_vars[$varName] = clone $tpl->tpl_vars[$varName];
|
||||
if ($scope != Smarty::SCOPE_LOCAL) {
|
||||
$tpl->tpl_vars[$tpl_var]->scope = $scope;
|
||||
$tpl->tpl_vars[$varName]->scope = $scope;
|
||||
}
|
||||
if (!(is_array($tpl->tpl_vars[$tpl_var]->value) ||
|
||||
$tpl->tpl_vars[$tpl_var]->value instanceof ArrayAccess)
|
||||
if (!(is_array($tpl->tpl_vars[$varName]->value) ||
|
||||
$tpl->tpl_vars[$varName]->value instanceof ArrayAccess)
|
||||
) {
|
||||
settype($tpl->tpl_vars[$tpl_var]->value, 'array');
|
||||
settype($tpl->tpl_vars[$varName]->value, 'array');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
90
libs/sysplugins/smarty_internal_runtime_writefile.php
Normal file
90
libs/sysplugins/smarty_internal_runtime_writefile.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty write file plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsInternal
|
||||
* @author Monte Ohrt
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Write File Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsInternal
|
||||
*/
|
||||
class Smarty_Internal_Runtime_WriteFile
|
||||
{
|
||||
/**
|
||||
* Writes file in a safe way to disk
|
||||
*
|
||||
* @param string $_filepath complete filepath
|
||||
* @param string $_contents file content
|
||||
* @param Smarty $smarty smarty instance
|
||||
*
|
||||
* @throws SmartyException
|
||||
* @return boolean true
|
||||
*/
|
||||
public function writeFile($_filepath, $_contents, Smarty $smarty)
|
||||
{
|
||||
$_error_reporting = error_reporting();
|
||||
error_reporting($_error_reporting & ~E_NOTICE & ~E_WARNING);
|
||||
$_file_perms = property_exists($smarty, '_file_perms') ? $smarty->_file_perms : 0644;
|
||||
$_dir_perms = property_exists($smarty, '_dir_perms') ? (isset($smarty->_dir_perms) ? $smarty->_dir_perms : 0777) : 0771;
|
||||
if ($_file_perms !== null) {
|
||||
$old_umask = umask(0);
|
||||
}
|
||||
|
||||
$_dirpath = dirname($_filepath);
|
||||
// if subdirs, create dir structure
|
||||
if ($_dirpath !== '.' && !file_exists($_dirpath)) {
|
||||
mkdir($_dirpath, $_dir_perms, true);
|
||||
}
|
||||
|
||||
// write to tmp file, then move to overt file lock race condition
|
||||
$_tmp_file = $_dirpath . DS . str_replace(array('.', ','), '_', uniqid('wrt', true));
|
||||
if (!file_put_contents($_tmp_file, $_contents)) {
|
||||
error_reporting($_error_reporting);
|
||||
throw new SmartyException("unable to write file {$_tmp_file}");
|
||||
}
|
||||
|
||||
/*
|
||||
* Windows' rename() fails if the destination exists,
|
||||
* Linux' rename() properly handles the overwrite.
|
||||
* Simply unlink()ing a file might cause other processes
|
||||
* currently reading that file to fail, but linux' rename()
|
||||
* seems to be smart enough to handle that for us.
|
||||
*/
|
||||
if (Smarty::$_IS_WINDOWS) {
|
||||
// remove original file
|
||||
if (is_file($_filepath)) {
|
||||
@unlink($_filepath);
|
||||
}
|
||||
// rename tmp file
|
||||
$success = @rename($_tmp_file, $_filepath);
|
||||
} else {
|
||||
// rename tmp file
|
||||
$success = @rename($_tmp_file, $_filepath);
|
||||
if (!$success) {
|
||||
// remove original file
|
||||
if (is_file($_filepath)) {
|
||||
@unlink($_filepath);
|
||||
}
|
||||
// rename tmp file
|
||||
$success = @rename($_tmp_file, $_filepath);
|
||||
}
|
||||
}
|
||||
if (!$success) {
|
||||
error_reporting($_error_reporting);
|
||||
throw new SmartyException("unable to write file {$_filepath}");
|
||||
}
|
||||
if ($_file_perms !== null) {
|
||||
// set file permissions
|
||||
chmod($_filepath, $_file_perms);
|
||||
umask($old_umask);
|
||||
}
|
||||
error_reporting($_error_reporting);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -202,7 +202,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
||||
!$no_output_filter && (isset($this->smarty->autoload_filters['output']) ||
|
||||
isset($this->smarty->registered_filters['output']))
|
||||
) {
|
||||
echo Smarty_Internal_Filter_Handler::runFilter('output', ob_get_clean(), $this);
|
||||
echo $this->smarty->ext->_filterHandler->runFilter('output', ob_get_clean(), $this);
|
||||
} else {
|
||||
ob_end_flush();
|
||||
flush();
|
||||
@@ -247,7 +247,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
||||
(!$this->caching || $this->cached->has_nocache_code || $this->source->handler->recompiled) &&
|
||||
(isset($this->smarty->autoload_filters['output']) || isset($this->smarty->registered_filters['output']))
|
||||
) {
|
||||
return Smarty_Internal_Filter_Handler::runFilter('output', ob_get_clean(), $this);
|
||||
return $this->smarty->ext->_filterHandler->runFilter('output', ob_get_clean(), $this);
|
||||
}
|
||||
// return cache content
|
||||
return null;
|
||||
@@ -286,75 +286,6 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
||||
$this->smarty->_getTemplateId($this->template_resource, $this->cache_id, $this->compile_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is executed automatically when a compiled or cached template file is included
|
||||
* - Decode saved properties from compiled template and cache files
|
||||
* - Check if compiled or cache file is valid
|
||||
*
|
||||
* @param array $properties special template properties
|
||||
* @param bool $cache flag if called from cache file
|
||||
*
|
||||
* @return bool flag if compiled or cache file is valid
|
||||
*/
|
||||
public function decodeProperties($properties, $cache = false)
|
||||
{
|
||||
$is_valid = true;
|
||||
if (Smarty::SMARTY_VERSION != $properties['version']) {
|
||||
// new version must rebuild
|
||||
$is_valid = false;
|
||||
} elseif (!empty($properties['file_dependency']) &&
|
||||
((!$cache && $this->smarty->compile_check) || $this->smarty->compile_check == 1)
|
||||
) {
|
||||
// check file dependencies at compiled code
|
||||
foreach ($properties['file_dependency'] as $_file_to_check) {
|
||||
if ($_file_to_check[2] == 'file' || $_file_to_check[2] == 'extends' || $_file_to_check[2] == 'php') {
|
||||
if ($this->source->filepath == $_file_to_check[0]) {
|
||||
// do not recheck current template
|
||||
continue;
|
||||
//$mtime = $this->source->getTimeStamp();
|
||||
} else {
|
||||
// file and php types can be checked without loading the respective resource handlers
|
||||
$mtime = is_file($_file_to_check[0]) ? filemtime($_file_to_check[0]) : false;
|
||||
}
|
||||
} elseif ($_file_to_check[2] == 'string') {
|
||||
continue;
|
||||
} else {
|
||||
$source = Smarty_Template_Source::load(null, $this->smarty, $_file_to_check[0]);
|
||||
$mtime = $source->getTimeStamp();
|
||||
}
|
||||
if (!$mtime || $mtime > $_file_to_check[1]) {
|
||||
$is_valid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($cache) {
|
||||
// CACHING_LIFETIME_SAVED cache expiry has to be validated here since otherwise we'd define the unifunc
|
||||
if ($this->caching === Smarty::CACHING_LIFETIME_SAVED && $properties['cache_lifetime'] >= 0 &&
|
||||
(time() > ($this->cached->timestamp + $properties['cache_lifetime']))
|
||||
) {
|
||||
$is_valid = false;
|
||||
}
|
||||
$this->cached->cache_lifetime = $properties['cache_lifetime'];
|
||||
$this->cached->valid = $is_valid;
|
||||
$resource = $this->cached;
|
||||
} else {
|
||||
$this->mustCompile = !$is_valid;
|
||||
$resource = $this->compiled;
|
||||
$resource->includes = isset($properties['includes']) ? $properties['includes'] : array();
|
||||
}
|
||||
if ($is_valid) {
|
||||
$resource->unifunc = $properties['unifunc'];
|
||||
$resource->has_nocache_code = $properties['has_nocache_code'];
|
||||
// $this->compiled->nocache_hash = $properties['nocache_hash'];
|
||||
$resource->file_dependency = $properties['file_dependency'];
|
||||
if (isset($properties['tpl_function'])) {
|
||||
$this->tpl_function = $properties['tpl_function'];
|
||||
}
|
||||
}
|
||||
return $is_valid;
|
||||
}
|
||||
|
||||
/**
|
||||
* runtime error not matching capture tags
|
||||
*/
|
||||
|
@@ -150,7 +150,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
|
||||
*/
|
||||
private function _execute($template, $cache_id, $compile_id, $parent, $function)
|
||||
{
|
||||
/* @var Smarty $smarty */
|
||||
/* @var Smarty $this ->smarty */
|
||||
$smarty = $this->_objType == 1 ? $this : $this->smarty;
|
||||
if ($template === null) {
|
||||
if ($this->_objType != 2) {
|
||||
@@ -207,7 +207,6 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
|
||||
|
||||
/**
|
||||
* Registers plugin to be used in templates
|
||||
* NOTE: this method can be safely removed for dynamic loading
|
||||
*
|
||||
* @api Smarty::registerPlugin()
|
||||
* @link http://www.smarty.net/docs/en/api.register.plugin.tpl
|
||||
@@ -223,21 +222,11 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
|
||||
*/
|
||||
public function registerPlugin($type, $name, $callback, $cacheable = true, $cache_attr = null)
|
||||
{
|
||||
/* @var Smarty $smarty */
|
||||
$smarty = isset($this->smarty) ? $this->smarty : $this;
|
||||
if (isset($smarty->registered_plugins[$type][$name])) {
|
||||
throw new SmartyException("Plugin tag \"{$name}\" already registered");
|
||||
} elseif (!is_callable($callback)) {
|
||||
throw new SmartyException("Plugin \"{$name}\" not callable");
|
||||
} else {
|
||||
$smarty->registered_plugins[$type][$name] = array($callback, (bool) $cacheable, (array) $cache_attr);
|
||||
}
|
||||
return $this;
|
||||
return $this->ext->registerPlugin->registerPlugin($this, $type, $name, $callback, $cacheable, $cache_attr);
|
||||
}
|
||||
|
||||
/**
|
||||
* load a filter of specified type and name
|
||||
* NOTE: this method can be safely removed for dynamic loading
|
||||
*
|
||||
* @api Smarty::loadFilter()
|
||||
* @link http://www.smarty.net/docs/en/api.load.filter.tpl
|
||||
@@ -250,32 +239,11 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
|
||||
*/
|
||||
public function loadFilter($type, $name)
|
||||
{
|
||||
/* @var Smarty $smarty */
|
||||
$smarty = isset($this->smarty) ? $this->smarty : $this;
|
||||
if (!in_array($type, array('pre', 'post', 'output', 'variable'))) {
|
||||
throw new SmartyException("Illegal filter type \"{$type}\"");
|
||||
}
|
||||
$_plugin = "smarty_{$type}filter_{$name}";
|
||||
$_filter_name = $_plugin;
|
||||
if (is_callable($_plugin)) {
|
||||
$smarty->registered_filters[$type][$_filter_name] = $_plugin;
|
||||
return true;
|
||||
}
|
||||
if ($smarty->loadPlugin($_plugin)) {
|
||||
if (class_exists($_plugin, false)) {
|
||||
$_plugin = array($_plugin, 'execute');
|
||||
}
|
||||
if (is_callable($_plugin)) {
|
||||
$smarty->registered_filters[$type][$_filter_name] = $_plugin;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
throw new SmartyException("{$type}filter \"{$name}\" not found or callable");
|
||||
return $this->ext->loadFilter->loadFilter($this, $type, $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a filter function
|
||||
* NOTE: this method can be safely removed for dynamic loading
|
||||
*
|
||||
* @api Smarty::registerFilter()
|
||||
* @link http://www.smarty.net/docs/en/api.register.filter.tpl
|
||||
@@ -289,42 +257,11 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
|
||||
*/
|
||||
public function registerFilter($type, $callback, $name = null)
|
||||
{
|
||||
/* @var Smarty $smarty */
|
||||
$smarty = isset($this->smarty) ? $this->smarty : $this;
|
||||
if (!in_array($type, array('pre', 'post', 'output', 'variable'))) {
|
||||
throw new SmartyException("Illegal filter type \"{$type}\"");
|
||||
}
|
||||
$name = isset($name) ? $name : $this->_getFilterName($callback);
|
||||
if (!is_callable($callback)) {
|
||||
throw new SmartyException("{$type}filter \"{$name}\" not callable");
|
||||
}
|
||||
$smarty->registered_filters[$type][$name] = $callback;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return internal filter name
|
||||
*
|
||||
* @param callback $function_name
|
||||
*
|
||||
* @return string internal filter name
|
||||
*/
|
||||
public function _getFilterName($function_name)
|
||||
{
|
||||
if (is_array($function_name)) {
|
||||
$_class_name = (is_object($function_name[0]) ? get_class($function_name[0]) : $function_name[0]);
|
||||
|
||||
return $_class_name . '_' . $function_name[1];
|
||||
} elseif (is_string($function_name)) {
|
||||
return $function_name;
|
||||
} else {
|
||||
return 'closure';
|
||||
}
|
||||
return $this->ext->registerFilter->registerFilter($this, $type, $callback, $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers object to be used in templates
|
||||
* NOTE: this method can be safely removed for dynamic loading
|
||||
*
|
||||
* @api Smarty::registerObject()
|
||||
* @link http://www.smarty.net/docs/en/api.register.object.tpl
|
||||
@@ -341,28 +278,8 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
|
||||
public function registerObject($object_name, $object, $allowed_methods_properties = array(), $format = true,
|
||||
$block_methods = array())
|
||||
{
|
||||
/* @var Smarty $smarty */
|
||||
$smarty = isset($this->smarty) ? $this->smarty : $this;
|
||||
// test if allowed methods callable
|
||||
if (!empty($allowed_methods_properties)) {
|
||||
foreach ((array) $allowed_methods_properties as $method) {
|
||||
if (!is_callable(array($object, $method)) && !property_exists($object, $method)) {
|
||||
throw new SmartyException("Undefined method or property '$method' in registered object");
|
||||
}
|
||||
}
|
||||
}
|
||||
// test if block methods callable
|
||||
if (!empty($block_methods)) {
|
||||
foreach ((array) $block_methods as $method) {
|
||||
if (!is_callable(array($object, $method))) {
|
||||
throw new SmartyException("Undefined method '$method' in registered object");
|
||||
}
|
||||
}
|
||||
}
|
||||
// register the object
|
||||
$smarty->registered_objects[$object_name] =
|
||||
array($object, (array) $allowed_methods_properties, (boolean) $format, (array) $block_methods);
|
||||
return $this;
|
||||
return $this->ext->registerObject->registerObject($this, $object_name, $object, $allowed_methods_properties,
|
||||
$format, $block_methods);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -317,10 +317,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
Smarty_Internal_TemplateCompilerBase $parent_compiler = null)
|
||||
{
|
||||
// get code frame of compiled template
|
||||
$_compiled_code =
|
||||
"<?php /* Smarty version " . Smarty::SMARTY_VERSION . ", created on " . strftime("%Y-%m-%d %H:%M:%S") .
|
||||
"\n compiled from \"" . $template->source->filepath . "\" */ ?>\n" .
|
||||
Smarty_Internal_Extension_CodeFrame::create($template, $this->compileTemplateSource($template, $nocache,
|
||||
$_compiled_code = $template->smarty->ext->_codeFrame->create($template, $this->compileTemplateSource($template, $nocache,
|
||||
$parent_compiler),
|
||||
$this->postFilter($this->blockOrFunctionCode) .
|
||||
join('', $this->mergedSubTemplatesCode));
|
||||
@@ -420,7 +417,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
if (!empty($code) &&
|
||||
(isset($this->smarty->autoload_filters['post']) || isset($this->smarty->registered_filters['post']))
|
||||
) {
|
||||
return Smarty_Internal_Filter_Handler::runFilter('post', $code, $this->template);
|
||||
return $this->smarty->ext->_filterHandler->runFilter('post', $code, $this->template);
|
||||
} else {
|
||||
return $code;
|
||||
}
|
||||
@@ -440,7 +437,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
if ($_content != '' &&
|
||||
((isset($this->smarty->autoload_filters['pre']) || isset($this->smarty->registered_filters['pre'])))
|
||||
) {
|
||||
return Smarty_Internal_Filter_Handler::runFilter('pre', $_content, $this->template);
|
||||
return $this->smarty->ext->_filterHandler->runFilter('pre', $_content, $this->template);
|
||||
} else {
|
||||
return $_content;
|
||||
}
|
||||
@@ -747,7 +744,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
if (strpos($variable, '(') == 0) {
|
||||
// not a variable variable
|
||||
$var = trim($variable, '\'');
|
||||
$this->tag_nocache = $this->tag_nocache | $this->template->_getVariable($var, null, true, false)->nocache;
|
||||
$this->tag_nocache = $this->tag_nocache | $this->template->ext->getTemplateVars->_getVariable($this->template, $var, null, true, false)->nocache;
|
||||
// todo $this->template->compiled->properties['variables'][$var] = $this->tag_nocache | $this->nocache;
|
||||
}
|
||||
return '$_smarty_tpl->tpl_vars[' . $variable . ']->value';
|
||||
|
@@ -2197,29 +2197,31 @@ class Smarty_Internal_Templateparser
|
||||
#line 905 "../smarty/lexer/smarty_internal_templateparser.y"
|
||||
function yy_r118()
|
||||
{
|
||||
$this->_retvalue = '$_smarty_tpl->_getConfigVariable( \'' . $this->yystack[$this->yyidx + - 1]->minor . '\')';
|
||||
$this->_retvalue = '$_smarty_tpl->smarty->ext->_config->_getConfigVariable($_smarty_tpl, \'' .
|
||||
$this->yystack[$this->yyidx + - 1]->minor . '\')';
|
||||
}
|
||||
|
||||
#line 909 "../smarty/lexer/smarty_internal_templateparser.y"
|
||||
function yy_r119()
|
||||
{
|
||||
$this->_retvalue =
|
||||
'(is_array($tmp = $_smarty_tpl->_getConfigVariable( \'' . $this->yystack[$this->yyidx + - 2]->minor .
|
||||
'\')) ? $tmp' . $this->yystack[$this->yyidx + 0]->minor . ' :null)';
|
||||
$this->_retvalue = '(is_array($tmp = $_smarty_tpl->smarty->ext->_config->_getConfigVariable($_smarty_tpl, \'' .
|
||||
$this->yystack[$this->yyidx + - 2]->minor . '\')) ? $tmp' . $this->yystack[$this->yyidx + 0]->minor .
|
||||
' :null)';
|
||||
}
|
||||
|
||||
#line 913 "../smarty/lexer/smarty_internal_templateparser.y"
|
||||
function yy_r120()
|
||||
{
|
||||
$this->_retvalue = '$_smarty_tpl->_getConfigVariable( ' . $this->yystack[$this->yyidx + - 1]->minor . ')';
|
||||
$this->_retvalue = '$_smarty_tpl->smarty->ext->_config->_getConfigVariable($_smarty_tpl, ' .
|
||||
$this->yystack[$this->yyidx + - 1]->minor . ')';
|
||||
}
|
||||
|
||||
#line 917 "../smarty/lexer/smarty_internal_templateparser.y"
|
||||
function yy_r121()
|
||||
{
|
||||
$this->_retvalue =
|
||||
'(is_array($tmp = $_smarty_tpl->_getConfigVariable( ' . $this->yystack[$this->yyidx + - 2]->minor .
|
||||
')) ? $tmp' . $this->yystack[$this->yyidx + 0]->minor . ' : null)';
|
||||
$this->_retvalue = '(is_array($tmp = $_smarty_tpl->smarty->ext->_config->_getConfigVariable($_smarty_tpl, ' .
|
||||
$this->yystack[$this->yyidx + - 2]->minor . ')) ? $tmp' . $this->yystack[$this->yyidx + 0]->minor .
|
||||
' : null)';
|
||||
}
|
||||
|
||||
#line 921 "../smarty/lexer/smarty_internal_templateparser.y"
|
||||
@@ -2449,8 +2451,8 @@ class Smarty_Internal_Templateparser
|
||||
$this->compiler->trigger_template_error('Illegal number of paramer in "isset()"');
|
||||
}
|
||||
$par = implode(',', $this->yystack[$this->yyidx + - 1]->minor);
|
||||
if (strncasecmp($par, '$_smarty_tpl->_getConfigVariable',
|
||||
strlen('$_smarty_tpl->_getConfigVariable')) === 0
|
||||
if (strncasecmp($par, '$_smarty_tpl->smarty->ext->_config->_getConfigVariable',
|
||||
strlen('$_smarty_tpl->smarty->ext->_config->_getConfigVariable')) === 0
|
||||
) {
|
||||
self::$prefix_number ++;
|
||||
$this->compiler->prefix_code[] =
|
||||
|
48
libs/sysplugins/smarty_internal_undefined.php
Normal file
48
libs/sysplugins/smarty_internal_undefined.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty Method AppendByRef
|
||||
*
|
||||
* Smarty::appendByRef() method
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsInternal
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
class Smarty_Internal_Undefined
|
||||
{
|
||||
|
||||
/**
|
||||
* This function is executed automatically when a compiled or cached template file is included
|
||||
* - Decode saved properties from compiled template and cache files
|
||||
* - Check if compiled or cache file is valid
|
||||
*
|
||||
* @param array $properties special template properties
|
||||
* @param bool $cache flag if called from cache file
|
||||
*
|
||||
* @return bool flag if compiled or cache file is valid
|
||||
*/
|
||||
public function decodeProperties($tpl, $properties, $cache = false)
|
||||
{
|
||||
if ($cache) {
|
||||
$tpl->cached->valid = false;
|
||||
} else {
|
||||
$tpl->mustCompile = true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call error handler for undefined method
|
||||
*
|
||||
* @param string $name unknown method-name
|
||||
* @param array $args argument array
|
||||
*
|
||||
* @return mixed
|
||||
* @throws SmartyException
|
||||
*/
|
||||
public function __call($name, $args)
|
||||
{
|
||||
throw new SmartyException(get_class($args[0]) . "->{$name}() undefined method");
|
||||
}
|
||||
}
|
@@ -514,7 +514,7 @@ class Smarty_Security
|
||||
}
|
||||
if ($this->smarty->use_include_path) {
|
||||
$this->_include_dir = array();
|
||||
$_dirs = Smarty_Internal_Get_Include_Path::getIncludePathDirs($this->smarty);
|
||||
$_dirs = $this->smarty->ext->_getIncludePath->getIncludePathDirs($this->smarty);
|
||||
foreach ($_dirs as $directory) {
|
||||
$this->_include_dir[] = $directory;
|
||||
$this->_resource_dir[$directory] = true;
|
||||
|
@@ -344,7 +344,7 @@ class Smarty_Template_Cached extends Smarty_Template_Resource_Base
|
||||
(isset($_template->smarty->autoload_filters['output']) ||
|
||||
isset($_template->smarty->registered_filters['output']))
|
||||
) {
|
||||
$content = Smarty_Internal_Filter_Handler::runFilter('output', $content, $_template);
|
||||
$content = $_template->smarty->ext->_filterHandler->runFilter('output', $content, $_template);
|
||||
}
|
||||
// write cache file content
|
||||
$this->writeCachedContent($_template, $content);
|
||||
@@ -366,7 +366,7 @@ class Smarty_Template_Cached extends Smarty_Template_Resource_Base
|
||||
// don't write cache file
|
||||
return false;
|
||||
}
|
||||
$content = Smarty_Internal_Extension_CodeFrame::create($_template, $content, '', true);
|
||||
$content = $_template->smarty->ext->_codeFrame->create($_template, $content, '', true);
|
||||
if (!empty($_template->cached->tpl_function)) {
|
||||
foreach ($_template->cached->tpl_function as $funcParam) {
|
||||
if (is_file($funcParam['compiled_filepath'])) {
|
||||
|
Reference in New Issue
Block a user