mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
- move code of {call} processing back into Smarty_Internal_Template class
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
- optimize autoloader
|
- optimize autoloader
|
||||||
- optimize subtemplate handling
|
- optimize subtemplate handling
|
||||||
- update template inheritance processing
|
- update template inheritance processing
|
||||||
|
- move code of {call} processing back into Smarty_Internal_Template class
|
||||||
|
|
||||||
30.08.2015
|
30.08.2015
|
||||||
- size optimization move some runtime functions into extension
|
- size optimization move some runtime functions into extension
|
||||||
|
@@ -119,7 +119,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
/**
|
/**
|
||||||
* smarty version
|
* smarty version
|
||||||
*/
|
*/
|
||||||
const SMARTY_VERSION = '3.1.28-dev/57';
|
const SMARTY_VERSION = '3.1.28-dev/58';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* define variable scopes
|
* define variable scopes
|
||||||
|
@@ -23,6 +23,7 @@ class Smarty_Internal_Compile_Call extends Smarty_Internal_CompileBase
|
|||||||
* @see Smarty_Internal_CompileBase
|
* @see Smarty_Internal_CompileBase
|
||||||
*/
|
*/
|
||||||
public $required_attributes = array('name');
|
public $required_attributes = array('name');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attribute definition: Overwrites base class.
|
* Attribute definition: Overwrites base class.
|
||||||
*
|
*
|
||||||
@@ -30,6 +31,7 @@ class Smarty_Internal_Compile_Call extends Smarty_Internal_CompileBase
|
|||||||
* @see Smarty_Internal_CompileBase
|
* @see Smarty_Internal_CompileBase
|
||||||
*/
|
*/
|
||||||
public $shorttag_order = array('name');
|
public $shorttag_order = array('name');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attribute definition: Overwrites base class.
|
* Attribute definition: Overwrites base class.
|
||||||
*
|
*
|
||||||
@@ -76,9 +78,11 @@ class Smarty_Internal_Compile_Call extends Smarty_Internal_CompileBase
|
|||||||
//$compiler->suppressNocacheProcessing = true;
|
//$compiler->suppressNocacheProcessing = true;
|
||||||
// was there an assign attribute
|
// was there an assign attribute
|
||||||
if (isset($_assign)) {
|
if (isset($_assign)) {
|
||||||
$_output = "<?php ob_start();\n\$_smarty_tpl->_Function->callTemplateFunction({$_name}, \$_smarty_tpl, {$_params}, {$_nocache});\n\$_smarty_tpl->assign({$_assign}, ob_get_clean());?>\n";
|
$_output =
|
||||||
|
"<?php ob_start();\n\$_smarty_tpl->callTemplateFunction({$_name}, \$_smarty_tpl, {$_params}, {$_nocache});\n\$_smarty_tpl->assign({$_assign}, ob_get_clean());?>\n";
|
||||||
} else {
|
} else {
|
||||||
$_output = "<?php \$_smarty_tpl->_Function->callTemplateFunction({$_name}, \$_smarty_tpl, {$_params}, {$_nocache});?>\n";
|
$_output =
|
||||||
|
"<?php \$_smarty_tpl->callTemplateFunction({$_name}, \$_smarty_tpl, {$_params}, {$_nocache});?>\n";
|
||||||
}
|
}
|
||||||
return $_output;
|
return $_output;
|
||||||
}
|
}
|
||||||
|
@@ -1,48 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Runtime Method _callTemplateFunction
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage PluginsInternal
|
|
||||||
* @author Uwe Tews
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
class Smarty_Internal_Runtime_Function
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Call template function
|
|
||||||
*
|
|
||||||
* @param string $name template function name
|
|
||||||
* @param object|\Smarty_Internal_Template $_smarty_tpl template object
|
|
||||||
* @param array $params parameter array
|
|
||||||
* @param bool $nocache true if called nocache
|
|
||||||
*
|
|
||||||
* @throws \SmartyException
|
|
||||||
*/
|
|
||||||
public function callTemplateFunction($name, Smarty_Internal_Template $_smarty_tpl, $params, $nocache)
|
|
||||||
{
|
|
||||||
if (isset($_smarty_tpl->tpl_function[$name])) {
|
|
||||||
if (!$_smarty_tpl->caching || ($_smarty_tpl->caching && $nocache)) {
|
|
||||||
$function = $_smarty_tpl->tpl_function[$name]['call_name'];
|
|
||||||
} else {
|
|
||||||
if (isset($_smarty_tpl->tpl_function[$name]['call_name_caching'])) {
|
|
||||||
$function = $_smarty_tpl->tpl_function[$name]['call_name_caching'];
|
|
||||||
} else {
|
|
||||||
$function = $_smarty_tpl->tpl_function[$name]['call_name'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (function_exists($function)) {
|
|
||||||
$function ($_smarty_tpl, $params);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// try to load template function dynamically
|
|
||||||
if (Smarty_Internal_Function_Call_Handler::call($name, $_smarty_tpl, $function)) {
|
|
||||||
$function ($_smarty_tpl, $params);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new SmartyException("Unable to find template function '{$name}'");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -426,7 +426,42 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Call template function
|
||||||
|
*
|
||||||
|
* @param string $name template function name
|
||||||
|
* @param object|\Smarty_Internal_Template $_smarty_tpl template object
|
||||||
|
* @param array $params parameter array
|
||||||
|
* @param bool $nocache true if called nocache
|
||||||
|
*
|
||||||
|
* @throws \SmartyException
|
||||||
|
*/
|
||||||
|
public function callTemplateFunction($name, Smarty_Internal_Template $_smarty_tpl, $params, $nocache)
|
||||||
|
{
|
||||||
|
if (isset($_smarty_tpl->tpl_function[$name])) {
|
||||||
|
if (!$_smarty_tpl->caching || ($_smarty_tpl->caching && $nocache)) {
|
||||||
|
$function = $_smarty_tpl->tpl_function[$name]['call_name'];
|
||||||
|
} else {
|
||||||
|
if (isset($_smarty_tpl->tpl_function[$name]['call_name_caching'])) {
|
||||||
|
$function = $_smarty_tpl->tpl_function[$name]['call_name_caching'];
|
||||||
|
} else {
|
||||||
|
$function = $_smarty_tpl->tpl_function[$name]['call_name'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (function_exists($function)) {
|
||||||
|
$function ($_smarty_tpl, $params);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// try to load template function dynamically
|
||||||
|
if (Smarty_Internal_Function_Call_Handler::call($name, $_smarty_tpl, $function)) {
|
||||||
|
$function ($_smarty_tpl, $params);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new SmartyException("Unable to find template function '{$name}'");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
* This function is executed automatically when a compiled or cached template file is included
|
* This function is executed automatically when a compiled or cached template file is included
|
||||||
* - Decode saved properties from compiled template and cache files
|
* - Decode saved properties from compiled template and cache files
|
||||||
* - Check if compiled or cache file is valid
|
* - Check if compiled or cache file is valid
|
||||||
|
@@ -97,6 +97,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
|
|||||||
* @return string rendered template output
|
* @return string rendered template output
|
||||||
*/
|
*/
|
||||||
public function fetch($template = null, $cache_id = null, $compile_id = null, $parent = null, $display = false, $merge_tpl_vars = true, $no_output_filter = false)
|
public function fetch($template = null, $cache_id = null, $compile_id = null, $parent = null, $display = false, $merge_tpl_vars = true, $no_output_filter = false)
|
||||||
|
$merge_tpl_vars = true, $no_output_filter = false)
|
||||||
{
|
{
|
||||||
$result = $this->_execute($template, $cache_id, $compile_id, $parent, 'fetch');
|
$result = $this->_execute($template, $cache_id, $compile_id, $parent, 'fetch');
|
||||||
return $result === null ? ob_get_clean() : $result;
|
return $result === null ? ob_get_clean() : $result;
|
||||||
@@ -173,8 +174,9 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
|
|||||||
// fetch template content
|
// fetch template content
|
||||||
$level = ob_get_level();
|
$level = ob_get_level();
|
||||||
try {
|
try {
|
||||||
$_smarty_old_error_level = ($this->_objType == 1 &&
|
$_smarty_old_error_level =
|
||||||
isset($smarty->error_reporting)) ? error_reporting($smarty->error_reporting) : null;
|
($this->_objType == 1 && isset($smarty->error_reporting)) ? error_reporting($smarty->error_reporting) :
|
||||||
|
null;
|
||||||
if ($function == 'isCached') {
|
if ($function == 'isCached') {
|
||||||
if ($template->caching) {
|
if ($template->caching) {
|
||||||
// return cache status of template
|
// return cache status of template
|
||||||
@@ -336,7 +338,8 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
|
|||||||
* @return \Smarty|\Smarty_Internal_Template
|
* @return \Smarty|\Smarty_Internal_Template
|
||||||
* @throws \SmartyException
|
* @throws \SmartyException
|
||||||
*/
|
*/
|
||||||
public function registerObject($object_name, $object, $allowed_methods_properties = array(), $format = true, $block_methods = array())
|
public function registerObject($object_name, $object, $allowed_methods_properties = array(), $format = true,
|
||||||
|
$block_methods = array())
|
||||||
{
|
{
|
||||||
/* @var Smarty $smarty */
|
/* @var Smarty $smarty */
|
||||||
$smarty = isset($this->smarty) ? $this->smarty : $this;
|
$smarty = isset($this->smarty) ? $this->smarty : $this;
|
||||||
@@ -357,8 +360,8 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// register the object
|
// register the object
|
||||||
$smarty->registered_objects[$object_name] = array($object, (array) $allowed_methods_properties,
|
$smarty->registered_objects[$object_name] =
|
||||||
(boolean) $format, (array) $block_methods);
|
array($object, (array) $allowed_methods_properties, (boolean) $format, (array) $block_methods);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user