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_gettags.php 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * Smarty Method GetTags
  4. *
  5. * Smarty::getTags() method
  6. *
  7. * @package Smarty
  8. * @subpackage PluginsInternal
  9. * @author Uwe Tews
  10. */
  11. class Smarty_Internal_Method_GetTags
  12. {
  13. /**
  14. * Valid for Smarty and template object
  15. *
  16. * @var int
  17. */
  18. public $objMap = 3;
  19. /**
  20. * Return array of tag/attributes of all tags used by an template
  21. *
  22. * @api Smarty::getTags()
  23. * @link http://www.smarty.net/docs/en/api.get.tags.tpl
  24. *
  25. * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
  26. * @param null|string|Smarty_Internal_Template $template
  27. *
  28. * @return array of tag/attributes
  29. * @throws \SmartyException
  30. */
  31. public function getTags(Smarty_Internal_TemplateBase $obj, $template = null)
  32. {
  33. /* @var Smarty $smarty */
  34. $smarty = isset($this->smarty) ? $this->smarty : $obj;
  35. if ($obj->_objType == 2 && !isset($template)) {
  36. $tpl = clone $obj;
  37. } elseif (isset($template) && $template->_objType == 2) {
  38. $tpl = clone $template;
  39. } elseif (isset($template) && is_string($template)) {
  40. /* @var Smarty_Internal_Template $tpl */
  41. $tpl = new $smarty->template_class($template, $smarty);
  42. // checks if template exists
  43. if (!$tpl->source->exists) {
  44. throw new SmartyException("Unable to load template {$tpl->source->type} '{$tpl->source->name}'");
  45. }
  46. }
  47. if (isset($tpl)) {
  48. $tpl->smarty = clone $tpl->smarty;
  49. $tpl->smarty->_cache['get_used_tags'] = true;
  50. $tpl->_cache['used_tags'] = array();
  51. $tpl->smarty->merge_compiled_includes = false;
  52. $tpl->smarty->disableSecurity();
  53. $tpl->caching = false;
  54. $tpl->loadCompiler();
  55. $tpl->compiler->compileTemplate($tpl);
  56. return $tpl->_cache['used_tags'];
  57. }
  58. throw new SmartyException("Missing template specification");
  59. }
  60. }