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 |
InlineTextElements.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 DOMElement;
11
12 class InlineTextElements extends AbstractNormalization
13 {
14 /**
15 * {@inheritdoc}
16 */
17 protected $queries = ['//xsl:text[not(@disable-output-escaping="yes")]'];
18
19 /**
20 * Test whether an element is followed by a text node
21 *
22 * @param DOMElement $element
23 * @return bool
24 */
25 protected function isFollowedByText(DOMElement $element)
26 {
27 return ($element->nextSibling && $element->nextSibling->nodeType === XML_TEXT_NODE);
28 }
29
30 /**
31 * Test whether an element is preceded by a text node
32 *
33 * @param DOMElement $element
34 * @return bool
35 */
36 protected function isPrecededByText(DOMElement $element)
37 {
38 return ($element->previousSibling && $element->previousSibling->nodeType === XML_TEXT_NODE);
39 }
40
41 /**
42 * {@inheritdoc}
43 */
44 protected function normalizeElement(DOMElement $element)
45 {
46 // If this node's content is whitespace, ensure it's preceded or followed by a text node
47 if (trim($element->textContent) === '')
48 {
49 if (!$this->isFollowedByText($element) && !$this->isPrecededByText($element))
50 {
51 // This would become inter-element whitespace, therefore we can't inline
52 return;
53 }
54 }
55 $element->parentNode->replaceChild($this->createTextNode($element->textContent), $element);
56 }
57 }