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_append.php 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * Smarty Internal Plugin Compile Append
  4. * Compiles the {append} tag
  5. *
  6. * @package Smarty
  7. * @subpackage Compiler
  8. * @author Uwe Tews
  9. */
  10. /**
  11. * Smarty Internal Plugin Compile Append Class
  12. *
  13. * @package Smarty
  14. * @subpackage Compiler
  15. */
  16. class Smarty_Internal_Compile_Append extends Smarty_Internal_Compile_Assign
  17. {
  18. /**
  19. * Compiles code for the {append} tag
  20. *
  21. * @param array $args array with attributes from parser
  22. * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
  23. * @param array $parameter array with compilation parameter
  24. *
  25. * @return string compiled code
  26. * @throws \SmartyCompilerException
  27. */
  28. public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
  29. {
  30. // the following must be assigned at runtime because it will be overwritten in parent class
  31. $this->required_attributes = array('var', 'value');
  32. $this->shorttag_order = array('var', 'value');
  33. $this->optional_attributes = array('scope', 'index');
  34. $this->mapCache = array();
  35. // check and get attributes
  36. $_attr = $this->getAttributes($compiler, $args);
  37. // map to compile assign attributes
  38. if (isset($_attr[ 'index' ])) {
  39. $_params[ 'smarty_internal_index' ] = '[' . $_attr[ 'index' ] . ']';
  40. unset($_attr[ 'index' ]);
  41. } else {
  42. $_params[ 'smarty_internal_index' ] = '[]';
  43. }
  44. $_new_attr = array();
  45. foreach ($_attr as $key => $value) {
  46. $_new_attr[] = array($key => $value);
  47. }
  48. // call compile assign
  49. return parent::compile($_new_attr, $compiler, $_params);
  50. }
  51. }