@@ -39,7 +39,7 @@ |
||
| 39 | 39 | parent::__construct($content, ...$intents); |
| 40 | 40 | |
| 41 | 41 | $attributes ??= []; |
| 42 | - $tag ??= static::DEFAULT_TAG; |
|
| 42 | + $tag ??= static::DEFAULT_TAG; |
|
| 43 | 43 | |
| 44 | 44 | $this->setAttributes($attributes); |
| 45 | 45 | $this->setTag($tag); |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | return [ |
| 26 | 26 | 'simple' => ['abc', 'ABC', false, null, null, null, "<option value=\"abc\">ABC</option>"], |
| 27 | 27 | 'attributes' => ['abc', 'ABC', false, $attribs, null, null, "<option$str value=\"abc\">ABC</option>"], |
| 28 | - 'w/o translations' => ['abc', 'ABC', false, null, [], null, "<option value=\"abc\">ABC</option>",], |
|
| 28 | + 'w/o translations' => ['abc', 'ABC', false, null, [], null, "<option value=\"abc\">ABC</option>", ], |
|
| 29 | 29 | 'custom tag' => ['abc', 'ABC', false, null, null, 'foo', "<foo value=\"abc\">ABC</foo>"], |
| 30 | 30 | 'w translations' => ['abc', 'ABC', false, null, ['ABC' => '+'], null, "<option value=\"abc\">+</option>"], |
| 31 | 31 | ]; |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | null, |
| 26 | 26 | "<button foo=\"foo baz\" bar=\"bar baz\">Button</button>", |
| 27 | 27 | ], |
| 28 | - 'missing translations' => ['Button', [], null, [], null, "<button>Button</button>",], |
|
| 28 | + 'missing translations' => ['Button', [], null, [], null, "<button>Button</button>", ], |
|
| 29 | 29 | 'custom tag' => ['Button', [], null, null, 'mybutton', "<mybutton>Button</mybutton>"], |
| 30 | 30 | 'with translations' => ['Button', [], null, ['Button' => 'Gomb'], null, "<button>Gomb</button>"], |
| 31 | 31 | ]; |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | |
| 30 | 30 | return [ |
| 31 | 31 | 'simple' => [$text, $icon, [], null, null, null, "<button>$iconStr $textStr</button>"], |
| 32 | - 'with attributes' => [$text, $icon, [], $attr, null, null, "<button$str>$iconStr $textStr</button>",], |
|
| 32 | + 'with attributes' => [$text, $icon, [], $attr, null, null, "<button$str>$iconStr $textStr</button>", ], |
|
| 33 | 33 | 'missing translations' => [$text, $icon, [], null, [], null, "<button>$iconStr $textStr</button>"], |
| 34 | 34 | 'custom tag' => [$text, $icon, [], null, null, 'mytag', "<mytag>$iconStr $textStr</mytag>"], |
| 35 | 35 | 'with translations' => [ |
@@ -22,8 +22,8 @@ |
||
| 22 | 22 | |
| 23 | 23 | return [ |
| 24 | 24 | 'simple' => ['ABC', 'a', '', '', null, null, null, "<th>ABC <a></a></th>"], |
| 25 | - 'with attributes' => ['ABC', 'a', '', '', $attribs, null, null, "<th$str>ABC <a></a></th>",], |
|
| 26 | - 'missing translations' => ['ABC', 'a', '', '', null, [], null, "<th>ABC <a></a></th>",], |
|
| 25 | + 'with attributes' => ['ABC', 'a', '', '', $attribs, null, null, "<th$str>ABC <a></a></th>", ], |
|
| 26 | + 'missing translations' => ['ABC', 'a', '', '', null, [], null, "<th>ABC <a></a></th>", ], |
|
| 27 | 27 | 'custom tag' => ['ABC', 'a', '', '', null, null, 'myth', "<myth>ABC <a></a></myth>"], |
| 28 | 28 | 'with translations' => ['ABC', 'a', '', '', null, ['ABC' => 'CBA'], null, "<th>CBA <a></a></th>"], |
| 29 | 29 | ]; |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | 'number as int' => [23.4, \PDO::PARAM_INT, [23.4, \PDO::PARAM_INT]], |
| 23 | 23 | 'false as bool' => [false, \PDO::PARAM_BOOL, [false, \PDO::PARAM_BOOL]], |
| 24 | 24 | 'true as bool' => [true, \PDO::PARAM_BOOL, [true, \PDO::PARAM_BOOL]], |
| 25 | - 'datetime' => [$dateTime, \PDO::PARAM_STR, ['2010-11-27 09:08:59', \PDO::PARAM_STR],], |
|
| 25 | + 'datetime' => [$dateTime, \PDO::PARAM_STR, ['2010-11-27 09:08:59', \PDO::PARAM_STR], ], |
|
| 26 | 26 | 'date' => [ |
| 27 | 27 | $dateTime, |
| 28 | 28 | \PDO::PARAM_STR, |
@@ -21,10 +21,10 @@ |
||
| 21 | 21 | $str = Attributes::toString($attributes); |
| 22 | 22 | |
| 23 | 23 | return [ |
| 24 | - 'simple' => ['a', 'ABC', null, null, null, '<label for="a">ABC</label>',], |
|
| 25 | - 'with attributes' => ['a', 'ABC', $attributes, null, null, "<label$str for=\"a\">ABC</label>",], |
|
| 26 | - 'with translations' => ['a', 'ABC', null, ['ABC' => 'CBA'], null, '<label for="a">CBA</label>',], |
|
| 27 | - 'custom tag' => ['a', 'ABC', null, [], 'foo', '<foo for="a">ABC</foo>',], |
|
| 24 | + 'simple' => ['a', 'ABC', null, null, null, '<label for="a">ABC</label>', ], |
|
| 25 | + 'with attributes' => ['a', 'ABC', $attributes, null, null, "<label$str for=\"a\">ABC</label>", ], |
|
| 26 | + 'with translations' => ['a', 'ABC', null, ['ABC' => 'CBA'], null, '<label for="a">CBA</label>', ], |
|
| 27 | + 'custom tag' => ['a', 'ABC', null, [], 'foo', '<foo for="a">ABC</foo>', ], |
|
| 28 | 28 | ]; |
| 29 | 29 | } |
| 30 | 30 | |
@@ -41,173 +41,3 @@ |
||
| 41 | 41 | * %2$s - nodes (filters) |
| 42 | 42 | */ |
| 43 | 43 | protected const DEFAULT_TEMPLATE = <<<'EOT' |
| 44 | - <div class="hidable"> |
|
| 45 | - <p class="hider">%1$s</p> |
|
| 46 | - <div class="hidee">%2$s</div> |
|
| 47 | - </div> |
|
| 48 | - EOT; |
|
| 49 | - |
|
| 50 | - protected string $template = self::DEFAULT_TEMPLATE; |
|
| 51 | - |
|
| 52 | - /** @var IFilter[] */ |
|
| 53 | - protected array $content = []; |
|
| 54 | - |
|
| 55 | - protected string $nodeClass = IFilter::class; |
|
| 56 | - |
|
| 57 | - protected Action $hiderBtn; |
|
| 58 | - protected Action $filterBtn; |
|
| 59 | - protected Action $resetBtn; |
|
| 60 | - |
|
| 61 | - /** @var array<string,Attribute> */ |
|
| 62 | - protected array $formAttributes; |
|
| 63 | - |
|
| 64 | - /** @var array<string,Attribute> */ |
|
| 65 | - protected array $searchAttributes; |
|
| 66 | - |
|
| 67 | - /** @var array<string,Attribute> */ |
|
| 68 | - protected array $resetAttributes; |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * Filters constructor. |
|
| 72 | - * |
|
| 73 | - * @param string[] $intents |
|
| 74 | - * @param array<string,Attribute>|null $attributes |
|
| 75 | - * @param string|null $tag |
|
| 76 | - */ |
|
| 77 | - public function __construct(array $intents = [], ?array $attributes = null, ?string $tag = null) |
|
| 78 | - { |
|
| 79 | - parent::__construct(null, $intents, $attributes, $tag); |
|
| 80 | - |
|
| 81 | - $this->formAttributes = Attributes::fromArray(static::ATTRIBUTES_FORM); |
|
| 82 | - $this->searchAttributes = Attributes::fromArray(static::ATTRIBUTES_SEARCH); |
|
| 83 | - $this->resetAttributes = Attributes::fromArray(static::ATTRIBUTES_RESET); |
|
| 84 | - |
|
| 85 | - $this->hiderBtn = new Action(static::BTN_CONTENT_FILTERS, [Action::INTENT_INFO]); |
|
| 86 | - $this->filterBtn = new Action(static::BTN_CONTENT_FILTER, [Action::INTENT_PRIMARY], $this->searchAttributes); |
|
| 87 | - $this->resetBtn = new Action(static::BTN_CONTENT_RESET, [Action::INTENT_SECONDARY], $this->resetAttributes); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * @param array $params |
|
| 92 | - * |
|
| 93 | - * @return $this |
|
| 94 | - */ |
|
| 95 | - public function setParams(array $params): Filters |
|
| 96 | - { |
|
| 97 | - foreach ($this->content as $filter) { |
|
| 98 | - $filter->setParams($params); |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - return $this; |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * @param string $baseUrl |
|
| 106 | - * |
|
| 107 | - * @return string |
|
| 108 | - */ |
|
| 109 | - public function getUrl(string $baseUrl): string |
|
| 110 | - { |
|
| 111 | - $queryParts = []; |
|
| 112 | - foreach ($this->content as $filter) { |
|
| 113 | - $queryPart = $filter->getQueryPart(); |
|
| 114 | - if (!$queryPart) { |
|
| 115 | - continue; |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - $queryParts[] = $queryPart; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - if (empty($queryParts)) { |
|
| 122 | - return $baseUrl; |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - return sprintf('%s%s&', $baseUrl, implode('&', $queryParts)); |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - /** |
|
| 129 | - * @return array |
|
| 130 | - */ |
|
| 131 | - public function getWhereConditions(): array |
|
| 132 | - { |
|
| 133 | - $conditions = []; |
|
| 134 | - foreach ($this->content as $filter) { |
|
| 135 | - $conditions = array_merge($conditions, $filter->getWhereConditions()); |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - return $conditions; |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * @return array<string,string> |
|
| 143 | - */ |
|
| 144 | - public function getSqlParams(): array |
|
| 145 | - { |
|
| 146 | - $params = []; |
|
| 147 | - foreach ($this->content as $filter) { |
|
| 148 | - $params = array_merge($params, $filter->getQueryParams()); |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - return $params; |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * @return INode[] |
|
| 156 | - */ |
|
| 157 | - public function getExtendedNodes(): array |
|
| 158 | - { |
|
| 159 | - return array_merge([$this->hiderBtn, $this->filterBtn, $this->resetBtn], $this->getNodes()); |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - /** |
|
| 163 | - * @param string $template |
|
| 164 | - * |
|
| 165 | - * @return INode |
|
| 166 | - */ |
|
| 167 | - public function setTemplate(string $template): INode |
|
| 168 | - { |
|
| 169 | - $this->template = $template; |
|
| 170 | - |
|
| 171 | - return $this; |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - /** |
|
| 175 | - * @return string |
|
| 176 | - */ |
|
| 177 | - public function __toString(): string |
|
| 178 | - { |
|
| 179 | - $nodes = Tag::__toString(); |
|
| 180 | - |
|
| 181 | - $form = TagHelper::toString($this->tag, $nodes, $this->formAttributes); |
|
| 182 | - |
|
| 183 | - return sprintf( |
|
| 184 | - $this->template, |
|
| 185 | - (string)$this->hiderBtn, |
|
| 186 | - $form |
|
| 187 | - ); |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - /** |
|
| 191 | - * @return Action |
|
| 192 | - */ |
|
| 193 | - public function getHiderBtn(): Action |
|
| 194 | - { |
|
| 195 | - return $this->hiderBtn; |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - /** |
|
| 199 | - * @return Action |
|
| 200 | - */ |
|
| 201 | - public function getFilterBtn(): Action |
|
| 202 | - { |
|
| 203 | - return $this->filterBtn; |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - /** |
|
| 207 | - * @return Action |
|
| 208 | - */ |
|
| 209 | - public function getResetBtn(): Action |
|
| 210 | - { |
|
| 211 | - return $this->resetBtn; |
|
| 212 | - } |
|
| 213 | -} |
|
@@ -41,173 +41,3 @@ |
||
| 41 | 41 | * %2$s - nodes (filters) |
| 42 | 42 | */ |
| 43 | 43 | protected const DEFAULT_TEMPLATE = <<<'EOT' |
| 44 | - <div class="hidable"> |
|
| 45 | - <p class="hider">%1$s</p> |
|
| 46 | - <div class="hidee">%2$s</div> |
|
| 47 | - </div> |
|
| 48 | - EOT; |
|
| 49 | - |
|
| 50 | - protected string $template = self::DEFAULT_TEMPLATE; |
|
| 51 | - |
|
| 52 | - /** @var IFilter[] */ |
|
| 53 | - protected array $content = []; |
|
| 54 | - |
|
| 55 | - protected string $nodeClass = IFilter::class; |
|
| 56 | - |
|
| 57 | - protected Action $hiderBtn; |
|
| 58 | - protected Action $filterBtn; |
|
| 59 | - protected Action $resetBtn; |
|
| 60 | - |
|
| 61 | - /** @var array<string,Attribute> */ |
|
| 62 | - protected array $formAttributes; |
|
| 63 | - |
|
| 64 | - /** @var array<string,Attribute> */ |
|
| 65 | - protected array $searchAttributes; |
|
| 66 | - |
|
| 67 | - /** @var array<string,Attribute> */ |
|
| 68 | - protected array $resetAttributes; |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * Filters constructor. |
|
| 72 | - * |
|
| 73 | - * @param string[] $intents |
|
| 74 | - * @param array<string,Attribute>|null $attributes |
|
| 75 | - * @param string|null $tag |
|
| 76 | - */ |
|
| 77 | - public function __construct(array $intents = [], ?array $attributes = null, ?string $tag = null) |
|
| 78 | - { |
|
| 79 | - parent::__construct(null, $intents, $attributes, $tag); |
|
| 80 | - |
|
| 81 | - $this->formAttributes = Attributes::fromArray(static::ATTRIBUTES_FORM); |
|
| 82 | - $this->searchAttributes = Attributes::fromArray(static::ATTRIBUTES_SEARCH); |
|
| 83 | - $this->resetAttributes = Attributes::fromArray(static::ATTRIBUTES_RESET); |
|
| 84 | - |
|
| 85 | - $this->hiderBtn = new Action(static::BTN_CONTENT_FILTERS, [Action::INTENT_INFO]); |
|
| 86 | - $this->filterBtn = new Action(static::BTN_CONTENT_FILTER, [Action::INTENT_PRIMARY], $this->searchAttributes); |
|
| 87 | - $this->resetBtn = new Action(static::BTN_CONTENT_RESET, [Action::INTENT_SECONDARY], $this->resetAttributes); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * @param array $params |
|
| 92 | - * |
|
| 93 | - * @return $this |
|
| 94 | - */ |
|
| 95 | - public function setParams(array $params): Filters |
|
| 96 | - { |
|
| 97 | - foreach ($this->content as $filter) { |
|
| 98 | - $filter->setParams($params); |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - return $this; |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * @param string $baseUrl |
|
| 106 | - * |
|
| 107 | - * @return string |
|
| 108 | - */ |
|
| 109 | - public function getUrl(string $baseUrl): string |
|
| 110 | - { |
|
| 111 | - $queryParts = []; |
|
| 112 | - foreach ($this->content as $filter) { |
|
| 113 | - $queryPart = $filter->getQueryPart(); |
|
| 114 | - if (!$queryPart) { |
|
| 115 | - continue; |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - $queryParts[] = $queryPart; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - if (empty($queryParts)) { |
|
| 122 | - return $baseUrl; |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - return sprintf('%s%s&', $baseUrl, implode('&', $queryParts)); |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - /** |
|
| 129 | - * @return array |
|
| 130 | - */ |
|
| 131 | - public function getWhereConditions(): array |
|
| 132 | - { |
|
| 133 | - $conditions = []; |
|
| 134 | - foreach ($this->content as $filter) { |
|
| 135 | - $conditions = array_merge($conditions, $filter->getWhereConditions()); |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - return $conditions; |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * @return array<string,string> |
|
| 143 | - */ |
|
| 144 | - public function getSqlParams(): array |
|
| 145 | - { |
|
| 146 | - $params = []; |
|
| 147 | - foreach ($this->content as $filter) { |
|
| 148 | - $params = array_merge($params, $filter->getQueryParams()); |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - return $params; |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * @return INode[] |
|
| 156 | - */ |
|
| 157 | - public function getExtendedNodes(): array |
|
| 158 | - { |
|
| 159 | - return array_merge([$this->hiderBtn, $this->filterBtn, $this->resetBtn], $this->getNodes()); |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - /** |
|
| 163 | - * @param string $template |
|
| 164 | - * |
|
| 165 | - * @return INode |
|
| 166 | - */ |
|
| 167 | - public function setTemplate(string $template): INode |
|
| 168 | - { |
|
| 169 | - $this->template = $template; |
|
| 170 | - |
|
| 171 | - return $this; |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - /** |
|
| 175 | - * @return string |
|
| 176 | - */ |
|
| 177 | - public function __toString(): string |
|
| 178 | - { |
|
| 179 | - $nodes = Tag::__toString(); |
|
| 180 | - |
|
| 181 | - $form = TagHelper::toString($this->tag, $nodes, $this->formAttributes); |
|
| 182 | - |
|
| 183 | - return sprintf( |
|
| 184 | - $this->template, |
|
| 185 | - (string)$this->hiderBtn, |
|
| 186 | - $form |
|
| 187 | - ); |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - /** |
|
| 191 | - * @return Action |
|
| 192 | - */ |
|
| 193 | - public function getHiderBtn(): Action |
|
| 194 | - { |
|
| 195 | - return $this->hiderBtn; |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - /** |
|
| 199 | - * @return Action |
|
| 200 | - */ |
|
| 201 | - public function getFilterBtn(): Action |
|
| 202 | - { |
|
| 203 | - return $this->filterBtn; |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - /** |
|
| 207 | - * @return Action |
|
| 208 | - */ |
|
| 209 | - public function getResetBtn(): Action |
|
| 210 | - { |
|
| 211 | - return $this->resetBtn; |
|
| 212 | - } |
|
| 213 | -} |
|
@@ -41,173 +41,3 @@ |
||
| 41 | 41 | * %2$s - nodes (filters) |
| 42 | 42 | */ |
| 43 | 43 | protected const DEFAULT_TEMPLATE = <<<'EOT' |
| 44 | - <div class="hidable"> |
|
| 45 | - <p class="hider">%1$s</p> |
|
| 46 | - <div class="hidee">%2$s</div> |
|
| 47 | - </div> |
|
| 48 | - EOT; |
|
| 49 | - |
|
| 50 | - protected string $template = self::DEFAULT_TEMPLATE; |
|
| 51 | - |
|
| 52 | - /** @var IFilter[] */ |
|
| 53 | - protected array $content = []; |
|
| 54 | - |
|
| 55 | - protected string $nodeClass = IFilter::class; |
|
| 56 | - |
|
| 57 | - protected Action $hiderBtn; |
|
| 58 | - protected Action $filterBtn; |
|
| 59 | - protected Action $resetBtn; |
|
| 60 | - |
|
| 61 | - /** @var array<string,Attribute> */ |
|
| 62 | - protected array $formAttributes; |
|
| 63 | - |
|
| 64 | - /** @var array<string,Attribute> */ |
|
| 65 | - protected array $searchAttributes; |
|
| 66 | - |
|
| 67 | - /** @var array<string,Attribute> */ |
|
| 68 | - protected array $resetAttributes; |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * Filters constructor. |
|
| 72 | - * |
|
| 73 | - * @param string[] $intents |
|
| 74 | - * @param array<string,Attribute>|null $attributes |
|
| 75 | - * @param string|null $tag |
|
| 76 | - */ |
|
| 77 | - public function __construct(array $intents = [], ?array $attributes = null, ?string $tag = null) |
|
| 78 | - { |
|
| 79 | - parent::__construct(null, $intents, $attributes, $tag); |
|
| 80 | - |
|
| 81 | - $this->formAttributes = Attributes::fromArray(static::ATTRIBUTES_FORM); |
|
| 82 | - $this->searchAttributes = Attributes::fromArray(static::ATTRIBUTES_SEARCH); |
|
| 83 | - $this->resetAttributes = Attributes::fromArray(static::ATTRIBUTES_RESET); |
|
| 84 | - |
|
| 85 | - $this->hiderBtn = new Action(static::BTN_CONTENT_FILTERS, [Action::INTENT_INFO]); |
|
| 86 | - $this->filterBtn = new Action(static::BTN_CONTENT_FILTER, [Action::INTENT_PRIMARY], $this->searchAttributes); |
|
| 87 | - $this->resetBtn = new Action(static::BTN_CONTENT_RESET, [Action::INTENT_SECONDARY], $this->resetAttributes); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * @param array $params |
|
| 92 | - * |
|
| 93 | - * @return $this |
|
| 94 | - */ |
|
| 95 | - public function setParams(array $params): Filters |
|
| 96 | - { |
|
| 97 | - foreach ($this->content as $filter) { |
|
| 98 | - $filter->setParams($params); |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - return $this; |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * @param string $baseUrl |
|
| 106 | - * |
|
| 107 | - * @return string |
|
| 108 | - */ |
|
| 109 | - public function getUrl(string $baseUrl): string |
|
| 110 | - { |
|
| 111 | - $queryParts = []; |
|
| 112 | - foreach ($this->content as $filter) { |
|
| 113 | - $queryPart = $filter->getQueryPart(); |
|
| 114 | - if (!$queryPart) { |
|
| 115 | - continue; |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - $queryParts[] = $queryPart; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - if (empty($queryParts)) { |
|
| 122 | - return $baseUrl; |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - return sprintf('%s%s&', $baseUrl, implode('&', $queryParts)); |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - /** |
|
| 129 | - * @return array |
|
| 130 | - */ |
|
| 131 | - public function getWhereConditions(): array |
|
| 132 | - { |
|
| 133 | - $conditions = []; |
|
| 134 | - foreach ($this->content as $filter) { |
|
| 135 | - $conditions = array_merge($conditions, $filter->getWhereConditions()); |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - return $conditions; |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * @return array<string,string> |
|
| 143 | - */ |
|
| 144 | - public function getSqlParams(): array |
|
| 145 | - { |
|
| 146 | - $params = []; |
|
| 147 | - foreach ($this->content as $filter) { |
|
| 148 | - $params = array_merge($params, $filter->getQueryParams()); |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - return $params; |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * @return INode[] |
|
| 156 | - */ |
|
| 157 | - public function getExtendedNodes(): array |
|
| 158 | - { |
|
| 159 | - return array_merge([$this->hiderBtn, $this->filterBtn, $this->resetBtn], $this->getNodes()); |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - /** |
|
| 163 | - * @param string $template |
|
| 164 | - * |
|
| 165 | - * @return INode |
|
| 166 | - */ |
|
| 167 | - public function setTemplate(string $template): INode |
|
| 168 | - { |
|
| 169 | - $this->template = $template; |
|
| 170 | - |
|
| 171 | - return $this; |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - /** |
|
| 175 | - * @return string |
|
| 176 | - */ |
|
| 177 | - public function __toString(): string |
|
| 178 | - { |
|
| 179 | - $nodes = Tag::__toString(); |
|
| 180 | - |
|
| 181 | - $form = TagHelper::toString($this->tag, $nodes, $this->formAttributes); |
|
| 182 | - |
|
| 183 | - return sprintf( |
|
| 184 | - $this->template, |
|
| 185 | - (string)$this->hiderBtn, |
|
| 186 | - $form |
|
| 187 | - ); |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - /** |
|
| 191 | - * @return Action |
|
| 192 | - */ |
|
| 193 | - public function getHiderBtn(): Action |
|
| 194 | - { |
|
| 195 | - return $this->hiderBtn; |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - /** |
|
| 199 | - * @return Action |
|
| 200 | - */ |
|
| 201 | - public function getFilterBtn(): Action |
|
| 202 | - { |
|
| 203 | - return $this->filterBtn; |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - /** |
|
| 207 | - * @return Action |
|
| 208 | - */ |
|
| 209 | - public function getResetBtn(): Action |
|
| 210 | - { |
|
| 211 | - return $this->resetBtn; |
|
| 212 | - } |
|
| 213 | -} |
|
@@ -41,173 +41,3 @@ |
||
| 41 | 41 | * %2$s - nodes (filters) |
| 42 | 42 | */ |
| 43 | 43 | protected const DEFAULT_TEMPLATE = <<<'EOT' |
| 44 | - <div class="hidable"> |
|
| 45 | - <p class="hider">%1$s</p> |
|
| 46 | - <div class="hidee">%2$s</div> |
|
| 47 | - </div> |
|
| 48 | - EOT; |
|
| 49 | - |
|
| 50 | - protected string $template = self::DEFAULT_TEMPLATE; |
|
| 51 | - |
|
| 52 | - /** @var IFilter[] */ |
|
| 53 | - protected array $content = []; |
|
| 54 | - |
|
| 55 | - protected string $nodeClass = IFilter::class; |
|
| 56 | - |
|
| 57 | - protected Action $hiderBtn; |
|
| 58 | - protected Action $filterBtn; |
|
| 59 | - protected Action $resetBtn; |
|
| 60 | - |
|
| 61 | - /** @var array<string,Attribute> */ |
|
| 62 | - protected array $formAttributes; |
|
| 63 | - |
|
| 64 | - /** @var array<string,Attribute> */ |
|
| 65 | - protected array $searchAttributes; |
|
| 66 | - |
|
| 67 | - /** @var array<string,Attribute> */ |
|
| 68 | - protected array $resetAttributes; |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * Filters constructor. |
|
| 72 | - * |
|
| 73 | - * @param string[] $intents |
|
| 74 | - * @param array<string,Attribute>|null $attributes |
|
| 75 | - * @param string|null $tag |
|
| 76 | - */ |
|
| 77 | - public function __construct(array $intents = [], ?array $attributes = null, ?string $tag = null) |
|
| 78 | - { |
|
| 79 | - parent::__construct(null, $intents, $attributes, $tag); |
|
| 80 | - |
|
| 81 | - $this->formAttributes = Attributes::fromArray(static::ATTRIBUTES_FORM); |
|
| 82 | - $this->searchAttributes = Attributes::fromArray(static::ATTRIBUTES_SEARCH); |
|
| 83 | - $this->resetAttributes = Attributes::fromArray(static::ATTRIBUTES_RESET); |
|
| 84 | - |
|
| 85 | - $this->hiderBtn = new Action(static::BTN_CONTENT_FILTERS, [Action::INTENT_INFO]); |
|
| 86 | - $this->filterBtn = new Action(static::BTN_CONTENT_FILTER, [Action::INTENT_PRIMARY], $this->searchAttributes); |
|
| 87 | - $this->resetBtn = new Action(static::BTN_CONTENT_RESET, [Action::INTENT_SECONDARY], $this->resetAttributes); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * @param array $params |
|
| 92 | - * |
|
| 93 | - * @return $this |
|
| 94 | - */ |
|
| 95 | - public function setParams(array $params): Filters |
|
| 96 | - { |
|
| 97 | - foreach ($this->content as $filter) { |
|
| 98 | - $filter->setParams($params); |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - return $this; |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * @param string $baseUrl |
|
| 106 | - * |
|
| 107 | - * @return string |
|
| 108 | - */ |
|
| 109 | - public function getUrl(string $baseUrl): string |
|
| 110 | - { |
|
| 111 | - $queryParts = []; |
|
| 112 | - foreach ($this->content as $filter) { |
|
| 113 | - $queryPart = $filter->getQueryPart(); |
|
| 114 | - if (!$queryPart) { |
|
| 115 | - continue; |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - $queryParts[] = $queryPart; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - if (empty($queryParts)) { |
|
| 122 | - return $baseUrl; |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - return sprintf('%s%s&', $baseUrl, implode('&', $queryParts)); |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - /** |
|
| 129 | - * @return array |
|
| 130 | - */ |
|
| 131 | - public function getWhereConditions(): array |
|
| 132 | - { |
|
| 133 | - $conditions = []; |
|
| 134 | - foreach ($this->content as $filter) { |
|
| 135 | - $conditions = array_merge($conditions, $filter->getWhereConditions()); |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - return $conditions; |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * @return array<string,string> |
|
| 143 | - */ |
|
| 144 | - public function getSqlParams(): array |
|
| 145 | - { |
|
| 146 | - $params = []; |
|
| 147 | - foreach ($this->content as $filter) { |
|
| 148 | - $params = array_merge($params, $filter->getQueryParams()); |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - return $params; |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * @return INode[] |
|
| 156 | - */ |
|
| 157 | - public function getExtendedNodes(): array |
|
| 158 | - { |
|
| 159 | - return array_merge([$this->hiderBtn, $this->filterBtn, $this->resetBtn], $this->getNodes()); |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - /** |
|
| 163 | - * @param string $template |
|
| 164 | - * |
|
| 165 | - * @return INode |
|
| 166 | - */ |
|
| 167 | - public function setTemplate(string $template): INode |
|
| 168 | - { |
|
| 169 | - $this->template = $template; |
|
| 170 | - |
|
| 171 | - return $this; |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - /** |
|
| 175 | - * @return string |
|
| 176 | - */ |
|
| 177 | - public function __toString(): string |
|
| 178 | - { |
|
| 179 | - $nodes = Tag::__toString(); |
|
| 180 | - |
|
| 181 | - $form = TagHelper::toString($this->tag, $nodes, $this->formAttributes); |
|
| 182 | - |
|
| 183 | - return sprintf( |
|
| 184 | - $this->template, |
|
| 185 | - (string)$this->hiderBtn, |
|
| 186 | - $form |
|
| 187 | - ); |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - /** |
|
| 191 | - * @return Action |
|
| 192 | - */ |
|
| 193 | - public function getHiderBtn(): Action |
|
| 194 | - { |
|
| 195 | - return $this->hiderBtn; |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - /** |
|
| 199 | - * @return Action |
|
| 200 | - */ |
|
| 201 | - public function getFilterBtn(): Action |
|
| 202 | - { |
|
| 203 | - return $this->filterBtn; |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - /** |
|
| 207 | - * @return Action |
|
| 208 | - */ |
|
| 209 | - public function getResetBtn(): Action |
|
| 210 | - { |
|
| 211 | - return $this->resetBtn; |
|
| 212 | - } |
|
| 213 | -} |
|
@@ -41,173 +41,3 @@ |
||
| 41 | 41 | * %2$s - nodes (filters) |
| 42 | 42 | */ |
| 43 | 43 | protected const DEFAULT_TEMPLATE = <<<'EOT' |
| 44 | - <div class="hidable"> |
|
| 45 | - <p class="hider">%1$s</p> |
|
| 46 | - <div class="hidee">%2$s</div> |
|
| 47 | - </div> |
|
| 48 | - EOT; |
|
| 49 | - |
|
| 50 | - protected string $template = self::DEFAULT_TEMPLATE; |
|
| 51 | - |
|
| 52 | - /** @var IFilter[] */ |
|
| 53 | - protected array $content = []; |
|
| 54 | - |
|
| 55 | - protected string $nodeClass = IFilter::class; |
|
| 56 | - |
|
| 57 | - protected Action $hiderBtn; |
|
| 58 | - protected Action $filterBtn; |
|
| 59 | - protected Action $resetBtn; |
|
| 60 | - |
|
| 61 | - /** @var array<string,Attribute> */ |
|
| 62 | - protected array $formAttributes; |
|
| 63 | - |
|
| 64 | - /** @var array<string,Attribute> */ |
|
| 65 | - protected array $searchAttributes; |
|
| 66 | - |
|
| 67 | - /** @var array<string,Attribute> */ |
|
| 68 | - protected array $resetAttributes; |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * Filters constructor. |
|
| 72 | - * |
|
| 73 | - * @param string[] $intents |
|
| 74 | - * @param array<string,Attribute>|null $attributes |
|
| 75 | - * @param string|null $tag |
|
| 76 | - */ |
|
| 77 | - public function __construct(array $intents = [], ?array $attributes = null, ?string $tag = null) |
|
| 78 | - { |
|
| 79 | - parent::__construct(null, $intents, $attributes, $tag); |
|
| 80 | - |
|
| 81 | - $this->formAttributes = Attributes::fromArray(static::ATTRIBUTES_FORM); |
|
| 82 | - $this->searchAttributes = Attributes::fromArray(static::ATTRIBUTES_SEARCH); |
|
| 83 | - $this->resetAttributes = Attributes::fromArray(static::ATTRIBUTES_RESET); |
|
| 84 | - |
|
| 85 | - $this->hiderBtn = new Action(static::BTN_CONTENT_FILTERS, [Action::INTENT_INFO]); |
|
| 86 | - $this->filterBtn = new Action(static::BTN_CONTENT_FILTER, [Action::INTENT_PRIMARY], $this->searchAttributes); |
|
| 87 | - $this->resetBtn = new Action(static::BTN_CONTENT_RESET, [Action::INTENT_SECONDARY], $this->resetAttributes); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * @param array $params |
|
| 92 | - * |
|
| 93 | - * @return $this |
|
| 94 | - */ |
|
| 95 | - public function setParams(array $params): Filters |
|
| 96 | - { |
|
| 97 | - foreach ($this->content as $filter) { |
|
| 98 | - $filter->setParams($params); |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - return $this; |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * @param string $baseUrl |
|
| 106 | - * |
|
| 107 | - * @return string |
|
| 108 | - */ |
|
| 109 | - public function getUrl(string $baseUrl): string |
|
| 110 | - { |
|
| 111 | - $queryParts = []; |
|
| 112 | - foreach ($this->content as $filter) { |
|
| 113 | - $queryPart = $filter->getQueryPart(); |
|
| 114 | - if (!$queryPart) { |
|
| 115 | - continue; |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - $queryParts[] = $queryPart; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - if (empty($queryParts)) { |
|
| 122 | - return $baseUrl; |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - return sprintf('%s%s&', $baseUrl, implode('&', $queryParts)); |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - /** |
|
| 129 | - * @return array |
|
| 130 | - */ |
|
| 131 | - public function getWhereConditions(): array |
|
| 132 | - { |
|
| 133 | - $conditions = []; |
|
| 134 | - foreach ($this->content as $filter) { |
|
| 135 | - $conditions = array_merge($conditions, $filter->getWhereConditions()); |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - return $conditions; |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * @return array<string,string> |
|
| 143 | - */ |
|
| 144 | - public function getSqlParams(): array |
|
| 145 | - { |
|
| 146 | - $params = []; |
|
| 147 | - foreach ($this->content as $filter) { |
|
| 148 | - $params = array_merge($params, $filter->getQueryParams()); |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - return $params; |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * @return INode[] |
|
| 156 | - */ |
|
| 157 | - public function getExtendedNodes(): array |
|
| 158 | - { |
|
| 159 | - return array_merge([$this->hiderBtn, $this->filterBtn, $this->resetBtn], $this->getNodes()); |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - /** |
|
| 163 | - * @param string $template |
|
| 164 | - * |
|
| 165 | - * @return INode |
|
| 166 | - */ |
|
| 167 | - public function setTemplate(string $template): INode |
|
| 168 | - { |
|
| 169 | - $this->template = $template; |
|
| 170 | - |
|
| 171 | - return $this; |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - /** |
|
| 175 | - * @return string |
|
| 176 | - */ |
|
| 177 | - public function __toString(): string |
|
| 178 | - { |
|
| 179 | - $nodes = Tag::__toString(); |
|
| 180 | - |
|
| 181 | - $form = TagHelper::toString($this->tag, $nodes, $this->formAttributes); |
|
| 182 | - |
|
| 183 | - return sprintf( |
|
| 184 | - $this->template, |
|
| 185 | - (string)$this->hiderBtn, |
|
| 186 | - $form |
|
| 187 | - ); |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - /** |
|
| 191 | - * @return Action |
|
| 192 | - */ |
|
| 193 | - public function getHiderBtn(): Action |
|
| 194 | - { |
|
| 195 | - return $this->hiderBtn; |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - /** |
|
| 199 | - * @return Action |
|
| 200 | - */ |
|
| 201 | - public function getFilterBtn(): Action |
|
| 202 | - { |
|
| 203 | - return $this->filterBtn; |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - /** |
|
| 207 | - * @return Action |
|
| 208 | - */ |
|
| 209 | - public function getResetBtn(): Action |
|
| 210 | - { |
|
| 211 | - return $this->resetBtn; |
|
| 212 | - } |
|
| 213 | -} |
|
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | ?array $attributes = null, |
| 79 | 79 | ?string $tag = Html5::TAG_A |
| 80 | 80 | ): ButtonComponent { |
| 81 | - $attributes ??= []; |
|
| 81 | + $attributes ??= []; |
|
| 82 | 82 | $attributes[Html5::ATTR_HREF] = new Attribute(Html5::ATTR_HREF, $url); |
| 83 | 83 | |
| 84 | 84 | if ($icon) { |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | ): ButtonComponent { |
| 120 | 120 | $url = $this->urlGenerator->createFromName($urlName, ...$urlArgs); |
| 121 | 121 | |
| 122 | - $attributes ??= []; |
|
| 122 | + $attributes ??= []; |
|
| 123 | 123 | $attributes[Html5::ATTR_HREF] = new Attribute(Html5::ATTR_HREF, $url); |
| 124 | 124 | |
| 125 | 125 | if ($icon) { |