[ Index ] |
PHP Cross Reference of phpBB-3.3.12-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\TemplateNormalizations; 9 10 use DOMAttr; 11 use DOMElement; 12 use s9e\TextFormatter\Configurator\Helpers\AVTHelper; 13 14 class InlineXPathLiterals extends AbstractNormalization 15 { 16 /** 17 * {@inheritdoc} 18 */ 19 protected $queries = [ 20 '//xsl:value-of', 21 '//*[namespace-uri() != $XSL]/@*[contains(., "{")]' 22 ]; 23 24 /** 25 * Return the textContent value of an XPath expression 26 * 27 * @param string $expr XPath expression 28 * @return string|bool Text value, or FALSE if not a literal 29 */ 30 protected function getTextContent($expr) 31 { 32 $regexp = '(^(?|\'([^\']*)\'|"([^"]*)"|0*([0-9]+(?:\\.[0-9]+)?)|(false|true)\\s*\\(\\s*\\))$)'; 33 if (preg_match($regexp, trim($expr), $m)) 34 { 35 return $m[1]; 36 } 37 38 return false; 39 } 40 41 /** 42 * {@inheritdoc} 43 */ 44 protected function normalizeAttribute(DOMAttr $attribute) 45 { 46 AVTHelper::replace( 47 $attribute, 48 function ($token) 49 { 50 if ($token[0] === 'expression') 51 { 52 $textContent = $this->getTextContent($token[1]); 53 if ($textContent !== false) 54 { 55 // Turn this token into a literal 56 $token = ['literal', $textContent]; 57 } 58 } 59 60 return $token; 61 } 62 ); 63 } 64 65 /** 66 * {@inheritdoc} 67 */ 68 protected function normalizeElement(DOMElement $element) 69 { 70 $textContent = $this->getTextContent($element->getAttribute('select')); 71 if ($textContent !== false) 72 { 73 $element->parentNode->replaceChild($this->createText($textContent), $element); 74 } 75 } 76 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Jun 23 12:25:44 2024 | Cross-referenced by PHPXref 0.7.1 |