1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Metaways Infosystems GmbH, 2013 |
6
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2022 |
7
|
|
|
* @package Client |
8
|
|
|
* @subpackage Html |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
namespace Aimeos\Client\Html\Catalog\Session; |
13
|
|
|
|
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Default implementation of catalog session section HTML clients. |
17
|
|
|
* |
18
|
|
|
* @package Client |
19
|
|
|
* @subpackage Html |
20
|
|
|
*/ |
21
|
|
|
class Standard |
22
|
|
|
extends \Aimeos\Client\Html\Common\Client\Factory\Base |
23
|
|
|
implements \Aimeos\Client\Html\Common\Client\Factory\Iface |
24
|
|
|
{ |
25
|
|
|
/** client/html/catalog/session/subparts |
26
|
|
|
* List of HTML sub-clients rendered within the catalog session section |
27
|
|
|
* |
28
|
|
|
* The output of the frontend is composed of the code generated by the HTML |
29
|
|
|
* clients. Each HTML client can consist of serveral (or none) sub-clients |
30
|
|
|
* that are responsible for rendering certain sub-parts of the output. The |
31
|
|
|
* sub-clients can contain HTML clients themselves and therefore a |
32
|
|
|
* hierarchical tree of HTML clients is composed. Each HTML client creates |
33
|
|
|
* the output that is placed inside the container of its parent. |
34
|
|
|
* |
35
|
|
|
* At first, always the HTML code generated by the parent is printed, then |
36
|
|
|
* the HTML code of its sub-clients. The order of the HTML sub-clients |
37
|
|
|
* determines the order of the output of these sub-clients inside the parent |
38
|
|
|
* container. If the configured list of clients is |
39
|
|
|
* |
40
|
|
|
* array( "subclient1", "subclient2" ) |
41
|
|
|
* |
42
|
|
|
* you can easily change the order of the output by reordering the subparts: |
43
|
|
|
* |
44
|
|
|
* client/html/<clients>/subparts = array( "subclient1", "subclient2" ) |
45
|
|
|
* |
46
|
|
|
* You can also remove one or more parts if they shouldn't be rendered: |
47
|
|
|
* |
48
|
|
|
* client/html/<clients>/subparts = array( "subclient1" ) |
49
|
|
|
* |
50
|
|
|
* As the clients only generates structural HTML, the layout defined via CSS |
51
|
|
|
* should support adding, removing or reordering content by a fluid like |
52
|
|
|
* design. |
53
|
|
|
* |
54
|
|
|
* @param array List of sub-client names |
55
|
|
|
* @since 2014.03 |
56
|
|
|
*/ |
57
|
|
|
private $subPartPath = 'client/html/catalog/session/subparts'; |
58
|
|
|
|
59
|
|
|
/** client/html/catalog/session/pinned/name |
60
|
|
|
* Name of the pinned part used by the catalog session client implementation |
61
|
|
|
* |
62
|
|
|
* Use "Myname" if your class is named "\Aimeos\Client\Html\Catalog\Session\Pinned\Myname". |
63
|
|
|
* The name is case-sensitive and you should avoid camel case names like "MyName". |
64
|
|
|
* |
65
|
|
|
* @param string Last part of the client class name |
66
|
|
|
* @since 2014.09 |
67
|
|
|
*/ |
68
|
|
|
|
69
|
|
|
/** client/html/catalog/session/seen/name |
70
|
|
|
* Name of the seen part used by the catalog session client implementation |
71
|
|
|
* |
72
|
|
|
* Use "Myname" if your class is named "\Aimeos\Client\Html\Catalog\Session\Seen\Myname". |
73
|
|
|
* The name is case-sensitive and you should avoid camel case names like "MyName". |
74
|
|
|
* |
75
|
|
|
* @param string Last part of the client class name |
76
|
|
|
* @since 2014.03 |
77
|
|
|
*/ |
78
|
|
|
private $subPartNames = array( 'pinned', 'seen' ); |
79
|
|
|
|
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Returns the sub-client given by its name. |
83
|
|
|
* |
84
|
|
|
* @param string $type Name of the client type |
85
|
|
|
* @param string|null $name Name of the sub-client (Default if null) |
86
|
|
|
* @return \Aimeos\Client\Html\Iface Sub-client object |
87
|
|
|
*/ |
88
|
|
|
public function getSubClient( string $type, string $name = null ) : \Aimeos\Client\Html\Iface |
89
|
|
|
{ |
90
|
|
|
/** client/html/catalog/session/decorators/excludes |
91
|
|
|
* Excludes decorators added by the "common" option from the catalog session html client |
92
|
|
|
* |
93
|
|
|
* Decorators extend the functionality of a class by adding new aspects |
94
|
|
|
* (e.g. log what is currently done), executing the methods of the underlying |
95
|
|
|
* class only in certain conditions (e.g. only for logged in users) or |
96
|
|
|
* modify what is returned to the caller. |
97
|
|
|
* |
98
|
|
|
* This option allows you to remove a decorator added via |
99
|
|
|
* "client/html/common/decorators/default" before they are wrapped |
100
|
|
|
* around the html client. |
101
|
|
|
* |
102
|
|
|
* client/html/catalog/session/decorators/excludes = array( 'decorator1' ) |
103
|
|
|
* |
104
|
|
|
* This would remove the decorator named "decorator1" from the list of |
105
|
|
|
* common decorators ("\Aimeos\Client\Html\Common\Decorator\*") added via |
106
|
|
|
* "client/html/common/decorators/default" to the html client. |
107
|
|
|
* |
108
|
|
|
* @param array List of decorator names |
109
|
|
|
* @since 2014.05 |
110
|
|
|
* @see client/html/common/decorators/default |
111
|
|
|
* @see client/html/catalog/session/decorators/global |
112
|
|
|
* @see client/html/catalog/session/decorators/local |
113
|
|
|
*/ |
114
|
|
|
|
115
|
|
|
/** client/html/catalog/session/decorators/global |
116
|
|
|
* Adds a list of globally available decorators only to the catalog session html client |
117
|
|
|
* |
118
|
|
|
* Decorators extend the functionality of a class by adding new aspects |
119
|
|
|
* (e.g. log what is currently done), executing the methods of the underlying |
120
|
|
|
* class only in certain conditions (e.g. only for logged in users) or |
121
|
|
|
* modify what is returned to the caller. |
122
|
|
|
* |
123
|
|
|
* This option allows you to wrap global decorators |
124
|
|
|
* ("\Aimeos\Client\Html\Common\Decorator\*") around the html client. |
125
|
|
|
* |
126
|
|
|
* client/html/catalog/session/decorators/global = array( 'decorator1' ) |
127
|
|
|
* |
128
|
|
|
* This would add the decorator named "decorator1" defined by |
129
|
|
|
* "\Aimeos\Client\Html\Common\Decorator\Decorator1" only to the html client. |
130
|
|
|
* |
131
|
|
|
* @param array List of decorator names |
132
|
|
|
* @since 2014.05 |
133
|
|
|
* @see client/html/common/decorators/default |
134
|
|
|
* @see client/html/catalog/session/decorators/excludes |
135
|
|
|
* @see client/html/catalog/session/decorators/local |
136
|
|
|
*/ |
137
|
|
|
|
138
|
|
|
/** client/html/catalog/session/decorators/local |
139
|
|
|
* Adds a list of local decorators only to the catalog session html client |
140
|
|
|
* |
141
|
|
|
* Decorators extend the functionality of a class by adding new aspects |
142
|
|
|
* (e.g. log what is currently done), executing the methods of the underlying |
143
|
|
|
* class only in certain conditions (e.g. only for logged in users) or |
144
|
|
|
* modify what is returned to the caller. |
145
|
|
|
* |
146
|
|
|
* This option allows you to wrap local decorators |
147
|
|
|
* ("\Aimeos\Client\Html\Catalog\Decorator\*") around the html client. |
148
|
|
|
* |
149
|
|
|
* client/html/catalog/session/decorators/local = array( 'decorator2' ) |
150
|
|
|
* |
151
|
|
|
* This would add the decorator named "decorator2" defined by |
152
|
|
|
* "\Aimeos\Client\Html\Catalog\Decorator\Decorator2" only to the html client. |
153
|
|
|
* |
154
|
|
|
* @param array List of decorator names |
155
|
|
|
* @since 2014.05 |
156
|
|
|
* @see client/html/common/decorators/default |
157
|
|
|
* @see client/html/catalog/session/decorators/excludes |
158
|
|
|
* @see client/html/catalog/session/decorators/global |
159
|
|
|
*/ |
160
|
|
|
|
161
|
|
|
return $this->createSubClient( 'catalog/session/' . $type, $name ); |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* Returns the list of sub-client names configured for the client. |
167
|
|
|
* |
168
|
|
|
* @return array List of HTML client names |
169
|
|
|
*/ |
170
|
|
|
protected function getSubClientNames() : array |
171
|
|
|
{ |
172
|
|
|
return $this->context()->config()->get( $this->subPartPath, $this->subPartNames ); |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
|
176
|
|
|
/** client/html/catalog/session/template-body |
177
|
|
|
* Relative path to the HTML body template of the catalog session client. |
178
|
|
|
* |
179
|
|
|
* The template file contains the HTML code and processing instructions |
180
|
|
|
* to generate the result shown in the body of the frontend. The |
181
|
|
|
* configuration string is the path to the template file relative |
182
|
|
|
* to the templates directory (usually in client/html/templates). |
183
|
|
|
* |
184
|
|
|
* You can overwrite the template file configuration in extensions and |
185
|
|
|
* provide alternative templates. These alternative templates should be |
186
|
|
|
* named like the default one but suffixed by |
187
|
|
|
* an unique name. You may use the name of your project for this. If |
188
|
|
|
* you've implemented an alternative client class as well, it |
189
|
|
|
* should be suffixed by the name of the new class. |
190
|
|
|
* |
191
|
|
|
* @param string Relative path to the template creating code for the HTML page body |
192
|
|
|
* @since 2014.03 |
193
|
|
|
* @see client/html/catalog/session/template-header |
194
|
|
|
*/ |
195
|
|
|
|
196
|
|
|
/** client/html/catalog/session/template-header |
197
|
|
|
* Relative path to the HTML header template of the catalog session client. |
198
|
|
|
* |
199
|
|
|
* The template file contains the HTML code and processing instructions |
200
|
|
|
* to generate the HTML code that is inserted into the HTML page header |
201
|
|
|
* of the rendered page in the frontend. The configuration string is the |
202
|
|
|
* path to the template file relative to the templates directory (usually |
203
|
|
|
* in client/html/templates). |
204
|
|
|
* |
205
|
|
|
* You can overwrite the template file configuration in extensions and |
206
|
|
|
* provide alternative templates. These alternative templates should be |
207
|
|
|
* named like the default one but suffixed by |
208
|
|
|
* an unique name. You may use the name of your project for this. If |
209
|
|
|
* you've implemented an alternative client class as well, it |
210
|
|
|
* should be suffixed by the name of the new class. |
211
|
|
|
* |
212
|
|
|
* @param string Relative path to the template creating code for the HTML page head |
213
|
|
|
* @since 2014.03 |
214
|
|
|
* @see client/html/catalog/session/template-body |
215
|
|
|
*/ |
216
|
|
|
} |
217
|
|
|
|