Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
InlineXPathLiterals.php
01 <?php
02
03 /**
04 * @package s9e\TextFormatter
05 * @copyright Copyright (c) 2010-2022 The s9e authors
06 * @license http://www.opensource.org/licenses/mit-license.php The MIT License
07 */
08 namespace s9e\TextFormatter\Configurator\TemplateNormalizations;
09
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 }