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.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

NormalizeElementNames.php

Zuletzt modifiziert: 02.04.2025, 15:04 - Dateigröße: 1.92 KiB


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 NormalizeElementNames extends AbstractNormalization
13  {
14      /**
15      * {@inheritdoc}
16      */
17      protected $queries = [
18          '//*[namespace-uri() != $XSL]',
19          '//xsl:element[not(contains(@name, "{"))]'
20      ];
21   
22      /**
23      * {@inheritdoc}
24      */
25      protected function normalizeElement(DOMElement $element)
26      {
27          if ($this->isXsl($element, 'element'))
28          {
29              $this->replaceXslElement($element);
30          }
31          else
32          {
33              $this->replaceElement($element);
34          }
35      }
36   
37      /**
38      * Normalize and replace a non-XSL element if applicable
39      *
40      * @param  DOMElement $element
41      * @return void
42      */
43      protected function replaceElement(DOMElement $element)
44      {
45          $elName = $this->lowercase($element->localName);
46          if ($elName === $element->localName)
47          {
48              return;
49          }
50   
51          // Create a new element with the correct name
52          $newElement = (is_null($element->namespaceURI))
53                      ? $this->ownerDocument->createElement($elName)
54                      : $this->ownerDocument->createElementNS($element->namespaceURI, $elName);
55   
56          // Move every child to the new element
57          while ($element->firstChild)
58          {
59              $newElement->appendChild($element->removeChild($element->firstChild));
60          }
61   
62          // Copy attributes to the new node
63          foreach ($element->attributes as $attribute)
64          {
65              $newElement->setAttributeNS(
66                  $attribute->namespaceURI,
67                  $attribute->nodeName,
68                  $attribute->value
69              );
70          }
71   
72          // Replace the old element with the new one
73          $element->parentNode->replaceChild($newElement, $element);
74      }
75   
76      /**
77      * Normalize the name used in a xsl:element
78      *
79      * @param  DOMElement $element
80      * @return void
81      */
82      protected function replaceXslElement(DOMElement $element)
83      {
84          $elName = $this->lowercase($element->getAttribute('name'));
85          $element->setAttribute('name', $elName);
86      }
87  }