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