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