[ Index ] |
PHP Cross Reference of phpBB-3.3.14-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package s9e\TextFormatter 5 * @copyright Copyright (c) 2010-2022 The s9e authors 6 * @license http://www.opensource.org/licenses/mit-license.php The MIT License 7 */ 8 namespace s9e\TextFormatter\Configurator\TemplateChecks; 9 10 use DOMElement; 11 use DOMXPath; 12 use s9e\TextFormatter\Configurator\Exceptions\UnsafeTemplateException; 13 use s9e\TextFormatter\Configurator\Items\Tag; 14 use s9e\TextFormatter\Configurator\TemplateCheck; 15 16 class DisallowElement extends TemplateCheck 17 { 18 /** 19 * @var string Local name of the disallowed element 20 */ 21 public $elName; 22 23 /** 24 * Constructor 25 * 26 * @param string $elName Local name of the disallowed element 27 */ 28 public function __construct($elName) 29 { 30 // NOTE: the default template normalization rules force elements' names to be lowercase 31 $this->elName = strtolower($elName); 32 } 33 34 /** 35 * Test for the presence of an element of given name 36 * 37 * @param DOMElement $template <xsl:template/> node 38 * @param Tag $tag Tag this template belongs to 39 * @return void 40 */ 41 public function check(DOMElement $template, Tag $tag) 42 { 43 $xpath = new DOMXPath($template->ownerDocument); 44 $query 45 = '//*[translate(local-name(), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz") = "' . $this->elName . '"]' 46 . '|' 47 . '//xsl:element[translate(@name,"ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz") = "' . $this->elName . '"]'; 48 49 $node = $xpath->query($query)->item(0); 50 if ($node) 51 { 52 throw new UnsafeTemplateException("Element '" . $this->elName . "' is disallowed", $node); 53 } 54 } 55 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Mon Nov 25 19:05:08 2024 | Cross-referenced by PHPXref 0.7.1 |