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

BBCode.php

Zuletzt modifiziert: 01.05.2026, 11:28 - Dateigröße: 3.20 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\BBCodes\Configurator;
 009   
 010  use InvalidArgumentException;
 011  use s9e\TextFormatter\Configurator\Collections\AttributeList;
 012  use s9e\TextFormatter\Configurator\ConfigProvider;
 013  use s9e\TextFormatter\Configurator\Helpers\ConfigHelper;
 014  use s9e\TextFormatter\Configurator\JavaScript\Dictionary;
 015  use s9e\TextFormatter\Configurator\Traits\Configurable;
 016  use s9e\TextFormatter\Configurator\Validators\AttributeName;
 017  use s9e\TextFormatter\Configurator\Validators\TagName;
 018   
 019  /**
 020  * @property AttributeList $contentAttributes List of attributes whose value is to be made the content between the BBCode's tags if it's not explicitly given
 021  * @property string $defaultAttribute Name of the default attribute
 022  * @property bool $forceLookahead Whether the parser should look ahead in the text for an end tag before adding a start tag
 023  * @property string $tagName Name of the tag used to represent this BBCode in the intermediate representation
 024  */
 025  class BBCode implements ConfigProvider
 026  {
 027      use Configurable;
 028   
 029      /**
 030      * @var AttributeList List of attributes whose value is to be made the content between the
 031      *                    BBCode's tags if it's not explicitly given
 032      */
 033      protected $contentAttributes;
 034   
 035      /**
 036      * @var string Name of the default attribute
 037      */
 038      protected $defaultAttribute;
 039   
 040      /**
 041      * @var bool Whether the parser should look ahead in the text for an end tag before adding a
 042      *           start tag
 043      */
 044      protected $forceLookahead = false;
 045   
 046      /**
 047      * @var string Name of the tag used to represent this BBCode in the intermediate representation
 048      */
 049      protected $tagName;
 050   
 051      /**
 052      * @param array $options This BBCode's options
 053      */
 054      public function __construct(array $options = null)
 055      {
 056          $this->contentAttributes = new AttributeList;
 057          if (isset($options))
 058          {
 059              foreach ($options as $optionName => $optionValue)
 060              {
 061                  $this->__set($optionName, $optionValue);
 062              }
 063          }
 064      }
 065   
 066      /**
 067      * {@inheritdoc}
 068      */
 069      public function asConfig()
 070      {
 071          $config = ConfigHelper::toArray(get_object_vars($this));
 072          if (!$this->forceLookahead)
 073          {
 074              unset($config['forceLookahead']);
 075          }
 076   
 077          return $config;
 078      }
 079   
 080      /**
 081      * Normalize the name of a BBCode
 082      *
 083      * Follows the same rules as tag names with one exception: "*" is kept for compatibility with
 084      * other BBCode engines
 085      *
 086      * @param  string $bbcodeName Original name
 087      * @return string             Normalized name
 088      */
 089      public static function normalizeName($bbcodeName)
 090      {
 091          if ($bbcodeName === '*')
 092          {
 093              return '*';
 094          }
 095   
 096          if (strpos($bbcodeName, ':') !== false || !TagName::isValid($bbcodeName))
 097          {
 098              throw new InvalidArgumentException("Invalid BBCode name '" . $bbcodeName . "'");
 099          }
 100   
 101          return TagName::normalize($bbcodeName);
 102      }
 103   
 104      /**
 105      * Set the default attribute name for this BBCode
 106      *
 107      * @param string $attrName
 108      */
 109      public function setDefaultAttribute($attrName)
 110      {
 111          $this->defaultAttribute = AttributeName::normalize($attrName);
 112      }
 113   
 114      /**
 115      * Set the tag name that represents this BBCode in the intermediate representation
 116      *
 117      * @param string $tagName
 118      */
 119      public function setTagName($tagName)
 120      {
 121          $this->tagName = TagName::normalize($tagName);
 122      }
 123  }