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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * Smarty Internal Plugin Nocache Insert
  4. * Compiles the {insert} tag into the cache file
  5. *
  6. * @package Smarty
  7. * @subpackage Compiler
  8. * @author Uwe Tews
  9. */
  10. /**
  11. * Smarty Internal Plugin Compile Insert Class
  12. *
  13. * @package Smarty
  14. * @subpackage Compiler
  15. */
  16. class Smarty_Internal_Nocache_Insert
  17. {
  18. /**
  19. * Compiles code for the {insert} tag into cache file
  20. *
  21. * @param string $_function insert function name
  22. * @param array $_attr array with parameter
  23. * @param Smarty_Internal_Template $_template template object
  24. * @param string $_script script name to load or 'null'
  25. * @param string $_assign optional variable name
  26. *
  27. * @return string compiled code
  28. */
  29. public static function compile($_function, $_attr, $_template, $_script, $_assign = null)
  30. {
  31. $_output = '<?php ';
  32. if ($_script != 'null') {
  33. // script which must be included
  34. // code for script file loading
  35. $_output .= "require_once '{$_script}';";
  36. }
  37. // call insert
  38. if (isset($_assign)) {
  39. $_output .= "\$_smarty_tpl->assign('{$_assign}' , {$_function} (" . var_export($_attr, true) . ",\$_smarty_tpl), true);?>";
  40. } else {
  41. $_output .= "echo {$_function}(" . var_export($_attr, true) . ",\$_smarty_tpl);?>";
  42. }
  43. $_tpl = $_template;
  44. while (isset($_tpl->parent) && $_tpl->parent->_objType == 2) {
  45. $_tpl = $_tpl->parent;
  46. }
  47. return "/*%%SmartyNocache:{$_tpl->compiled->nocache_hash}%%*/" . $_output . "/*/%%SmartyNocache:{$_tpl->compiled->nocache_hash}%%*/";
  48. }
  49. }