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

AbstractChooseOptimization.php

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


001  <?php
002   
003  /**
004  * @package   s9e\TextFormatter
005  * @copyright Copyright (c) 2010-2022 The s9e authors
006  * @license   http://www.opensource.org/licenses/mit-license.php The MIT License
007  */
008  namespace s9e\TextFormatter\Configurator\TemplateNormalizations;
009   
010  use DOMElement;
011  use DOMNode;
012   
013  abstract class AbstractChooseOptimization extends AbstractNormalization
014  {
015      /**
016      * @var DOMElement Current xsl:choose element
017      */
018      protected $choose;
019   
020      /**
021      * {@inheritdoc}
022      */
023      protected $queries = ['//xsl:choose'];
024   
025      /**
026      * Retrieve a list of attributes from given element
027      *
028      * @return array NamespaceURI#nodeName as keys, attribute values as values
029      */
030      protected function getAttributes(DOMElement $element)
031      {
032          $attributes = array();
033          foreach ($element->attributes as $attribute)
034          {
035              $key = $attribute->namespaceURI . '#' . $attribute->nodeName;
036              $attributes[$key] = $attribute->nodeValue;
037          }
038   
039          return $attributes;
040      }
041   
042      /**
043      * Return a list the xsl:when and xsl:otherwise children of current xsl:choose element
044      *
045      * @return DOMElement[]
046      */
047      protected function getBranches()
048      {
049          $query = 'xsl:when|xsl:otherwise';
050   
051          return $this->xpath($query, $this->choose);
052      }
053   
054      /**
055      * Test whether current xsl:choose element has an xsl:otherwise child
056      *
057      * @return bool
058      */
059      protected function hasOtherwise()
060      {
061          return (bool) $this->xpath->evaluate('count(xsl:otherwise)', $this->choose);
062      }
063   
064      /**
065      * Test whether current xsl:choose element has no content besides xsl:when and xsl:otherwise
066      *
067      * @return bool
068      */
069      protected function isEmpty()
070      {
071          $query = 'count(xsl:when/node() | xsl:otherwise/node())';
072   
073          return !$this->xpath->evaluate($query, $this->choose);
074      }
075   
076      /**
077      * Test whether two nodes are identical
078      *
079      * ext/dom does not support isEqualNode() from DOM Level 3 so this is a makeshift replacement.
080      * Unlike the DOM 3 function, attributes order matters
081      *
082      * @param  DOMNode $node1
083      * @param  DOMNode $node2
084      * @return bool
085      */
086      protected function isEqualNode(DOMNode $node1, DOMNode $node2)
087      {
088          return ($node1->ownerDocument->saveXML($node1) === $node2->ownerDocument->saveXML($node2));
089      }
090   
091      /**
092      * Test whether two elements have the same start tag
093      *
094      * @param  DOMElement $el1
095      * @param  DOMElement $el2
096      * @return bool
097      */
098      protected function isEqualTag(DOMElement $el1, DOMElement $el2)
099      {
100          return ($el1->namespaceURI === $el2->namespaceURI && $el1->nodeName === $el2->nodeName && $this->getAttributes($el1) === $this->getAttributes($el2));
101      }
102   
103      /**
104      * {@inheritdoc}
105      */
106      protected function normalizeElement(DOMElement $element)
107      {
108          $this->choose = $element;
109          $this->optimizeChoose();
110      }
111   
112      /**
113      * Optimize the current xsl:choose element
114      *
115      * @return void
116      */
117      abstract protected function optimizeChoose();
118   
119      /**
120      * {@inheritdoc}
121      */
122      protected function reset()
123      {
124          $this->choose = null;
125          parent::reset();
126      }
127  }