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 |
ChoiceFilter.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\Configurator\Items\AttributeFilters;
09
10 use InvalidArgumentException;
11 use s9e\TextFormatter\Configurator\Helpers\RegexpBuilder;
12
13 class ChoiceFilter extends RegexpFilter
14 {
15 /**
16 * Constructor
17 *
18 * @param array $values List of allowed values
19 * @param bool $caseSensitive Whether the choice is case-sensitive
20 */
21 public function __construct(array $values = null, $caseSensitive = false)
22 {
23 parent::__construct();
24
25 if (isset($values))
26 {
27 $this->setValues($values, $caseSensitive);
28 }
29 }
30
31 /**
32 * Set the list of allowed values
33 *
34 * @param array $values List of allowed values
35 * @param bool $caseSensitive Whether the choice is case-sensitive
36 * @return void
37 */
38 public function setValues(array $values, $caseSensitive = false)
39 {
40 if (!is_bool($caseSensitive))
41 {
42 throw new InvalidArgumentException('Argument 2 passed to ' . __METHOD__ . ' must be a boolean');
43 }
44
45 // Create a regexp based on the list of allowed values
46 $regexp = RegexpBuilder::fromList($values, ['delimiter' => '/']);
47 $regexp = '/^' . $regexp . '$/D';
48
49 // Add the case-insensitive flag if applicable
50 if (!$caseSensitive)
51 {
52 $regexp .= 'i';
53 }
54
55 // Add the Unicode flag if the regexp isn't purely ASCII
56 if (!preg_match('#^[[:ascii:]]*$#D', $regexp))
57 {
58 $regexp .= 'u';
59 }
60
61 // Set the regexp associated with this list of values
62 $this->setRegexp($regexp);
63 }
64 }