Verzeichnisstruktur phpBB-3.3.16


Veröffentlicht
27.04.2026

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

Configurator.php

Zuletzt modifiziert: 01.05.2026, 11:28 - Dateigröße: 5.92 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\Plugins\Litedown;
 009   
 010  use s9e\TextFormatter\Configurator\Items\Tag;
 011  use s9e\TextFormatter\Plugins\ConfiguratorBase;
 012  use s9e\TextFormatter\Plugins\Litedown\Parser\Slugger;
 013   
 014  class Configurator extends ConfiguratorBase
 015  {
 016      /**
 017      * @var bool Whether to decode HTML entities in attribute values
 018      */
 019      public $decodeHtmlEntities = false;
 020   
 021      /**
 022      * @var array Default tags
 023      */
 024      protected $tags = [
 025          'C'      => '<code><xsl:apply-templates/></code>',
 026          'CODE'   => [
 027              'attributes' => [
 028                  'lang' => [
 029                      'filterChain' => ['#simpletext'],
 030                      'required'    => false
 031                  ]
 032              ],
 033              'template' =>
 034                  '<pre>
 035                      <code>
 036                          <xsl:if test="@lang">
 037                              <xsl:attribute name="class">
 038                                  <xsl:text>language-</xsl:text>
 039                                  <xsl:value-of select="@lang"/>
 040                              </xsl:attribute>
 041                          </xsl:if>
 042                          <xsl:apply-templates/>
 043                      </code>
 044                  </pre>'
 045          ],
 046          'DEL'    => '<del><xsl:apply-templates/></del>',
 047          'EM'     => '<em><xsl:apply-templates/></em>',
 048          'EMAIL'  => [
 049              'attributes' => ['email' => ['filterChain' => ['#email']]],
 050              'template'   => '<a href="mailto:{@email}"><xsl:apply-templates/></a>'
 051          ],
 052          'H1'     => '<h1><xsl:apply-templates/></h1>',
 053          'H2'     => '<h2><xsl:apply-templates/></h2>',
 054          'H3'     => '<h3><xsl:apply-templates/></h3>',
 055          'H4'     => '<h4><xsl:apply-templates/></h4>',
 056          'H5'     => '<h5><xsl:apply-templates/></h5>',
 057          'H6'     => '<h6><xsl:apply-templates/></h6>',
 058          'HR'     => '<hr/>',
 059          'IMG'    => [
 060              'attributes' => [
 061                  'alt'   => ['required'    => false   ],
 062                  'src'   => ['filterChain' => ['#url']],
 063                  'title' => ['required'    => false   ]
 064              ],
 065              'template' => '<img src="{@src}"><xsl:copy-of select="@alt"/><xsl:copy-of select="@title"/></img>'
 066          ],
 067          'ISPOILER' => '<span class="spoiler" data-s9e-livepreview-ignore-attrs="style" onclick="removeAttribute(\'style\')" style="background:#444;color:transparent"><xsl:apply-templates/></span>',
 068          'LI'     => '<li><xsl:apply-templates/></li>',
 069          'LIST'   => [
 070              'attributes' => [
 071                  'start' => [
 072                      'filterChain' => ['#uint'],
 073                      'required'    => false
 074                  ],
 075                  'type' => [
 076                      'filterChain' => ['#simpletext'],
 077                      'required'    => false
 078                  ]
 079              ],
 080              'template' =>
 081                  '<xsl:choose>
 082                      <xsl:when test="not(@type)">
 083                          <ul><xsl:apply-templates/></ul>
 084                      </xsl:when>
 085                      <xsl:otherwise>
 086                          <ol><xsl:copy-of select="@start"/><xsl:apply-templates/></ol>
 087                      </xsl:otherwise>
 088                  </xsl:choose>'
 089          ],
 090          'QUOTE'   => '<blockquote><xsl:apply-templates/></blockquote>',
 091          'SPOILER' => '<details class="spoiler" data-s9e-livepreview-ignore-attrs="open"><xsl:apply-templates/></details>',
 092          'STRONG'  => '<strong><xsl:apply-templates/></strong>',
 093          'SUB'     => '<sub><xsl:apply-templates/></sub>',
 094          'SUP'     => '<sup><xsl:apply-templates/></sup>',
 095          'URL'     => [
 096              'attributes' => [
 097                  'title' => ['required'    => false   ],
 098                  'url'   => ['filterChain' => ['#url']]
 099              ],
 100              'template' => '<a href="{@url}"><xsl:copy-of select="@title"/><xsl:apply-templates/></a>'
 101          ]
 102      ];
 103   
 104      /**
 105      * {@inheritdoc}
 106      */
 107      protected function setUp()
 108      {
 109          $this->configurator->rulesGenerator->append('ManageParagraphs');
 110   
 111          foreach ($this->tags as $tagName => $tagConfig)
 112          {
 113              // Skip this tag if it already exists
 114              if (isset($this->configurator->tags[$tagName]))
 115              {
 116                  continue;
 117              }
 118   
 119              // If the tag's config is a single string, it's really its default template
 120              if (is_string($tagConfig))
 121              {
 122                  $tagConfig = ['template' => $tagConfig];
 123              }
 124   
 125              // Add this tag
 126              $this->configurator->tags->add($tagName, $tagConfig);
 127          }
 128      }
 129   
 130      /**
 131      * Add an "id" attribute to headers
 132      *
 133      * @param  string $prefix Prefix used for the "id" value
 134      * @return void
 135      */
 136      public function addHeadersId(string $prefix = ''): void
 137      {
 138          for ($i = 1; $i <= 6; ++$i)
 139          {
 140              $tagName = 'H' . $i;
 141              if (isset($this->configurator->tags[$tagName]))
 142              {
 143                  $this->addHeaderId($this->configurator->tags[$tagName], $prefix);
 144              }
 145          }
 146      }
 147   
 148      /**
 149      * Add an "id" attribute to given tag
 150      *
 151      * @param  Tag    $tag
 152      * @param  string $prefix Prefix used for the "id" value
 153      * @return void
 154      */
 155      protected function addHeaderId(Tag $tag, string $prefix): void
 156      {
 157          if (!isset($tag->attributes['slug']))
 158          {
 159              unset($tag->attributes['slug']);
 160          }
 161   
 162          $tag->attributes->add('slug')->required = false;
 163          $tag->filterChain
 164              ->append(Slugger::class . '::setTagSlug($tag, $innerText)')
 165              ->setJS(Slugger::getJS());
 166   
 167          $dom = $tag->template->asDOM();
 168          foreach ($dom->query('//xsl:if[@test = "@slug"]') as $if)
 169          {
 170              // Remove any pre-existing xsl:if from previous invocations
 171              $if->remove();
 172          }
 173          foreach ($dom->query('//h1 | //h2 | //h3 | //h4 | //h5 | //h6') as $header)
 174          {
 175              $header->prependXslIf('@slug')
 176                     ->appendXslAttribute('id', $prefix)
 177                     ->appendXslValueOf('@slug');
 178          }
 179          $dom->saveChanges();
 180      }
 181   
 182      /**
 183      * {@inheritdoc}
 184      */
 185      public function asConfig()
 186      {
 187          return ['decodeHtmlEntities' => (bool) $this->decodeHtmlEntities];
 188      }
 189   
 190      /**
 191      * {@inheritdoc}
 192      */
 193      public function getJSHints()
 194      {
 195          return ['LITEDOWN_DECODE_HTML_ENTITIES' => (int) $this->decodeHtmlEntities];
 196      }
 197   
 198      /**
 199      * {@inheritdoc}
 200      */
 201      public function getJSParser()
 202      {
 203          $js = file_get_contents(__DIR__ . '/Parser/ParsedText.js') . "\n"
 204              . file_get_contents(__DIR__ . '/Parser/Passes/AbstractInlineMarkup.js') . "\n"
 205              . file_get_contents(__DIR__ . '/Parser/Passes/AbstractScript.js') . "\n"
 206              . file_get_contents(__DIR__ . '/Parser/LinkAttributesSetter.js');
 207   
 208          $passes = [
 209              'Blocks',
 210              'LinkReferences',
 211              'InlineCode',
 212              'Images',
 213              'InlineSpoiler',
 214              'Links',
 215              'Strikethrough',
 216              'Subscript',
 217              'Superscript',
 218              'Emphasis',
 219              'ForcedLineBreaks'
 220          ];
 221          foreach ($passes as $pass)
 222          {
 223              $js .= "\n(function(){\n"
 224                   . file_get_contents(__DIR__ . '/Parser/Passes/' . $pass . '.js') . "\n"
 225                   . "parse();\n"
 226                   . "})();";
 227          }
 228   
 229          return $js;
 230      }
 231  }