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. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
BBCodeCollection.php
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\BBCodes\Configurator;
09
10 use RuntimeException;
11 use s9e\TextFormatter\Configurator\Collections\NormalizedCollection;
12 use s9e\TextFormatter\Configurator\JavaScript\Dictionary;
13 use s9e\TextFormatter\Configurator\Validators\AttributeName;
14 use s9e\TextFormatter\Configurator\Validators\TagName;
15
16 class BBCodeCollection extends NormalizedCollection
17 {
18 /**
19 * {@inheritdoc}
20 */
21 protected $onDuplicateAction = 'replace';
22
23 /**
24 * {@inheritdoc}
25 */
26 protected function getAlreadyExistsException($key)
27 {
28 return new RuntimeException("BBCode '" . $key . "' already exists");
29 }
30
31 /**
32 * {@inheritdoc}
33 */
34 protected function getNotExistException($key)
35 {
36 return new RuntimeException("BBCode '" . $key . "' does not exist");
37 }
38
39 /**
40 * {@inheritdoc}
41 */
42 public function normalizeKey($key)
43 {
44 return BBCode::normalizeName($key);
45 }
46
47 /**
48 * {@inheritdoc}
49 */
50 public function normalizeValue($value)
51 {
52 return ($value instanceof BBCode)
53 ? $value
54 : new BBCode($value);
55 }
56
57 /**
58 * {@inheritdoc}
59 *
60 * This method will remove redundant info such as the BBCode's tagName or defaultAttribute values
61 * if they are the same as their default values
62 */
63 public function asConfig()
64 {
65 $bbcodes = parent::asConfig();
66 foreach ($bbcodes as $bbcodeName => &$bbcode)
67 {
68 // Remove the tag name if it's the same name as the BBCode
69 if (isset($bbcode['tagName'])
70 && TagName::isValid($bbcodeName)
71 && TagName::normalize($bbcodeName) === $bbcode['tagName'])
72 {
73 unset($bbcode['tagName']);
74 }
75
76 // Remove the defaultAttribute name if it's the same name as the BBCode
77 if (isset($bbcode['defaultAttribute'])
78 && AttributeName::isValid($bbcodeName)
79 && AttributeName::normalize($bbcodeName) === $bbcode['defaultAttribute'])
80 {
81 unset($bbcode['defaultAttribute']);
82 }
83 }
84 unset($bbcode);
85
86 return new Dictionary($bbcodes);
87 }
88 }