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 |
MapFilter.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\Helpers\RegexpBuilder;
13 use s9e\TextFormatter\Configurator\Items\AttributeFilter;
14 use s9e\TextFormatter\Configurator\Items\Regexp;
15 class MapFilter extends AttributeFilter
16 {
17 public function __construct(array $map = \null, $caseSensitive = \false, $strict = \false)
18 {
19 parent::__construct('s9e\\TextFormatter\\Parser\\BuiltInFilters::filterMap');
20 $this->resetParameters();
21 $this->addParameterByName('attrValue');
22 $this->addParameterByName('map');
23 $this->setJS('BuiltInFilters.filterMap');
24 if (isset($map))
25 $this->setMap($map, $caseSensitive, $strict);
26 }
27 public function asConfig()
28 {
29 if (!isset($this->vars['map']))
30 throw new RuntimeException("Map filter is missing a 'map' value");
31 return parent::asConfig();
32 }
33 public function setMap(array $map, $caseSensitive = \false, $strict = \false)
34 {
35 if (!\is_bool($caseSensitive))
36 throw new InvalidArgumentException('Argument 2 passed to ' . __METHOD__ . ' must be a boolean');
37 if (!\is_bool($strict))
38 throw new InvalidArgumentException('Argument 3 passed to ' . __METHOD__ . ' must be a boolean');
39 $this->resetSafeness();
40 if ($strict)
41 $this->assessSafeness($map);
42 $valueKeys = array();
43 foreach ($map as $key => $value)
44 $valueKeys[$value][] = $key;
45 $map = array();
46 foreach ($valueKeys as $value => $keys)
47 {
48 $regexp = RegexpBuilder::fromList(
49 $keys,
50 array(
51 'delimiter' => '/',
52 'caseInsensitive' => !$caseSensitive
53 )
54 );
55 $regexp = '/^' . $regexp . '$/D';
56 if (!$caseSensitive)
57 $regexp .= 'i';
58 if (!\preg_match('#^[[:ascii:]]*$#D', $regexp))
59 $regexp .= 'u';
60 $map[] = array(new Regexp($regexp), $value);
61 }
62 if ($strict)
63 $map[] = array('//', \false);
64 $this->vars['map'] = $map;
65 }
66 protected function assessSafeness(array $map)
67 {
68 $values = \implode('', $map);
69 $isSafeInCSS = \true;
70 foreach (ContextSafeness::getDisallowedCharactersInCSS() as $char)
71 if (\strpos($values, $char) !== \false)
72 {
73 $isSafeInCSS = \false;
74 break;
75 }
76 if ($isSafeInCSS)
77 $this->markAsSafeInCSS();
78 $isSafeInJS = \true;
79 foreach (ContextSafeness::getDisallowedCharactersInJS() as $char)
80 if (\strpos($values, $char) !== \false)
81 {
82 $isSafeInJS = \false;
83 break;
84 }
85 if ($isSafeInJS)
86 $this->markAsSafeInJS();
87 }
88 }