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 |
HashmapFilter.php
01 <?php
02
03 /*
04 * @package s9e\TextFormatter
05 * @copyright Copyright (c) 2010-2016 The s9e Authors
06 * @license http://www.opensource.org/licenses/mit-license.php The MIT License
07 */
08 namespace s9e\TextFormatter\Configurator\Items\AttributeFilters;
09 use InvalidArgumentException;
10 use RuntimeException;
11 use s9e\TextFormatter\Configurator\Helpers\ContextSafeness;
12 use s9e\TextFormatter\Configurator\Items\AttributeFilter;
13 class HashmapFilter extends AttributeFilter
14 {
15 public function __construct(array $map = \null, $strict = \false)
16 {
17 parent::__construct('s9e\\TextFormatter\\Parser\\BuiltInFilters::filterHashmap');
18 $this->resetParameters();
19 $this->addParameterByName('attrValue');
20 $this->addParameterByName('map');
21 $this->addParameterByName('strict');
22 $this->setJS('BuiltInFilters.filterHashmap');
23 if (isset($map))
24 $this->setMap($map, $strict);
25 }
26 public function asConfig()
27 {
28 if (!isset($this->vars['map']))
29 throw new RuntimeException("Hashmap filter is missing a 'map' value");
30 return parent::asConfig();
31 }
32 public function setMap(array $map, $strict = \false)
33 {
34 if (!\is_bool($strict))
35 throw new InvalidArgumentException('Argument 2 passed to ' . __METHOD__ . ' must be a boolean');
36 if (!$strict)
37 $map = $this->optimizeLooseMap($map);
38 \ksort($map);
39 $this->vars['map'] = $map;
40 $this->vars['strict'] = $strict;
41 $this->resetSafeness();
42 if (!empty($this->vars['strict']))
43 {
44 $this->evaluateSafenessInCSS();
45 $this->evaluateSafenessInJS();
46 }
47 }
48 protected function evaluateSafenessInCSS()
49 {
50 $disallowedChars = ContextSafeness::getDisallowedCharactersInCSS();
51 foreach ($this->vars['map'] as $value)
52 foreach ($disallowedChars as $char)
53 if (\strpos($value, $char) !== \false)
54 return;
55 $this->markAsSafeInCSS();
56 }
57 protected function evaluateSafenessInJS()
58 {
59 $disallowedChars = ContextSafeness::getDisallowedCharactersInJS();
60 foreach ($this->vars['map'] as $value)
61 foreach ($disallowedChars as $char)
62 if (\strpos($value, $char) !== \false)
63 return;
64 $this->markAsSafeInJS();
65 }
66 protected function optimizeLooseMap(array $map)
67 {
68 foreach ($map as $k => $v)
69 if ($k === $v)
70 unset($map[$k]);
71 return $map;
72 }
73 }