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.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /**
  3. * Smarty Resource Plugin
  4. *
  5. * @package Smarty
  6. * @subpackage TemplateResources
  7. * @author Rodney Rehm
  8. */
  9. /**
  10. * Smarty Resource Plugin
  11. * Base implementation for resource plugins that don't compile cache
  12. *
  13. * @package Smarty
  14. * @subpackage TemplateResources
  15. */
  16. abstract class Smarty_Resource_Recompiled extends Smarty_Resource
  17. {
  18. /**
  19. * Flag that it's an recompiled resource
  20. *
  21. * @var bool
  22. */
  23. public $recompiled = true;
  24. /**
  25. * Resource does implement populateCompiledFilepath() method
  26. *
  27. * @var bool
  28. */
  29. public $hasCompiledHandler = true;
  30. /**
  31. * compile template from source
  32. *
  33. * @param Smarty_Internal_Template $_smarty_tpl do not change variable name, is used by compiled template
  34. *
  35. * @throws Exception
  36. */
  37. public function process(Smarty_Internal_Template $_smarty_tpl)
  38. {
  39. $compiled = &$_smarty_tpl->compiled;
  40. $compiled->file_dependency = array();
  41. $compiled->includes = array();
  42. $compiled->nocache_hash = null;
  43. $compiled->unifunc = null;
  44. $level = ob_get_level();
  45. ob_start();
  46. $_smarty_tpl->loadCompiler();
  47. // call compiler
  48. try {
  49. eval('?>' . $_smarty_tpl->compiler->compileTemplate($_smarty_tpl));
  50. }
  51. catch (Exception $e) {
  52. unset($_smarty_tpl->compiler);
  53. while (ob_get_level() > $level) {
  54. ob_end_clean();
  55. }
  56. throw $e;
  57. }
  58. // release compiler object to free memory
  59. unset($_smarty_tpl->compiler);
  60. ob_get_clean();
  61. $compiled->timestamp = time();
  62. $compiled->exists = true;
  63. }
  64. /**
  65. * populate Compiled Object with compiled filepath
  66. *
  67. * @param Smarty_Template_Compiled $compiled compiled object
  68. * @param Smarty_Internal_Template $_template template object
  69. *
  70. * @return void
  71. */
  72. public function populateCompiledFilepath(Smarty_Template_Compiled $compiled, Smarty_Internal_Template $_template)
  73. {
  74. $compiled->filepath = false;
  75. $compiled->timestamp = false;
  76. $compiled->exists = false;
  77. }
  78. /*
  79. * Disable timestamp checks for recompiled resource.
  80. *
  81. * @return bool
  82. */
  83. /**
  84. * @return bool
  85. */
  86. public function checkTimestamps()
  87. {
  88. return false;
  89. }
  90. }