1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2018-2025 |
6
|
|
|
* @package Client |
7
|
|
|
* @subpackage Html |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
namespace Aimeos\Client\Html\Catalog\Search; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Default implementation of catalog search HTML client |
16
|
|
|
* |
17
|
|
|
* @package Client |
18
|
|
|
* @subpackage Html |
19
|
|
|
*/ |
20
|
|
|
class Standard |
21
|
|
|
extends \Aimeos\Client\Html\Catalog\Filter\Standard |
22
|
|
|
implements \Aimeos\Client\Html\Common\Client\Factory\Iface |
23
|
|
|
{ |
24
|
|
|
/** client/html/catalog/search/name |
25
|
|
|
* Class name of the used catalog search client implementation |
26
|
|
|
* |
27
|
|
|
* Each default HTML client can be replace by an alternative imlementation. |
28
|
|
|
* To use this implementation, you have to set the last part of the class |
29
|
|
|
* name as configuration value so the client factory knows which class it |
30
|
|
|
* has to instantiate. |
31
|
|
|
* |
32
|
|
|
* For example, if the name of the default class is |
33
|
|
|
* |
34
|
|
|
* \Aimeos\Client\Html\Catalog\Search\Standard |
35
|
|
|
* |
36
|
|
|
* and you want to replace it with your own version named |
37
|
|
|
* |
38
|
|
|
* \Aimeos\Client\Html\Catalog\Search\Mysearch |
39
|
|
|
* |
40
|
|
|
* then you have to set the this configuration option: |
41
|
|
|
* |
42
|
|
|
* client/html/catalog/search/name = Mysearch |
43
|
|
|
* |
44
|
|
|
* The value is the last part of your own class name and it's case sensitive, |
45
|
|
|
* so take care that the configuration value is exactly named like the last |
46
|
|
|
* part of the class name. |
47
|
|
|
* |
48
|
|
|
* The allowed characters of the class name are A-Z, a-z and 0-9. No other |
49
|
|
|
* characters are possible! You should always start the last part of the class |
50
|
|
|
* name with an upper case character and continue only with lower case characters |
51
|
|
|
* or numbers. Avoid chamel case names like "MySearch"! |
52
|
|
|
* |
53
|
|
|
* @param string Last part of the class name |
54
|
|
|
* @since 2018.04 |
55
|
|
|
*/ |
56
|
|
|
|
57
|
|
|
|
58
|
|
|
/** client/html/catalog/search/subparts |
59
|
|
|
* List of HTML sub-clients rendered within the catalog search section |
60
|
|
|
* |
61
|
|
|
* The output of the frontend is composed of the code generated by the HTML |
62
|
|
|
* clients. Each HTML client can consist of serveral (or none) sub-clients |
63
|
|
|
* that are responsible for rendering certain sub-parts of the output. The |
64
|
|
|
* sub-clients can contain HTML clients themselves and therefore a |
65
|
|
|
* hierarchical tree of HTML clients is composed. Each HTML client creates |
66
|
|
|
* the output that is placed inside the container of its parent. |
67
|
|
|
* |
68
|
|
|
* At first, always the HTML code generated by the parent is printed, then |
69
|
|
|
* the HTML code of its sub-clients. The order of the HTML sub-clients |
70
|
|
|
* determines the order of the output of these sub-clients inside the parent |
71
|
|
|
* container. If the configured list of clients is |
72
|
|
|
* |
73
|
|
|
* array( "subclient1", "subclient2" ) |
74
|
|
|
* |
75
|
|
|
* you can easily change the order of the output by reordering the subparts: |
76
|
|
|
* |
77
|
|
|
* client/html/<clients>/subparts = array( "subclient1", "subclient2" ) |
78
|
|
|
* |
79
|
|
|
* You can also remove one or more parts if they shouldn't be rendered: |
80
|
|
|
* |
81
|
|
|
* client/html/<clients>/subparts = array( "subclient1" ) |
82
|
|
|
* |
83
|
|
|
* As the clients only generates structural HTML, the layout defined via CSS |
84
|
|
|
* should support adding, removing or reordering content by a fluid like |
85
|
|
|
* design. |
86
|
|
|
* |
87
|
|
|
* @param array List of sub-client names |
88
|
|
|
* @since 2018.04 |
89
|
|
|
*/ |
90
|
|
|
private string $subPartPath = 'client/html/catalog/search/subparts'; |
91
|
|
|
private array $subPartNames = ['search']; |
92
|
|
|
|
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Returns the sub-client given by its name. |
96
|
|
|
* |
97
|
|
|
* @param string $type Name of the client type |
98
|
|
|
* @param string|null $name Name of the sub-client (Default if null) |
99
|
|
|
* @return \Aimeos\Client\Html\Iface Sub-client object |
100
|
|
|
*/ |
101
|
|
|
public function getSubClient( string $type, ?string $name = null ) : \Aimeos\Client\Html\Iface |
102
|
|
|
{ |
103
|
|
|
return parent::getSubClient( $type, $name ); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Returns the names of the subpart clients |
109
|
|
|
* |
110
|
|
|
* @return array List of client names |
111
|
|
|
*/ |
112
|
|
|
protected function getSubClientNames() : array |
113
|
|
|
{ |
114
|
|
|
return $this->context()->config()->get( $this->subPartPath, $this->subPartNames ); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
|
118
|
|
|
/** client/html/catalog/search/decorators/excludes |
119
|
|
|
* Excludes decorators added by the "common" option from the catalog filter search html client |
120
|
|
|
* |
121
|
|
|
* Decorators extend the functionality of a class by adding new aspects |
122
|
|
|
* (e.g. log what is currently done), executing the methods of the underlying |
123
|
|
|
* class only in certain conditions (e.g. only for logged in users) or |
124
|
|
|
* modify what is returned to the caller. |
125
|
|
|
* |
126
|
|
|
* This option allows you to remove a decorator added via |
127
|
|
|
* "client/html/common/decorators/default" before they are wrapped |
128
|
|
|
* around the html client. |
129
|
|
|
* |
130
|
|
|
* client/html/catalog/search/decorators/excludes = array( 'decorator1' ) |
131
|
|
|
* |
132
|
|
|
* This would remove the decorator named "decorator1" from the list of |
133
|
|
|
* common decorators ("\Aimeos\Client\Html\Common\Decorator\*") added via |
134
|
|
|
* "client/html/common/decorators/default" to the html client. |
135
|
|
|
* |
136
|
|
|
* @param array List of decorator names |
137
|
|
|
* @since 2018.04 |
138
|
|
|
* @see client/html/common/decorators/default |
139
|
|
|
* @see client/html/catalog/search/decorators/global |
140
|
|
|
* @see client/html/catalog/search/decorators/local |
141
|
|
|
*/ |
142
|
|
|
|
143
|
|
|
/** client/html/catalog/search/decorators/global |
144
|
|
|
* Adds a list of globally available decorators only to the catalog filter search html client |
145
|
|
|
* |
146
|
|
|
* Decorators extend the functionality of a class by adding new aspects |
147
|
|
|
* (e.g. log what is currently done), executing the methods of the underlying |
148
|
|
|
* class only in certain conditions (e.g. only for logged in users) or |
149
|
|
|
* modify what is returned to the caller. |
150
|
|
|
* |
151
|
|
|
* This option allows you to wrap global decorators |
152
|
|
|
* ("\Aimeos\Client\Html\Common\Decorator\*") around the html client. |
153
|
|
|
* |
154
|
|
|
* client/html/catalog/search/decorators/global = array( 'decorator1' ) |
155
|
|
|
* |
156
|
|
|
* This would add the decorator named "decorator1" defined by |
157
|
|
|
* "\Aimeos\Client\Html\Common\Decorator\Decorator1" only to the html client. |
158
|
|
|
* |
159
|
|
|
* @param array List of decorator names |
160
|
|
|
* @since 2018.04 |
161
|
|
|
* @see client/html/common/decorators/default |
162
|
|
|
* @see client/html/catalog/search/decorators/excludes |
163
|
|
|
* @see client/html/catalog/search/decorators/local |
164
|
|
|
*/ |
165
|
|
|
|
166
|
|
|
/** client/html/catalog/search/decorators/local |
167
|
|
|
* Adds a list of local decorators only to the catalog filter search html client |
168
|
|
|
* |
169
|
|
|
* Decorators extend the functionality of a class by adding new aspects |
170
|
|
|
* (e.g. log what is currently done), executing the methods of the underlying |
171
|
|
|
* class only in certain conditions (e.g. only for logged in users) or |
172
|
|
|
* modify what is returned to the caller. |
173
|
|
|
* |
174
|
|
|
* This option allows you to wrap local decorators |
175
|
|
|
* ("\Aimeos\Client\Html\Catalog\Decorator\*") around the html client. |
176
|
|
|
* |
177
|
|
|
* client/html/catalog/search/decorators/local = array( 'decorator2' ) |
178
|
|
|
* |
179
|
|
|
* This would add the decorator named "decorator2" defined by |
180
|
|
|
* "\Aimeos\Client\Html\Catalog\Decorator\Decorator2" only to the html client. |
181
|
|
|
* |
182
|
|
|
* @param array List of decorator names |
183
|
|
|
* @since 2018.04 |
184
|
|
|
* @see client/html/common/decorators/default |
185
|
|
|
* @see client/html/catalog/search/decorators/excludes |
186
|
|
|
* @see client/html/catalog/search/decorators/global |
187
|
|
|
*/ |
188
|
|
|
} |
189
|
|
|
|