smarty_internal_compile_append.php 1.5 KB

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