smarty_internal_compile_make_nocache.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * Smarty Internal Plugin Compile Make_Nocache
  4. * Compiles the {make_nocache} tag
  5. *
  6. * @package Smarty
  7. * @subpackage Compiler
  8. * @author Uwe Tews
  9. */
  10. /**
  11. * Smarty Internal Plugin Compile Make_Nocache Class
  12. *
  13. * @package Smarty
  14. * @subpackage Compiler
  15. */
  16. class Smarty_Internal_Compile_Make_Nocache extends Smarty_Internal_CompileBase
  17. {
  18. /**
  19. * Attribute definition: Overwrites base class.
  20. *
  21. * @var array
  22. * @see Smarty_Internal_CompileBase
  23. */
  24. public $option_flags = array();
  25. /**
  26. * Array of names of required attribute required by tag
  27. *
  28. * @var array
  29. */
  30. public $required_attributes = array('var');
  31. /**
  32. * Shorttag attribute order defined by its names
  33. *
  34. * @var array
  35. */
  36. public $shorttag_order = array('var');
  37. /**
  38. * Compiles code for the {make_nocache} tag
  39. *
  40. * @param array $args array with attributes from parser
  41. * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
  42. * @param array $parameter array with compilation parameter
  43. *
  44. * @return string compiled code
  45. * @throws \SmartyCompilerException
  46. */
  47. public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
  48. {
  49. // check and get attributes
  50. $_attr = $this->getAttributes($compiler, $args);
  51. if ($compiler->template->caching) {
  52. $output = "<?php \$_smarty_tpl->smarty->ext->_make_nocache->save(\$_smarty_tpl, {$_attr[ 'var' ]});\n?>\n";
  53. $compiler->has_code = true;
  54. $compiler->suppressNocacheProcessing = true;
  55. return $output;
  56. } else {
  57. return true;
  58. }
  59. }
  60. }