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_parsetree_tag.php 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * Smarty Internal Plugin Templateparser Parse Tree
  4. * These are classes to build parse tree in the template parser
  5. *
  6. * @package Smarty
  7. * @subpackage Compiler
  8. * @author Thue Kristensen
  9. * @author Uwe Tews
  10. */
  11. /**
  12. * A complete smarty tag.
  13. *
  14. * @package Smarty
  15. * @subpackage Compiler
  16. * @ignore
  17. */
  18. class Smarty_Internal_ParseTree_Tag extends Smarty_Internal_ParseTree
  19. {
  20. /**
  21. * Saved block nesting level
  22. *
  23. * @var int
  24. */
  25. public $saved_block_nesting;
  26. /**
  27. * Create parse tree buffer for Smarty tag
  28. *
  29. * @param \Smarty_Internal_Templateparser $parser parser object
  30. * @param string $data content
  31. */
  32. public function __construct(Smarty_Internal_Templateparser $parser, $data)
  33. {
  34. $this->data = $data;
  35. $this->saved_block_nesting = $parser->block_nesting_level;
  36. }
  37. /**
  38. * Return buffer content
  39. *
  40. * @param \Smarty_Internal_Templateparser $parser
  41. *
  42. * @return string content
  43. */
  44. public function to_smarty_php(Smarty_Internal_Templateparser $parser)
  45. {
  46. return $this->data;
  47. }
  48. /**
  49. * Return complied code that loads the evaluated output of buffer content into a temporary variable
  50. *
  51. * @param \Smarty_Internal_Templateparser $parser
  52. *
  53. * @return string template code
  54. */
  55. public function assign_to_var(Smarty_Internal_Templateparser $parser)
  56. {
  57. $var = sprintf('$_tmp%d', ++ Smarty_Internal_Templateparser::$prefix_number);
  58. $tmp = $parser->compiler->appendCode('<?php ob_start();?>', $this->data);
  59. $tmp = $parser->compiler->appendCode($tmp, "<?php {$var}=ob_get_clean();?>");
  60. $parser->compiler->prefix_code[] = sprintf("%s", $tmp);
  61. return $var;
  62. }
  63. }