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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * Smarty Method MustCompile
  4. *
  5. * Smarty_Internal_Template::mustCompile() method
  6. *
  7. * @package Smarty
  8. * @subpackage PluginsInternal
  9. * @author Uwe Tews
  10. */
  11. class Smarty_Internal_Method_MustCompile
  12. {
  13. /**
  14. * Valid for template object
  15. *
  16. * @var int
  17. */
  18. public $objMap = 2;
  19. /**
  20. * Returns if the current template must be compiled by the Smarty compiler
  21. * It does compare the timestamps of template source and the compiled templates and checks the force compile
  22. * configuration
  23. *
  24. * @param \Smarty_Internal_Template $_template
  25. *
  26. * @return bool
  27. * @throws \SmartyException
  28. */
  29. public function mustCompile(Smarty_Internal_Template $_template)
  30. {
  31. if (!$_template->source->exists) {
  32. if ($_template->_isSubTpl()) {
  33. $parent_resource = " in '$_template->parent->template_resource}'";
  34. } else {
  35. $parent_resource = '';
  36. }
  37. throw new SmartyException("Unable to load template {$_template->source->type} '{$_template->source->name}'{$parent_resource}");
  38. }
  39. if ($_template->mustCompile === null) {
  40. $_template->mustCompile = (!$_template->source->handler->uncompiled &&
  41. ($_template->smarty->force_compile || $_template->source->handler->recompiled ||
  42. !$_template->compiled->exists || ($_template->compile_check &&
  43. $_template->compiled->getTimeStamp() <
  44. $_template->source->getTimeStamp())));
  45. }
  46. return $_template->mustCompile;
  47. }
  48. }