IP/libs/sysplugins/smarty_internal_compile_private_registered_block.php

73 lines
2.9 KiB
PHP
Raw Permalink Normal View History

2014-04-01 18:38:34 +00:00
<?php
/**
* Smarty Internal Plugin Compile Registered Block
* Compiles code for the execution of a registered block function
*
2014-10-13 09:24:53 +00:00
* @package Smarty
2014-04-01 18:38:34 +00:00
* @subpackage Compiler
2014-10-13 09:24:53 +00:00
* @author Uwe Tews
2014-04-01 18:38:34 +00:00
*/
/**
* Smarty Internal Plugin Compile Registered Block Class
*
2014-10-13 09:24:53 +00:00
* @package Smarty
2014-04-01 18:38:34 +00:00
* @subpackage Compiler
*/
class Smarty_Internal_Compile_Private_Registered_Block extends Smarty_Internal_Compile_Private_Block_Plugin
2014-04-01 18:38:34 +00:00
{
/**
* Setup callback, parameter array and nocache mode
2014-04-01 18:38:34 +00:00
*
* @param \Smarty_Internal_TemplateCompilerBase $compiler
* @param array $_attr attributes
* @param string $tag
* @param null $function
2014-10-13 09:24:53 +00:00
*
* @return array
2014-04-01 18:38:34 +00:00
*/
public function setup(Smarty_Internal_TemplateCompilerBase $compiler, $_attr, $tag, $function)
2014-04-01 18:38:34 +00:00
{
if (isset($compiler->smarty->registered_plugins[ Smarty::PLUGIN_BLOCK ][ $tag ])) {
$tag_info = $compiler->smarty->registered_plugins[ Smarty::PLUGIN_BLOCK ][ $tag ];
$callback = $tag_info[ 0 ];
if (is_array($callback)) {
if (is_object($callback[ 0 ])) {
$callable = "array(\$_block_plugin{$this->nesting}, '{$callback[1]}')";
$callback =
array("\$_smarty_tpl->smarty->registered_plugins['block']['{$tag}'][0][0]", "->{$callback[1]}");
2014-04-01 18:38:34 +00:00
} else {
$callable = "array(\$_block_plugin{$this->nesting}, '{$callback[1]}')";
$callback =
array("\$_smarty_tpl->smarty->registered_plugins['block']['{$tag}'][0][0]", "::{$callback[1]}");
2014-04-01 18:38:34 +00:00
}
} else {
$callable = "\$_block_plugin{$this->nesting}";
$callback = array("\$_smarty_tpl->smarty->registered_plugins['block']['{$tag}'][0]", '');
2014-04-01 18:38:34 +00:00
}
} else {
$tag_info = $compiler->default_handler_plugins[ Smarty::PLUGIN_BLOCK ][ $tag ];
$callback = $tag_info[ 0 ];
if (is_array($callback)) {
$callable = "array('{$callback[0]}', '{$callback[1]}')";
$callback = "{$callback[1]}::{$callback[1]}";
2014-10-13 09:24:53 +00:00
} else {
$callable = null;
2014-10-13 09:24:53 +00:00
}
}
$compiler->tag_nocache = !$tag_info[ 1 ] | $compiler->tag_nocache;
$_paramsArray = array();
foreach ($_attr as $_key => $_value) {
if (is_int($_key)) {
$_paramsArray[] = "$_key=>$_value";
} elseif ($compiler->template->caching && in_array($_key, $tag_info[ 2 ])) {
$_value = str_replace("'", "^#^", $_value);
$_paramsArray[] = "'$_key'=>^#^.var_export($_value,true).^#^";
2014-04-01 18:38:34 +00:00
} else {
$_paramsArray[] = "'$_key'=>$_value";
2014-04-01 18:38:34 +00:00
}
}
return array($callback, $_paramsArray, $callable);
2014-04-01 18:38:34 +00:00
}
}