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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 \Exception
  30. * @throws \SmartyException
  31. */
  32. public function getTags(Smarty_Internal_TemplateBase $obj, $template = null)
  33. {
  34. /* @var Smarty $smarty */
  35. $smarty = $obj->_getSmartyObj();
  36. if ($obj->_isTplObj() && !isset($template)) {
  37. $tpl = clone $obj;
  38. } elseif (isset($template) && $template->_isTplObj()) {
  39. $tpl = clone $template;
  40. } elseif (isset($template) && is_string($template)) {
  41. /* @var Smarty_Internal_Template $tpl */
  42. $tpl = new $smarty->template_class($template, $smarty);
  43. // checks if template exists
  44. if (!$tpl->source->exists) {
  45. throw new SmartyException("Unable to load template {$tpl->source->type} '{$tpl->source->name}'");
  46. }
  47. }
  48. if (isset($tpl)) {
  49. $tpl->smarty = clone $tpl->smarty;
  50. $tpl->smarty->_cache[ 'get_used_tags' ] = true;
  51. $tpl->_cache[ 'used_tags' ] = array();
  52. $tpl->smarty->merge_compiled_includes = false;
  53. $tpl->smarty->disableSecurity();
  54. $tpl->caching = Smarty::CACHING_OFF;
  55. $tpl->loadCompiler();
  56. $tpl->compiler->compileTemplate($tpl);
  57. return $tpl->_cache[ 'used_tags' ];
  58. }
  59. throw new SmartyException('Missing template specification');
  60. }
  61. }