- code optimizations

This commit is contained in:
Uwe.Tews
2010-02-28 12:50:33 +00:00
parent ed2458e9ae
commit 428889e762
6 changed files with 70 additions and 59 deletions

View File

@@ -45,7 +45,7 @@ class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_Compi
$this->compiler->nocache = $this->compiler->nocache | $this->compiler->tag_nocache;
// compile code
if (is_array($function)) {
$output = "<?php \$_smarty_tpl->smarty->_tag_stack[] = array('{$tag}', {$_params}); \$_block_repeat=true; call_user_func_array(array('{$function[0]}','{$function[1]}'),(array({$_params}, null, \$_smarty_tpl->smarty, \$_block_repeat, \$_smarty_tpl));while (\$_block_repeat) { ob_start();?>";
$output = "<?php \$_smarty_tpl->smarty->_tag_stack[] = array('{$tag}', {$_params}); \$_block_repeat=true; call_user_func(array('{$function[0]}','{$function[1]}'),{$_params}, null, \$_smarty_tpl->smarty, \$_block_repeat, \$_smarty_tpl);while (\$_block_repeat) { ob_start();?>";
} else {
$output = "<?php \$_smarty_tpl->smarty->_tag_stack[] = array('{$tag}', {$_params}); \$_block_repeat=true; {$function}({$_params}, null, \$_smarty_tpl->smarty, \$_block_repeat, \$_smarty_tpl);while (\$_block_repeat) { ob_start();?>";
}
@@ -60,7 +60,7 @@ class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_Compi
$this->compiler->has_output = true;
// compile code
if (is_array($function)) {
$output = "<?php \$_block_content = ob_get_clean(); \$_block_repeat=false; echo call_user_func_array(array('{$function[0]}','{$function[1]}'),(array({$_params}, \$_block_content, \$_smarty_tpl->smarty, \$_block_repeat, \$_smarty_tpl)); } array_pop(\$_smarty_tpl->smarty->_tag_stack);?>";
$output = "<?php \$_block_content = ob_get_clean(); \$_block_repeat=false; echo call_user_func(array('{$function[0]}','{$function[1]}'),({$_params}, \$_block_content, \$_smarty_tpl->smarty, \$_block_repeat, \$_smarty_tpl); } array_pop(\$_smarty_tpl->smarty->_tag_stack);?>";
} else {
$output = "<?php \$_block_content = ob_get_clean(); \$_block_repeat=false; echo {$function}({$_params}, \$_block_content, \$_smarty_tpl->smarty, \$_block_repeat, \$_smarty_tpl); } array_pop(\$_smarty_tpl->smarty->_tag_stack);?>";
}
@@ -69,4 +69,4 @@ class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_Compi
}
}
?>
?>

View File

@@ -42,7 +42,7 @@ class Smarty_Internal_Compile_Private_Function_Plugin extends Smarty_Internal_Co
$_params = 'array(' . implode(",", $_paramsArray) . ')';
// compile code
if (is_array($function)) {
$output = "<?php echo call_user_func_array(array('{$function[0]}','{$function[1]}'),(array({$_params},\$_smarty_tpl->smarty,\$_smarty_tpl));?>\n";
$output = "<?php echo call_user_func(array('{$function[0]}','{$function[1]}'),{$_params},\$_smarty_tpl->smarty,\$_smarty_tpl);?>\n";
} else {
$output = "<?php echo {$function}({$_params},\$_smarty_tpl->smarty,\$_smarty_tpl);?>\n";
}
@@ -50,4 +50,4 @@ class Smarty_Internal_Compile_Private_Function_Plugin extends Smarty_Internal_Co
}
}
?>
?>

View File

@@ -48,9 +48,9 @@ class Smarty_Internal_Compile_Private_Registered_Block extends Smarty_Internal_C
if (!is_array($function)) {
$output = "<?php \$_smarty_tpl->smarty->_tag_stack[] = array('{$tag}', {$_params}); \$_block_repeat=true; {$function}({$_params}, null, \$_smarty_tpl->smarty, \$_block_repeat, \$_smarty_tpl);while (\$_block_repeat) { ob_start();?>";
} else if (is_object($function[0])) {
$output = "<?php \$_smarty_tpl->smarty->_tag_stack[] = array('{$tag}', {$_params}); \$_block_repeat=true; call_user_func_array(\$_smarty_tpl->smarty->registered_plugins['block']['{$tag}'][0],array({$_params}, null, \$_smarty_tpl->smarty, \$_block_repeat, \$_smarty_tpl));while (\$_block_repeat) { ob_start();?>";
$output = "<?php \$_smarty_tpl->smarty->_tag_stack[] = array('{$tag}', {$_params}); \$_block_repeat=true; call_user_func(\$_smarty_tpl->smarty->registered_plugins['block']['{$tag}'][0],{$_params}, null, \$_smarty_tpl->smarty, \$_block_repeat, \$_smarty_tpl);while (\$_block_repeat) { ob_start();?>";
} else {
$output = "<?php \$_smarty_tpl->smarty->_tag_stack[] = array('{$tag}', {$_params}); \$_block_repeat=true; call_user_func_array(array({$function[0]}','{$function[1]}'),array({$_params}, null, \$_smarty_tpl->smarty, \$_block_repeat, \$_smarty_tpl));while (\$_block_repeat) { ob_start();?>";
$output = "<?php \$_smarty_tpl->smarty->_tag_stack[] = array('{$tag}', {$_params}); \$_block_repeat=true; call_user_func(array('{$function[0]}','{$function[1]}'),{$_params}, null, \$_smarty_tpl->smarty, \$_block_repeat, \$_smarty_tpl);while (\$_block_repeat) { ob_start();?>";
}
} else {
// must endblock be nocache?
@@ -67,13 +67,13 @@ class Smarty_Internal_Compile_Private_Registered_Block extends Smarty_Internal_C
if (!is_array($function)) {
$output = "<?php \$_block_content = ob_get_clean(); \$_block_repeat=false; echo {$function}({$_params}, \$_block_content, \$_smarty_tpl->smarty, \$_block_repeat, \$_smarty_tpl); } array_pop(\$_smarty_tpl->smarty->_tag_stack);?>";
} else if (is_object($function[0])) {
$output = "<?php \$_block_content = ob_get_clean(); \$_block_repeat=false; echo call_user_func_array(\$_smarty_tpl->smarty->registered_plugins['block']['{$base_tag}'][0],array({$_params}, \$_block_content, \$_smarty_tpl->smarty, \$_block_repeat, \$_smarty_tpl)); } array_pop(\$_smarty_tpl->smarty->_tag_stack);?>";
$output = "<?php \$_block_content = ob_get_clean(); \$_block_repeat=false; echo call_user_func(\$_smarty_tpl->smarty->registered_plugins['block']['{$base_tag}'][0],{$_params}, \$_block_content, \$_smarty_tpl->smarty, \$_block_repeat, \$_smarty_tpl); } array_pop(\$_smarty_tpl->smarty->_tag_stack);?>";
} else {
$output = "<?php \$_block_content = ob_get_clean(); \$_block_repeat=false; echo call_user_func_array(array('{$function[0]}','{$function[1]}'),array({$_params}, \$_block_content, \$_smarty_tpl->smarty, \$_block_repeat, \$_smarty_tpl)); } array_pop(\$_smarty_tpl->smarty->_tag_stack);?>";
$output = "<?php \$_block_content = ob_get_clean(); \$_block_repeat=false; echo call_user_func(array('{$function[0]}','{$function[1]}'),{$_params}, \$_block_content, \$_smarty_tpl->smarty, \$_block_repeat, \$_smarty_tpl); } array_pop(\$_smarty_tpl->smarty->_tag_stack);?>";
}
}
return $output."\n";
}
}
?>
?>

View File

@@ -1,25 +1,25 @@
<?php
/**
* Smarty Internal Plugin Compile Registered Function
*
* Compiles code for the execution of a registered function
*
* @package Smarty
* @subpackage Compiler
* @author Uwe Tews
*/
* Smarty Internal Plugin Compile Registered Function
*
* Compiles code for the execution of a registered function
*
* @package Smarty
* @subpackage Compiler
* @author Uwe Tews
*/
/**
* Smarty Internal Plugin Compile Registered Function Class
*/
* Smarty Internal Plugin Compile Registered Function Class
*/
class Smarty_Internal_Compile_Private_Registered_Function extends Smarty_Internal_CompileBase {
/**
* Compiles code for the execution of a registered function
*
* @param array $args array with attributes from parser
* @param string $tag name of function
* @param object $compiler compiler object
* @return string compiled code
*/
* Compiles code for the execution of a registered function
*
* @param array $args array with attributes from parser
* @param string $tag name of function
* @param object $compiler compiler object
* @return string compiled code
*/
public function compile($args, $compiler, $tag)
{
$this->compiler = $compiler;
@@ -43,9 +43,17 @@ class Smarty_Internal_Compile_Private_Registered_Function extends Smarty_Interna
}
$_params = 'array(' . implode(",", $_paramsArray) . ')';
// compile code
$output = "<?php echo call_user_func_array(\$_smarty_tpl->smarty->registered_plugins['function']['{$tag}'][0],array({$_params},\$_smarty_tpl->smarty,\$_smarty_tpl));?>\n";
$function = $compiler->smarty->registered_plugins['function'][$tag][0];
// compile code
if (!is_array($function)) {
$output = "<?php echo {$function}({$_params},\$_smarty_tpl->smarty,\$_smarty_tpl);?>\n";
} else if (is_object($function[0])) {
$output = "<?php echo call_user_func(\$_smarty_tpl->smarty->registered_plugins['function']['{$tag}'][0],{$_params},\$_smarty_tpl->smarty,\$_smarty_tpl);?>\n";
} else {
$output = "<?php echo call_user_func(array('{$function[0]}','{$function[1]}'),{$_params},\$_smarty_tpl->smarty,\$_smarty_tpl);?>\n";
}
return $output;
}
}
?>
?>

View File

@@ -1,31 +1,31 @@
<?php
/**
* Smarty Internal Plugin Filter Handler
*
* Smarty filter handler class
*
* @package Smarty
* @subpackage PluginsInternal
* @author Uwe Tews
*/
* Smarty Internal Plugin Filter Handler
*
* Smarty filter handler class
*
* @package Smarty
* @subpackage PluginsInternal
* @author Uwe Tews
*/
/**
* Class for filter processing
*/
* Class for filter processing
*/
class Smarty_Internal_Filter_Handler {
/**
* 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' or 'variable') which shall run
* @param string $content the content which shall be processed by the filters
* @return string the filtered content
*/
* 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' or 'variable') which shall run
* @param string $content the content which shall be processed by the filters
* @return string the filtered content
*/
static function runFilter($type, $content, $smarty, $flag = null)
{
$output = $content;
@@ -35,13 +35,12 @@ class Smarty_Internal_Filter_Handler {
foreach ((array)$smarty->autoload_filters[$type] as $name) {
$plugin_name = "Smarty_{$type}filter_{$name}";
if ($smarty->loadPlugin($plugin_name)) {
// use class plugin if found
if (class_exists($plugin_name, false)) {
// loaded class of filter plugin
$output = call_user_func_array(array($plugin_name, 'execute'), array($output, $smarty));
} elseif (function_exists($plugin_name)) {
if (function_exists($plugin_name)) {
// use loaded Smarty2 style plugin
$output = call_user_func_array($plugin_name, array($output, $smarty));
$output = $plugin_name($output, $smarty);
} elseif (class_exists($plugin_name, false)) {
// loaded class of filter plugin
$output = call_user_func(array($plugin_name, 'execute'), $output, $smarty);
}
} else {
// nothing found, throw exception
@@ -52,7 +51,11 @@ class Smarty_Internal_Filter_Handler {
// loop over registerd filters of specified type
if (!empty($smarty->registered_filters[$type])) {
foreach ($smarty->registered_filters[$type] as $key => $name) {
$output = call_user_func_array($smarty->registered_filters[$type][$key], array($output, $smarty));
if (is_array($smarty->registered_filters[$type][$key])) {
$output = call_user_func($smarty->registered_filters[$type][$key], $output, $smarty);
} else {
$output = $smarty->registered_filters[$type][$key]($output, $smarty);
}
}
}
}
@@ -61,4 +64,4 @@ class Smarty_Internal_Filter_Handler {
}
}
?>
?>

View File

@@ -33,7 +33,7 @@ class Smarty_Internal_Resource_Registered {
*/
public function isExisting($_template)
{
if (is_integer($this->getTemplateTimestamp($_template))) {
if (is_integer($_template->getTemplateTimestamp())) {
return true;
} else {
return false;