Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

smarty_internal_compile_private_registered_block.php 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * Smarty Internal Plugin Compile Registered Block
  4. * Compiles code for the execution of a registered block function
  5. *
  6. * @package Smarty
  7. * @subpackage Compiler
  8. * @author Uwe Tews
  9. */
  10. /**
  11. * Smarty Internal Plugin Compile Registered Block Class
  12. *
  13. * @package Smarty
  14. * @subpackage Compiler
  15. */
  16. class Smarty_Internal_Compile_Private_Registered_Block extends Smarty_Internal_Compile_Private_Block_Plugin
  17. {
  18. /**
  19. * Setup callback, parameter array and nocache mode
  20. *
  21. * @param \Smarty_Internal_TemplateCompilerBase $compiler
  22. * @param array $_attr attributes
  23. * @param string $tag
  24. * @param null $function
  25. *
  26. * @return array
  27. */
  28. public function setup(Smarty_Internal_TemplateCompilerBase $compiler, $_attr, $tag, $function)
  29. {
  30. if (isset($compiler->smarty->registered_plugins[ Smarty::PLUGIN_BLOCK ][ $tag ])) {
  31. $tag_info = $compiler->smarty->registered_plugins[ Smarty::PLUGIN_BLOCK ][ $tag ];
  32. $callback = $tag_info[ 0 ];
  33. if (is_array($callback)) {
  34. if (is_object($callback[ 0 ])) {
  35. $callable = "array(\$_block_plugin{$this->nesting}, '{$callback[1]}')";
  36. $callback =
  37. array("\$_smarty_tpl->smarty->registered_plugins['block']['{$tag}'][0][0]", "->{$callback[1]}");
  38. } else {
  39. $callable = "array(\$_block_plugin{$this->nesting}, '{$callback[1]}')";
  40. $callback =
  41. array("\$_smarty_tpl->smarty->registered_plugins['block']['{$tag}'][0][0]", "::{$callback[1]}");
  42. }
  43. } else {
  44. $callable = "\$_block_plugin{$this->nesting}";
  45. $callback = array("\$_smarty_tpl->smarty->registered_plugins['block']['{$tag}'][0]", '');
  46. }
  47. } else {
  48. $tag_info = $compiler->default_handler_plugins[ Smarty::PLUGIN_BLOCK ][ $tag ];
  49. $callback = $tag_info[ 0 ];
  50. if (is_array($callback)) {
  51. $callable = "array('{$callback[0]}', '{$callback[1]}')";
  52. $callback = "{$callback[1]}::{$callback[1]}";
  53. } else {
  54. $callable = null;
  55. }
  56. }
  57. $compiler->tag_nocache = !$tag_info[ 1 ] | $compiler->tag_nocache;
  58. $_paramsArray = array();
  59. foreach ($_attr as $_key => $_value) {
  60. if (is_int($_key)) {
  61. $_paramsArray[] = "$_key=>$_value";
  62. } elseif ($compiler->template->caching && in_array($_key, $tag_info[ 2 ])) {
  63. $_value = str_replace('\'', "^#^", $_value);
  64. $_paramsArray[] = "'$_key'=>^#^.var_export($_value,true).^#^";
  65. } else {
  66. $_paramsArray[] = "'$_key'=>$_value";
  67. }
  68. }
  69. return array($callback, $_paramsArray, $callable);
  70. }
  71. }