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

Parser.php

Zuletzt modifiziert: 01.05.2026, 11:28 - Dateigröße: 2.11 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\Plugins\Autolink;
 09   
 10  use s9e\TextFormatter\Plugins\ParserBase;
 11   
 12  class Parser extends ParserBase
 13  {
 14      /**
 15      * {@inheritdoc}
 16      */
 17      public function parse($text, array $matches)
 18      {
 19          foreach ($matches as $m)
 20          {
 21              // Linkify the trimmed URL
 22              $this->linkifyUrl($m[0][1], $this->trimUrl($m[0][0]));
 23          }
 24      }
 25   
 26      /**
 27      * Linkify given URL at given position
 28      *
 29      * @param  integer $tagPos URL's position in the text
 30      * @param  string  $url    URL
 31      * @return void
 32      */
 33      protected function linkifyUrl($tagPos, $url)
 34      {
 35          // Create a zero-width end tag right after the URL
 36          $endPos = $tagPos + strlen($url);
 37          $endTag = $this->parser->addEndTag($this->config['tagName'], $endPos, 0);
 38   
 39          // If the URL starts with "www." we prepend "http://"
 40          if ($url[3] === '.')
 41          {
 42              $url = 'http://' . $url;
 43          }
 44   
 45          // Create a zero-width start tag right before the URL, with a slightly worse priority to
 46          // allow specialized plugins to use the URL instead
 47          $startTag = $this->parser->addStartTag($this->config['tagName'], $tagPos, 0, 1);
 48          $startTag->setAttribute($this->config['attrName'], $url);
 49   
 50          // Pair the tags together
 51          $startTag->pairWith($endTag);
 52   
 53          // Protect the tag's content from partial replacements with a low priority tag
 54          $contentTag = $this->parser->addVerbatim($tagPos, $endPos - $tagPos, 1000);
 55          $startTag->cascadeInvalidationTo($contentTag);
 56      }
 57   
 58      /**
 59      * Remove trailing punctuation from given URL
 60      *
 61      * We remove most ASCII non-letters and Unicode punctuation from the end of the string.
 62      * Exceptions:
 63      *  - dashes and underscores, (base64 IDs could end with one)
 64      *  - equal signs, (because of "foo?bar=")
 65      *  - plus signs, (used by some file share services to force download)
 66      *  - trailing slashes,
 67      *  - closing parentheses. (they are balanced separately)
 68      *
 69      * @param  string $url Original URL
 70      * @return string      Trimmed URL
 71      */
 72      protected function trimUrl($url)
 73      {
 74          return preg_replace('#(?:(?![-=+)/_])[\\s!-.:-@[-`{-~\\pP])+$#Du', '', $url);
 75      }
 76  }