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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * Smarty Internal Plugin Compile Shared Inheritance
  4. * Shared methods for {extends} and {block} tags
  5. *
  6. * @package Smarty
  7. * @subpackage Compiler
  8. * @author Uwe Tews
  9. */
  10. /**
  11. * Smarty Internal Plugin Compile Shared Inheritance Class
  12. *
  13. * @package Smarty
  14. * @subpackage Compiler
  15. */
  16. class Smarty_Internal_Compile_Shared_Inheritance extends Smarty_Internal_CompileBase
  17. {
  18. /**
  19. * Compile inheritance initialization code as prefix
  20. *
  21. * @param \Smarty_Internal_TemplateCompilerBase $compiler
  22. * @param bool|false $initChildSequence if true force child template
  23. */
  24. static function postCompile(Smarty_Internal_TemplateCompilerBase $compiler, $initChildSequence = false)
  25. {
  26. $compiler->prefixCompiledCode .= "<?php \$_smarty_tpl->_loadInheritance();\n\$_smarty_tpl->inheritance->init(\$_smarty_tpl, " .
  27. var_export($initChildSequence, true) . ");\n?>\n";
  28. }
  29. /**
  30. * Register post compile callback to compile inheritance initialization code
  31. *
  32. * @param \Smarty_Internal_TemplateCompilerBase $compiler
  33. * @param bool|false $initChildSequence if true force child template
  34. */
  35. public function registerInit(Smarty_Internal_TemplateCompilerBase $compiler, $initChildSequence = false)
  36. {
  37. if ($initChildSequence || !isset($compiler->_cache['inheritanceInit'])) {
  38. $compiler->registerPostCompileCallback(array('Smarty_Internal_Compile_Shared_Inheritance', 'postCompile'),
  39. array($initChildSequence),
  40. 'inheritanceInit',
  41. $initChildSequence);
  42. $compiler->_cache['inheritanceInit'] = true;
  43. }
  44. }
  45. }