@@ -59,7 +59,7 @@ |
||
59 | 59 | Html5::ATTR_CLASS => [static::CLASS_COUNT], |
60 | 60 | ] |
61 | 61 | ); |
62 | - $this->counter = new Component(null, [], $counterAttributes); |
|
62 | + $this->counter = new Component(null, [], $counterAttributes); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -40,168 +40,3 @@ |
||
40 | 40 | * %2$s - nodes (filters) |
41 | 41 | */ |
42 | 42 | protected const DEFAULT_TEMPLATE = <<<'EOT' |
43 | - <div class="hidable"> |
|
44 | - <p class="hider">%1$s</p> |
|
45 | - <div class="hidee">%2$s</div> |
|
46 | - </div> |
|
47 | - EOT; |
|
48 | - |
|
49 | - protected string $template = self::DEFAULT_TEMPLATE; |
|
50 | - |
|
51 | - /** @var IFilter[] */ |
|
52 | - protected array $nodes = []; |
|
53 | - |
|
54 | - protected string $nodeClass = IFilter::class; |
|
55 | - |
|
56 | - protected Action $hiderBtn; |
|
57 | - protected Action $filterBtn; |
|
58 | - protected Action $resetBtn; |
|
59 | - |
|
60 | - protected Attributes $formAttributes; |
|
61 | - protected Attributes $searchAttributes; |
|
62 | - protected Attributes $resetAttributes; |
|
63 | - |
|
64 | - /** |
|
65 | - * Filters constructor. |
|
66 | - * |
|
67 | - * @param string[] $intents |
|
68 | - * @param Attributes|null $attributes |
|
69 | - * @param string|null $tag |
|
70 | - */ |
|
71 | - public function __construct(array $intents = [], ?Attributes $attributes = null, ?string $tag = null) |
|
72 | - { |
|
73 | - parent::__construct(null, $intents, $attributes, $tag); |
|
74 | - |
|
75 | - $this->formAttributes = new Attributes(static::ATTRIBUTES_FORM); |
|
76 | - $this->searchAttributes = new Attributes(static::ATTRIBUTES_SEARCH); |
|
77 | - $this->resetAttributes = new Attributes(static::ATTRIBUTES_RESET); |
|
78 | - |
|
79 | - $this->hiderBtn = new Action(static::BTN_CONTENT_FILTERS, [Action::INTENT_INFO]); |
|
80 | - $this->filterBtn = new Action(static::BTN_CONTENT_FILTER, [Action::INTENT_PRIMARY], $this->searchAttributes); |
|
81 | - $this->resetBtn = new Action(static::BTN_CONTENT_RESET, [Action::INTENT_SECONDARY], $this->resetAttributes); |
|
82 | - } |
|
83 | - |
|
84 | - /** |
|
85 | - * @param array $params |
|
86 | - * |
|
87 | - * @return $this |
|
88 | - */ |
|
89 | - public function setParams(array $params): Filters |
|
90 | - { |
|
91 | - foreach ($this->nodes as $filter) { |
|
92 | - $filter->setParams($params); |
|
93 | - } |
|
94 | - |
|
95 | - return $this; |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * @param string $baseUrl |
|
100 | - * |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - public function getUrl(string $baseUrl): string |
|
104 | - { |
|
105 | - $queryParts = []; |
|
106 | - foreach ($this->nodes as $filter) { |
|
107 | - $queryPart = $filter->getQueryPart(); |
|
108 | - if (!$queryPart) { |
|
109 | - continue; |
|
110 | - } |
|
111 | - |
|
112 | - $queryParts[] = $queryPart; |
|
113 | - } |
|
114 | - |
|
115 | - if (empty($queryParts)) { |
|
116 | - return $baseUrl; |
|
117 | - } |
|
118 | - |
|
119 | - return sprintf('%s%s&', $baseUrl, implode('&', $queryParts)); |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * @return array |
|
124 | - */ |
|
125 | - public function getWhereConditions(): array |
|
126 | - { |
|
127 | - $conditions = []; |
|
128 | - foreach ($this->nodes as $filter) { |
|
129 | - $conditions = array_merge($conditions, $filter->getWhereConditions()); |
|
130 | - } |
|
131 | - |
|
132 | - return $conditions; |
|
133 | - } |
|
134 | - |
|
135 | - /** |
|
136 | - * @return array<string,string> |
|
137 | - */ |
|
138 | - public function getSqlParams(): array |
|
139 | - { |
|
140 | - $params = []; |
|
141 | - foreach ($this->nodes as $filter) { |
|
142 | - $params = array_merge($params, $filter->getQueryParams()); |
|
143 | - } |
|
144 | - |
|
145 | - return $params; |
|
146 | - } |
|
147 | - |
|
148 | - /** |
|
149 | - * @return INode[] |
|
150 | - */ |
|
151 | - public function getExtendedNodes(): array |
|
152 | - { |
|
153 | - return array_merge([$this->hiderBtn, $this->filterBtn, $this->resetBtn], $this->getNodes()); |
|
154 | - } |
|
155 | - |
|
156 | - /** |
|
157 | - * @param string $template |
|
158 | - * |
|
159 | - * @return INode |
|
160 | - */ |
|
161 | - public function setTemplate(string $template): INode |
|
162 | - { |
|
163 | - $this->template = $template; |
|
164 | - |
|
165 | - return $this; |
|
166 | - } |
|
167 | - |
|
168 | - /** |
|
169 | - * @return string |
|
170 | - */ |
|
171 | - public function __toString(): string |
|
172 | - { |
|
173 | - $nodes = Collection::__toString(); |
|
174 | - |
|
175 | - $form = TagHelper::toString($this->tag, $nodes, $this->formAttributes); |
|
176 | - |
|
177 | - return sprintf( |
|
178 | - $this->template, |
|
179 | - (string)$this->hiderBtn, |
|
180 | - $form |
|
181 | - ); |
|
182 | - } |
|
183 | - |
|
184 | - /** |
|
185 | - * @return Action |
|
186 | - */ |
|
187 | - public function getHiderBtn(): Action |
|
188 | - { |
|
189 | - return $this->hiderBtn; |
|
190 | - } |
|
191 | - |
|
192 | - /** |
|
193 | - * @return Action |
|
194 | - */ |
|
195 | - public function getFilterBtn(): Action |
|
196 | - { |
|
197 | - return $this->filterBtn; |
|
198 | - } |
|
199 | - |
|
200 | - /** |
|
201 | - * @return Action |
|
202 | - */ |
|
203 | - public function getResetBtn(): Action |
|
204 | - { |
|
205 | - return $this->resetBtn; |
|
206 | - } |
|
207 | -} |
@@ -40,168 +40,3 @@ |
||
40 | 40 | * %2$s - nodes (filters) |
41 | 41 | */ |
42 | 42 | protected const DEFAULT_TEMPLATE = <<<'EOT' |
43 | - <div class="hidable"> |
|
44 | - <p class="hider">%1$s</p> |
|
45 | - <div class="hidee">%2$s</div> |
|
46 | - </div> |
|
47 | - EOT; |
|
48 | - |
|
49 | - protected string $template = self::DEFAULT_TEMPLATE; |
|
50 | - |
|
51 | - /** @var IFilter[] */ |
|
52 | - protected array $nodes = []; |
|
53 | - |
|
54 | - protected string $nodeClass = IFilter::class; |
|
55 | - |
|
56 | - protected Action $hiderBtn; |
|
57 | - protected Action $filterBtn; |
|
58 | - protected Action $resetBtn; |
|
59 | - |
|
60 | - protected Attributes $formAttributes; |
|
61 | - protected Attributes $searchAttributes; |
|
62 | - protected Attributes $resetAttributes; |
|
63 | - |
|
64 | - /** |
|
65 | - * Filters constructor. |
|
66 | - * |
|
67 | - * @param string[] $intents |
|
68 | - * @param Attributes|null $attributes |
|
69 | - * @param string|null $tag |
|
70 | - */ |
|
71 | - public function __construct(array $intents = [], ?Attributes $attributes = null, ?string $tag = null) |
|
72 | - { |
|
73 | - parent::__construct(null, $intents, $attributes, $tag); |
|
74 | - |
|
75 | - $this->formAttributes = new Attributes(static::ATTRIBUTES_FORM); |
|
76 | - $this->searchAttributes = new Attributes(static::ATTRIBUTES_SEARCH); |
|
77 | - $this->resetAttributes = new Attributes(static::ATTRIBUTES_RESET); |
|
78 | - |
|
79 | - $this->hiderBtn = new Action(static::BTN_CONTENT_FILTERS, [Action::INTENT_INFO]); |
|
80 | - $this->filterBtn = new Action(static::BTN_CONTENT_FILTER, [Action::INTENT_PRIMARY], $this->searchAttributes); |
|
81 | - $this->resetBtn = new Action(static::BTN_CONTENT_RESET, [Action::INTENT_SECONDARY], $this->resetAttributes); |
|
82 | - } |
|
83 | - |
|
84 | - /** |
|
85 | - * @param array $params |
|
86 | - * |
|
87 | - * @return $this |
|
88 | - */ |
|
89 | - public function setParams(array $params): Filters |
|
90 | - { |
|
91 | - foreach ($this->nodes as $filter) { |
|
92 | - $filter->setParams($params); |
|
93 | - } |
|
94 | - |
|
95 | - return $this; |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * @param string $baseUrl |
|
100 | - * |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - public function getUrl(string $baseUrl): string |
|
104 | - { |
|
105 | - $queryParts = []; |
|
106 | - foreach ($this->nodes as $filter) { |
|
107 | - $queryPart = $filter->getQueryPart(); |
|
108 | - if (!$queryPart) { |
|
109 | - continue; |
|
110 | - } |
|
111 | - |
|
112 | - $queryParts[] = $queryPart; |
|
113 | - } |
|
114 | - |
|
115 | - if (empty($queryParts)) { |
|
116 | - return $baseUrl; |
|
117 | - } |
|
118 | - |
|
119 | - return sprintf('%s%s&', $baseUrl, implode('&', $queryParts)); |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * @return array |
|
124 | - */ |
|
125 | - public function getWhereConditions(): array |
|
126 | - { |
|
127 | - $conditions = []; |
|
128 | - foreach ($this->nodes as $filter) { |
|
129 | - $conditions = array_merge($conditions, $filter->getWhereConditions()); |
|
130 | - } |
|
131 | - |
|
132 | - return $conditions; |
|
133 | - } |
|
134 | - |
|
135 | - /** |
|
136 | - * @return array<string,string> |
|
137 | - */ |
|
138 | - public function getSqlParams(): array |
|
139 | - { |
|
140 | - $params = []; |
|
141 | - foreach ($this->nodes as $filter) { |
|
142 | - $params = array_merge($params, $filter->getQueryParams()); |
|
143 | - } |
|
144 | - |
|
145 | - return $params; |
|
146 | - } |
|
147 | - |
|
148 | - /** |
|
149 | - * @return INode[] |
|
150 | - */ |
|
151 | - public function getExtendedNodes(): array |
|
152 | - { |
|
153 | - return array_merge([$this->hiderBtn, $this->filterBtn, $this->resetBtn], $this->getNodes()); |
|
154 | - } |
|
155 | - |
|
156 | - /** |
|
157 | - * @param string $template |
|
158 | - * |
|
159 | - * @return INode |
|
160 | - */ |
|
161 | - public function setTemplate(string $template): INode |
|
162 | - { |
|
163 | - $this->template = $template; |
|
164 | - |
|
165 | - return $this; |
|
166 | - } |
|
167 | - |
|
168 | - /** |
|
169 | - * @return string |
|
170 | - */ |
|
171 | - public function __toString(): string |
|
172 | - { |
|
173 | - $nodes = Collection::__toString(); |
|
174 | - |
|
175 | - $form = TagHelper::toString($this->tag, $nodes, $this->formAttributes); |
|
176 | - |
|
177 | - return sprintf( |
|
178 | - $this->template, |
|
179 | - (string)$this->hiderBtn, |
|
180 | - $form |
|
181 | - ); |
|
182 | - } |
|
183 | - |
|
184 | - /** |
|
185 | - * @return Action |
|
186 | - */ |
|
187 | - public function getHiderBtn(): Action |
|
188 | - { |
|
189 | - return $this->hiderBtn; |
|
190 | - } |
|
191 | - |
|
192 | - /** |
|
193 | - * @return Action |
|
194 | - */ |
|
195 | - public function getFilterBtn(): Action |
|
196 | - { |
|
197 | - return $this->filterBtn; |
|
198 | - } |
|
199 | - |
|
200 | - /** |
|
201 | - * @return Action |
|
202 | - */ |
|
203 | - public function getResetBtn(): Action |
|
204 | - { |
|
205 | - return $this->resetBtn; |
|
206 | - } |
|
207 | -} |
@@ -40,168 +40,3 @@ |
||
40 | 40 | * %2$s - nodes (filters) |
41 | 41 | */ |
42 | 42 | protected const DEFAULT_TEMPLATE = <<<'EOT' |
43 | - <div class="hidable"> |
|
44 | - <p class="hider">%1$s</p> |
|
45 | - <div class="hidee">%2$s</div> |
|
46 | - </div> |
|
47 | - EOT; |
|
48 | - |
|
49 | - protected string $template = self::DEFAULT_TEMPLATE; |
|
50 | - |
|
51 | - /** @var IFilter[] */ |
|
52 | - protected array $nodes = []; |
|
53 | - |
|
54 | - protected string $nodeClass = IFilter::class; |
|
55 | - |
|
56 | - protected Action $hiderBtn; |
|
57 | - protected Action $filterBtn; |
|
58 | - protected Action $resetBtn; |
|
59 | - |
|
60 | - protected Attributes $formAttributes; |
|
61 | - protected Attributes $searchAttributes; |
|
62 | - protected Attributes $resetAttributes; |
|
63 | - |
|
64 | - /** |
|
65 | - * Filters constructor. |
|
66 | - * |
|
67 | - * @param string[] $intents |
|
68 | - * @param Attributes|null $attributes |
|
69 | - * @param string|null $tag |
|
70 | - */ |
|
71 | - public function __construct(array $intents = [], ?Attributes $attributes = null, ?string $tag = null) |
|
72 | - { |
|
73 | - parent::__construct(null, $intents, $attributes, $tag); |
|
74 | - |
|
75 | - $this->formAttributes = new Attributes(static::ATTRIBUTES_FORM); |
|
76 | - $this->searchAttributes = new Attributes(static::ATTRIBUTES_SEARCH); |
|
77 | - $this->resetAttributes = new Attributes(static::ATTRIBUTES_RESET); |
|
78 | - |
|
79 | - $this->hiderBtn = new Action(static::BTN_CONTENT_FILTERS, [Action::INTENT_INFO]); |
|
80 | - $this->filterBtn = new Action(static::BTN_CONTENT_FILTER, [Action::INTENT_PRIMARY], $this->searchAttributes); |
|
81 | - $this->resetBtn = new Action(static::BTN_CONTENT_RESET, [Action::INTENT_SECONDARY], $this->resetAttributes); |
|
82 | - } |
|
83 | - |
|
84 | - /** |
|
85 | - * @param array $params |
|
86 | - * |
|
87 | - * @return $this |
|
88 | - */ |
|
89 | - public function setParams(array $params): Filters |
|
90 | - { |
|
91 | - foreach ($this->nodes as $filter) { |
|
92 | - $filter->setParams($params); |
|
93 | - } |
|
94 | - |
|
95 | - return $this; |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * @param string $baseUrl |
|
100 | - * |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - public function getUrl(string $baseUrl): string |
|
104 | - { |
|
105 | - $queryParts = []; |
|
106 | - foreach ($this->nodes as $filter) { |
|
107 | - $queryPart = $filter->getQueryPart(); |
|
108 | - if (!$queryPart) { |
|
109 | - continue; |
|
110 | - } |
|
111 | - |
|
112 | - $queryParts[] = $queryPart; |
|
113 | - } |
|
114 | - |
|
115 | - if (empty($queryParts)) { |
|
116 | - return $baseUrl; |
|
117 | - } |
|
118 | - |
|
119 | - return sprintf('%s%s&', $baseUrl, implode('&', $queryParts)); |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * @return array |
|
124 | - */ |
|
125 | - public function getWhereConditions(): array |
|
126 | - { |
|
127 | - $conditions = []; |
|
128 | - foreach ($this->nodes as $filter) { |
|
129 | - $conditions = array_merge($conditions, $filter->getWhereConditions()); |
|
130 | - } |
|
131 | - |
|
132 | - return $conditions; |
|
133 | - } |
|
134 | - |
|
135 | - /** |
|
136 | - * @return array<string,string> |
|
137 | - */ |
|
138 | - public function getSqlParams(): array |
|
139 | - { |
|
140 | - $params = []; |
|
141 | - foreach ($this->nodes as $filter) { |
|
142 | - $params = array_merge($params, $filter->getQueryParams()); |
|
143 | - } |
|
144 | - |
|
145 | - return $params; |
|
146 | - } |
|
147 | - |
|
148 | - /** |
|
149 | - * @return INode[] |
|
150 | - */ |
|
151 | - public function getExtendedNodes(): array |
|
152 | - { |
|
153 | - return array_merge([$this->hiderBtn, $this->filterBtn, $this->resetBtn], $this->getNodes()); |
|
154 | - } |
|
155 | - |
|
156 | - /** |
|
157 | - * @param string $template |
|
158 | - * |
|
159 | - * @return INode |
|
160 | - */ |
|
161 | - public function setTemplate(string $template): INode |
|
162 | - { |
|
163 | - $this->template = $template; |
|
164 | - |
|
165 | - return $this; |
|
166 | - } |
|
167 | - |
|
168 | - /** |
|
169 | - * @return string |
|
170 | - */ |
|
171 | - public function __toString(): string |
|
172 | - { |
|
173 | - $nodes = Collection::__toString(); |
|
174 | - |
|
175 | - $form = TagHelper::toString($this->tag, $nodes, $this->formAttributes); |
|
176 | - |
|
177 | - return sprintf( |
|
178 | - $this->template, |
|
179 | - (string)$this->hiderBtn, |
|
180 | - $form |
|
181 | - ); |
|
182 | - } |
|
183 | - |
|
184 | - /** |
|
185 | - * @return Action |
|
186 | - */ |
|
187 | - public function getHiderBtn(): Action |
|
188 | - { |
|
189 | - return $this->hiderBtn; |
|
190 | - } |
|
191 | - |
|
192 | - /** |
|
193 | - * @return Action |
|
194 | - */ |
|
195 | - public function getFilterBtn(): Action |
|
196 | - { |
|
197 | - return $this->filterBtn; |
|
198 | - } |
|
199 | - |
|
200 | - /** |
|
201 | - * @return Action |
|
202 | - */ |
|
203 | - public function getResetBtn(): Action |
|
204 | - { |
|
205 | - return $this->resetBtn; |
|
206 | - } |
|
207 | -} |
@@ -40,168 +40,3 @@ |
||
40 | 40 | * %2$s - nodes (filters) |
41 | 41 | */ |
42 | 42 | protected const DEFAULT_TEMPLATE = <<<'EOT' |
43 | - <div class="hidable"> |
|
44 | - <p class="hider">%1$s</p> |
|
45 | - <div class="hidee">%2$s</div> |
|
46 | - </div> |
|
47 | - EOT; |
|
48 | - |
|
49 | - protected string $template = self::DEFAULT_TEMPLATE; |
|
50 | - |
|
51 | - /** @var IFilter[] */ |
|
52 | - protected array $nodes = []; |
|
53 | - |
|
54 | - protected string $nodeClass = IFilter::class; |
|
55 | - |
|
56 | - protected Action $hiderBtn; |
|
57 | - protected Action $filterBtn; |
|
58 | - protected Action $resetBtn; |
|
59 | - |
|
60 | - protected Attributes $formAttributes; |
|
61 | - protected Attributes $searchAttributes; |
|
62 | - protected Attributes $resetAttributes; |
|
63 | - |
|
64 | - /** |
|
65 | - * Filters constructor. |
|
66 | - * |
|
67 | - * @param string[] $intents |
|
68 | - * @param Attributes|null $attributes |
|
69 | - * @param string|null $tag |
|
70 | - */ |
|
71 | - public function __construct(array $intents = [], ?Attributes $attributes = null, ?string $tag = null) |
|
72 | - { |
|
73 | - parent::__construct(null, $intents, $attributes, $tag); |
|
74 | - |
|
75 | - $this->formAttributes = new Attributes(static::ATTRIBUTES_FORM); |
|
76 | - $this->searchAttributes = new Attributes(static::ATTRIBUTES_SEARCH); |
|
77 | - $this->resetAttributes = new Attributes(static::ATTRIBUTES_RESET); |
|
78 | - |
|
79 | - $this->hiderBtn = new Action(static::BTN_CONTENT_FILTERS, [Action::INTENT_INFO]); |
|
80 | - $this->filterBtn = new Action(static::BTN_CONTENT_FILTER, [Action::INTENT_PRIMARY], $this->searchAttributes); |
|
81 | - $this->resetBtn = new Action(static::BTN_CONTENT_RESET, [Action::INTENT_SECONDARY], $this->resetAttributes); |
|
82 | - } |
|
83 | - |
|
84 | - /** |
|
85 | - * @param array $params |
|
86 | - * |
|
87 | - * @return $this |
|
88 | - */ |
|
89 | - public function setParams(array $params): Filters |
|
90 | - { |
|
91 | - foreach ($this->nodes as $filter) { |
|
92 | - $filter->setParams($params); |
|
93 | - } |
|
94 | - |
|
95 | - return $this; |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * @param string $baseUrl |
|
100 | - * |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - public function getUrl(string $baseUrl): string |
|
104 | - { |
|
105 | - $queryParts = []; |
|
106 | - foreach ($this->nodes as $filter) { |
|
107 | - $queryPart = $filter->getQueryPart(); |
|
108 | - if (!$queryPart) { |
|
109 | - continue; |
|
110 | - } |
|
111 | - |
|
112 | - $queryParts[] = $queryPart; |
|
113 | - } |
|
114 | - |
|
115 | - if (empty($queryParts)) { |
|
116 | - return $baseUrl; |
|
117 | - } |
|
118 | - |
|
119 | - return sprintf('%s%s&', $baseUrl, implode('&', $queryParts)); |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * @return array |
|
124 | - */ |
|
125 | - public function getWhereConditions(): array |
|
126 | - { |
|
127 | - $conditions = []; |
|
128 | - foreach ($this->nodes as $filter) { |
|
129 | - $conditions = array_merge($conditions, $filter->getWhereConditions()); |
|
130 | - } |
|
131 | - |
|
132 | - return $conditions; |
|
133 | - } |
|
134 | - |
|
135 | - /** |
|
136 | - * @return array<string,string> |
|
137 | - */ |
|
138 | - public function getSqlParams(): array |
|
139 | - { |
|
140 | - $params = []; |
|
141 | - foreach ($this->nodes as $filter) { |
|
142 | - $params = array_merge($params, $filter->getQueryParams()); |
|
143 | - } |
|
144 | - |
|
145 | - return $params; |
|
146 | - } |
|
147 | - |
|
148 | - /** |
|
149 | - * @return INode[] |
|
150 | - */ |
|
151 | - public function getExtendedNodes(): array |
|
152 | - { |
|
153 | - return array_merge([$this->hiderBtn, $this->filterBtn, $this->resetBtn], $this->getNodes()); |
|
154 | - } |
|
155 | - |
|
156 | - /** |
|
157 | - * @param string $template |
|
158 | - * |
|
159 | - * @return INode |
|
160 | - */ |
|
161 | - public function setTemplate(string $template): INode |
|
162 | - { |
|
163 | - $this->template = $template; |
|
164 | - |
|
165 | - return $this; |
|
166 | - } |
|
167 | - |
|
168 | - /** |
|
169 | - * @return string |
|
170 | - */ |
|
171 | - public function __toString(): string |
|
172 | - { |
|
173 | - $nodes = Collection::__toString(); |
|
174 | - |
|
175 | - $form = TagHelper::toString($this->tag, $nodes, $this->formAttributes); |
|
176 | - |
|
177 | - return sprintf( |
|
178 | - $this->template, |
|
179 | - (string)$this->hiderBtn, |
|
180 | - $form |
|
181 | - ); |
|
182 | - } |
|
183 | - |
|
184 | - /** |
|
185 | - * @return Action |
|
186 | - */ |
|
187 | - public function getHiderBtn(): Action |
|
188 | - { |
|
189 | - return $this->hiderBtn; |
|
190 | - } |
|
191 | - |
|
192 | - /** |
|
193 | - * @return Action |
|
194 | - */ |
|
195 | - public function getFilterBtn(): Action |
|
196 | - { |
|
197 | - return $this->filterBtn; |
|
198 | - } |
|
199 | - |
|
200 | - /** |
|
201 | - * @return Action |
|
202 | - */ |
|
203 | - public function getResetBtn(): Action |
|
204 | - { |
|
205 | - return $this->resetBtn; |
|
206 | - } |
|
207 | -} |
@@ -40,168 +40,3 @@ |
||
40 | 40 | * %2$s - nodes (filters) |
41 | 41 | */ |
42 | 42 | protected const DEFAULT_TEMPLATE = <<<'EOT' |
43 | - <div class="hidable"> |
|
44 | - <p class="hider">%1$s</p> |
|
45 | - <div class="hidee">%2$s</div> |
|
46 | - </div> |
|
47 | - EOT; |
|
48 | - |
|
49 | - protected string $template = self::DEFAULT_TEMPLATE; |
|
50 | - |
|
51 | - /** @var IFilter[] */ |
|
52 | - protected array $nodes = []; |
|
53 | - |
|
54 | - protected string $nodeClass = IFilter::class; |
|
55 | - |
|
56 | - protected Action $hiderBtn; |
|
57 | - protected Action $filterBtn; |
|
58 | - protected Action $resetBtn; |
|
59 | - |
|
60 | - protected Attributes $formAttributes; |
|
61 | - protected Attributes $searchAttributes; |
|
62 | - protected Attributes $resetAttributes; |
|
63 | - |
|
64 | - /** |
|
65 | - * Filters constructor. |
|
66 | - * |
|
67 | - * @param string[] $intents |
|
68 | - * @param Attributes|null $attributes |
|
69 | - * @param string|null $tag |
|
70 | - */ |
|
71 | - public function __construct(array $intents = [], ?Attributes $attributes = null, ?string $tag = null) |
|
72 | - { |
|
73 | - parent::__construct(null, $intents, $attributes, $tag); |
|
74 | - |
|
75 | - $this->formAttributes = new Attributes(static::ATTRIBUTES_FORM); |
|
76 | - $this->searchAttributes = new Attributes(static::ATTRIBUTES_SEARCH); |
|
77 | - $this->resetAttributes = new Attributes(static::ATTRIBUTES_RESET); |
|
78 | - |
|
79 | - $this->hiderBtn = new Action(static::BTN_CONTENT_FILTERS, [Action::INTENT_INFO]); |
|
80 | - $this->filterBtn = new Action(static::BTN_CONTENT_FILTER, [Action::INTENT_PRIMARY], $this->searchAttributes); |
|
81 | - $this->resetBtn = new Action(static::BTN_CONTENT_RESET, [Action::INTENT_SECONDARY], $this->resetAttributes); |
|
82 | - } |
|
83 | - |
|
84 | - /** |
|
85 | - * @param array $params |
|
86 | - * |
|
87 | - * @return $this |
|
88 | - */ |
|
89 | - public function setParams(array $params): Filters |
|
90 | - { |
|
91 | - foreach ($this->nodes as $filter) { |
|
92 | - $filter->setParams($params); |
|
93 | - } |
|
94 | - |
|
95 | - return $this; |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * @param string $baseUrl |
|
100 | - * |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - public function getUrl(string $baseUrl): string |
|
104 | - { |
|
105 | - $queryParts = []; |
|
106 | - foreach ($this->nodes as $filter) { |
|
107 | - $queryPart = $filter->getQueryPart(); |
|
108 | - if (!$queryPart) { |
|
109 | - continue; |
|
110 | - } |
|
111 | - |
|
112 | - $queryParts[] = $queryPart; |
|
113 | - } |
|
114 | - |
|
115 | - if (empty($queryParts)) { |
|
116 | - return $baseUrl; |
|
117 | - } |
|
118 | - |
|
119 | - return sprintf('%s%s&', $baseUrl, implode('&', $queryParts)); |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * @return array |
|
124 | - */ |
|
125 | - public function getWhereConditions(): array |
|
126 | - { |
|
127 | - $conditions = []; |
|
128 | - foreach ($this->nodes as $filter) { |
|
129 | - $conditions = array_merge($conditions, $filter->getWhereConditions()); |
|
130 | - } |
|
131 | - |
|
132 | - return $conditions; |
|
133 | - } |
|
134 | - |
|
135 | - /** |
|
136 | - * @return array<string,string> |
|
137 | - */ |
|
138 | - public function getSqlParams(): array |
|
139 | - { |
|
140 | - $params = []; |
|
141 | - foreach ($this->nodes as $filter) { |
|
142 | - $params = array_merge($params, $filter->getQueryParams()); |
|
143 | - } |
|
144 | - |
|
145 | - return $params; |
|
146 | - } |
|
147 | - |
|
148 | - /** |
|
149 | - * @return INode[] |
|
150 | - */ |
|
151 | - public function getExtendedNodes(): array |
|
152 | - { |
|
153 | - return array_merge([$this->hiderBtn, $this->filterBtn, $this->resetBtn], $this->getNodes()); |
|
154 | - } |
|
155 | - |
|
156 | - /** |
|
157 | - * @param string $template |
|
158 | - * |
|
159 | - * @return INode |
|
160 | - */ |
|
161 | - public function setTemplate(string $template): INode |
|
162 | - { |
|
163 | - $this->template = $template; |
|
164 | - |
|
165 | - return $this; |
|
166 | - } |
|
167 | - |
|
168 | - /** |
|
169 | - * @return string |
|
170 | - */ |
|
171 | - public function __toString(): string |
|
172 | - { |
|
173 | - $nodes = Collection::__toString(); |
|
174 | - |
|
175 | - $form = TagHelper::toString($this->tag, $nodes, $this->formAttributes); |
|
176 | - |
|
177 | - return sprintf( |
|
178 | - $this->template, |
|
179 | - (string)$this->hiderBtn, |
|
180 | - $form |
|
181 | - ); |
|
182 | - } |
|
183 | - |
|
184 | - /** |
|
185 | - * @return Action |
|
186 | - */ |
|
187 | - public function getHiderBtn(): Action |
|
188 | - { |
|
189 | - return $this->hiderBtn; |
|
190 | - } |
|
191 | - |
|
192 | - /** |
|
193 | - * @return Action |
|
194 | - */ |
|
195 | - public function getFilterBtn(): Action |
|
196 | - { |
|
197 | - return $this->filterBtn; |
|
198 | - } |
|
199 | - |
|
200 | - /** |
|
201 | - * @return Action |
|
202 | - */ |
|
203 | - public function getResetBtn(): Action |
|
204 | - { |
|
205 | - return $this->resetBtn; |
|
206 | - } |
|
207 | -} |