You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

smarty_internal_compile_call.php 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /**
  3. * Smarty Internal Plugin Compile Function_Call
  4. * Compiles the calls of user defined tags defined by {function}
  5. *
  6. * @package Smarty
  7. * @subpackage Compiler
  8. * @author Uwe Tews
  9. */
  10. /**
  11. * Smarty Internal Plugin Compile Function_Call Class
  12. *
  13. * @package Smarty
  14. * @subpackage Compiler
  15. */
  16. class Smarty_Internal_Compile_Call extends Smarty_Internal_CompileBase
  17. {
  18. /**
  19. * Attribute definition: Overwrites base class.
  20. *
  21. * @var array
  22. * @see Smarty_Internal_CompileBase
  23. */
  24. public $required_attributes = array('name');
  25. /**
  26. * Attribute definition: Overwrites base class.
  27. *
  28. * @var array
  29. * @see Smarty_Internal_CompileBase
  30. */
  31. public $shorttag_order = array('name');
  32. /**
  33. * Attribute definition: Overwrites base class.
  34. *
  35. * @var array
  36. * @see Smarty_Internal_CompileBase
  37. */
  38. public $optional_attributes = array('_any');
  39. /**
  40. * Compiles the calls of user defined tags defined by {function}
  41. *
  42. * @param array $args array with attributes from parser
  43. * @param object $compiler compiler object
  44. *
  45. * @return string compiled code
  46. */
  47. public function compile($args, $compiler)
  48. {
  49. // check and get attributes
  50. $_attr = $this->getAttributes($compiler, $args);
  51. // save possible attributes
  52. if (isset($_attr[ 'assign' ])) {
  53. // output will be stored in a smarty variable instead of being displayed
  54. $_assign = $_attr[ 'assign' ];
  55. }
  56. //$_name = trim($_attr['name'], "''");
  57. $_name = $_attr[ 'name' ];
  58. unset($_attr[ 'name' ], $_attr[ 'assign' ], $_attr[ 'nocache' ]);
  59. // set flag (compiled code of {function} must be included in cache file
  60. if (!$compiler->template->caching || $compiler->nocache || $compiler->tag_nocache) {
  61. $_nocache = 'true';
  62. } else {
  63. $_nocache = 'false';
  64. }
  65. $_paramsArray = array();
  66. foreach ($_attr as $_key => $_value) {
  67. if (is_int($_key)) {
  68. $_paramsArray[] = "$_key=>$_value";
  69. } else {
  70. $_paramsArray[] = "'$_key'=>$_value";
  71. }
  72. }
  73. $_params = 'array(' . implode(',', $_paramsArray) . ')';
  74. //$compiler->suppressNocacheProcessing = true;
  75. // was there an assign attribute
  76. if (isset($_assign)) {
  77. $_output =
  78. "<?php ob_start();\n\$_smarty_tpl->smarty->ext->_tplFunction->callTemplateFunction(\$_smarty_tpl, {$_name}, {$_params}, {$_nocache});\n\$_smarty_tpl->assign({$_assign}, ob_get_clean());?>\n";
  79. } else {
  80. $_output =
  81. "<?php \$_smarty_tpl->smarty->ext->_tplFunction->callTemplateFunction(\$_smarty_tpl, {$_name}, {$_params}, {$_nocache});?>\n";
  82. }
  83. return $_output;
  84. }
  85. }