1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2016 |
6
|
|
|
* @package Controller |
7
|
|
|
* @subpackage Frontend |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
namespace Aimeos\Controller\Frontend\Catalog\Decorator; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Base for catalog frontend controller decorators |
16
|
|
|
* |
17
|
|
|
* @package Controller |
18
|
|
|
* @subpackage Frontend |
19
|
|
|
*/ |
20
|
|
|
abstract class Base |
21
|
|
|
extends \Aimeos\Controller\Frontend\Base |
|
|
|
|
22
|
|
|
implements \Aimeos\Controller\Frontend\Common\Decorator\Iface |
|
|
|
|
23
|
|
|
{ |
24
|
|
|
private $controller; |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Initializes the controller decorator. |
29
|
|
|
* |
30
|
|
|
* @param \Aimeos\Controller\Frontend\Iface $controller Controller object |
31
|
|
|
* @param \Aimeos\MShop\Context\Item\Iface $context Context object with required objects |
32
|
|
|
*/ |
33
|
|
|
public function __construct( \Aimeos\Controller\Frontend\Iface $controller, \Aimeos\MShop\Context\Item\Iface $context ) |
34
|
|
|
{ |
35
|
|
|
$iface = '\Aimeos\Controller\Frontend\Catalog\Iface'; |
36
|
|
|
if( !( $controller instanceof $iface ) ) |
37
|
|
|
{ |
38
|
|
|
$msg = sprintf( 'Class "%1$s" does not implement interface "%2$s"', get_class( $controller ), $iface ); |
39
|
|
|
throw new \Aimeos\Controller\Frontend\Exception( $msg ); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
$this->controller = $controller; |
43
|
|
|
|
44
|
|
|
parent::__construct( $context ); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Passes unknown methods to wrapped objects. |
50
|
|
|
* |
51
|
|
|
* @param string $name Name of the method |
52
|
|
|
* @param array $param List of method parameter |
53
|
|
|
* @return mixed Returns the value of the called method |
54
|
|
|
* @throws \Aimeos\Controller\Frontend\Exception If method call failed |
55
|
|
|
*/ |
56
|
|
|
public function __call( $name, array $param ) |
57
|
|
|
{ |
58
|
|
|
return @call_user_func_array( array( $this->controller, $name ), $param ); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Returns the manager for the given name |
64
|
|
|
* |
65
|
|
|
* @param string $name Name of the manager |
66
|
|
|
* @return \Aimeos\MShop\Common\Manager\Iface Manager object |
67
|
|
|
*/ |
68
|
|
|
public function createManager( $name ) |
69
|
|
|
{ |
70
|
|
|
return $this->controller->createManager( $name ); |
|
|
|
|
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Returns the default catalog filter |
76
|
|
|
* |
77
|
|
|
* @param boolean True to add default criteria, e.g. status > 0 |
78
|
|
|
* @return \Aimeos\MW\Criteria\Iface Criteria object for filtering |
79
|
|
|
* @since 2017.03 |
80
|
|
|
*/ |
81
|
|
|
public function createFilter() |
82
|
|
|
{ |
83
|
|
|
return $this->controller->createFilter(); |
|
|
|
|
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
|
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Returns the list of categries that are in the path to the root node including the one specified by its ID. |
90
|
|
|
* |
91
|
|
|
* @param integer $id Category ID to start from, null for root node |
92
|
|
|
* @param string[] $domains Domain names of items that are associated with the categories and that should be fetched too |
93
|
|
|
* @return array Associative list of items implementing \Aimeos\MShop\Catalog\Item\Iface with their IDs as keys |
94
|
|
|
* @since 2017.03 |
95
|
|
|
*/ |
96
|
|
|
public function getPath( $id, array $domains = array( 'text', 'media' ) ) |
97
|
|
|
{ |
98
|
|
|
return $this->controller->getPath( $id, $domains ); |
|
|
|
|
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Returns the hierarchical catalog tree starting from the given ID. |
104
|
|
|
* |
105
|
|
|
* @param integer|null $id Category ID to start from, null for root node |
106
|
|
|
* @param string[] $domains Domain names of items that are associated with the categories and that should be fetched too |
107
|
|
|
* @param integer $level Constant from \Aimeos\MW\Tree\Manager\Base for the depth of the returned tree, LEVEL_ONE for |
108
|
|
|
* specific node only, LEVEL_LIST for node and all direct child nodes, LEVEL_TREE for the whole tree |
109
|
|
|
* @param \Aimeos\MW\Criteria\Iface|null $search Optional criteria object with conditions |
110
|
|
|
* @return \Aimeos\MShop\Catalog\Item\Iface Catalog node, maybe with children depending on the level constant |
111
|
|
|
* @since 2017.03 |
112
|
|
|
*/ |
113
|
|
|
public function getTree( $id = null, array $domains = array( 'text', 'media' ), |
114
|
|
|
$level = \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE, \Aimeos\MW\Criteria\Iface $search = null ) |
115
|
|
|
{ |
116
|
|
|
return $this->controller->getTree( $id, $domains, $level, $search ); |
|
|
|
|
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* Returns the default catalog filter |
122
|
|
|
* |
123
|
|
|
* @param boolean True to add default criteria, e.g. status > 0 |
124
|
|
|
* @return \Aimeos\MW\Criteria\Iface Criteria object for filtering |
125
|
|
|
* @since 2015.08 |
126
|
|
|
* @deprecated Use createFilter() instead |
127
|
|
|
*/ |
128
|
|
|
public function createCatalogFilter( $default = true ) |
129
|
|
|
{ |
130
|
|
|
return $this->controller->createCatalogFilter( $default ); |
|
|
|
|
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
|
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* Returns the list of categries that are in the path to the root node including the one specified by its ID. |
137
|
|
|
* |
138
|
|
|
* @param integer $id Category ID to start from, null for root node |
139
|
|
|
* @param string[] $domains Domain names of items that are associated with the categories and that should be fetched too |
140
|
|
|
* @return array Associative list of items implementing \Aimeos\MShop\Catalog\Item\Iface with their IDs as keys |
141
|
|
|
* @since 2015.08 |
142
|
|
|
* @deprecated Use getPath() instead |
143
|
|
|
*/ |
144
|
|
|
public function getCatalogPath( $id, array $domains = array( 'text', 'media' ) ) |
145
|
|
|
{ |
146
|
|
|
return $this->controller->getCatalogPath( $id, $domains ); |
|
|
|
|
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* Returns the hierarchical catalog tree starting from the given ID. |
152
|
|
|
* |
153
|
|
|
* @param integer|null $id Category ID to start from, null for root node |
154
|
|
|
* @param string[] $domains Domain names of items that are associated with the categories and that should be fetched too |
155
|
|
|
* @param integer $level Constant from \Aimeos\MW\Tree\Manager\Base for the depth of the returned tree, LEVEL_ONE for |
156
|
|
|
* specific node only, LEVEL_LIST for node and all direct child nodes, LEVEL_TREE for the whole tree |
157
|
|
|
* @param \Aimeos\MW\Criteria\Iface|null $search Optional criteria object with conditions |
158
|
|
|
* @return \Aimeos\MShop\Catalog\Item\Iface Catalog node, maybe with children depending on the level constant |
159
|
|
|
* @since 2015.08 |
160
|
|
|
* @deprecated Use getTree() instead |
161
|
|
|
*/ |
162
|
|
|
public function getCatalogTree( $id = null, array $domains = array( 'text', 'media' ), |
163
|
|
|
$level = \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE, \Aimeos\MW\Criteria\Iface $search = null ) |
164
|
|
|
{ |
165
|
|
|
return $this->controller->getCatalogTree( $id, $domains, $level, $search ); |
|
|
|
|
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* Returns the aggregated count of products from the index for the given key. |
171
|
|
|
* |
172
|
|
|
* @param \Aimeos\MW\Criteria\Iface $filter Critera object which contains the filter conditions |
173
|
|
|
* @param string $key Search key to aggregate for, e.g. "index.attribute.id" |
174
|
|
|
* @return array Associative list of key values as key and the product count for this key as value |
175
|
|
|
* @since 2015.08 |
176
|
|
|
* @deprecated Use product controller instead |
177
|
|
|
*/ |
178
|
|
|
public function aggregateIndex( \Aimeos\MW\Criteria\Iface $filter, $key ) |
179
|
|
|
{ |
180
|
|
|
return $this->controller->aggregateIndex( $filter, $key ); |
|
|
|
|
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
|
184
|
|
|
/** |
185
|
|
|
* Returns the given search filter with the conditions attached for filtering by category. |
186
|
|
|
* |
187
|
|
|
* @param \Aimeos\MW\Criteria\Iface $search Criteria object used for product search |
188
|
|
|
* @param string $catid Selected category by the user |
189
|
|
|
* @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
190
|
|
|
* @since 2015.08 |
191
|
|
|
* @deprecated Use product controller instead |
192
|
|
|
*/ |
193
|
|
|
public function addIndexFilterCategory( \Aimeos\MW\Criteria\Iface $search, $catid ) |
194
|
|
|
{ |
195
|
|
|
return $this->controller->addIndexFilterCategory( $search, $catid ); |
|
|
|
|
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
|
199
|
|
|
/** |
200
|
|
|
* Returns the given search filter with the conditions attached for filtering texts. |
201
|
|
|
* |
202
|
|
|
* @param \Aimeos\MW\Criteria\Iface $search Criteria object used for product search |
203
|
|
|
* @param string $input Search string entered by the user |
204
|
|
|
* @param string $listtype List type of the text associated to the product, usually "default" |
205
|
|
|
* @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
206
|
|
|
* @since 2015.08 |
207
|
|
|
* @deprecated Use product controller instead |
208
|
|
|
*/ |
209
|
|
|
public function addIndexFilterText( \Aimeos\MW\Criteria\Iface $search, $input, $listtype = 'default' ) |
210
|
|
|
{ |
211
|
|
|
return $this->controller->addIndexFilterText( $search, $input, $listtype ); |
|
|
|
|
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
|
215
|
|
|
/** |
216
|
|
|
* Returns the default index filter. |
217
|
|
|
* |
218
|
|
|
* @param string|null $sort Sortation of the product list like "name", "code", "price" and "position", null for no sortation |
219
|
|
|
* @param string $direction Sort direction of the product list ("+", "-") |
220
|
|
|
* @param integer $start Position in the list of found products where to begin retrieving the items |
221
|
|
|
* @param integer $size Number of products that should be returned |
222
|
|
|
* @param string $listtype Type of the product list, e.g. default, promotion, etc. |
223
|
|
|
* @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
224
|
|
|
* @since 2015.08 |
225
|
|
|
* @deprecated Use product controller instead |
226
|
|
|
*/ |
227
|
|
|
public function createIndexFilter( $sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default' ) |
228
|
|
|
{ |
229
|
|
|
return $this->controller->createIndexFilter( $sort, $direction, $start, $size, $listtype ); |
|
|
|
|
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
|
233
|
|
|
/** |
234
|
|
|
* Returns a index filter for the given category ID. |
235
|
|
|
* |
236
|
|
|
* @param integer $catid ID of the category to get the product list from |
237
|
|
|
* @param string $sort Sortation of the product list like "name", "price" and "position" |
238
|
|
|
* @param string $direction Sort direction of the product list ("+", "-") |
239
|
|
|
* @param integer $start Position in the list of found products where to begin retrieving the items |
240
|
|
|
* @param integer $size Number of products that should be returned |
241
|
|
|
* @param string $listtype Type of the product list, e.g. default, promotion, etc. |
242
|
|
|
* @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
243
|
|
|
* @since 2015.08 |
244
|
|
|
* @deprecated Use product controller instead |
245
|
|
|
*/ |
246
|
|
|
public function createIndexFilterCategory( $catid, $sort = 'position', $direction = '+', $start = 0, $size = 100, $listtype = 'default' ) |
247
|
|
|
{ |
248
|
|
|
return $this->controller->createIndexFilterCategory( $catid, $sort, $direction, $start, $size, $listtype ); |
|
|
|
|
249
|
|
|
} |
250
|
|
|
|
251
|
|
|
|
252
|
|
|
/** |
253
|
|
|
* Returns the index filter for the given search string. |
254
|
|
|
* |
255
|
|
|
* @param string $input Search string entered by the user |
256
|
|
|
* @param string $sort Sortation of the product list like "name", "price" and "relevance" |
257
|
|
|
* @param string $direction Sort direction of the product list ("+", "-", but not for relevance ) |
258
|
|
|
* @param integer $start Position in the list of found products where to begin retrieving the items |
259
|
|
|
* @param integer $size Number of products that should be returned |
260
|
|
|
* @param string $listtype List type of the text associated to the product, usually "default" |
261
|
|
|
* @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
262
|
|
|
* @since 2015.08 |
263
|
|
|
* @deprecated Use product controller instead |
264
|
|
|
*/ |
265
|
|
|
public function createIndexFilterText( $input, $sort = 'relevance', $direction = '+', $start = 0, $size = 100, $listtype = 'default' ) |
266
|
|
|
{ |
267
|
|
|
return $this->controller->createIndexFilterText( $input, $sort, $direction, $start, $size, $listtype ); |
|
|
|
|
268
|
|
|
} |
269
|
|
|
|
270
|
|
|
|
271
|
|
|
/** |
272
|
|
|
* Returns the products from the index filtered by the given criteria object. |
273
|
|
|
* |
274
|
|
|
* @param \Aimeos\MW\Criteria\Iface $filter Critera object which contains the filter conditions |
275
|
|
|
* @param string[] $domains Domain names of items that are associated with the products and that should be fetched too |
276
|
|
|
* @param integer &$total Parameter where the total number of found products will be stored in |
277
|
|
|
* @return array Ordered list of product items implementing \Aimeos\MShop\Product\Item\Iface |
278
|
|
|
* @since 2015.08 |
279
|
|
|
* @deprecated Use product controller instead |
280
|
|
|
*/ |
281
|
|
|
public function getIndexItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = array( 'media', 'price', 'text' ), &$total = null ) |
282
|
|
|
{ |
283
|
|
|
return $this->controller->getIndexItems( $filter, $domains, $total ); |
|
|
|
|
284
|
|
|
} |
285
|
|
|
|
286
|
|
|
|
287
|
|
|
/** |
288
|
|
|
* Returns the product item for the given ID if it's available |
289
|
|
|
* |
290
|
|
|
* @param array $ids List of product IDs |
291
|
|
|
* @param array $domains Domain names of items that are associated with the products and that should be fetched too |
292
|
|
|
* @return array List of product items implementing \Aimeos\MShop\Product\Item\Iface |
293
|
|
|
* @since 2015.08 |
294
|
|
|
* @deprecated Use product controller instead |
295
|
|
|
*/ |
296
|
|
|
public function getProductItems( array $ids, array $domains = array( 'media', 'price', 'text' ) ) |
297
|
|
|
{ |
298
|
|
|
return $this->controller->getProductItems( $ids, $domains ); |
|
|
|
|
299
|
|
|
} |
300
|
|
|
|
301
|
|
|
|
302
|
|
|
/** |
303
|
|
|
* Returns text filter for the given search string. |
304
|
|
|
* |
305
|
|
|
* @param string $input Search string entered by the user |
306
|
|
|
* @param string|null $sort Sortation of the product list like "name" and "relevance", null for no sortation |
307
|
|
|
* @param string $direction Sort direction of the product list ("+", "-") |
308
|
|
|
* @param integer $start Position in the list of found products where to begin retrieving the items |
309
|
|
|
* @param integer $size Number of products that should be returned |
310
|
|
|
* @param string $listtype List type of the text associated to the product, usually "default" |
311
|
|
|
* @param string $type Type of the text like "name", "short", "long", etc. |
312
|
|
|
* @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
313
|
|
|
* @deprecated Use product controller instead |
314
|
|
|
*/ |
315
|
|
|
public function createTextFilter( $input, $sort = null, $direction = '-', $start = 0, $size = 25, $listtype = 'default', $type = 'name' ) |
316
|
|
|
{ |
317
|
|
|
return $this->controller->createTextFilter( $input, $sort, $direction, $start, $size, $listtype, $type ); |
|
|
|
|
318
|
|
|
} |
319
|
|
|
|
320
|
|
|
|
321
|
|
|
/** |
322
|
|
|
* Returns an list of product text strings matched by the filter. |
323
|
|
|
* |
324
|
|
|
* @param \Aimeos\MW\Criteria\Iface $filter Critera object which contains the filter conditions |
325
|
|
|
* @return array Associative list of the product ID as key and the product text as value |
326
|
|
|
* @deprecated Use product controller instead |
327
|
|
|
*/ |
328
|
|
|
public function getTextList( \Aimeos\MW\Criteria\Iface $filter ) |
329
|
|
|
{ |
330
|
|
|
return $this->controller->getTextList( $filter ); |
|
|
|
|
331
|
|
|
} |
332
|
|
|
|
333
|
|
|
|
334
|
|
|
/** |
335
|
|
|
* Returns the frontend controller |
336
|
|
|
* |
337
|
|
|
* @return \Aimeos\Controller\Frontend\Catalog\Iface Frontend controller object |
338
|
|
|
*/ |
339
|
|
|
protected function getController() |
340
|
|
|
{ |
341
|
|
|
return $this->controller; |
342
|
|
|
} |
343
|
|
|
} |
344
|
|
|
|