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_private_function_plugin.php 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * Smarty Internal Plugin Compile Function Plugin
  4. * Compiles code for the execution of function plugin
  5. *
  6. * @package Smarty
  7. * @subpackage Compiler
  8. * @author Uwe Tews
  9. */
  10. /**
  11. * Smarty Internal Plugin Compile Function Plugin Class
  12. *
  13. * @package Smarty
  14. * @subpackage Compiler
  15. */
  16. class Smarty_Internal_Compile_Private_Function_Plugin 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();
  25. /**
  26. * Attribute definition: Overwrites base class.
  27. *
  28. * @var array
  29. * @see Smarty_Internal_CompileBase
  30. */
  31. public $optional_attributes = array('_any');
  32. /**
  33. * Compiles code for the execution of function plugin
  34. *
  35. * @param array $args array with attributes from parser
  36. * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
  37. * @param array $parameter array with compilation parameter
  38. * @param string $tag name of function plugin
  39. * @param string $function PHP function name
  40. *
  41. * @return string compiled code
  42. */
  43. public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter, $tag, $function)
  44. {
  45. // This tag does create output
  46. $compiler->has_output = true;
  47. // check and get attributes
  48. $_attr = $this->getAttributes($compiler, $args);
  49. if ($_attr['nocache'] === true) {
  50. $compiler->tag_nocache = true;
  51. }
  52. unset($_attr['nocache']);
  53. // convert attributes into parameter array string
  54. $_paramsArray = array();
  55. foreach ($_attr as $_key => $_value) {
  56. if (is_int($_key)) {
  57. $_paramsArray[] = "$_key=>$_value";
  58. } else {
  59. $_paramsArray[] = "'$_key'=>$_value";
  60. }
  61. }
  62. $_params = 'array(' . implode(",", $_paramsArray) . ')';
  63. // compile code
  64. $output = "<?php echo {$function}({$_params},\$_smarty_tpl);?>\n";
  65. return $output;
  66. }
  67. }