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 |
RangeFilter.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 RuntimeException;
12 use s9e\TextFormatter\Configurator\Items\AttributeFilter;
13
14 class RangeFilter extends AttributeFilter
15 {
16 /**
17 * Constructor
18 *
19 * @param integer $min Minimum value for this range
20 * @param integer $max Maximum value for this range
21 */
22 public function __construct($min = null, $max = null)
23 {
24 parent::__construct('s9e\\TextFormatter\\Parser\\AttributeFilters\\NumericFilter::filterRange');
25
26 $this->resetParameters();
27 $this->addParameterByName('attrValue');
28 $this->addParameterByName('min');
29 $this->addParameterByName('max');
30 $this->addParameterByName('logger');
31 $this->setJS('NumericFilter.filterRange');
32 $this->markAsSafeAsURL();
33 $this->markAsSafeInCSS();
34 $this->markAsSafeInJS();
35
36 if (isset($min))
37 {
38 $this->setRange($min, $max);
39 }
40 }
41
42 /**
43 * {@inheritdoc}
44 */
45 public function asConfig()
46 {
47 if (!isset($this->vars['min']))
48 {
49 throw new RuntimeException("Range filter is missing a 'min' value");
50 }
51
52 if (!isset($this->vars['max']))
53 {
54 throw new RuntimeException("Range filter is missing a 'max' value");
55 }
56
57 return parent::asConfig();
58 }
59
60 /**
61 * Set the allowed range of values
62 *
63 * @param integer $min Minimum value
64 * @param integer $max Maximum value
65 * @return void
66 */
67 public function setRange($min, $max)
68 {
69 $min = filter_var($min, FILTER_VALIDATE_INT);
70 $max = filter_var($max, FILTER_VALIDATE_INT);
71
72 if ($min === false)
73 {
74 throw new InvalidArgumentException('Argument 1 passed to ' . __METHOD__ . ' must be an integer');
75 }
76
77 if ($max === false)
78 {
79 throw new InvalidArgumentException('Argument 2 passed to ' . __METHOD__ . ' must be an integer');
80 }
81
82 if ($min > $max)
83 {
84 throw new InvalidArgumentException('Invalid range: min (' . $min . ') > max (' . $max . ')');
85 }
86
87 $this->vars['min'] = $min;
88 $this->vars['max'] = $max;
89 }
90 }