1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2021 |
6
|
|
|
* @package Admin |
7
|
|
|
* @subpackage JQAdm |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
namespace Aimeos\Admin\JQAdm\Type\Rule; |
12
|
|
|
|
13
|
|
|
sprintf( 'type/rule' ); // for translation |
14
|
|
|
|
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Default implementation of type rule JQAdm client. |
18
|
|
|
* |
19
|
|
|
* @package Admin |
20
|
|
|
* @subpackage JQAdm |
21
|
|
|
*/ |
22
|
|
|
class Standard |
23
|
|
|
extends \Aimeos\Admin\JQAdm\Type\Base |
24
|
|
|
implements \Aimeos\Admin\JQAdm\Common\Admin\Factory\Iface |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* Copies a resource |
28
|
|
|
* |
29
|
|
|
* @return string|null HTML output |
30
|
|
|
*/ |
31
|
|
|
public function copy() : ?string |
32
|
|
|
{ |
33
|
|
|
return $this->copyBase( 'rule' ); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Creates a new resource |
39
|
|
|
* |
40
|
|
|
* @return string|null HTML output |
41
|
|
|
*/ |
42
|
|
|
public function create() : ?string |
43
|
|
|
{ |
44
|
|
|
return $this->createBase( 'rule' ); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Deletes a resource |
50
|
|
|
* |
51
|
|
|
* @return string|null HTML output |
52
|
|
|
*/ |
53
|
|
|
public function delete() : ?string |
54
|
|
|
{ |
55
|
|
|
return $this->deleteBase( 'rule' ); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Returns a single resource |
61
|
|
|
* |
62
|
|
|
* @return string|null HTML output |
63
|
|
|
*/ |
64
|
|
|
public function get() : ?string |
65
|
|
|
{ |
66
|
|
|
return $this->getBase( 'rule' ); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Saves the data |
72
|
|
|
* |
73
|
|
|
* @return string|null HTML output |
74
|
|
|
*/ |
75
|
|
|
public function save() : ?string |
76
|
|
|
{ |
77
|
|
|
return $this->saveBase( 'rule' ); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Returns a list of resource according to the conditions |
83
|
|
|
* |
84
|
|
|
* @return string|null HTML output |
85
|
|
|
*/ |
86
|
|
|
public function search() : ?string |
87
|
|
|
{ |
88
|
|
|
$view = $this->searchBase( 'rule' ); |
89
|
|
|
|
90
|
|
|
/** admin/jqadm/type/rule/template-list |
91
|
|
|
* Relative path to the HTML body template for the type list. |
92
|
|
|
* |
93
|
|
|
* The template file contains the HTML code and processing instructions |
94
|
|
|
* to generate the result shown in the body of the frontend. The |
95
|
|
|
* configuration string is the path to the template file relative |
96
|
|
|
* to the templates directory (usually in admin/jqadm/templates). |
97
|
|
|
* |
98
|
|
|
* You can overwrite the template file configuration in extensions and |
99
|
|
|
* provide alternative templates. These alternative templates should be |
100
|
|
|
* named like the default one but with the string "default" replaced by |
101
|
|
|
* an unique name. You may use the name of your project for this. If |
102
|
|
|
* you've implemented an alternative client class as well, "default" |
103
|
|
|
* should be replaced by the name of the new class. |
104
|
|
|
* |
105
|
|
|
* @param string Relative path to the template creating the HTML code |
106
|
|
|
* @since 2021.04 |
107
|
|
|
* @category Developer |
108
|
|
|
*/ |
109
|
|
|
$tplconf = 'admin/jqadm/type/rule/template-list'; |
110
|
|
|
$default = 'type/rule/list-standard'; |
111
|
|
|
|
112
|
|
|
return $view->render( $view->config( $tplconf, $default ) ); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* Returns the sub-client given by its name. |
118
|
|
|
* |
119
|
|
|
* @param string $type Name of the client type |
120
|
|
|
* @param string|null $name Name of the sub-client (Default if null) |
121
|
|
|
* @return \Aimeos\Admin\JQAdm\Iface Sub-client object |
122
|
|
|
*/ |
123
|
|
|
public function getSubClient( string $type, string $name = null ) : \Aimeos\Admin\JQAdm\Iface |
124
|
|
|
{ |
125
|
|
|
/** admin/jqadm/type/rule/decorators/excludes |
126
|
|
|
* Excludes decorators added by the "common" option from the type JQAdm client |
127
|
|
|
* |
128
|
|
|
* Decorators extend the functionality of a class by adding new aspects |
129
|
|
|
* (e.g. log what is currently done), executing the methods of the underlying |
130
|
|
|
* class only in certain conditions (e.g. only for logged in users) or |
131
|
|
|
* modify what is returned to the caller. |
132
|
|
|
* |
133
|
|
|
* This option allows you to remove a decorator added via |
134
|
|
|
* "client/jqadm/common/decorators/default" before they are wrapped |
135
|
|
|
* around the JQAdm client. |
136
|
|
|
* |
137
|
|
|
* admin/jqadm/type/rule/decorators/excludes = array( 'decorator1' ) |
138
|
|
|
* |
139
|
|
|
* This would remove the decorator named "decorator1" from the list of |
140
|
|
|
* common decorators ("\Aimeos\Admin\JQAdm\Common\Decorator\*") added via |
141
|
|
|
* "client/jqadm/common/decorators/default" to the JQAdm client. |
142
|
|
|
* |
143
|
|
|
* @param array List of decorator names |
144
|
|
|
* @since 2021.04 |
145
|
|
|
* @category Developer |
146
|
|
|
* @see admin/jqadm/common/decorators/default |
147
|
|
|
* @see admin/jqadm/type/rule/decorators/global |
148
|
|
|
* @see admin/jqadm/type/rule/decorators/local |
149
|
|
|
*/ |
150
|
|
|
|
151
|
|
|
/** admin/jqadm/type/rule/decorators/global |
152
|
|
|
* Adds a list of globally available decorators only to the type JQAdm client |
153
|
|
|
* |
154
|
|
|
* Decorators extend the functionality of a class by adding new aspects |
155
|
|
|
* (e.g. log what is currently done), executing the methods of the underlying |
156
|
|
|
* class only in certain conditions (e.g. only for logged in users) or |
157
|
|
|
* modify what is returned to the caller. |
158
|
|
|
* |
159
|
|
|
* This option allows you to wrap global decorators |
160
|
|
|
* ("\Aimeos\Admin\JQAdm\Common\Decorator\*") around the JQAdm client. |
161
|
|
|
* |
162
|
|
|
* admin/jqadm/type/rule/decorators/global = array( 'decorator1' ) |
163
|
|
|
* |
164
|
|
|
* This would add the decorator named "decorator1" defined by |
165
|
|
|
* "\Aimeos\Admin\JQAdm\Common\Decorator\Decorator1" only to the JQAdm client. |
166
|
|
|
* |
167
|
|
|
* @param array List of decorator names |
168
|
|
|
* @since 2021.04 |
169
|
|
|
* @category Developer |
170
|
|
|
* @see admin/jqadm/common/decorators/default |
171
|
|
|
* @see admin/jqadm/type/rule/decorators/excludes |
172
|
|
|
* @see admin/jqadm/type/rule/decorators/local |
173
|
|
|
*/ |
174
|
|
|
|
175
|
|
|
/** admin/jqadm/type/rule/decorators/local |
176
|
|
|
* Adds a list of local decorators only to the type JQAdm client |
177
|
|
|
* |
178
|
|
|
* Decorators extend the functionality of a class by adding new aspects |
179
|
|
|
* (e.g. log what is currently done), executing the methods of the underlying |
180
|
|
|
* class only in certain conditions (e.g. only for logged in users) or |
181
|
|
|
* modify what is returned to the caller. |
182
|
|
|
* |
183
|
|
|
* This option allows you to wrap local decorators |
184
|
|
|
* ("\Aimeos\Admin\JQAdm\Type\Rule\Decorator\*") around the JQAdm client. |
185
|
|
|
* |
186
|
|
|
* admin/jqadm/type/rule/decorators/local = array( 'decorator2' ) |
187
|
|
|
* |
188
|
|
|
* This would add the decorator named "decorator2" defined by |
189
|
|
|
* "\Aimeos\Admin\JQAdm\Type\Rule\Decorator\Decorator2" only to the JQAdm client. |
190
|
|
|
* |
191
|
|
|
* @param array List of decorator names |
192
|
|
|
* @since 2021.04 |
193
|
|
|
* @category Developer |
194
|
|
|
* @see admin/jqadm/common/decorators/default |
195
|
|
|
* @see admin/jqadm/type/rule/decorators/excludes |
196
|
|
|
* @see admin/jqadm/type/rule/decorators/global |
197
|
|
|
*/ |
198
|
|
|
return $this->createSubClient( 'type/rule' . $type, $name ); |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
|
202
|
|
|
/** |
203
|
|
|
* Returns the list of sub-client names configured for the client. |
204
|
|
|
* |
205
|
|
|
* @return array List of JQAdm client names |
206
|
|
|
*/ |
207
|
|
|
protected function getSubClientNames() : array |
208
|
|
|
{ |
209
|
|
|
/** admin/jqadm/type/rule/subparts |
210
|
|
|
* List of JQAdm sub-clients rendered within the type section |
211
|
|
|
* |
212
|
|
|
* The output of the frontend is composed of the code generated by the JQAdm |
213
|
|
|
* clients. Each JQAdm client can consist of serveral (or none) sub-clients |
214
|
|
|
* that are responsible for rendering certain sub-parts of the output. The |
215
|
|
|
* sub-clients can contain JQAdm clients themselves and therefore a |
216
|
|
|
* hierarchical tree of JQAdm clients is composed. Each JQAdm client creates |
217
|
|
|
* the output that is placed inside the container of its parent. |
218
|
|
|
* |
219
|
|
|
* At first, always the JQAdm code generated by the parent is printed, then |
220
|
|
|
* the JQAdm code of its sub-clients. The order of the JQAdm sub-clients |
221
|
|
|
* determines the order of the output of these sub-clients inside the parent |
222
|
|
|
* container. If the configured list of clients is |
223
|
|
|
* |
224
|
|
|
* array( "subclient1", "subclient2" ) |
225
|
|
|
* |
226
|
|
|
* you can easily change the order of the output by reordering the subparts: |
227
|
|
|
* |
228
|
|
|
* admin/jqadm/<clients>/subparts = array( "subclient1", "subclient2" ) |
229
|
|
|
* |
230
|
|
|
* You can also remove one or more parts if they shouldn't be rendered: |
231
|
|
|
* |
232
|
|
|
* admin/jqadm/<clients>/subparts = array( "subclient1" ) |
233
|
|
|
* |
234
|
|
|
* As the clients only generates structural JQAdm, the layout defined via CSS |
235
|
|
|
* should support adding, removing or reordering content by a fluid like |
236
|
|
|
* design. |
237
|
|
|
* |
238
|
|
|
* @param array List of sub-client names |
239
|
|
|
* @since 2021.04 |
240
|
|
|
* @category Developer |
241
|
|
|
*/ |
242
|
|
|
return $this->getContext()->getConfig()->get( 'admin/jqadm/type/rule/subparts', [] ); |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
|
246
|
|
|
/** |
247
|
|
|
* Returns the rendered template including the view data |
248
|
|
|
* |
249
|
|
|
* @param \Aimeos\MW\View\Iface $view View object with data assigned |
250
|
|
|
* @return string HTML output |
251
|
|
|
*/ |
252
|
|
|
protected function render( \Aimeos\MW\View\Iface $view ) : string |
253
|
|
|
{ |
254
|
|
|
/** admin/jqadm/type/rule/template-item |
255
|
|
|
* Relative path to the HTML body template for the type item. |
256
|
|
|
* |
257
|
|
|
* The template file contains the HTML code and processing instructions |
258
|
|
|
* to generate the result shown in the body of the frontend. The |
259
|
|
|
* configuration string is the path to the template file relative |
260
|
|
|
* to the templates directory (usually in admin/jqadm/templates). |
261
|
|
|
* |
262
|
|
|
* You can overwrite the template file configuration in extensions and |
263
|
|
|
* provide alternative templates. These alternative templates should be |
264
|
|
|
* named like the default one but with the string "default" replaced by |
265
|
|
|
* an unique name. You may use the name of your project for this. If |
266
|
|
|
* you've implemented an alternative client class as well, "default" |
267
|
|
|
* should be replaced by the name of the new class. |
268
|
|
|
* |
269
|
|
|
* @param string Relative path to the template creating the HTML code |
270
|
|
|
* @since 2021.04 |
271
|
|
|
* @category Developer |
272
|
|
|
*/ |
273
|
|
|
$tplconf = 'admin/jqadm/type/rule/template-item'; |
274
|
|
|
$default = 'type/rule/item-standard'; |
275
|
|
|
|
276
|
|
|
return $view->render( $view->config( $tplconf, $default ) ); |
277
|
|
|
} |
278
|
|
|
} |
279
|
|
|
|