Verzeichnisstruktur phpBB-3.2.0
- Veröffentlicht
- 06.01.2017
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. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
BBCode.php
001 <?php
002
003 /*
004 * @package s9e\TextFormatter
005 * @copyright Copyright (c) 2010-2016 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 use InvalidArgumentException;
010 use RuntimeException;
011 use Traversable;
012 use s9e\TextFormatter\Configurator\Collections\AttributeList;
013 use s9e\TextFormatter\Configurator\Collections\Collection;
014 use s9e\TextFormatter\Configurator\Collections\NormalizedCollection;
015 use s9e\TextFormatter\Configurator\ConfigProvider;
016 use s9e\TextFormatter\Configurator\Helpers\ConfigHelper;
017 use s9e\TextFormatter\Configurator\JavaScript\Dictionary;
018 use s9e\TextFormatter\Configurator\Traits\Configurable;
019 use s9e\TextFormatter\Configurator\Validators\AttributeName;
020 use s9e\TextFormatter\Configurator\Validators\TagName;
021 class BBCode implements ConfigProvider
022 {
023 public function __get($propName)
024 {
025 $methodName = 'get' . \ucfirst($propName);
026 if (\method_exists($this, $methodName))
027 return $this->$methodName();
028 if (!\property_exists($this, $propName))
029 throw new RuntimeException("Property '" . $propName . "' does not exist");
030 return $this->$propName;
031 }
032 public function __set($propName, $propValue)
033 {
034 $methodName = 'set' . \ucfirst($propName);
035 if (\method_exists($this, $methodName))
036 {
037 $this->$methodName($propValue);
038 return;
039 }
040 if (!isset($this->$propName))
041 {
042 $this->$propName = $propValue;
043 return;
044 }
045 if ($this->$propName instanceof NormalizedCollection)
046 {
047 if (!\is_array($propValue)
048 && !($propValue instanceof Traversable))
049 throw new InvalidArgumentException("Property '" . $propName . "' expects an array or a traversable object to be passed");
050 $this->$propName->clear();
051 foreach ($propValue as $k => $v)
052 $this->$propName->set($k, $v);
053 return;
054 }
055 if (\is_object($this->$propName))
056 {
057 if (!($propValue instanceof $this->$propName))
058 throw new InvalidArgumentException("Cannot replace property '" . $propName . "' of class '" . \get_class($this->$propName) . "' with instance of '" . \get_class($propValue) . "'");
059 }
060 else
061 {
062 $oldType = \gettype($this->$propName);
063 $newType = \gettype($propValue);
064 if ($oldType === 'boolean')
065 if ($propValue === 'false')
066 {
067 $newType = 'boolean';
068 $propValue = \false;
069 }
070 elseif ($propValue === 'true')
071 {
072 $newType = 'boolean';
073 $propValue = \true;
074 }
075 if ($oldType !== $newType)
076 {
077 $tmp = $propValue;
078 \settype($tmp, $oldType);
079 \settype($tmp, $newType);
080 if ($tmp !== $propValue)
081 throw new InvalidArgumentException("Cannot replace property '" . $propName . "' of type " . $oldType . ' with value of type ' . $newType);
082 \settype($propValue, $oldType);
083 }
084 }
085 $this->$propName = $propValue;
086 }
087 public function __isset($propName)
088 {
089 $methodName = 'isset' . \ucfirst($propName);
090 if (\method_exists($this, $methodName))
091 return $this->$methodName();
092 return isset($this->$propName);
093 }
094 public function __unset($propName)
095 {
096 $methodName = 'unset' . \ucfirst($propName);
097 if (\method_exists($this, $methodName))
098 {
099 $this->$methodName();
100 return;
101 }
102 if (!isset($this->$propName))
103 return;
104 if ($this->$propName instanceof Collection)
105 {
106 $this->$propName->clear();
107 return;
108 }
109 throw new RuntimeException("Property '" . $propName . "' cannot be unset");
110 }
111 protected $contentAttributes;
112 protected $defaultAttribute;
113 protected $forceLookahead = \false;
114 protected $predefinedAttributes;
115 protected $tagName;
116 public function __construct(array $options = \null)
117 {
118 $this->contentAttributes = new AttributeList;
119 $this->predefinedAttributes = new AttributeValueCollection;
120 if (isset($options))
121 foreach ($options as $optionName => $optionValue)
122 $this->__set($optionName, $optionValue);
123 }
124 public function asConfig()
125 {
126 $config = ConfigHelper::toArray(\get_object_vars($this));
127 if (!$this->forceLookahead)
128 unset($config['forceLookahead']);
129 if (isset($config['predefinedAttributes']))
130 $config['predefinedAttributes'] = new Dictionary($config['predefinedAttributes']);
131 return $config;
132 }
133 public static function normalizeName($bbcodeName)
134 {
135 if ($bbcodeName === '*')
136 return '*';
137 if (!TagName::isValid($bbcodeName))
138 throw new InvalidArgumentException("Invalid BBCode name '" . $bbcodeName . "'");
139 return TagName::normalize($bbcodeName);
140 }
141 public function setDefaultAttribute($attrName)
142 {
143 $this->defaultAttribute = AttributeName::normalize($attrName);
144 }
145 public function setTagName($tagName)
146 {
147 $this->tagName = TagName::normalize($tagName);
148 }
149 }