Completed
Push — master ( 8b8334...2005c2 )
by Aimeos
07:11
created
client/html/src/Client/Html/Catalog/Base.php 1 patch
Indentation   +443 added lines, -443 removed lines patch added patch discarded remove patch
@@ -19,448 +19,448 @@
 block discarded – undo
19 19
  * @subpackage Html
20 20
  */
21 21
 abstract class Base
22
-	extends \Aimeos\Client\Html\Common\Client\Factory\Base
22
+    extends \Aimeos\Client\Html\Common\Client\Factory\Base
23 23
 {
24
-	private $controller;
25
-	private $productList;
26
-	private $productTotal = 0;
27
-
28
-
29
-	/**
30
-	 * Adds the conditions for the selected attributes to the given search filter.
31
-	 *
32
-	 * @param array $params Associative list of parameters that should be used for filtering
33
-	 * @param \Aimeos\MW\Criteria\Iface $filter Criteria object for searching
34
-	 */
35
-	protected function addAttributeFilterByParam( array $params, \Aimeos\MW\Criteria\Iface $filter )
36
-	{
37
-		$attrids = ( isset( $params['f_attrid'] ) ? (array) $params['f_attrid'] : array() );
38
-
39
-		if( !empty( $attrids ) )
40
-		{
41
-			$func = $filter->createFunction( 'index.attributeaggregate', array( array_keys( $attrids ) ) );
42
-			$expr = array(
43
-				$filter->getConditions(),
44
-				$filter->compare( '==', $func, count( $attrids ) ),
45
-			);
46
-			$filter->setConditions( $filter->combine( '&&', $expr ) );
47
-		}
48
-	}
49
-
50
-
51
-	/**
52
-	 * Adds the conditions for the selected attributes to the given search filter.
53
-	 *
54
-	 * @param \Aimeos\MW\View\Iface $view View instance with helper for retrieving the required parameters
55
-	 * @param \Aimeos\MW\Criteria\Iface $filter Criteria object for searching
56
-	 */
57
-	protected function addAttributeFilter( \Aimeos\MW\View\Iface $view, \Aimeos\MW\Criteria\Iface $filter )
58
-	{
59
-		$this->addAttributeFilterByParam( $view->param(), $filter );
60
-	}
61
-
62
-
63
-	/**
64
-	 * Creates the filter from the given parameters for the product list.
65
-	 *
66
-	 * @param string $text Text to search for
67
-	 * @param string $catid Category ID to search for
68
-	 * @param string $sort Sortation string (relevance, name, price)
69
-	 * @param string $sortdir Sortation direction (+ or -)
70
-	 * @param integer $page Page number starting from 1
71
-	 * @param integer $size Page size
72
-	 * @param boolean $catfilter True to include catalog criteria in product filter, false if not
73
-	 * @param boolean $textfilter True to include text criteria in product filter, false if not
74
-	 * @return \Aimeos\MW\Criteria\Iface Search criteria object
75
-	 */
76
-	protected function createProductListFilter( $text, $catid, $sort, $sortdir, $page, $size, $catfilter, $textfilter )
77
-	{
78
-		$controller = $this->getCatalogController();
79
-
80
-		if( $text !== '' && $textfilter === true )
81
-		{
82
-			$filter = $controller->createIndexFilterText( $text, $sort, $sortdir, ( $page - 1 ) * $size, $size );
83
-
84
-			if( $catid !== '' && $catfilter === true ) {
85
-				$filter = $controller->addIndexFilterCategory( $filter, $this->getCatalogIds( $catid ) );
86
-			}
87
-
88
-			return $filter;
89
-		}
90
-		elseif( $catid !== '' && $catfilter === true )
91
-		{
92
-			$catIds = $this->getCatalogIds( $catid );
93
-			return $controller->createIndexFilterCategory( $catIds, $sort, $sortdir, ( $page - 1 ) * $size, $size );
94
-		}
95
-		else
96
-		{
97
-			return $controller->createIndexFilter( $sort, $sortdir, ( $page - 1 ) * $size, $size );
98
-		}
99
-	}
100
-
101
-
102
-	/**
103
-	 * Returns the catalog controller object
104
-	 *
105
-	 * @return \Aimeos\Controller\Frontend\Catalog\Interface Catalog controller
106
-	 */
107
-	protected function getCatalogController()
108
-	{
109
-		if( !isset( $this->controller ) )
110
-		{
111
-			$context = $this->getContext();
112
-			$this->controller = \Aimeos\Controller\Frontend\Factory::createController( $context, 'catalog' );
113
-		}
114
-
115
-		return $this->controller;
116
-	}
117
-
118
-
119
-	/**
120
-	 * Returns the list of catetory IDs if subcategories should be included
121
-	 *
122
-	 * @param string $catId Category ID
123
-	 * @return string|array Cateogory ID or list of catetory IDs
124
-	 */
125
-	protected function getCatalogIds( $catId )
126
-	{
127
-		$config = $this->getContext()->getConfig();
128
-		$default = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE;
129
-
130
-		/** client/html/catalog/lists/levels
131
-		 * Include products of sub-categories in the product list of the current category
132
-		 *
133
-		 * Sometimes it may be useful to show products of sub-categories in the
134
-		 * current category product list, e.g. if the current category contains
135
-		 * no products at all or if there are only a few products in all categories.
136
-		 *
137
-		 * Possible constant values for this setting are:
138
-		 * * 1 : Only products from the current category
139
-		 * * 2 : Products from the current category and the direct child categories
140
-		 * * 3 : Products from the current category and the whole category sub-tree
141
-		 *
142
-		 * Caution: Please keep in mind that displaying products of sub-categories
143
-		 * can slow down your shop, especially if it contains more than a few
144
-		 * products! You have no real control over the positions of the products
145
-		 * in the result list too because all products from different categories
146
-		 * with the same position value are placed randomly.
147
-		 *
148
-		 * Usually, a better way is to associate products to all categories they
149
-		 * should be listed in. This can be done manually if there are only a few
150
-		 * ones or during the product import automatically.
151
-		 *
152
-		 * @param integer Tree level constant
153
-		 * @since 2015.11
154
-		 * @category Developer
155
-		 * @see client/html/catalog/lists/catid-default
156
-		 * @see client/html/catalog/lists/domains
157
-		 * @see client/html/catalog/lists/size
158
-		 */
159
-		$level = $config->get( 'client/html/catalog/lists/levels', $default );
160
-
161
-		if( $level != $default )
162
-		{
163
-			$tree = $this->getCatalogController()->getCatalogTree( $catId, array(), $level );
164
-			$catId = $this->getCatalogIdsFromTree( $tree );
165
-		}
166
-
167
-		return $catId;
168
-	}
169
-
170
-
171
-	/**
172
-	 * Returns the list of catalog IDs for the given catalog tree
173
-	 *
174
-	 * @param \Aimeos\MShop\Catalog\Item\Iface $item Catalog item with children
175
-	 * @return array List of catalog IDs
176
-	 */
177
-	protected function getCatalogIdsFromTree( \Aimeos\MShop\Catalog\Item\Iface $item )
178
-	{
179
-		$list = array( $item->getId() );
180
-
181
-		foreach( $item->getChildren() as $child ) {
182
-			$list = array_merge( $list, $this->getCatalogIdsFromTree( $child ) );
183
-		}
184
-
185
-		return $list;
186
-	}
187
-
188
-
189
-	/**
190
-	 * Returns the products found for the current parameters.
191
-	 *
192
-	 * @param \Aimeos\MW\View\Iface $view View instance with helper for retrieving the required parameters
193
-	 * @return array List of products implementing \Aimeos\MShop\Product\Item\Iface
194
-	 */
195
-	protected function getProductList( \Aimeos\MW\View\Iface $view )
196
-	{
197
-		if( $this->productList === null ) {
198
-			$this->searchProducts( $view );
199
-		}
200
-
201
-		return $this->productList;
202
-	}
203
-
204
-
205
-	/**
206
-	 * Returns the filter from the given parameters for the product list.
207
-	 *
208
-	 * @param array $params Associative list of parameters that should be used for filtering
209
-	 * @param boolean $catfilter True to include catalog criteria in product filter, false if not
210
-	 * @param boolean $textfilter True to include text criteria in product filter, false if not
211
-	 * @param boolean $attrfilter True to include attribute criteria in product filter, false if not
212
-	 * @return \Aimeos\MW\Criteria\Iface Search criteria object
213
-	 */
214
-	protected function getProductListFilterByParam( array $params, $catfilter = true, $textfilter = true, $attrfilter = true )
215
-	{
216
-		$sortdir = '+';
217
-		$context = $this->getContext();
218
-		$config = $context->getConfig();
219
-
220
-		$text = ( isset( $params['f_search'] ) ? (string) $params['f_search'] : '' );
221
-		$catid = ( isset( $params['f_catid'] ) ? (string) $params['f_catid'] : '' );
222
-
223
-		if( $catid == '' && $catfilter === true )
224
-		{
225
-			/** client/html/catalog/lists/catid-default
226
-			 * The default category ID used if none is given as parameter
227
-			 *
228
-			 * If users view a product list page without a category ID in the
229
-			 * parameter list, the first found products are displayed with a
230
-			 * random order. You can circumvent this by configuring a default
231
-			 * category ID that should be used in this case (the ID of the root
232
-			 * category is best for this). In most cases you can set this value
233
-			 * via the administration interface of the shop application.
234
-			 *
235
-			 * @param string Category ID
236
-			 * @since 2014.03
237
-			 * @category User
238
-			 * @category Developer
239
-			 * @see client/html/catalog/lists/size
240
-			 * @see client/html/catalog/lists/domains
241
-			 * @see client/html/catalog/lists/levels
242
-			 * @see client/html/catalog/detail/prodid-default
243
-			 */
244
-			$catid = $config->get( 'client/html/catalog/lists/catid-default', '' );
245
-		}
246
-
247
-		$page = $this->getProductListPageByParam( $params );
248
-		$size = $this->getProductListSizeByParam( $params );
249
-		$sort = $this->getProductListSortByParam( $params, $sortdir );
250
-
251
-		$filter = $this->createProductListFilter( $text, $catid, $sort, $sortdir, $page, $size, $catfilter, $textfilter );
252
-
253
-		if( $attrfilter === true ) {
254
-			$this->addAttributeFilterByParam( $params, $filter );
255
-		}
256
-
257
-
258
-		return $filter;
259
-	}
260
-
261
-
262
-	/**
263
-	 * Returns the filter created from the view parameters for the product list.
264
-	 *
265
-	 * @param \Aimeos\MW\View\Iface $view View instance with helper for retrieving the required parameters
266
-	 * @param boolean $catfilter True to include catalog criteria in product filter, false if not
267
-	 * @param boolean $textfilter True to include text criteria in product filter, false if not
268
-	 * @param boolean $attrfilter True to include attribute criteria in product filter, false if not
269
-	 * @return \Aimeos\MW\Criteria\Iface Search criteria object
270
-	 */
271
-	protected function getProductListFilter( \Aimeos\MW\View\Iface $view, $catfilter = true, $textfilter = true, $attrfilter = true )
272
-	{
273
-		return $this->getProductListFilterByParam( $view->param(), $catfilter, $textfilter, $attrfilter );
274
-	}
275
-
276
-
277
-	/**
278
-	 * Returns the total number of products available for the current parameters.
279
-	 *
280
-	 * @param \Aimeos\MW\View\Iface $view View instance with helper for retrieving the required parameters
281
-	 * @return integer Total number of products
282
-	 */
283
-	protected function getProductListTotal( \Aimeos\MW\View\Iface $view )
284
-	{
285
-		if( $this->productList === null ) {
286
-			$this->searchProducts( $view );
287
-		}
288
-
289
-		return $this->productTotal;
290
-	}
291
-
292
-
293
-	/**
294
-	 * Returns the sanitized page from the parameters for the product list.
295
-	 *
296
-	 * @param array $params Associative list of parameters that should be used for filtering
297
-	 * @return integer Page number starting from 1
298
-	 */
299
-	protected function getProductListPageByParam( array $params )
300
-	{
301
-		return ( isset( $params['l_page'] ) && $params['l_page'] > 0 ? (int) $params['l_page'] : 1 );
302
-	}
303
-
304
-
305
-	/**
306
-	 * Returns the sanitized page from the parameters for the product list.
307
-	 *
308
-	 * @param \Aimeos\MW\View\Iface $view View instance with helper for retrieving the required parameters
309
-	 * @return integer Page number starting from 1
310
-	 */
311
-	protected function getProductListPage( \Aimeos\MW\View\Iface $view )
312
-	{
313
-		return $this->getProductListPageByParam( $view->param() );
314
-	}
315
-
316
-
317
-	/**
318
-	 * Returns the sanitized page size from the parameters for the product list.
319
-	 *
320
-	 * @param array $params Associative list of parameters that should be used for filtering
321
-	 * @return integer Page size
322
-	 */
323
-	protected function getProductListSizeByParam( array $params )
324
-	{
325
-		/** client/html/catalog/lists/size
326
-		 * The number of products shown in a list page
327
-		 *
328
-		 * Limits the number of products that is shown in the list pages to the
329
-		 * given value. If more products are available, the products are split
330
-		 * into bunches which will be shown on their own list page. The user is
331
-		 * able to move to the next page (or previous one if it's not the first)
332
-		 * to display the next (or previous) products.
333
-		 *
334
-		 * The value must be an integer number from 1 to 100. Negative values as
335
-		 * well as values above 100 are not allowed. The value can be overwritten
336
-		 * per request if the "l_size" parameter is part of the URL.
337
-		 *
338
-		 * @param integer Number of products
339
-		 * @since 2014.03
340
-		 * @category User
341
-		 * @category Developer
342
-		 * @see client/html/catalog/lists/catid-default
343
-		 * @see client/html/catalog/lists/domains
344
-		 * @see client/html/catalog/lists/levels
345
-		 */
346
-		$defaultSize = $this->getContext()->getConfig()->get( 'client/html/catalog/lists/size', 48 );
347
-
348
-		$size = ( isset( $params['l_size'] ) ? (int) $params['l_size'] : $defaultSize );
349
-		return ( $size < 1 || $size > 100 ? $defaultSize : $size );
350
-	}
351
-
352
-
353
-	/**
354
-	 * Returns the sanitized page size from the parameters for the product list.
355
-	 *
356
-	 * @param \Aimeos\MW\View\Iface $view View instance with helper for retrieving the required parameters
357
-	 * @return integer Page size
358
-	 */
359
-	protected function getProductListSize( \Aimeos\MW\View\Iface $view )
360
-	{
361
-		return $this->getProductListSizeByParam( $view->param() );
362
-	}
363
-
364
-
365
-	/**
366
-	 * Returns the sanitized sortation from the parameters for the product list.
367
-	 *
368
-	 * @param array $params Associative list of parameters that should be used for filtering
369
-	 * @param string &$sortdir Value-result parameter where the sort direction will be stored
370
-	 * @return string Sortation string (relevance, name, price)
371
-	 */
372
-	protected function getProductListSortByParam( array $params, &$sortdir )
373
-	{
374
-		$sortation = ( isset( $params['f_sort'] ) ? (string) $params['f_sort'] : 'relevance' );
375
-
376
-		$sortdir = ( $sortation[0] === '-' ? '-' : '+' );
377
-		$sort = ltrim( $sortation, '-' );
378
-
379
-		return ( strlen( $sort ) > 0 ? $sort : 'relevance' );
380
-	}
381
-
382
-
383
-	/**
384
-	 * Returns the sanitized sortation from the parameters for the product list.
385
-	 *
386
-	 * @param \Aimeos\MW\View\Iface $view View instance with helper for retrieving the required parameters
387
-	 * @param string &$sortdir Value-result parameter where the sort direction will be stored
388
-	 * @return string Sortation string (relevance, name, price)
389
-	 */
390
-	protected function getProductListSort( \Aimeos\MW\View\Iface $view, &$sortdir )
391
-	{
392
-		return $this->getProductListSortByParam( $view->param(), $sortdir );
393
-	}
394
-
395
-
396
-	/**
397
-	 * Searches for the products based on the current paramters.
398
-	 *
399
-	 * The found products and the total number of available products can be
400
-	 * retrieved using the getProductList() and getProductTotal() methods.
401
-	 *
402
-	 * @param \Aimeos\MW\View\Iface $view View instance with helper for retrieving the required parameters
403
-	 */
404
-	protected function searchProducts( \Aimeos\MW\View\Iface $view )
405
-	{
406
-		$context = $this->getContext();
407
-		$config = $context->getConfig();
408
-
409
-		/** client/html/catalog/domains
410
-		 * A list of domain names whose items should be available in the catalog view templates
411
-		 *
412
-		 * The templates rendering catalog related data usually add the images and
413
-		 * texts associated to each item. If you want to display additional
414
-		 * content like the attributes, you can configure your own list of
415
-		 * domains (attribute, media, price, product, text, etc. are domains)
416
-		 * whose items are fetched from the storage. Please keep in mind that
417
-		 * the more domains you add to the configuration, the more time is required
418
-		 * for fetching the content!
419
-		 *
420
-		 * This configuration option can be overwritten by the "client/html/catalog/lists/domains"
421
-		 * configuration option that allows to configure the domain names of the
422
-		 * items fetched specifically for all types of product listings.
423
-		 *
424
-		 * @param array List of domain names
425
-		 * @since 2014.03
426
-		 * @category Developer
427
-		 * @see client/html/catalog/lists/domains
428
-		 * @see client/html/catalog/lists/catid-default
429
-		 * @see client/html/catalog/lists/size
430
-		 * @see client/html/catalog/lists/levels
431
-		 */
432
-		$domains = $config->get( 'client/html/catalog/domains', array( 'media', 'price', 'text' ) );
433
-
434
-		/** client/html/catalog/lists/domains
435
-		 * A list of domain names whose items should be available in the product list view template
436
-		 *
437
-		 * The templates rendering product lists usually add the images, prices
438
-		 * and texts associated to each product item. If you want to display additional
439
-		 * content like the product attributes, you can configure your own list of
440
-		 * domains (attribute, media, price, product, text, etc. are domains)
441
-		 * whose items are fetched from the storage. Please keep in mind that
442
-		 * the more domains you add to the configuration, the more time is required
443
-		 * for fetching the content!
444
-		 *
445
-		 * This configuration option overwrites the "client/html/catalog/domains"
446
-		 * option that allows to configure the domain names of the items fetched
447
-		 * for all catalog related data.
448
-		 *
449
-		 * @param array List of domain names
450
-		 * @since 2014.03
451
-		 * @category Developer
452
-		 * @see client/html/catalog/domains
453
-		 * @see client/html/catalog/detail/domains
454
-		 * @see client/html/catalog/stage/domains
455
-		 * @see client/html/catalog/lists/catid-default
456
-		 * @see client/html/catalog/lists/size
457
-		 * @see client/html/catalog/lists/levels
458
-		 */
459
-		$domains = $config->get( 'client/html/catalog/lists/domains', $domains );
460
-
461
-		$controller = $this->getCatalogController();
462
-		$productFilter = $this->getProductListFilter( $view );
463
-
464
-		$this->productList = $controller->getIndexItems( $productFilter, $domains, $this->productTotal );
465
-	}
24
+    private $controller;
25
+    private $productList;
26
+    private $productTotal = 0;
27
+
28
+
29
+    /**
30
+     * Adds the conditions for the selected attributes to the given search filter.
31
+     *
32
+     * @param array $params Associative list of parameters that should be used for filtering
33
+     * @param \Aimeos\MW\Criteria\Iface $filter Criteria object for searching
34
+     */
35
+    protected function addAttributeFilterByParam( array $params, \Aimeos\MW\Criteria\Iface $filter )
36
+    {
37
+        $attrids = ( isset( $params['f_attrid'] ) ? (array) $params['f_attrid'] : array() );
38
+
39
+        if( !empty( $attrids ) )
40
+        {
41
+            $func = $filter->createFunction( 'index.attributeaggregate', array( array_keys( $attrids ) ) );
42
+            $expr = array(
43
+                $filter->getConditions(),
44
+                $filter->compare( '==', $func, count( $attrids ) ),
45
+            );
46
+            $filter->setConditions( $filter->combine( '&&', $expr ) );
47
+        }
48
+    }
49
+
50
+
51
+    /**
52
+     * Adds the conditions for the selected attributes to the given search filter.
53
+     *
54
+     * @param \Aimeos\MW\View\Iface $view View instance with helper for retrieving the required parameters
55
+     * @param \Aimeos\MW\Criteria\Iface $filter Criteria object for searching
56
+     */
57
+    protected function addAttributeFilter( \Aimeos\MW\View\Iface $view, \Aimeos\MW\Criteria\Iface $filter )
58
+    {
59
+        $this->addAttributeFilterByParam( $view->param(), $filter );
60
+    }
61
+
62
+
63
+    /**
64
+     * Creates the filter from the given parameters for the product list.
65
+     *
66
+     * @param string $text Text to search for
67
+     * @param string $catid Category ID to search for
68
+     * @param string $sort Sortation string (relevance, name, price)
69
+     * @param string $sortdir Sortation direction (+ or -)
70
+     * @param integer $page Page number starting from 1
71
+     * @param integer $size Page size
72
+     * @param boolean $catfilter True to include catalog criteria in product filter, false if not
73
+     * @param boolean $textfilter True to include text criteria in product filter, false if not
74
+     * @return \Aimeos\MW\Criteria\Iface Search criteria object
75
+     */
76
+    protected function createProductListFilter( $text, $catid, $sort, $sortdir, $page, $size, $catfilter, $textfilter )
77
+    {
78
+        $controller = $this->getCatalogController();
79
+
80
+        if( $text !== '' && $textfilter === true )
81
+        {
82
+            $filter = $controller->createIndexFilterText( $text, $sort, $sortdir, ( $page - 1 ) * $size, $size );
83
+
84
+            if( $catid !== '' && $catfilter === true ) {
85
+                $filter = $controller->addIndexFilterCategory( $filter, $this->getCatalogIds( $catid ) );
86
+            }
87
+
88
+            return $filter;
89
+        }
90
+        elseif( $catid !== '' && $catfilter === true )
91
+        {
92
+            $catIds = $this->getCatalogIds( $catid );
93
+            return $controller->createIndexFilterCategory( $catIds, $sort, $sortdir, ( $page - 1 ) * $size, $size );
94
+        }
95
+        else
96
+        {
97
+            return $controller->createIndexFilter( $sort, $sortdir, ( $page - 1 ) * $size, $size );
98
+        }
99
+    }
100
+
101
+
102
+    /**
103
+     * Returns the catalog controller object
104
+     *
105
+     * @return \Aimeos\Controller\Frontend\Catalog\Interface Catalog controller
106
+     */
107
+    protected function getCatalogController()
108
+    {
109
+        if( !isset( $this->controller ) )
110
+        {
111
+            $context = $this->getContext();
112
+            $this->controller = \Aimeos\Controller\Frontend\Factory::createController( $context, 'catalog' );
113
+        }
114
+
115
+        return $this->controller;
116
+    }
117
+
118
+
119
+    /**
120
+     * Returns the list of catetory IDs if subcategories should be included
121
+     *
122
+     * @param string $catId Category ID
123
+     * @return string|array Cateogory ID or list of catetory IDs
124
+     */
125
+    protected function getCatalogIds( $catId )
126
+    {
127
+        $config = $this->getContext()->getConfig();
128
+        $default = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE;
129
+
130
+        /** client/html/catalog/lists/levels
131
+         * Include products of sub-categories in the product list of the current category
132
+         *
133
+         * Sometimes it may be useful to show products of sub-categories in the
134
+         * current category product list, e.g. if the current category contains
135
+         * no products at all or if there are only a few products in all categories.
136
+         *
137
+         * Possible constant values for this setting are:
138
+         * * 1 : Only products from the current category
139
+         * * 2 : Products from the current category and the direct child categories
140
+         * * 3 : Products from the current category and the whole category sub-tree
141
+         *
142
+         * Caution: Please keep in mind that displaying products of sub-categories
143
+         * can slow down your shop, especially if it contains more than a few
144
+         * products! You have no real control over the positions of the products
145
+         * in the result list too because all products from different categories
146
+         * with the same position value are placed randomly.
147
+         *
148
+         * Usually, a better way is to associate products to all categories they
149
+         * should be listed in. This can be done manually if there are only a few
150
+         * ones or during the product import automatically.
151
+         *
152
+         * @param integer Tree level constant
153
+         * @since 2015.11
154
+         * @category Developer
155
+         * @see client/html/catalog/lists/catid-default
156
+         * @see client/html/catalog/lists/domains
157
+         * @see client/html/catalog/lists/size
158
+         */
159
+        $level = $config->get( 'client/html/catalog/lists/levels', $default );
160
+
161
+        if( $level != $default )
162
+        {
163
+            $tree = $this->getCatalogController()->getCatalogTree( $catId, array(), $level );
164
+            $catId = $this->getCatalogIdsFromTree( $tree );
165
+        }
166
+
167
+        return $catId;
168
+    }
169
+
170
+
171
+    /**
172
+     * Returns the list of catalog IDs for the given catalog tree
173
+     *
174
+     * @param \Aimeos\MShop\Catalog\Item\Iface $item Catalog item with children
175
+     * @return array List of catalog IDs
176
+     */
177
+    protected function getCatalogIdsFromTree( \Aimeos\MShop\Catalog\Item\Iface $item )
178
+    {
179
+        $list = array( $item->getId() );
180
+
181
+        foreach( $item->getChildren() as $child ) {
182
+            $list = array_merge( $list, $this->getCatalogIdsFromTree( $child ) );
183
+        }
184
+
185
+        return $list;
186
+    }
187
+
188
+
189
+    /**
190
+     * Returns the products found for the current parameters.
191
+     *
192
+     * @param \Aimeos\MW\View\Iface $view View instance with helper for retrieving the required parameters
193
+     * @return array List of products implementing \Aimeos\MShop\Product\Item\Iface
194
+     */
195
+    protected function getProductList( \Aimeos\MW\View\Iface $view )
196
+    {
197
+        if( $this->productList === null ) {
198
+            $this->searchProducts( $view );
199
+        }
200
+
201
+        return $this->productList;
202
+    }
203
+
204
+
205
+    /**
206
+     * Returns the filter from the given parameters for the product list.
207
+     *
208
+     * @param array $params Associative list of parameters that should be used for filtering
209
+     * @param boolean $catfilter True to include catalog criteria in product filter, false if not
210
+     * @param boolean $textfilter True to include text criteria in product filter, false if not
211
+     * @param boolean $attrfilter True to include attribute criteria in product filter, false if not
212
+     * @return \Aimeos\MW\Criteria\Iface Search criteria object
213
+     */
214
+    protected function getProductListFilterByParam( array $params, $catfilter = true, $textfilter = true, $attrfilter = true )
215
+    {
216
+        $sortdir = '+';
217
+        $context = $this->getContext();
218
+        $config = $context->getConfig();
219
+
220
+        $text = ( isset( $params['f_search'] ) ? (string) $params['f_search'] : '' );
221
+        $catid = ( isset( $params['f_catid'] ) ? (string) $params['f_catid'] : '' );
222
+
223
+        if( $catid == '' && $catfilter === true )
224
+        {
225
+            /** client/html/catalog/lists/catid-default
226
+             * The default category ID used if none is given as parameter
227
+             *
228
+             * If users view a product list page without a category ID in the
229
+             * parameter list, the first found products are displayed with a
230
+             * random order. You can circumvent this by configuring a default
231
+             * category ID that should be used in this case (the ID of the root
232
+             * category is best for this). In most cases you can set this value
233
+             * via the administration interface of the shop application.
234
+             *
235
+             * @param string Category ID
236
+             * @since 2014.03
237
+             * @category User
238
+             * @category Developer
239
+             * @see client/html/catalog/lists/size
240
+             * @see client/html/catalog/lists/domains
241
+             * @see client/html/catalog/lists/levels
242
+             * @see client/html/catalog/detail/prodid-default
243
+             */
244
+            $catid = $config->get( 'client/html/catalog/lists/catid-default', '' );
245
+        }
246
+
247
+        $page = $this->getProductListPageByParam( $params );
248
+        $size = $this->getProductListSizeByParam( $params );
249
+        $sort = $this->getProductListSortByParam( $params, $sortdir );
250
+
251
+        $filter = $this->createProductListFilter( $text, $catid, $sort, $sortdir, $page, $size, $catfilter, $textfilter );
252
+
253
+        if( $attrfilter === true ) {
254
+            $this->addAttributeFilterByParam( $params, $filter );
255
+        }
256
+
257
+
258
+        return $filter;
259
+    }
260
+
261
+
262
+    /**
263
+     * Returns the filter created from the view parameters for the product list.
264
+     *
265
+     * @param \Aimeos\MW\View\Iface $view View instance with helper for retrieving the required parameters
266
+     * @param boolean $catfilter True to include catalog criteria in product filter, false if not
267
+     * @param boolean $textfilter True to include text criteria in product filter, false if not
268
+     * @param boolean $attrfilter True to include attribute criteria in product filter, false if not
269
+     * @return \Aimeos\MW\Criteria\Iface Search criteria object
270
+     */
271
+    protected function getProductListFilter( \Aimeos\MW\View\Iface $view, $catfilter = true, $textfilter = true, $attrfilter = true )
272
+    {
273
+        return $this->getProductListFilterByParam( $view->param(), $catfilter, $textfilter, $attrfilter );
274
+    }
275
+
276
+
277
+    /**
278
+     * Returns the total number of products available for the current parameters.
279
+     *
280
+     * @param \Aimeos\MW\View\Iface $view View instance with helper for retrieving the required parameters
281
+     * @return integer Total number of products
282
+     */
283
+    protected function getProductListTotal( \Aimeos\MW\View\Iface $view )
284
+    {
285
+        if( $this->productList === null ) {
286
+            $this->searchProducts( $view );
287
+        }
288
+
289
+        return $this->productTotal;
290
+    }
291
+
292
+
293
+    /**
294
+     * Returns the sanitized page from the parameters for the product list.
295
+     *
296
+     * @param array $params Associative list of parameters that should be used for filtering
297
+     * @return integer Page number starting from 1
298
+     */
299
+    protected function getProductListPageByParam( array $params )
300
+    {
301
+        return ( isset( $params['l_page'] ) && $params['l_page'] > 0 ? (int) $params['l_page'] : 1 );
302
+    }
303
+
304
+
305
+    /**
306
+     * Returns the sanitized page from the parameters for the product list.
307
+     *
308
+     * @param \Aimeos\MW\View\Iface $view View instance with helper for retrieving the required parameters
309
+     * @return integer Page number starting from 1
310
+     */
311
+    protected function getProductListPage( \Aimeos\MW\View\Iface $view )
312
+    {
313
+        return $this->getProductListPageByParam( $view->param() );
314
+    }
315
+
316
+
317
+    /**
318
+     * Returns the sanitized page size from the parameters for the product list.
319
+     *
320
+     * @param array $params Associative list of parameters that should be used for filtering
321
+     * @return integer Page size
322
+     */
323
+    protected function getProductListSizeByParam( array $params )
324
+    {
325
+        /** client/html/catalog/lists/size
326
+         * The number of products shown in a list page
327
+         *
328
+         * Limits the number of products that is shown in the list pages to the
329
+         * given value. If more products are available, the products are split
330
+         * into bunches which will be shown on their own list page. The user is
331
+         * able to move to the next page (or previous one if it's not the first)
332
+         * to display the next (or previous) products.
333
+         *
334
+         * The value must be an integer number from 1 to 100. Negative values as
335
+         * well as values above 100 are not allowed. The value can be overwritten
336
+         * per request if the "l_size" parameter is part of the URL.
337
+         *
338
+         * @param integer Number of products
339
+         * @since 2014.03
340
+         * @category User
341
+         * @category Developer
342
+         * @see client/html/catalog/lists/catid-default
343
+         * @see client/html/catalog/lists/domains
344
+         * @see client/html/catalog/lists/levels
345
+         */
346
+        $defaultSize = $this->getContext()->getConfig()->get( 'client/html/catalog/lists/size', 48 );
347
+
348
+        $size = ( isset( $params['l_size'] ) ? (int) $params['l_size'] : $defaultSize );
349
+        return ( $size < 1 || $size > 100 ? $defaultSize : $size );
350
+    }
351
+
352
+
353
+    /**
354
+     * Returns the sanitized page size from the parameters for the product list.
355
+     *
356
+     * @param \Aimeos\MW\View\Iface $view View instance with helper for retrieving the required parameters
357
+     * @return integer Page size
358
+     */
359
+    protected function getProductListSize( \Aimeos\MW\View\Iface $view )
360
+    {
361
+        return $this->getProductListSizeByParam( $view->param() );
362
+    }
363
+
364
+
365
+    /**
366
+     * Returns the sanitized sortation from the parameters for the product list.
367
+     *
368
+     * @param array $params Associative list of parameters that should be used for filtering
369
+     * @param string &$sortdir Value-result parameter where the sort direction will be stored
370
+     * @return string Sortation string (relevance, name, price)
371
+     */
372
+    protected function getProductListSortByParam( array $params, &$sortdir )
373
+    {
374
+        $sortation = ( isset( $params['f_sort'] ) ? (string) $params['f_sort'] : 'relevance' );
375
+
376
+        $sortdir = ( $sortation[0] === '-' ? '-' : '+' );
377
+        $sort = ltrim( $sortation, '-' );
378
+
379
+        return ( strlen( $sort ) > 0 ? $sort : 'relevance' );
380
+    }
381
+
382
+
383
+    /**
384
+     * Returns the sanitized sortation from the parameters for the product list.
385
+     *
386
+     * @param \Aimeos\MW\View\Iface $view View instance with helper for retrieving the required parameters
387
+     * @param string &$sortdir Value-result parameter where the sort direction will be stored
388
+     * @return string Sortation string (relevance, name, price)
389
+     */
390
+    protected function getProductListSort( \Aimeos\MW\View\Iface $view, &$sortdir )
391
+    {
392
+        return $this->getProductListSortByParam( $view->param(), $sortdir );
393
+    }
394
+
395
+
396
+    /**
397
+     * Searches for the products based on the current paramters.
398
+     *
399
+     * The found products and the total number of available products can be
400
+     * retrieved using the getProductList() and getProductTotal() methods.
401
+     *
402
+     * @param \Aimeos\MW\View\Iface $view View instance with helper for retrieving the required parameters
403
+     */
404
+    protected function searchProducts( \Aimeos\MW\View\Iface $view )
405
+    {
406
+        $context = $this->getContext();
407
+        $config = $context->getConfig();
408
+
409
+        /** client/html/catalog/domains
410
+         * A list of domain names whose items should be available in the catalog view templates
411
+         *
412
+         * The templates rendering catalog related data usually add the images and
413
+         * texts associated to each item. If you want to display additional
414
+         * content like the attributes, you can configure your own list of
415
+         * domains (attribute, media, price, product, text, etc. are domains)
416
+         * whose items are fetched from the storage. Please keep in mind that
417
+         * the more domains you add to the configuration, the more time is required
418
+         * for fetching the content!
419
+         *
420
+         * This configuration option can be overwritten by the "client/html/catalog/lists/domains"
421
+         * configuration option that allows to configure the domain names of the
422
+         * items fetched specifically for all types of product listings.
423
+         *
424
+         * @param array List of domain names
425
+         * @since 2014.03
426
+         * @category Developer
427
+         * @see client/html/catalog/lists/domains
428
+         * @see client/html/catalog/lists/catid-default
429
+         * @see client/html/catalog/lists/size
430
+         * @see client/html/catalog/lists/levels
431
+         */
432
+        $domains = $config->get( 'client/html/catalog/domains', array( 'media', 'price', 'text' ) );
433
+
434
+        /** client/html/catalog/lists/domains
435
+         * A list of domain names whose items should be available in the product list view template
436
+         *
437
+         * The templates rendering product lists usually add the images, prices
438
+         * and texts associated to each product item. If you want to display additional
439
+         * content like the product attributes, you can configure your own list of
440
+         * domains (attribute, media, price, product, text, etc. are domains)
441
+         * whose items are fetched from the storage. Please keep in mind that
442
+         * the more domains you add to the configuration, the more time is required
443
+         * for fetching the content!
444
+         *
445
+         * This configuration option overwrites the "client/html/catalog/domains"
446
+         * option that allows to configure the domain names of the items fetched
447
+         * for all catalog related data.
448
+         *
449
+         * @param array List of domain names
450
+         * @since 2014.03
451
+         * @category Developer
452
+         * @see client/html/catalog/domains
453
+         * @see client/html/catalog/detail/domains
454
+         * @see client/html/catalog/stage/domains
455
+         * @see client/html/catalog/lists/catid-default
456
+         * @see client/html/catalog/lists/size
457
+         * @see client/html/catalog/lists/levels
458
+         */
459
+        $domains = $config->get( 'client/html/catalog/lists/domains', $domains );
460
+
461
+        $controller = $this->getCatalogController();
462
+        $productFilter = $this->getProductListFilter( $view );
463
+
464
+        $this->productList = $controller->getIndexItems( $productFilter, $domains, $this->productTotal );
465
+    }
466 466
 }
Please login to merge, or discard this patch.
client/html/src/Client/Html/Catalog/Session/Pinned/Standard.php 1 patch
Indentation   +401 added lines, -401 removed lines patch added patch discarded remove patch
@@ -19,406 +19,406 @@
 block discarded – undo
19 19
  * @subpackage Html
20 20
  */
21 21
 class Standard
22
-	extends \Aimeos\Client\Html\Common\Client\Factory\Base
23
-	implements \Aimeos\Client\Html\Common\Client\Factory\Iface
22
+    extends \Aimeos\Client\Html\Common\Client\Factory\Base
23
+    implements \Aimeos\Client\Html\Common\Client\Factory\Iface
24 24
 {
25
-	/** client/html/catalog/session/pinned/standard/subparts
26
-	 * List of HTML sub-clients rendered within the catalog session pinned 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
-	 * @category Developer
57
-	 */
58
-	private $subPartPath = 'client/html/catalog/session/pinned/standard/subparts';
59
-	private $subPartNames = array();
60
-	private $cache;
61
-
62
-
63
-	/**
64
-	 * Returns the HTML code for insertion into the body.
65
-	 *
66
-	 * @param string $uid Unique identifier for the output if the content is placed more than once on the same page
67
-	 * @param array &$tags Result array for the list of tags that are associated to the output
68
-	 * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
69
-	 * @return string HTML code
70
-	 */
71
-	public function getBody( $uid = '', array &$tags = array(), &$expire = null )
72
-	{
73
-		$context = $this->getContext();
74
-		$session = $context->getSession();
75
-
76
-		/** client/html/catalog/session/pinned
77
-		 * All parameters defined for the catalog session pinned subpart
78
-		 *
79
-		 * This returns all settings related to the catalog session pinned subpart.
80
-		 * Please refer to the single settings for details.
81
-		 *
82
-		 * @param array Associative list of name/value settings
83
-		 * @category Developer
84
-		 * @see client/html/catalog/session#pinned
85
-		 */
86
-		$config = $context->getConfig()->get( 'client/html/catalog/session/pinned', array() );
87
-		$key = $this->getParamHash( array(), $uid . ':catalog:session-pinned-body', $config );
88
-
89
-		if( ( $html = $session->get( $key ) ) === null )
90
-		{
91
-			$view = $this->setViewParams( $this->getView(), $tags, $expire );
92
-
93
-			$output = '';
94
-			foreach( $this->getSubClients() as $subclient ) {
95
-				$output .= $subclient->setView( $view )->getBody( $uid, $tags, $expire );
96
-			}
97
-			$view->pinnedBody = $output;
98
-
99
-			/** client/html/catalog/session/pinned/standard/template-body
100
-			 * Relative path to the HTML body template of the catalog session pinned client.
101
-			 *
102
-			 * The template file contains the HTML code and processing instructions
103
-			 * to generate the result shown in the body of the frontend. The
104
-			 * configuration string is the path to the template file relative
105
-			 * to the templates directory (usually in client/html/templates).
106
-			 *
107
-			 * You can overwrite the template file configuration in extensions and
108
-			 * provide alternative templates. These alternative templates should be
109
-			 * named like the default one but with the string "standard" replaced by
110
-			 * an unique name. You may use the name of your project for this. If
111
-			 * you've implemented an alternative client class as well, "standard"
112
-			 * should be replaced by the name of the new class.
113
-			 *
114
-			 * @param string Relative path to the template creating code for the HTML page body
115
-			 * @since 2014.03
116
-			 * @category Developer
117
-			 * @see client/html/catalog/session/pinned/standard/template-header
118
-			 */
119
-			$tplconf = 'client/html/catalog/session/pinned/standard/template-body';
120
-			$default = 'catalog/session/pinned-body-default.php';
121
-
122
-			$html = $view->render( $view->config( $tplconf, $default ) );
123
-
124
-			$cached = $session->get( 'aimeos/catalog/session/pinned/cache', array() ) + array( $key => true );
125
-			$session->set( 'aimeos/catalog/session/pinned/cache', $cached );
126
-			$session->set( $key, $html );
127
-		}
128
-
129
-		return $html;
130
-	}
131
-
132
-
133
-	/**
134
-	 * Returns the HTML string for insertion into the header.
135
-	 *
136
-	 * @param string $uid Unique identifier for the output if the content is placed more than once on the same page
137
-	 * @param array &$tags Result array for the list of tags that are associated to the output
138
-	 * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
139
-	 * @return string|null String including HTML tags for the header on error
140
-	 */
141
-	public function getHeader( $uid = '', array &$tags = array(), &$expire = null )
142
-	{
143
-		$context = $this->getContext();
144
-		$session = $context->getSession();
145
-
146
-		$config = $context->getConfig()->get( 'client/html/catalog/session/pinned', array() );
147
-		$key = $this->getParamHash( array(), $uid . ':catalog:session-pinned-header', $config );
148
-
149
-		if( ( $html = $session->get( $key ) ) === null )
150
-		{
151
-			$view = $this->setViewParams( $this->getView(), $tags, $expire );
152
-
153
-			$output = '';
154
-			foreach( $this->getSubClients() as $subclient ) {
155
-				$output .= $subclient->setView( $view )->getHeader( $uid, $tags, $expire );
156
-			}
157
-			$view->pinnedHeader = $output;
158
-
159
-			/** client/html/catalog/session/pinned/standard/template-header
160
-			 * Relative path to the HTML header template of the catalog session pinned client.
161
-			 *
162
-			 * The template file contains the HTML code and processing instructions
163
-			 * to generate the HTML code that is inserted into the HTML page header
164
-			 * of the rendered page in the frontend. The configuration string is the
165
-			 * path to the template file relative to the templates directory (usually
166
-			 * in client/html/templates).
167
-			 *
168
-			 * You can overwrite the template file configuration in extensions and
169
-			 * provide alternative templates. These alternative templates should be
170
-			 * named like the default one but with the string "standard" replaced by
171
-			 * an unique name. You may use the name of your project for this. If
172
-			 * you've implemented an alternative client class as well, "standard"
173
-			 * should be replaced by the name of the new class.
174
-			 *
175
-			 * @param string Relative path to the template creating code for the HTML page head
176
-			 * @since 2014.03
177
-			 * @category Developer
178
-			 * @see client/html/catalog/session/pinned/standard/template-body
179
-			 */
180
-			$tplconf = 'client/html/catalog/session/pinned/standard/template-header';
181
-			$default = 'catalog/session/pinned-header-default.php';
182
-
183
-			$html = $view->render( $view->config( $tplconf, $default ) );
184
-
185
-			$cached = $session->get( 'aimeos/catalog/session/pinned/cache', array() ) + array( $key => true );
186
-			$session->set( 'aimeos/catalog/session/pinned/cache', $cached );
187
-			$session->set( $key, $html );
188
-		}
189
-
190
-		return $html;
191
-	}
192
-
193
-
194
-	/**
195
-	 * Returns the sub-client given by its name.
196
-	 *
197
-	 * @param string $type Name of the client type
198
-	 * @param string|null $name Name of the sub-client (Default if null)
199
-	 * @return \Aimeos\Client\Html\Iface Sub-client object
200
-	 */
201
-	public function getSubClient( $type, $name = null )
202
-	{
203
-		/** client/html/catalog/session/pinned/decorators/excludes
204
-		 * Excludes decorators added by the "common" option from the catalog session pinned html client
205
-		 *
206
-		 * Decorators extend the functionality of a class by adding new aspects
207
-		 * (e.g. log what is currently done), executing the methods of the underlying
208
-		 * class only in certain conditions (e.g. only for logged in users) or
209
-		 * modify what is returned to the caller.
210
-		 *
211
-		 * This option allows you to remove a decorator added via
212
-		 * "client/html/common/decorators/default" before they are wrapped
213
-		 * around the html client.
214
-		 *
215
-		 *  client/html/catalog/session/pinned/decorators/excludes = array( 'decorator1' )
216
-		 *
217
-		 * This would remove the decorator named "decorator1" from the list of
218
-		 * common decorators ("\Aimeos\Client\Html\Common\Decorator\*") added via
219
-		 * "client/html/common/decorators/default" to the html client.
220
-		 *
221
-		 * @param array List of decorator names
222
-		 * @since 2015.08
223
-		 * @category Developer
224
-		 * @see client/html/common/decorators/default
225
-		 * @see client/html/catalog/session/pinned/decorators/global
226
-		 * @see client/html/catalog/session/pinned/decorators/local
227
-		 */
228
-
229
-		/** client/html/catalog/session/pinned/decorators/global
230
-		 * Adds a list of globally available decorators only to the catalog session pinned html client
231
-		 *
232
-		 * Decorators extend the functionality of a class by adding new aspects
233
-		 * (e.g. log what is currently done), executing the methods of the underlying
234
-		 * class only in certain conditions (e.g. only for logged in users) or
235
-		 * modify what is returned to the caller.
236
-		 *
237
-		 * This option allows you to wrap global decorators
238
-		 * ("\Aimeos\Client\Html\Common\Decorator\*") around the html client.
239
-		 *
240
-		 *  client/html/catalog/session/pinned/decorators/global = array( 'decorator1' )
241
-		 *
242
-		 * This would add the decorator named "decorator1" defined by
243
-		 * "\Aimeos\Client\Html\Common\Decorator\Decorator1" only to the html client.
244
-		 *
245
-		 * @param array List of decorator names
246
-		 * @since 2015.08
247
-		 * @category Developer
248
-		 * @see client/html/common/decorators/default
249
-		 * @see client/html/catalog/session/pinned/decorators/excludes
250
-		 * @see client/html/catalog/session/pinned/decorators/local
251
-		 */
252
-
253
-		/** client/html/catalog/session/pinned/decorators/local
254
-		 * Adds a list of local decorators only to the catalog session pinned html client
255
-		 *
256
-		 * Decorators extend the functionality of a class by adding new aspects
257
-		 * (e.g. log what is currently done), executing the methods of the underlying
258
-		 * class only in certain conditions (e.g. only for logged in users) or
259
-		 * modify what is returned to the caller.
260
-		 *
261
-		 * This option allows you to wrap local decorators
262
-		 * ("\Aimeos\Client\Html\Catalog\Decorator\*") around the html client.
263
-		 *
264
-		 *  client/html/catalog/session/pinned/decorators/local = array( 'decorator2' )
265
-		 *
266
-		 * This would add the decorator named "decorator2" defined by
267
-		 * "\Aimeos\Client\Html\Catalog\Decorator\Decorator2" only to the html client.
268
-		 *
269
-		 * @param array List of decorator names
270
-		 * @since 2015.08
271
-		 * @category Developer
272
-		 * @see client/html/common/decorators/default
273
-		 * @see client/html/catalog/session/pinned/decorators/excludes
274
-		 * @see client/html/catalog/session/pinned/decorators/global
275
-		 */
276
-
277
-		return $this->createSubClient( 'catalog/session/pinned/' . $type, $name );
278
-	}
279
-
280
-
281
-	/**
282
-	 * Processes the input, e.g. store given values.
283
-	 * A view must be available and this method doesn't generate any output
284
-	 * besides setting view variables.
285
-	 */
286
-	public function process()
287
-	{
288
-		$refresh = false;
289
-		$view = $this->getView();
290
-		$context = $this->getContext();
291
-		$session = $context->getSession();
292
-		$pinned = $session->get( 'aimeos/catalog/session/pinned/list', array() );
293
-
294
-		switch( $view->param( 'pin_action' ) )
295
-		{
296
-			case 'add':
297
-
298
-				foreach( (array) $view->param( 'pin_id', array() ) as $id ) {
299
-					$pinned[$id] = $id;
300
-				}
301
-
302
-				/** client/html/catalog/session/pinned/standard/maxitems
303
-				 * Maximum number of products displayed in the "pinned" section
304
-				 *
305
-				 * This option limits the number of products that are shown in the
306
-				 * "pinned" section after the users added the product to their list
307
-				 * of pinned products. It must be a positive integer value greater
308
-				 * than 0.
309
-				 *
310
-				 * Note: The higher the value is the more data has to be transfered
311
-				 * to the client each time the user loads a page with the list of
312
-				 * pinned products.
313
-				 *
314
-				 * @param integer Number of products
315
-				 * @since 2014.09
316
-				 * @category User
317
-				 * @category Developer
318
-				 */
319
-				$max = $context->getConfig()->get( 'client/html/catalog/session/pinned/standard/maxitems', 50 );
320
-
321
-				$pinned = array_slice( $pinned, -$max, $max, true );
322
-				$refresh = true;
323
-				break;
324
-
325
-			case 'delete':
326
-
327
-				foreach( (array) $view->param( 'pin_id', array() ) as $id ) {
328
-					unset( $pinned[$id] );
329
-				}
330
-
331
-				$refresh = true;
332
-				break;
333
-		}
334
-
335
-
336
-		if( $refresh )
337
-		{
338
-			$session->set( 'aimeos/catalog/session/pinned/list', $pinned );
339
-
340
-			foreach( $session->get( 'aimeos/catalog/session/pinned/cache', array() ) as $key => $value ) {
341
-				$session->set( $key, null );
342
-			}
343
-		}
344
-
345
-		parent::process();
346
-	}
347
-
348
-
349
-	/**
350
-	 * Returns the list of sub-client names configured for the client.
351
-	 *
352
-	 * @return array List of HTML client names
353
-	 */
354
-	protected function getSubClientNames()
355
-	{
356
-		return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames );
357
-	}
358
-
359
-
360
-	/**
361
-	 * Sets the necessary parameter values in the view.
362
-	 *
363
-	 * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output
364
-	 * @param array &$tags Result array for the list of tags that are associated to the output
365
-	 * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
366
-	 * @return \Aimeos\MW\View\Iface Modified view object
367
-	 */
368
-	protected function setViewParams( \Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null )
369
-	{
370
-		if( !isset( $this->cache ) )
371
-		{
372
-			$expire = null;
373
-			$tags = $items = array();
374
-			$context = $this->getContext();
375
-			$config = $context->getConfig();
376
-			$session = $context->getSession();
377
-
378
-			$default = array( 'media', 'price', 'text' );
379
-			$domains = $config->get( 'client/html/catalog/domains', $default );
380
-
381
-			/** client/html/catalog/session/pinned/domains
382
-			 * A list of domain names whose items should be available in the pinned view template for the product
383
-			 *
384
-			 * The templates rendering product details usually add the images,
385
-			 * prices and texts, etc. associated to the product
386
-			 * item. If you want to display additional or less content, you can
387
-			 * configure your own list of domains (attribute, media, price, product,
388
-			 * text, etc. are domains) whose items are fetched from the storage.
389
-			 * Please keep in mind that the more domains you add to the configuration,
390
-			 * the more time is required for fetching the content!
391
-			 *
392
-			 * From 2014.09 to 2015.03, this setting was available as
393
-			 * client/html/catalog/detail/pinned/domains
394
-			 *
395
-			 * @param array List of domain names
396
-			 * @since 2015.04
397
-			 * @category Developer
398
-			 * @see client/html/catalog/domains
399
-			 * @see client/html/catalog/lists/domains
400
-			 * @see client/html/catalog/detail/domains
401
-			 */
402
-			$domains = $config->get( 'client/html/catalog/session/pinned/domains', $domains );
403
-
404
-			$pinned = $session->get( 'aimeos/catalog/session/pinned/list', array() );
405
-
406
-			$controller = \Aimeos\Controller\Frontend\Factory::createController( $context, 'catalog' );
407
-			$result = $controller->getProductItems( $pinned, $domains );
408
-
409
-			foreach( array_reverse( $pinned ) as $id )
410
-			{
411
-				if( isset( $result[$id] ) ) {
412
-					$items[$id] = $result[$id];
413
-				}
414
-			}
415
-
416
-			$view->pinnedProductItems = $items;
417
-			$view->pinnedParams = $this->getClientParams( $view->param() );
418
-
419
-			$this->cache = $view;
420
-		}
421
-
422
-		return $this->cache;
423
-	}
25
+    /** client/html/catalog/session/pinned/standard/subparts
26
+     * List of HTML sub-clients rendered within the catalog session pinned 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
+     * @category Developer
57
+     */
58
+    private $subPartPath = 'client/html/catalog/session/pinned/standard/subparts';
59
+    private $subPartNames = array();
60
+    private $cache;
61
+
62
+
63
+    /**
64
+     * Returns the HTML code for insertion into the body.
65
+     *
66
+     * @param string $uid Unique identifier for the output if the content is placed more than once on the same page
67
+     * @param array &$tags Result array for the list of tags that are associated to the output
68
+     * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
69
+     * @return string HTML code
70
+     */
71
+    public function getBody( $uid = '', array &$tags = array(), &$expire = null )
72
+    {
73
+        $context = $this->getContext();
74
+        $session = $context->getSession();
75
+
76
+        /** client/html/catalog/session/pinned
77
+         * All parameters defined for the catalog session pinned subpart
78
+         *
79
+         * This returns all settings related to the catalog session pinned subpart.
80
+         * Please refer to the single settings for details.
81
+         *
82
+         * @param array Associative list of name/value settings
83
+         * @category Developer
84
+         * @see client/html/catalog/session#pinned
85
+         */
86
+        $config = $context->getConfig()->get( 'client/html/catalog/session/pinned', array() );
87
+        $key = $this->getParamHash( array(), $uid . ':catalog:session-pinned-body', $config );
88
+
89
+        if( ( $html = $session->get( $key ) ) === null )
90
+        {
91
+            $view = $this->setViewParams( $this->getView(), $tags, $expire );
92
+
93
+            $output = '';
94
+            foreach( $this->getSubClients() as $subclient ) {
95
+                $output .= $subclient->setView( $view )->getBody( $uid, $tags, $expire );
96
+            }
97
+            $view->pinnedBody = $output;
98
+
99
+            /** client/html/catalog/session/pinned/standard/template-body
100
+             * Relative path to the HTML body template of the catalog session pinned client.
101
+             *
102
+             * The template file contains the HTML code and processing instructions
103
+             * to generate the result shown in the body of the frontend. The
104
+             * configuration string is the path to the template file relative
105
+             * to the templates directory (usually in client/html/templates).
106
+             *
107
+             * You can overwrite the template file configuration in extensions and
108
+             * provide alternative templates. These alternative templates should be
109
+             * named like the default one but with the string "standard" replaced by
110
+             * an unique name. You may use the name of your project for this. If
111
+             * you've implemented an alternative client class as well, "standard"
112
+             * should be replaced by the name of the new class.
113
+             *
114
+             * @param string Relative path to the template creating code for the HTML page body
115
+             * @since 2014.03
116
+             * @category Developer
117
+             * @see client/html/catalog/session/pinned/standard/template-header
118
+             */
119
+            $tplconf = 'client/html/catalog/session/pinned/standard/template-body';
120
+            $default = 'catalog/session/pinned-body-default.php';
121
+
122
+            $html = $view->render( $view->config( $tplconf, $default ) );
123
+
124
+            $cached = $session->get( 'aimeos/catalog/session/pinned/cache', array() ) + array( $key => true );
125
+            $session->set( 'aimeos/catalog/session/pinned/cache', $cached );
126
+            $session->set( $key, $html );
127
+        }
128
+
129
+        return $html;
130
+    }
131
+
132
+
133
+    /**
134
+     * Returns the HTML string for insertion into the header.
135
+     *
136
+     * @param string $uid Unique identifier for the output if the content is placed more than once on the same page
137
+     * @param array &$tags Result array for the list of tags that are associated to the output
138
+     * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
139
+     * @return string|null String including HTML tags for the header on error
140
+     */
141
+    public function getHeader( $uid = '', array &$tags = array(), &$expire = null )
142
+    {
143
+        $context = $this->getContext();
144
+        $session = $context->getSession();
145
+
146
+        $config = $context->getConfig()->get( 'client/html/catalog/session/pinned', array() );
147
+        $key = $this->getParamHash( array(), $uid . ':catalog:session-pinned-header', $config );
148
+
149
+        if( ( $html = $session->get( $key ) ) === null )
150
+        {
151
+            $view = $this->setViewParams( $this->getView(), $tags, $expire );
152
+
153
+            $output = '';
154
+            foreach( $this->getSubClients() as $subclient ) {
155
+                $output .= $subclient->setView( $view )->getHeader( $uid, $tags, $expire );
156
+            }
157
+            $view->pinnedHeader = $output;
158
+
159
+            /** client/html/catalog/session/pinned/standard/template-header
160
+             * Relative path to the HTML header template of the catalog session pinned client.
161
+             *
162
+             * The template file contains the HTML code and processing instructions
163
+             * to generate the HTML code that is inserted into the HTML page header
164
+             * of the rendered page in the frontend. The configuration string is the
165
+             * path to the template file relative to the templates directory (usually
166
+             * in client/html/templates).
167
+             *
168
+             * You can overwrite the template file configuration in extensions and
169
+             * provide alternative templates. These alternative templates should be
170
+             * named like the default one but with the string "standard" replaced by
171
+             * an unique name. You may use the name of your project for this. If
172
+             * you've implemented an alternative client class as well, "standard"
173
+             * should be replaced by the name of the new class.
174
+             *
175
+             * @param string Relative path to the template creating code for the HTML page head
176
+             * @since 2014.03
177
+             * @category Developer
178
+             * @see client/html/catalog/session/pinned/standard/template-body
179
+             */
180
+            $tplconf = 'client/html/catalog/session/pinned/standard/template-header';
181
+            $default = 'catalog/session/pinned-header-default.php';
182
+
183
+            $html = $view->render( $view->config( $tplconf, $default ) );
184
+
185
+            $cached = $session->get( 'aimeos/catalog/session/pinned/cache', array() ) + array( $key => true );
186
+            $session->set( 'aimeos/catalog/session/pinned/cache', $cached );
187
+            $session->set( $key, $html );
188
+        }
189
+
190
+        return $html;
191
+    }
192
+
193
+
194
+    /**
195
+     * Returns the sub-client given by its name.
196
+     *
197
+     * @param string $type Name of the client type
198
+     * @param string|null $name Name of the sub-client (Default if null)
199
+     * @return \Aimeos\Client\Html\Iface Sub-client object
200
+     */
201
+    public function getSubClient( $type, $name = null )
202
+    {
203
+        /** client/html/catalog/session/pinned/decorators/excludes
204
+         * Excludes decorators added by the "common" option from the catalog session pinned html client
205
+         *
206
+         * Decorators extend the functionality of a class by adding new aspects
207
+         * (e.g. log what is currently done), executing the methods of the underlying
208
+         * class only in certain conditions (e.g. only for logged in users) or
209
+         * modify what is returned to the caller.
210
+         *
211
+         * This option allows you to remove a decorator added via
212
+         * "client/html/common/decorators/default" before they are wrapped
213
+         * around the html client.
214
+         *
215
+         *  client/html/catalog/session/pinned/decorators/excludes = array( 'decorator1' )
216
+         *
217
+         * This would remove the decorator named "decorator1" from the list of
218
+         * common decorators ("\Aimeos\Client\Html\Common\Decorator\*") added via
219
+         * "client/html/common/decorators/default" to the html client.
220
+         *
221
+         * @param array List of decorator names
222
+         * @since 2015.08
223
+         * @category Developer
224
+         * @see client/html/common/decorators/default
225
+         * @see client/html/catalog/session/pinned/decorators/global
226
+         * @see client/html/catalog/session/pinned/decorators/local
227
+         */
228
+
229
+        /** client/html/catalog/session/pinned/decorators/global
230
+         * Adds a list of globally available decorators only to the catalog session pinned html client
231
+         *
232
+         * Decorators extend the functionality of a class by adding new aspects
233
+         * (e.g. log what is currently done), executing the methods of the underlying
234
+         * class only in certain conditions (e.g. only for logged in users) or
235
+         * modify what is returned to the caller.
236
+         *
237
+         * This option allows you to wrap global decorators
238
+         * ("\Aimeos\Client\Html\Common\Decorator\*") around the html client.
239
+         *
240
+         *  client/html/catalog/session/pinned/decorators/global = array( 'decorator1' )
241
+         *
242
+         * This would add the decorator named "decorator1" defined by
243
+         * "\Aimeos\Client\Html\Common\Decorator\Decorator1" only to the html client.
244
+         *
245
+         * @param array List of decorator names
246
+         * @since 2015.08
247
+         * @category Developer
248
+         * @see client/html/common/decorators/default
249
+         * @see client/html/catalog/session/pinned/decorators/excludes
250
+         * @see client/html/catalog/session/pinned/decorators/local
251
+         */
252
+
253
+        /** client/html/catalog/session/pinned/decorators/local
254
+         * Adds a list of local decorators only to the catalog session pinned html client
255
+         *
256
+         * Decorators extend the functionality of a class by adding new aspects
257
+         * (e.g. log what is currently done), executing the methods of the underlying
258
+         * class only in certain conditions (e.g. only for logged in users) or
259
+         * modify what is returned to the caller.
260
+         *
261
+         * This option allows you to wrap local decorators
262
+         * ("\Aimeos\Client\Html\Catalog\Decorator\*") around the html client.
263
+         *
264
+         *  client/html/catalog/session/pinned/decorators/local = array( 'decorator2' )
265
+         *
266
+         * This would add the decorator named "decorator2" defined by
267
+         * "\Aimeos\Client\Html\Catalog\Decorator\Decorator2" only to the html client.
268
+         *
269
+         * @param array List of decorator names
270
+         * @since 2015.08
271
+         * @category Developer
272
+         * @see client/html/common/decorators/default
273
+         * @see client/html/catalog/session/pinned/decorators/excludes
274
+         * @see client/html/catalog/session/pinned/decorators/global
275
+         */
276
+
277
+        return $this->createSubClient( 'catalog/session/pinned/' . $type, $name );
278
+    }
279
+
280
+
281
+    /**
282
+     * Processes the input, e.g. store given values.
283
+     * A view must be available and this method doesn't generate any output
284
+     * besides setting view variables.
285
+     */
286
+    public function process()
287
+    {
288
+        $refresh = false;
289
+        $view = $this->getView();
290
+        $context = $this->getContext();
291
+        $session = $context->getSession();
292
+        $pinned = $session->get( 'aimeos/catalog/session/pinned/list', array() );
293
+
294
+        switch( $view->param( 'pin_action' ) )
295
+        {
296
+            case 'add':
297
+
298
+                foreach( (array) $view->param( 'pin_id', array() ) as $id ) {
299
+                    $pinned[$id] = $id;
300
+                }
301
+
302
+                /** client/html/catalog/session/pinned/standard/maxitems
303
+                 * Maximum number of products displayed in the "pinned" section
304
+                 *
305
+                 * This option limits the number of products that are shown in the
306
+                 * "pinned" section after the users added the product to their list
307
+                 * of pinned products. It must be a positive integer value greater
308
+                 * than 0.
309
+                 *
310
+                 * Note: The higher the value is the more data has to be transfered
311
+                 * to the client each time the user loads a page with the list of
312
+                 * pinned products.
313
+                 *
314
+                 * @param integer Number of products
315
+                 * @since 2014.09
316
+                 * @category User
317
+                 * @category Developer
318
+                 */
319
+                $max = $context->getConfig()->get( 'client/html/catalog/session/pinned/standard/maxitems', 50 );
320
+
321
+                $pinned = array_slice( $pinned, -$max, $max, true );
322
+                $refresh = true;
323
+                break;
324
+
325
+            case 'delete':
326
+
327
+                foreach( (array) $view->param( 'pin_id', array() ) as $id ) {
328
+                    unset( $pinned[$id] );
329
+                }
330
+
331
+                $refresh = true;
332
+                break;
333
+        }
334
+
335
+
336
+        if( $refresh )
337
+        {
338
+            $session->set( 'aimeos/catalog/session/pinned/list', $pinned );
339
+
340
+            foreach( $session->get( 'aimeos/catalog/session/pinned/cache', array() ) as $key => $value ) {
341
+                $session->set( $key, null );
342
+            }
343
+        }
344
+
345
+        parent::process();
346
+    }
347
+
348
+
349
+    /**
350
+     * Returns the list of sub-client names configured for the client.
351
+     *
352
+     * @return array List of HTML client names
353
+     */
354
+    protected function getSubClientNames()
355
+    {
356
+        return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames );
357
+    }
358
+
359
+
360
+    /**
361
+     * Sets the necessary parameter values in the view.
362
+     *
363
+     * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output
364
+     * @param array &$tags Result array for the list of tags that are associated to the output
365
+     * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
366
+     * @return \Aimeos\MW\View\Iface Modified view object
367
+     */
368
+    protected function setViewParams( \Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null )
369
+    {
370
+        if( !isset( $this->cache ) )
371
+        {
372
+            $expire = null;
373
+            $tags = $items = array();
374
+            $context = $this->getContext();
375
+            $config = $context->getConfig();
376
+            $session = $context->getSession();
377
+
378
+            $default = array( 'media', 'price', 'text' );
379
+            $domains = $config->get( 'client/html/catalog/domains', $default );
380
+
381
+            /** client/html/catalog/session/pinned/domains
382
+             * A list of domain names whose items should be available in the pinned view template for the product
383
+             *
384
+             * The templates rendering product details usually add the images,
385
+             * prices and texts, etc. associated to the product
386
+             * item. If you want to display additional or less content, you can
387
+             * configure your own list of domains (attribute, media, price, product,
388
+             * text, etc. are domains) whose items are fetched from the storage.
389
+             * Please keep in mind that the more domains you add to the configuration,
390
+             * the more time is required for fetching the content!
391
+             *
392
+             * From 2014.09 to 2015.03, this setting was available as
393
+             * client/html/catalog/detail/pinned/domains
394
+             *
395
+             * @param array List of domain names
396
+             * @since 2015.04
397
+             * @category Developer
398
+             * @see client/html/catalog/domains
399
+             * @see client/html/catalog/lists/domains
400
+             * @see client/html/catalog/detail/domains
401
+             */
402
+            $domains = $config->get( 'client/html/catalog/session/pinned/domains', $domains );
403
+
404
+            $pinned = $session->get( 'aimeos/catalog/session/pinned/list', array() );
405
+
406
+            $controller = \Aimeos\Controller\Frontend\Factory::createController( $context, 'catalog' );
407
+            $result = $controller->getProductItems( $pinned, $domains );
408
+
409
+            foreach( array_reverse( $pinned ) as $id )
410
+            {
411
+                if( isset( $result[$id] ) ) {
412
+                    $items[$id] = $result[$id];
413
+                }
414
+            }
415
+
416
+            $view->pinnedProductItems = $items;
417
+            $view->pinnedParams = $this->getClientParams( $view->param() );
418
+
419
+            $this->cache = $view;
420
+        }
421
+
422
+        return $this->cache;
423
+    }
424 424
 }
425 425
\ No newline at end of file
Please login to merge, or discard this patch.
client/html/src/Client/Html/Catalog/Session/Factory.php 1 patch
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -19,69 +19,69 @@
 block discarded – undo
19 19
  * @subpackage Html
20 20
  */
21 21
 class Factory
22
-	extends \Aimeos\Client\Html\Common\Factory\Base
23
-	implements \Aimeos\Client\Html\Common\Factory\Iface
22
+    extends \Aimeos\Client\Html\Common\Factory\Base
23
+    implements \Aimeos\Client\Html\Common\Factory\Iface
24 24
 {
25
-	/**
26
-	 * Creates a catalog session client object.
27
-	 *
28
-	 * @param \Aimeos\MShop\Context\Item\Iface $context Shop context instance with necessary objects
29
-	 * @param array $templatePaths List of file system paths where the templates are stored
30
-	 * @param string|null $name Client name (default: "Standard")
31
-	 * @return \Aimeos\Client\Html\Iface Filter part implementing \Aimeos\Client\Html\Iface
32
-	 * @throws \Aimeos\Client\Html\Exception If requested client implementation couldn't be found or initialisation fails
33
-	 */
34
-	public static function createClient( \Aimeos\MShop\Context\Item\Iface $context, array $templatePaths, $name = null )
35
-	{
36
-		/** client/html/catalog/session/name
37
-		 * Class name of the used catalog session client implementation
38
-		 *
39
-		 * Each default HTML client can be replace by an alternative imlementation.
40
-		 * To use this implementation, you have to set the last part of the class
41
-		 * name as configuration value so the client factory knows which class it
42
-		 * has to instantiate.
43
-		 *
44
-		 * For example, if the name of the default class is
45
-		 *
46
-		 *  \Aimeos\Client\Html\Catalog\Session\Standard
47
-		 *
48
-		 * and you want to replace it with your own version named
49
-		 *
50
-		 *  \Aimeos\Client\Html\Catalog\Session\Mysession
51
-		 *
52
-		 * then you have to set the this configuration option:
53
-		 *
54
-		 *  client/html/catalog/session/name = Mysession
55
-		 *
56
-		 * The value is the last part of your own class name and it's case sensitive,
57
-		 * so take care that the configuration value is exactly named like the last
58
-		 * part of the class name.
59
-		 *
60
-		 * The allowed characters of the class name are A-Z, a-z and 0-9. No other
61
-		 * characters are possible! You should always start the last part of the class
62
-		 * name with an upper case character and continue only with lower case characters
63
-		 * or numbers. Avoid chamel case names like "MySession"!
64
-		 *
65
-		 * @param string Last part of the class name
66
-		 * @since 2014.03
67
-		 * @category Developer
68
-		 */
69
-		if( $name === null ) {
70
-			$name = $context->getConfig()->get( 'client/html/catalog/session/name', 'Standard' );
71
-		}
25
+    /**
26
+     * Creates a catalog session client object.
27
+     *
28
+     * @param \Aimeos\MShop\Context\Item\Iface $context Shop context instance with necessary objects
29
+     * @param array $templatePaths List of file system paths where the templates are stored
30
+     * @param string|null $name Client name (default: "Standard")
31
+     * @return \Aimeos\Client\Html\Iface Filter part implementing \Aimeos\Client\Html\Iface
32
+     * @throws \Aimeos\Client\Html\Exception If requested client implementation couldn't be found or initialisation fails
33
+     */
34
+    public static function createClient( \Aimeos\MShop\Context\Item\Iface $context, array $templatePaths, $name = null )
35
+    {
36
+        /** client/html/catalog/session/name
37
+         * Class name of the used catalog session client implementation
38
+         *
39
+         * Each default HTML client can be replace by an alternative imlementation.
40
+         * To use this implementation, you have to set the last part of the class
41
+         * name as configuration value so the client factory knows which class it
42
+         * has to instantiate.
43
+         *
44
+         * For example, if the name of the default class is
45
+         *
46
+         *  \Aimeos\Client\Html\Catalog\Session\Standard
47
+         *
48
+         * and you want to replace it with your own version named
49
+         *
50
+         *  \Aimeos\Client\Html\Catalog\Session\Mysession
51
+         *
52
+         * then you have to set the this configuration option:
53
+         *
54
+         *  client/html/catalog/session/name = Mysession
55
+         *
56
+         * The value is the last part of your own class name and it's case sensitive,
57
+         * so take care that the configuration value is exactly named like the last
58
+         * part of the class name.
59
+         *
60
+         * The allowed characters of the class name are A-Z, a-z and 0-9. No other
61
+         * characters are possible! You should always start the last part of the class
62
+         * name with an upper case character and continue only with lower case characters
63
+         * or numbers. Avoid chamel case names like "MySession"!
64
+         *
65
+         * @param string Last part of the class name
66
+         * @since 2014.03
67
+         * @category Developer
68
+         */
69
+        if( $name === null ) {
70
+            $name = $context->getConfig()->get( 'client/html/catalog/session/name', 'Standard' );
71
+        }
72 72
 
73
-		if( ctype_alnum( $name ) === false )
74
-		{
75
-			$classname = is_string( $name ) ? '\\Aimeos\\Client\\Html\\Catalog\\Session\\' . $name : '<not a string>';
76
-			throw new \Aimeos\Client\Html\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
77
-		}
73
+        if( ctype_alnum( $name ) === false )
74
+        {
75
+            $classname = is_string( $name ) ? '\\Aimeos\\Client\\Html\\Catalog\\Session\\' . $name : '<not a string>';
76
+            throw new \Aimeos\Client\Html\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
77
+        }
78 78
 
79
-		$iface = '\\Aimeos\\Client\\Html\\Iface';
80
-		$classname = '\\Aimeos\\Client\\Html\\Catalog\\Session\\' . $name;
79
+        $iface = '\\Aimeos\\Client\\Html\\Iface';
80
+        $classname = '\\Aimeos\\Client\\Html\\Catalog\\Session\\' . $name;
81 81
 
82
-		$client = self::createClientBase( $context, $classname, $iface, $templatePaths );
82
+        $client = self::createClientBase( $context, $classname, $iface, $templatePaths );
83 83
 
84
-		return self::addClientDecorators( $context, $client, $templatePaths, 'catalog/session' );
85
-	}
84
+        return self::addClientDecorators( $context, $client, $templatePaths, 'catalog/session' );
85
+    }
86 86
 }
87 87
 
Please login to merge, or discard this patch.
client/html/src/Client/Html/Catalog/Session/Standard.php 1 patch
Indentation   +300 added lines, -300 removed lines patch added patch discarded remove patch
@@ -19,329 +19,329 @@
 block discarded – undo
19 19
  * @subpackage Html
20 20
  */
21 21
 class Standard
22
-	extends \Aimeos\Client\Html\Common\Client\Factory\Base
23
-	implements \Aimeos\Client\Html\Common\Client\Factory\Iface
22
+    extends \Aimeos\Client\Html\Common\Client\Factory\Base
23
+    implements \Aimeos\Client\Html\Common\Client\Factory\Iface
24 24
 {
25
-	/** client/html/catalog/session/standard/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
-	 * @category Developer
57
-	 */
58
-	private $subPartPath = 'client/html/catalog/session/standard/subparts';
25
+    /** client/html/catalog/session/standard/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
+     * @category Developer
57
+     */
58
+    private $subPartPath = 'client/html/catalog/session/standard/subparts';
59 59
 
60
-	/** client/html/catalog/session/pinned/name
61
-	 * Name of the pinned part used by the catalog session client implementation
62
-	 *
63
-	 * Use "Myname" if your class is named "\Aimeos\Client\Html\Catalog\Session\Pinned\Myname".
64
-	 * The name is case-sensitive and you should avoid camel case names like "MyName".
65
-	 *
66
-	 * @param string Last part of the client class name
67
-	 * @since 2014.09
68
-	 * @category Developer
69
-	 */
60
+    /** client/html/catalog/session/pinned/name
61
+     * Name of the pinned part used by the catalog session client implementation
62
+     *
63
+     * Use "Myname" if your class is named "\Aimeos\Client\Html\Catalog\Session\Pinned\Myname".
64
+     * The name is case-sensitive and you should avoid camel case names like "MyName".
65
+     *
66
+     * @param string Last part of the client class name
67
+     * @since 2014.09
68
+     * @category Developer
69
+     */
70 70
 
71
-	/** client/html/catalog/session/seen/name
72
-	 * Name of the seen part used by the catalog session client implementation
73
-	 *
74
-	 * Use "Myname" if your class is named "\Aimeos\Client\Html\Catalog\Session\Seen\Myname".
75
-	 * The name is case-sensitive and you should avoid camel case names like "MyName".
76
-	 *
77
-	 * @param string Last part of the client class name
78
-	 * @since 2014.03
79
-	 * @category Developer
80
-	 */
81
-	private $subPartNames = array( 'pinned', 'seen' );
71
+    /** client/html/catalog/session/seen/name
72
+     * Name of the seen part used by the catalog session client implementation
73
+     *
74
+     * Use "Myname" if your class is named "\Aimeos\Client\Html\Catalog\Session\Seen\Myname".
75
+     * The name is case-sensitive and you should avoid camel case names like "MyName".
76
+     *
77
+     * @param string Last part of the client class name
78
+     * @since 2014.03
79
+     * @category Developer
80
+     */
81
+    private $subPartNames = array( 'pinned', 'seen' );
82 82
 
83 83
 
84
-	/**
85
-	 * Returns the HTML code for insertion into the body.
86
-	 *
87
-	 * @param string $uid Unique identifier for the output if the content is placed more than once on the same page
88
-	 * @param array &$tags Result array for the list of tags that are associated to the output
89
-	 * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
90
-	 * @return string HTML code
91
-	 */
92
-	public function getBody( $uid = '', array &$tags = array(), &$expire = null )
93
-	{
94
-		$context = $this->getContext();
95
-		$view = $this->getView();
84
+    /**
85
+     * Returns the HTML code for insertion into the body.
86
+     *
87
+     * @param string $uid Unique identifier for the output if the content is placed more than once on the same page
88
+     * @param array &$tags Result array for the list of tags that are associated to the output
89
+     * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
90
+     * @return string HTML code
91
+     */
92
+    public function getBody( $uid = '', array &$tags = array(), &$expire = null )
93
+    {
94
+        $context = $this->getContext();
95
+        $view = $this->getView();
96 96
 
97
-		try
98
-		{
99
-			$view = $this->setViewParams( $view, $tags, $expire );
97
+        try
98
+        {
99
+            $view = $this->setViewParams( $view, $tags, $expire );
100 100
 
101
-			$html = '';
102
-			foreach( $this->getSubClients() as $subclient ) {
103
-				$html .= $subclient->setView( $view )->getBody( $uid, $tags, $expire );
104
-			}
105
-			$view->sessionBody = $html;
106
-		}
107
-		catch( \Aimeos\Client\Html\Exception $e )
108
-		{
109
-			$error = array( $this->getContext()->getI18n()->dt( 'client', $e->getMessage() ) );
110
-			$view->sessionErrorList = $view->get( 'sessionErrorList', array() ) + $error;
111
-		}
112
-		catch( \Aimeos\Controller\Frontend\Exception $e )
113
-		{
114
-			$error = array( $this->getContext()->getI18n()->dt( 'controller/frontend', $e->getMessage() ) );
115
-			$view->sessionErrorList = $view->get( 'sessionErrorList', array() ) + $error;
116
-		}
117
-		catch( \Aimeos\MShop\Exception $e )
118
-		{
119
-			$error = array( $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ) );
120
-			$view->sessionErrorList = $view->get( 'sessionErrorList', array() ) + $error;
121
-		}
122
-		catch( \Exception $e )
123
-		{
124
-			$context->getLogger()->log( $e->getMessage() . PHP_EOL . $e->getTraceAsString() );
101
+            $html = '';
102
+            foreach( $this->getSubClients() as $subclient ) {
103
+                $html .= $subclient->setView( $view )->getBody( $uid, $tags, $expire );
104
+            }
105
+            $view->sessionBody = $html;
106
+        }
107
+        catch( \Aimeos\Client\Html\Exception $e )
108
+        {
109
+            $error = array( $this->getContext()->getI18n()->dt( 'client', $e->getMessage() ) );
110
+            $view->sessionErrorList = $view->get( 'sessionErrorList', array() ) + $error;
111
+        }
112
+        catch( \Aimeos\Controller\Frontend\Exception $e )
113
+        {
114
+            $error = array( $this->getContext()->getI18n()->dt( 'controller/frontend', $e->getMessage() ) );
115
+            $view->sessionErrorList = $view->get( 'sessionErrorList', array() ) + $error;
116
+        }
117
+        catch( \Aimeos\MShop\Exception $e )
118
+        {
119
+            $error = array( $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ) );
120
+            $view->sessionErrorList = $view->get( 'sessionErrorList', array() ) + $error;
121
+        }
122
+        catch( \Exception $e )
123
+        {
124
+            $context->getLogger()->log( $e->getMessage() . PHP_EOL . $e->getTraceAsString() );
125 125
 
126
-			$error = array( $context->getI18n()->dt( 'client', 'A non-recoverable error occured' ) );
127
-			$view->sessionErrorList = $view->get( 'sessionErrorList', array() ) + $error;
128
-		}
126
+            $error = array( $context->getI18n()->dt( 'client', 'A non-recoverable error occured' ) );
127
+            $view->sessionErrorList = $view->get( 'sessionErrorList', array() ) + $error;
128
+        }
129 129
 
130
-		/** client/html/catalog/session/standard/template-body
131
-		 * Relative path to the HTML body template of the catalog session client.
132
-		 *
133
-		 * The template file contains the HTML code and processing instructions
134
-		 * to generate the result shown in the body of the frontend. The
135
-		 * configuration string is the path to the template file relative
136
-		 * to the templates directory (usually in client/html/templates).
137
-		 *
138
-		 * You can overwrite the template file configuration in extensions and
139
-		 * provide alternative templates. These alternative templates should be
140
-		 * named like the default one but with the string "standard" replaced by
141
-		 * an unique name. You may use the name of your project for this. If
142
-		 * you've implemented an alternative client class as well, "standard"
143
-		 * should be replaced by the name of the new class.
144
-		 *
145
-		 * @param string Relative path to the template creating code for the HTML page body
146
-		 * @since 2014.03
147
-		 * @category Developer
148
-		 * @see client/html/catalog/session/standard/template-header
149
-		 */
150
-		$tplconf = 'client/html/catalog/session/standard/template-body';
151
-		$default = 'catalog/session/body-default.php';
130
+        /** client/html/catalog/session/standard/template-body
131
+         * Relative path to the HTML body template of the catalog session client.
132
+         *
133
+         * The template file contains the HTML code and processing instructions
134
+         * to generate the result shown in the body of the frontend. The
135
+         * configuration string is the path to the template file relative
136
+         * to the templates directory (usually in client/html/templates).
137
+         *
138
+         * You can overwrite the template file configuration in extensions and
139
+         * provide alternative templates. These alternative templates should be
140
+         * named like the default one but with the string "standard" replaced by
141
+         * an unique name. You may use the name of your project for this. If
142
+         * you've implemented an alternative client class as well, "standard"
143
+         * should be replaced by the name of the new class.
144
+         *
145
+         * @param string Relative path to the template creating code for the HTML page body
146
+         * @since 2014.03
147
+         * @category Developer
148
+         * @see client/html/catalog/session/standard/template-header
149
+         */
150
+        $tplconf = 'client/html/catalog/session/standard/template-body';
151
+        $default = 'catalog/session/body-default.php';
152 152
 
153
-		return $view->render( $view->config( $tplconf, $default ) );
154
-	}
153
+        return $view->render( $view->config( $tplconf, $default ) );
154
+    }
155 155
 
156 156
 
157
-	/**
158
-	 * Returns the HTML string for insertion into the header.
159
-	 *
160
-	 * @param string $uid Unique identifier for the output if the content is placed more than once on the same page
161
-	 * @param array &$tags Result array for the list of tags that are associated to the output
162
-	 * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
163
-	 * @return string|null String including HTML tags for the header on error
164
-	 */
165
-	public function getHeader( $uid = '', array &$tags = array(), &$expire = null )
166
-	{
167
-		try
168
-		{
169
-			$view = $this->setViewParams( $this->getView(), $tags, $expire );
157
+    /**
158
+     * Returns the HTML string for insertion into the header.
159
+     *
160
+     * @param string $uid Unique identifier for the output if the content is placed more than once on the same page
161
+     * @param array &$tags Result array for the list of tags that are associated to the output
162
+     * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
163
+     * @return string|null String including HTML tags for the header on error
164
+     */
165
+    public function getHeader( $uid = '', array &$tags = array(), &$expire = null )
166
+    {
167
+        try
168
+        {
169
+            $view = $this->setViewParams( $this->getView(), $tags, $expire );
170 170
 
171
-			$html = '';
172
-			foreach( $this->getSubClients() as $subclient ) {
173
-				$html .= $subclient->setView( $view )->getHeader( $uid, $tags, $expire );
174
-			}
175
-			$view->sessionHeader = $html;
171
+            $html = '';
172
+            foreach( $this->getSubClients() as $subclient ) {
173
+                $html .= $subclient->setView( $view )->getHeader( $uid, $tags, $expire );
174
+            }
175
+            $view->sessionHeader = $html;
176 176
 
177
-			/** client/html/catalog/session/standard/template-header
178
-			 * Relative path to the HTML header template of the catalog session client.
179
-			 *
180
-			 * The template file contains the HTML code and processing instructions
181
-			 * to generate the HTML code that is inserted into the HTML page header
182
-			 * of the rendered page in the frontend. The configuration string is the
183
-			 * path to the template file relative to the templates directory (usually
184
-			 * in client/html/templates).
185
-			 *
186
-			 * You can overwrite the template file configuration in extensions and
187
-			 * provide alternative templates. These alternative templates should be
188
-			 * named like the default one but with the string "standard" replaced by
189
-			 * an unique name. You may use the name of your project for this. If
190
-			 * you've implemented an alternative client class as well, "standard"
191
-			 * should be replaced by the name of the new class.
192
-			 *
193
-			 * @param string Relative path to the template creating code for the HTML page head
194
-			 * @since 2014.03
195
-			 * @category Developer
196
-			 * @see client/html/catalog/session/standard/template-body
197
-			 */
198
-			$tplconf = 'client/html/catalog/session/standard/template-header';
199
-			$default = 'catalog/session/header-default.php';
177
+            /** client/html/catalog/session/standard/template-header
178
+             * Relative path to the HTML header template of the catalog session client.
179
+             *
180
+             * The template file contains the HTML code and processing instructions
181
+             * to generate the HTML code that is inserted into the HTML page header
182
+             * of the rendered page in the frontend. The configuration string is the
183
+             * path to the template file relative to the templates directory (usually
184
+             * in client/html/templates).
185
+             *
186
+             * You can overwrite the template file configuration in extensions and
187
+             * provide alternative templates. These alternative templates should be
188
+             * named like the default one but with the string "standard" replaced by
189
+             * an unique name. You may use the name of your project for this. If
190
+             * you've implemented an alternative client class as well, "standard"
191
+             * should be replaced by the name of the new class.
192
+             *
193
+             * @param string Relative path to the template creating code for the HTML page head
194
+             * @since 2014.03
195
+             * @category Developer
196
+             * @see client/html/catalog/session/standard/template-body
197
+             */
198
+            $tplconf = 'client/html/catalog/session/standard/template-header';
199
+            $default = 'catalog/session/header-default.php';
200 200
 
201
-			return $view->render( $view->config( $tplconf, $default ) );
202
-		}
203
-		catch( \Exception $e )
204
-		{
205
-			$this->getContext()->getLogger()->log( $e->getMessage() . PHP_EOL . $e->getTraceAsString() );
206
-		}
207
-	}
201
+            return $view->render( $view->config( $tplconf, $default ) );
202
+        }
203
+        catch( \Exception $e )
204
+        {
205
+            $this->getContext()->getLogger()->log( $e->getMessage() . PHP_EOL . $e->getTraceAsString() );
206
+        }
207
+    }
208 208
 
209 209
 
210
-	/**
211
-	 * Returns the sub-client given by its name.
212
-	 *
213
-	 * @param string $type Name of the client type
214
-	 * @param string|null $name Name of the sub-client (Default if null)
215
-	 * @return \Aimeos\Client\Html\Iface Sub-client object
216
-	 */
217
-	public function getSubClient( $type, $name = null )
218
-	{
219
-		/** client/html/catalog/session/decorators/excludes
220
-		 * Excludes decorators added by the "common" option from the catalog session html client
221
-		 *
222
-		 * Decorators extend the functionality of a class by adding new aspects
223
-		 * (e.g. log what is currently done), executing the methods of the underlying
224
-		 * class only in certain conditions (e.g. only for logged in users) or
225
-		 * modify what is returned to the caller.
226
-		 *
227
-		 * This option allows you to remove a decorator added via
228
-		 * "client/html/common/decorators/default" before they are wrapped
229
-		 * around the html client.
230
-		 *
231
-		 *  client/html/catalog/session/decorators/excludes = array( 'decorator1' )
232
-		 *
233
-		 * This would remove the decorator named "decorator1" from the list of
234
-		 * common decorators ("\Aimeos\Client\Html\Common\Decorator\*") added via
235
-		 * "client/html/common/decorators/default" to the html client.
236
-		 *
237
-		 * @param array List of decorator names
238
-		 * @since 2014.05
239
-		 * @category Developer
240
-		 * @see client/html/common/decorators/default
241
-		 * @see client/html/catalog/session/decorators/global
242
-		 * @see client/html/catalog/session/decorators/local
243
-		 */
210
+    /**
211
+     * Returns the sub-client given by its name.
212
+     *
213
+     * @param string $type Name of the client type
214
+     * @param string|null $name Name of the sub-client (Default if null)
215
+     * @return \Aimeos\Client\Html\Iface Sub-client object
216
+     */
217
+    public function getSubClient( $type, $name = null )
218
+    {
219
+        /** client/html/catalog/session/decorators/excludes
220
+         * Excludes decorators added by the "common" option from the catalog session html client
221
+         *
222
+         * Decorators extend the functionality of a class by adding new aspects
223
+         * (e.g. log what is currently done), executing the methods of the underlying
224
+         * class only in certain conditions (e.g. only for logged in users) or
225
+         * modify what is returned to the caller.
226
+         *
227
+         * This option allows you to remove a decorator added via
228
+         * "client/html/common/decorators/default" before they are wrapped
229
+         * around the html client.
230
+         *
231
+         *  client/html/catalog/session/decorators/excludes = array( 'decorator1' )
232
+         *
233
+         * This would remove the decorator named "decorator1" from the list of
234
+         * common decorators ("\Aimeos\Client\Html\Common\Decorator\*") added via
235
+         * "client/html/common/decorators/default" to the html client.
236
+         *
237
+         * @param array List of decorator names
238
+         * @since 2014.05
239
+         * @category Developer
240
+         * @see client/html/common/decorators/default
241
+         * @see client/html/catalog/session/decorators/global
242
+         * @see client/html/catalog/session/decorators/local
243
+         */
244 244
 
245
-		/** client/html/catalog/session/decorators/global
246
-		 * Adds a list of globally available decorators only to the catalog session html client
247
-		 *
248
-		 * Decorators extend the functionality of a class by adding new aspects
249
-		 * (e.g. log what is currently done), executing the methods of the underlying
250
-		 * class only in certain conditions (e.g. only for logged in users) or
251
-		 * modify what is returned to the caller.
252
-		 *
253
-		 * This option allows you to wrap global decorators
254
-		 * ("\Aimeos\Client\Html\Common\Decorator\*") around the html client.
255
-		 *
256
-		 *  client/html/catalog/session/decorators/global = array( 'decorator1' )
257
-		 *
258
-		 * This would add the decorator named "decorator1" defined by
259
-		 * "\Aimeos\Client\Html\Common\Decorator\Decorator1" only to the html client.
260
-		 *
261
-		 * @param array List of decorator names
262
-		 * @since 2014.05
263
-		 * @category Developer
264
-		 * @see client/html/common/decorators/default
265
-		 * @see client/html/catalog/session/decorators/excludes
266
-		 * @see client/html/catalog/session/decorators/local
267
-		 */
245
+        /** client/html/catalog/session/decorators/global
246
+         * Adds a list of globally available decorators only to the catalog session html client
247
+         *
248
+         * Decorators extend the functionality of a class by adding new aspects
249
+         * (e.g. log what is currently done), executing the methods of the underlying
250
+         * class only in certain conditions (e.g. only for logged in users) or
251
+         * modify what is returned to the caller.
252
+         *
253
+         * This option allows you to wrap global decorators
254
+         * ("\Aimeos\Client\Html\Common\Decorator\*") around the html client.
255
+         *
256
+         *  client/html/catalog/session/decorators/global = array( 'decorator1' )
257
+         *
258
+         * This would add the decorator named "decorator1" defined by
259
+         * "\Aimeos\Client\Html\Common\Decorator\Decorator1" only to the html client.
260
+         *
261
+         * @param array List of decorator names
262
+         * @since 2014.05
263
+         * @category Developer
264
+         * @see client/html/common/decorators/default
265
+         * @see client/html/catalog/session/decorators/excludes
266
+         * @see client/html/catalog/session/decorators/local
267
+         */
268 268
 
269
-		/** client/html/catalog/session/decorators/local
270
-		 * Adds a list of local decorators only to the catalog session html client
271
-		 *
272
-		 * Decorators extend the functionality of a class by adding new aspects
273
-		 * (e.g. log what is currently done), executing the methods of the underlying
274
-		 * class only in certain conditions (e.g. only for logged in users) or
275
-		 * modify what is returned to the caller.
276
-		 *
277
-		 * This option allows you to wrap local decorators
278
-		 * ("\Aimeos\Client\Html\Catalog\Decorator\*") around the html client.
279
-		 *
280
-		 *  client/html/catalog/session/decorators/local = array( 'decorator2' )
281
-		 *
282
-		 * This would add the decorator named "decorator2" defined by
283
-		 * "\Aimeos\Client\Html\Catalog\Decorator\Decorator2" only to the html client.
284
-		 *
285
-		 * @param array List of decorator names
286
-		 * @since 2014.05
287
-		 * @category Developer
288
-		 * @see client/html/common/decorators/default
289
-		 * @see client/html/catalog/session/decorators/excludes
290
-		 * @see client/html/catalog/session/decorators/global
291
-		 */
269
+        /** client/html/catalog/session/decorators/local
270
+         * Adds a list of local decorators only to the catalog session html client
271
+         *
272
+         * Decorators extend the functionality of a class by adding new aspects
273
+         * (e.g. log what is currently done), executing the methods of the underlying
274
+         * class only in certain conditions (e.g. only for logged in users) or
275
+         * modify what is returned to the caller.
276
+         *
277
+         * This option allows you to wrap local decorators
278
+         * ("\Aimeos\Client\Html\Catalog\Decorator\*") around the html client.
279
+         *
280
+         *  client/html/catalog/session/decorators/local = array( 'decorator2' )
281
+         *
282
+         * This would add the decorator named "decorator2" defined by
283
+         * "\Aimeos\Client\Html\Catalog\Decorator\Decorator2" only to the html client.
284
+         *
285
+         * @param array List of decorator names
286
+         * @since 2014.05
287
+         * @category Developer
288
+         * @see client/html/common/decorators/default
289
+         * @see client/html/catalog/session/decorators/excludes
290
+         * @see client/html/catalog/session/decorators/global
291
+         */
292 292
 
293
-		return $this->createSubClient( 'catalog/session/' . $type, $name );
294
-	}
293
+        return $this->createSubClient( 'catalog/session/' . $type, $name );
294
+    }
295 295
 
296 296
 
297
-	/**
298
-	 * Processes the input, e.g. store given values.
299
-	 * A view must be available and this method doesn't generate any output
300
-	 * besides setting view variables.
301
-	 */
302
-	public function process()
303
-	{
304
-		try
305
-		{
306
-			parent::process();
307
-		}
308
-		catch( \Aimeos\Client\Html\Exception $e )
309
-		{
310
-			$view = $this->getView();
311
-			$error = array( $this->getContext()->getI18n()->dt( 'client', $e->getMessage() ) );
312
-			$view->sessionErrorList = $view->get( 'sessionErrorList', array() ) + $error;
313
-		}
314
-		catch( \Aimeos\Controller\Frontend\Exception $e )
315
-		{
316
-			$view = $this->getView();
317
-			$error = array( $this->getContext()->getI18n()->dt( 'controller/frontend', $e->getMessage() ) );
318
-			$view->sessionErrorList = $view->get( 'sessionErrorList', array() ) + $error;
319
-		}
320
-		catch( \Aimeos\MShop\Exception $e )
321
-		{
322
-			$view = $this->getView();
323
-			$error = array( $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ) );
324
-			$view->sessionErrorList = $view->get( 'sessionErrorList', array() ) + $error;
325
-		}
326
-		catch( \Exception $e )
327
-		{
328
-			$context = $this->getContext();
329
-			$context->getLogger()->log( $e->getMessage() . PHP_EOL . $e->getTraceAsString() );
297
+    /**
298
+     * Processes the input, e.g. store given values.
299
+     * A view must be available and this method doesn't generate any output
300
+     * besides setting view variables.
301
+     */
302
+    public function process()
303
+    {
304
+        try
305
+        {
306
+            parent::process();
307
+        }
308
+        catch( \Aimeos\Client\Html\Exception $e )
309
+        {
310
+            $view = $this->getView();
311
+            $error = array( $this->getContext()->getI18n()->dt( 'client', $e->getMessage() ) );
312
+            $view->sessionErrorList = $view->get( 'sessionErrorList', array() ) + $error;
313
+        }
314
+        catch( \Aimeos\Controller\Frontend\Exception $e )
315
+        {
316
+            $view = $this->getView();
317
+            $error = array( $this->getContext()->getI18n()->dt( 'controller/frontend', $e->getMessage() ) );
318
+            $view->sessionErrorList = $view->get( 'sessionErrorList', array() ) + $error;
319
+        }
320
+        catch( \Aimeos\MShop\Exception $e )
321
+        {
322
+            $view = $this->getView();
323
+            $error = array( $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ) );
324
+            $view->sessionErrorList = $view->get( 'sessionErrorList', array() ) + $error;
325
+        }
326
+        catch( \Exception $e )
327
+        {
328
+            $context = $this->getContext();
329
+            $context->getLogger()->log( $e->getMessage() . PHP_EOL . $e->getTraceAsString() );
330 330
 
331
-			$view = $this->getView();
332
-			$error = array( $context->getI18n()->dt( 'client', 'A non-recoverable error occured' ) );
333
-			$view->sessionErrorList = $view->get( 'sessionErrorList', array() ) + $error;
334
-		}
335
-	}
331
+            $view = $this->getView();
332
+            $error = array( $context->getI18n()->dt( 'client', 'A non-recoverable error occured' ) );
333
+            $view->sessionErrorList = $view->get( 'sessionErrorList', array() ) + $error;
334
+        }
335
+    }
336 336
 
337 337
 
338
-	/**
339
-	 * Returns the list of sub-client names configured for the client.
340
-	 *
341
-	 * @return array List of HTML client names
342
-	 */
343
-	protected function getSubClientNames()
344
-	{
345
-		return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames );
346
-	}
338
+    /**
339
+     * Returns the list of sub-client names configured for the client.
340
+     *
341
+     * @return array List of HTML client names
342
+     */
343
+    protected function getSubClientNames()
344
+    {
345
+        return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames );
346
+    }
347 347
 }
Please login to merge, or discard this patch.
client/html/src/Client/Html/Catalog/Session/Seen/Standard.php 1 patch
Indentation   +291 added lines, -291 removed lines patch added patch discarded remove patch
@@ -19,296 +19,296 @@
 block discarded – undo
19 19
  * @subpackage Html
20 20
  */
21 21
 class Standard
22
-	extends \Aimeos\Client\Html\Common\Client\Factory\Base
23
-	implements \Aimeos\Client\Html\Common\Client\Factory\Iface
22
+    extends \Aimeos\Client\Html\Common\Client\Factory\Base
23
+    implements \Aimeos\Client\Html\Common\Client\Factory\Iface
24 24
 {
25
-	/** client/html/catalog/session/seen/standard/subparts
26
-	 * List of HTML sub-clients rendered within the catalog session seen 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
-	 * @category Developer
57
-	 */
58
-	private $subPartPath = 'client/html/catalog/session/seen/standard/subparts';
59
-	private $subPartNames = array();
60
-	private $cache;
61
-
62
-
63
-	/**
64
-	 * Returns the HTML code for insertion into the body.
65
-	 *
66
-	 * @param string $uid Unique identifier for the output if the content is placed more than once on the same page
67
-	 * @param array &$tags Result array for the list of tags that are associated to the output
68
-	 * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
69
-	 * @return string HTML code
70
-	 */
71
-	public function getBody( $uid = '', array &$tags = array(), &$expire = null )
72
-	{
73
-		$context = $this->getContext();
74
-		$session = $context->getSession();
75
-
76
-		/** client/html/catalog/session/seen
77
-		 * All parameters defined for the catalog session seen subpart
78
-		 *
79
-		 * This returns all settings related to the catalog session seen subpart.
80
-		 * Please refer to the single settings for details.
81
-		 *
82
-		 * @param array Associative list of name/value settings
83
-		 * @category Developer
84
-		 * @see client/html/catalog#session
85
-		 */
86
-		$config = $context->getConfig()->get( 'client/html/catalog/session/seen', array() );
87
-		$key = $this->getParamHash( array(), $uid . ':catalog:session-seen-body', $config );
88
-
89
-		if( ( $html = $session->get( $key ) ) === null )
90
-		{
91
-			$view = $this->setViewParams( $this->getView(), $tags, $expire );
92
-
93
-			$output = '';
94
-			foreach( $this->getSubClients() as $subclient ) {
95
-				$output .= $subclient->setView( $view )->getBody( $uid, $tags, $expire );
96
-			}
97
-			$view->seenBody = $output;
98
-
99
-			/** client/html/catalog/session/seen/standard/template-body
100
-			 * Relative path to the HTML body template of the catalog session seen client.
101
-			 *
102
-			 * The template file contains the HTML code and processing instructions
103
-			 * to generate the result shown in the body of the frontend. The
104
-			 * configuration string is the path to the template file relative
105
-			 * to the templates directory (usually in client/html/templates).
106
-			 *
107
-			 * You can overwrite the template file configuration in extensions and
108
-			 * provide alternative templates. These alternative templates should be
109
-			 * named like the default one but with the string "standard" replaced by
110
-			 * an unique name. You may use the name of your project for this. If
111
-			 * you've implemented an alternative client class as well, "standard"
112
-			 * should be replaced by the name of the new class.
113
-			 *
114
-			 * @param string Relative path to the template creating code for the HTML page body
115
-			 * @since 2014.03
116
-			 * @category Developer
117
-			 * @see client/html/catalog/session/seen/standard/template-header
118
-			 */
119
-			$tplconf = 'client/html/catalog/session/seen/standard/template-body';
120
-			$default = 'catalog/session/seen-body-default.php';
121
-
122
-			$html = $view->render( $view->config( $tplconf, $default ) );
123
-
124
-			$cached = $session->get( 'aimeos/catalog/session/seen/cache', array() ) + array( $key => true );
125
-			$session->set( 'aimeos/catalog/session/seen/cache', $cached );
126
-			$session->set( $key, $html );
127
-		}
128
-
129
-		return $html;
130
-	}
131
-
132
-
133
-	/**
134
-	 * Returns the HTML string for insertion into the header.
135
-	 *
136
-	 * @param string $uid Unique identifier for the output if the content is placed more than once on the same page
137
-	 * @param array &$tags Result array for the list of tags that are associated to the output
138
-	 * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
139
-	 * @return string|null String including HTML tags for the header on error
140
-	 */
141
-	public function getHeader( $uid = '', array &$tags = array(), &$expire = null )
142
-	{
143
-		$context = $this->getContext();
144
-		$session = $context->getSession();
145
-
146
-		$config = $context->getConfig()->get( 'client/html/catalog/session/seen', array() );
147
-		$key = $this->getParamHash( array(), $uid . ':catalog:session-seen-header', $config );
148
-
149
-		if( ( $html = $session->get( $key ) ) === null )
150
-		{
151
-			$view = $this->setViewParams( $this->getView(), $tags, $expire );
152
-
153
-			$output = '';
154
-			foreach( $this->getSubClients() as $subclient ) {
155
-				$output .= $subclient->setView( $view )->getHeader( $uid, $tags, $expire );
156
-			}
157
-			$view->seenHeader = $output;
158
-
159
-			/** client/html/catalog/session/seen/standard/template-header
160
-			 * Relative path to the HTML header template of the catalog session seen client.
161
-			 *
162
-			 * The template file contains the HTML code and processing instructions
163
-			 * to generate the HTML code that is inserted into the HTML page header
164
-			 * of the rendered page in the frontend. The configuration string is the
165
-			 * path to the template file relative to the templates directory (usually
166
-			 * in client/html/templates).
167
-			 *
168
-			 * You can overwrite the template file configuration in extensions and
169
-			 * provide alternative templates. These alternative templates should be
170
-			 * named like the default one but with the string "standard" replaced by
171
-			 * an unique name. You may use the name of your project for this. If
172
-			 * you've implemented an alternative client class as well, "standard"
173
-			 * should be replaced by the name of the new class.
174
-			 *
175
-			 * @param string Relative path to the template creating code for the HTML page head
176
-			 * @since 2014.03
177
-			 * @category Developer
178
-			 * @see client/html/catalog/session/seen/standard/template-body
179
-			 */
180
-			$tplconf = 'client/html/catalog/session/seen/standard/template-header';
181
-			$default = 'catalog/session/seen-header-default.php';
182
-
183
-			$html = $view->render( $view->config( $tplconf, $default ) );
184
-
185
-			$cached = $session->get( 'aimeos/catalog/session/seen/cache', array() ) + array( $key => true );
186
-			$session->set( 'aimeos/catalog/session/seen/cache', $cached );
187
-			$session->set( $key, $html );
188
-		}
189
-
190
-		return $html;
191
-	}
192
-
193
-
194
-	/**
195
-	 * Returns the sub-client given by its name.
196
-	 *
197
-	 * @param string $type Name of the client type
198
-	 * @param string|null $name Name of the sub-client (Default if null)
199
-	 * @return \Aimeos\Client\Html\Iface Sub-client object
200
-	 */
201
-	public function getSubClient( $type, $name = null )
202
-	{
203
-		/** client/html/catalog/session/seen/decorators/excludes
204
-		 * Excludes decorators added by the "common" option from the catalog session seen html client
205
-		 *
206
-		 * Decorators extend the functionality of a class by adding new aspects
207
-		 * (e.g. log what is currently done), executing the methods of the underlying
208
-		 * class only in certain conditions (e.g. only for logged in users) or
209
-		 * modify what is returned to the caller.
210
-		 *
211
-		 * This option allows you to remove a decorator added via
212
-		 * "client/html/common/decorators/default" before they are wrapped
213
-		 * around the html client.
214
-		 *
215
-		 *  client/html/catalog/session/seen/decorators/excludes = array( 'decorator1' )
216
-		 *
217
-		 * This would remove the decorator named "decorator1" from the list of
218
-		 * common decorators ("\Aimeos\Client\Html\Common\Decorator\*") added via
219
-		 * "client/html/common/decorators/default" to the html client.
220
-		 *
221
-		 * @param array List of decorator names
222
-		 * @since 2015.08
223
-		 * @category Developer
224
-		 * @see client/html/common/decorators/default
225
-		 * @see client/html/catalog/session/seen/decorators/global
226
-		 * @see client/html/catalog/session/seen/decorators/local
227
-		 */
228
-
229
-		/** client/html/catalog/session/seen/decorators/global
230
-		 * Adds a list of globally available decorators only to the catalog session seen html client
231
-		 *
232
-		 * Decorators extend the functionality of a class by adding new aspects
233
-		 * (e.g. log what is currently done), executing the methods of the underlying
234
-		 * class only in certain conditions (e.g. only for logged in users) or
235
-		 * modify what is returned to the caller.
236
-		 *
237
-		 * This option allows you to wrap global decorators
238
-		 * ("\Aimeos\Client\Html\Common\Decorator\*") around the html client.
239
-		 *
240
-		 *  client/html/catalog/session/seen/decorators/global = array( 'decorator1' )
241
-		 *
242
-		 * This would add the decorator named "decorator1" defined by
243
-		 * "\Aimeos\Client\Html\Common\Decorator\Decorator1" only to the html client.
244
-		 *
245
-		 * @param array List of decorator names
246
-		 * @since 2015.08
247
-		 * @category Developer
248
-		 * @see client/html/common/decorators/default
249
-		 * @see client/html/catalog/session/seen/decorators/excludes
250
-		 * @see client/html/catalog/session/seen/decorators/local
251
-		 */
252
-
253
-		/** client/html/catalog/session/seen/decorators/local
254
-		 * Adds a list of local decorators only to the catalog session seen html client
255
-		 *
256
-		 * Decorators extend the functionality of a class by adding new aspects
257
-		 * (e.g. log what is currently done), executing the methods of the underlying
258
-		 * class only in certain conditions (e.g. only for logged in users) or
259
-		 * modify what is returned to the caller.
260
-		 *
261
-		 * This option allows you to wrap local decorators
262
-		 * ("\Aimeos\Client\Html\Catalog\Decorator\*") around the html client.
263
-		 *
264
-		 *  client/html/catalog/session/seen/decorators/local = array( 'decorator2' )
265
-		 *
266
-		 * This would add the decorator named "decorator2" defined by
267
-		 * "\Aimeos\Client\Html\Catalog\Decorator\Decorator2" only to the html client.
268
-		 *
269
-		 * @param array List of decorator names
270
-		 * @since 2015.08
271
-		 * @category Developer
272
-		 * @see client/html/common/decorators/default
273
-		 * @see client/html/catalog/session/seen/decorators/excludes
274
-		 * @see client/html/catalog/session/seen/decorators/global
275
-		 */
276
-
277
-		return $this->createSubClient( 'catalog/session/seen/' . $type, $name );
278
-	}
279
-
280
-
281
-	/**
282
-	 * Returns the list of sub-client names configured for the client.
283
-	 *
284
-	 * @return array List of HTML client names
285
-	 */
286
-	protected function getSubClientNames()
287
-	{
288
-		return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames );
289
-	}
290
-
291
-
292
-	/**
293
-	 * Sets the necessary parameter values in the view.
294
-	 *
295
-	 * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output
296
-	 * @param array &$tags Result array for the list of tags that are associated to the output
297
-	 * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
298
-	 * @return \Aimeos\MW\View\Iface Modified view object
299
-	 */
300
-	protected function setViewParams( \Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null )
301
-	{
302
-		if( !isset( $this->cache ) )
303
-		{
304
-			$session = $this->getContext()->getSession();
305
-			$lastSeen = $session->get( 'aimeos/catalog/session/seen/list', array() );
306
-
307
-			$view->seenItems = array_reverse( $lastSeen );
308
-
309
-			$this->cache = $view;
310
-		}
311
-
312
-		return $this->cache;
313
-	}
25
+    /** client/html/catalog/session/seen/standard/subparts
26
+     * List of HTML sub-clients rendered within the catalog session seen 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
+     * @category Developer
57
+     */
58
+    private $subPartPath = 'client/html/catalog/session/seen/standard/subparts';
59
+    private $subPartNames = array();
60
+    private $cache;
61
+
62
+
63
+    /**
64
+     * Returns the HTML code for insertion into the body.
65
+     *
66
+     * @param string $uid Unique identifier for the output if the content is placed more than once on the same page
67
+     * @param array &$tags Result array for the list of tags that are associated to the output
68
+     * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
69
+     * @return string HTML code
70
+     */
71
+    public function getBody( $uid = '', array &$tags = array(), &$expire = null )
72
+    {
73
+        $context = $this->getContext();
74
+        $session = $context->getSession();
75
+
76
+        /** client/html/catalog/session/seen
77
+         * All parameters defined for the catalog session seen subpart
78
+         *
79
+         * This returns all settings related to the catalog session seen subpart.
80
+         * Please refer to the single settings for details.
81
+         *
82
+         * @param array Associative list of name/value settings
83
+         * @category Developer
84
+         * @see client/html/catalog#session
85
+         */
86
+        $config = $context->getConfig()->get( 'client/html/catalog/session/seen', array() );
87
+        $key = $this->getParamHash( array(), $uid . ':catalog:session-seen-body', $config );
88
+
89
+        if( ( $html = $session->get( $key ) ) === null )
90
+        {
91
+            $view = $this->setViewParams( $this->getView(), $tags, $expire );
92
+
93
+            $output = '';
94
+            foreach( $this->getSubClients() as $subclient ) {
95
+                $output .= $subclient->setView( $view )->getBody( $uid, $tags, $expire );
96
+            }
97
+            $view->seenBody = $output;
98
+
99
+            /** client/html/catalog/session/seen/standard/template-body
100
+             * Relative path to the HTML body template of the catalog session seen client.
101
+             *
102
+             * The template file contains the HTML code and processing instructions
103
+             * to generate the result shown in the body of the frontend. The
104
+             * configuration string is the path to the template file relative
105
+             * to the templates directory (usually in client/html/templates).
106
+             *
107
+             * You can overwrite the template file configuration in extensions and
108
+             * provide alternative templates. These alternative templates should be
109
+             * named like the default one but with the string "standard" replaced by
110
+             * an unique name. You may use the name of your project for this. If
111
+             * you've implemented an alternative client class as well, "standard"
112
+             * should be replaced by the name of the new class.
113
+             *
114
+             * @param string Relative path to the template creating code for the HTML page body
115
+             * @since 2014.03
116
+             * @category Developer
117
+             * @see client/html/catalog/session/seen/standard/template-header
118
+             */
119
+            $tplconf = 'client/html/catalog/session/seen/standard/template-body';
120
+            $default = 'catalog/session/seen-body-default.php';
121
+
122
+            $html = $view->render( $view->config( $tplconf, $default ) );
123
+
124
+            $cached = $session->get( 'aimeos/catalog/session/seen/cache', array() ) + array( $key => true );
125
+            $session->set( 'aimeos/catalog/session/seen/cache', $cached );
126
+            $session->set( $key, $html );
127
+        }
128
+
129
+        return $html;
130
+    }
131
+
132
+
133
+    /**
134
+     * Returns the HTML string for insertion into the header.
135
+     *
136
+     * @param string $uid Unique identifier for the output if the content is placed more than once on the same page
137
+     * @param array &$tags Result array for the list of tags that are associated to the output
138
+     * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
139
+     * @return string|null String including HTML tags for the header on error
140
+     */
141
+    public function getHeader( $uid = '', array &$tags = array(), &$expire = null )
142
+    {
143
+        $context = $this->getContext();
144
+        $session = $context->getSession();
145
+
146
+        $config = $context->getConfig()->get( 'client/html/catalog/session/seen', array() );
147
+        $key = $this->getParamHash( array(), $uid . ':catalog:session-seen-header', $config );
148
+
149
+        if( ( $html = $session->get( $key ) ) === null )
150
+        {
151
+            $view = $this->setViewParams( $this->getView(), $tags, $expire );
152
+
153
+            $output = '';
154
+            foreach( $this->getSubClients() as $subclient ) {
155
+                $output .= $subclient->setView( $view )->getHeader( $uid, $tags, $expire );
156
+            }
157
+            $view->seenHeader = $output;
158
+
159
+            /** client/html/catalog/session/seen/standard/template-header
160
+             * Relative path to the HTML header template of the catalog session seen client.
161
+             *
162
+             * The template file contains the HTML code and processing instructions
163
+             * to generate the HTML code that is inserted into the HTML page header
164
+             * of the rendered page in the frontend. The configuration string is the
165
+             * path to the template file relative to the templates directory (usually
166
+             * in client/html/templates).
167
+             *
168
+             * You can overwrite the template file configuration in extensions and
169
+             * provide alternative templates. These alternative templates should be
170
+             * named like the default one but with the string "standard" replaced by
171
+             * an unique name. You may use the name of your project for this. If
172
+             * you've implemented an alternative client class as well, "standard"
173
+             * should be replaced by the name of the new class.
174
+             *
175
+             * @param string Relative path to the template creating code for the HTML page head
176
+             * @since 2014.03
177
+             * @category Developer
178
+             * @see client/html/catalog/session/seen/standard/template-body
179
+             */
180
+            $tplconf = 'client/html/catalog/session/seen/standard/template-header';
181
+            $default = 'catalog/session/seen-header-default.php';
182
+
183
+            $html = $view->render( $view->config( $tplconf, $default ) );
184
+
185
+            $cached = $session->get( 'aimeos/catalog/session/seen/cache', array() ) + array( $key => true );
186
+            $session->set( 'aimeos/catalog/session/seen/cache', $cached );
187
+            $session->set( $key, $html );
188
+        }
189
+
190
+        return $html;
191
+    }
192
+
193
+
194
+    /**
195
+     * Returns the sub-client given by its name.
196
+     *
197
+     * @param string $type Name of the client type
198
+     * @param string|null $name Name of the sub-client (Default if null)
199
+     * @return \Aimeos\Client\Html\Iface Sub-client object
200
+     */
201
+    public function getSubClient( $type, $name = null )
202
+    {
203
+        /** client/html/catalog/session/seen/decorators/excludes
204
+         * Excludes decorators added by the "common" option from the catalog session seen html client
205
+         *
206
+         * Decorators extend the functionality of a class by adding new aspects
207
+         * (e.g. log what is currently done), executing the methods of the underlying
208
+         * class only in certain conditions (e.g. only for logged in users) or
209
+         * modify what is returned to the caller.
210
+         *
211
+         * This option allows you to remove a decorator added via
212
+         * "client/html/common/decorators/default" before they are wrapped
213
+         * around the html client.
214
+         *
215
+         *  client/html/catalog/session/seen/decorators/excludes = array( 'decorator1' )
216
+         *
217
+         * This would remove the decorator named "decorator1" from the list of
218
+         * common decorators ("\Aimeos\Client\Html\Common\Decorator\*") added via
219
+         * "client/html/common/decorators/default" to the html client.
220
+         *
221
+         * @param array List of decorator names
222
+         * @since 2015.08
223
+         * @category Developer
224
+         * @see client/html/common/decorators/default
225
+         * @see client/html/catalog/session/seen/decorators/global
226
+         * @see client/html/catalog/session/seen/decorators/local
227
+         */
228
+
229
+        /** client/html/catalog/session/seen/decorators/global
230
+         * Adds a list of globally available decorators only to the catalog session seen html client
231
+         *
232
+         * Decorators extend the functionality of a class by adding new aspects
233
+         * (e.g. log what is currently done), executing the methods of the underlying
234
+         * class only in certain conditions (e.g. only for logged in users) or
235
+         * modify what is returned to the caller.
236
+         *
237
+         * This option allows you to wrap global decorators
238
+         * ("\Aimeos\Client\Html\Common\Decorator\*") around the html client.
239
+         *
240
+         *  client/html/catalog/session/seen/decorators/global = array( 'decorator1' )
241
+         *
242
+         * This would add the decorator named "decorator1" defined by
243
+         * "\Aimeos\Client\Html\Common\Decorator\Decorator1" only to the html client.
244
+         *
245
+         * @param array List of decorator names
246
+         * @since 2015.08
247
+         * @category Developer
248
+         * @see client/html/common/decorators/default
249
+         * @see client/html/catalog/session/seen/decorators/excludes
250
+         * @see client/html/catalog/session/seen/decorators/local
251
+         */
252
+
253
+        /** client/html/catalog/session/seen/decorators/local
254
+         * Adds a list of local decorators only to the catalog session seen html client
255
+         *
256
+         * Decorators extend the functionality of a class by adding new aspects
257
+         * (e.g. log what is currently done), executing the methods of the underlying
258
+         * class only in certain conditions (e.g. only for logged in users) or
259
+         * modify what is returned to the caller.
260
+         *
261
+         * This option allows you to wrap local decorators
262
+         * ("\Aimeos\Client\Html\Catalog\Decorator\*") around the html client.
263
+         *
264
+         *  client/html/catalog/session/seen/decorators/local = array( 'decorator2' )
265
+         *
266
+         * This would add the decorator named "decorator2" defined by
267
+         * "\Aimeos\Client\Html\Catalog\Decorator\Decorator2" only to the html client.
268
+         *
269
+         * @param array List of decorator names
270
+         * @since 2015.08
271
+         * @category Developer
272
+         * @see client/html/common/decorators/default
273
+         * @see client/html/catalog/session/seen/decorators/excludes
274
+         * @see client/html/catalog/session/seen/decorators/global
275
+         */
276
+
277
+        return $this->createSubClient( 'catalog/session/seen/' . $type, $name );
278
+    }
279
+
280
+
281
+    /**
282
+     * Returns the list of sub-client names configured for the client.
283
+     *
284
+     * @return array List of HTML client names
285
+     */
286
+    protected function getSubClientNames()
287
+    {
288
+        return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames );
289
+    }
290
+
291
+
292
+    /**
293
+     * Sets the necessary parameter values in the view.
294
+     *
295
+     * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output
296
+     * @param array &$tags Result array for the list of tags that are associated to the output
297
+     * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
298
+     * @return \Aimeos\MW\View\Iface Modified view object
299
+     */
300
+    protected function setViewParams( \Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null )
301
+    {
302
+        if( !isset( $this->cache ) )
303
+        {
304
+            $session = $this->getContext()->getSession();
305
+            $lastSeen = $session->get( 'aimeos/catalog/session/seen/list', array() );
306
+
307
+            $view->seenItems = array_reverse( $lastSeen );
308
+
309
+            $this->cache = $view;
310
+        }
311
+
312
+        return $this->cache;
313
+    }
314 314
 }
315 315
\ No newline at end of file
Please login to merge, or discard this patch.
client/html/src/Client/Html/Catalog/Stock/Factory.php 1 patch
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -19,69 +19,69 @@
 block discarded – undo
19 19
  * @subpackage Html
20 20
  */
21 21
 class Factory
22
-	extends \Aimeos\Client\Html\Common\Factory\Base
23
-	implements \Aimeos\Client\Html\Common\Factory\Iface
22
+    extends \Aimeos\Client\Html\Common\Factory\Base
23
+    implements \Aimeos\Client\Html\Common\Factory\Iface
24 24
 {
25
-	/**
26
-	 * Creates a stock client object.
27
-	 *
28
-	 * @param \Aimeos\MShop\Context\Item\Iface $context Shop context instance with necessary objects
29
-	 * @param array $templatePaths Stock of file system paths where the templates are stored
30
-	 * @param string|null $name Client name (default: "Standard")
31
-	 * @return \Aimeos\Client\Html\Iface Filter part implementing \Aimeos\Client\Html\Iface
32
-	 * @throws \Aimeos\Client\Html\Exception If requested client implementation couldn't be found or initialisation fails
33
-	 */
34
-	public static function createClient( \Aimeos\MShop\Context\Item\Iface $context, array $templatePaths, $name = null )
35
-	{
36
-		/** client/html/catalog/stock/name
37
-		 * Class name of the used catalog stock client implementation
38
-		 *
39
-		 * Each default HTML client can be replace by an alternative imlementation.
40
-		 * To use this implementation, you have to set the last part of the class
41
-		 * name as configuration value so the client factory knows which class it
42
-		 * has to instantiate.
43
-		 *
44
-		 * For example, if the name of the default class is
45
-		 *
46
-		 *  \Aimeos\Client\Html\Catalog\Stock\Standard
47
-		 *
48
-		 * and you want to replace it with your own version named
49
-		 *
50
-		 *  \Aimeos\Client\Html\Catalog\Stock\Mystock
51
-		 *
52
-		 * then you have to set the this configuration option:
53
-		 *
54
-		 *  client/html/catalog/stock/name = Mystock
55
-		 *
56
-		 * The value is the last part of your own class name and it's case sensitive,
57
-		 * so take care that the configuration value is exactly named like the last
58
-		 * part of the class name.
59
-		 *
60
-		 * The allowed characters of the class name are A-Z, a-z and 0-9. No other
61
-		 * characters are possible! You should always start the last part of the class
62
-		 * name with an upper case character and continue only with lower case characters
63
-		 * or numbers. Avoid chamel case names like "MyStock"!
64
-		 *
65
-		 * @param string Last part of the class name
66
-		 * @since 2014.03
67
-		 * @category Developer
68
-		 */
69
-		if( $name === null ) {
70
-			$name = $context->getConfig()->get( 'client/html/catalog/stock/name', 'Standard' );
71
-		}
25
+    /**
26
+     * Creates a stock client object.
27
+     *
28
+     * @param \Aimeos\MShop\Context\Item\Iface $context Shop context instance with necessary objects
29
+     * @param array $templatePaths Stock of file system paths where the templates are stored
30
+     * @param string|null $name Client name (default: "Standard")
31
+     * @return \Aimeos\Client\Html\Iface Filter part implementing \Aimeos\Client\Html\Iface
32
+     * @throws \Aimeos\Client\Html\Exception If requested client implementation couldn't be found or initialisation fails
33
+     */
34
+    public static function createClient( \Aimeos\MShop\Context\Item\Iface $context, array $templatePaths, $name = null )
35
+    {
36
+        /** client/html/catalog/stock/name
37
+         * Class name of the used catalog stock client implementation
38
+         *
39
+         * Each default HTML client can be replace by an alternative imlementation.
40
+         * To use this implementation, you have to set the last part of the class
41
+         * name as configuration value so the client factory knows which class it
42
+         * has to instantiate.
43
+         *
44
+         * For example, if the name of the default class is
45
+         *
46
+         *  \Aimeos\Client\Html\Catalog\Stock\Standard
47
+         *
48
+         * and you want to replace it with your own version named
49
+         *
50
+         *  \Aimeos\Client\Html\Catalog\Stock\Mystock
51
+         *
52
+         * then you have to set the this configuration option:
53
+         *
54
+         *  client/html/catalog/stock/name = Mystock
55
+         *
56
+         * The value is the last part of your own class name and it's case sensitive,
57
+         * so take care that the configuration value is exactly named like the last
58
+         * part of the class name.
59
+         *
60
+         * The allowed characters of the class name are A-Z, a-z and 0-9. No other
61
+         * characters are possible! You should always start the last part of the class
62
+         * name with an upper case character and continue only with lower case characters
63
+         * or numbers. Avoid chamel case names like "MyStock"!
64
+         *
65
+         * @param string Last part of the class name
66
+         * @since 2014.03
67
+         * @category Developer
68
+         */
69
+        if( $name === null ) {
70
+            $name = $context->getConfig()->get( 'client/html/catalog/stock/name', 'Standard' );
71
+        }
72 72
 
73
-		if( ctype_alnum( $name ) === false )
74
-		{
75
-			$classname = is_string( $name ) ? '\\Aimeos\\Client\\Html\\Catalog\\Stock\\' . $name : '<not a string>';
76
-			throw new \Aimeos\Client\Html\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
77
-		}
73
+        if( ctype_alnum( $name ) === false )
74
+        {
75
+            $classname = is_string( $name ) ? '\\Aimeos\\Client\\Html\\Catalog\\Stock\\' . $name : '<not a string>';
76
+            throw new \Aimeos\Client\Html\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
77
+        }
78 78
 
79
-		$iface = '\\Aimeos\\Client\\Html\\Iface';
80
-		$classname = '\\Aimeos\\Client\\Html\\Catalog\\Stock\\' . $name;
79
+        $iface = '\\Aimeos\\Client\\Html\\Iface';
80
+        $classname = '\\Aimeos\\Client\\Html\\Catalog\\Stock\\' . $name;
81 81
 
82
-		$client = self::createClientBase( $context, $classname, $iface, $templatePaths );
82
+        $client = self::createClientBase( $context, $classname, $iface, $templatePaths );
83 83
 
84
-		return self::addClientDecorators( $context, $client, $templatePaths, 'catalog/stock' );
85
-	}
84
+        return self::addClientDecorators( $context, $client, $templatePaths, 'catalog/stock' );
85
+    }
86 86
 }
87 87
 
Please login to merge, or discard this patch.
client/html/src/Client/Html/Catalog/Stock/Standard.php 1 patch
Indentation   +349 added lines, -349 removed lines patch added patch discarded remove patch
@@ -19,358 +19,358 @@
 block discarded – undo
19 19
  * @subpackage Html
20 20
  */
21 21
 class Standard
22
-	extends \Aimeos\Client\Html\Common\Client\Factory\Base
23
-	implements \Aimeos\Client\Html\Common\Client\Factory\Iface
22
+    extends \Aimeos\Client\Html\Common\Client\Factory\Base
23
+    implements \Aimeos\Client\Html\Common\Client\Factory\Iface
24 24
 {
25
-	/** client/html/catalog/stock/standard/subparts
26
-	 * List of HTML sub-clients rendered within the catalog stock 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
-	 * @category Developer
57
-	 */
58
-	private $subPartPath = 'client/html/catalog/stock/standard/subparts';
59
-	private $subPartNames = array();
60
-	private $cache;
61
-
62
-
63
-	/**
64
-	 * Returns the HTML code for insertion into the body.
65
-	 *
66
-	 * @param string $uid Unique identifier for the output if the content is placed more than once on the same page
67
-	 * @param array &$tags Result array for the list of tags that are associated to the output
68
-	 * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
69
-	 * @return string HTML code
70
-	 */
71
-	public function getBody( $uid = '', array &$tags = array(), &$expire = null )
72
-	{
73
-		try
74
-		{
75
-			$view = $this->setViewParams( $this->getView(), $tags, $expire );
76
-
77
-			$html = '';
78
-			foreach( $this->getSubClients() as $subclient ) {
79
-				$html .= $subclient->setView( $view )->getBody( $uid, $tags, $expire );
80
-			}
81
-			$view->stockBody = $html;
82
-
83
-			/** client/html/catalog/stock/standard/template-body
84
-			 * Relative path to the HTML body template of the catalog stock client.
85
-			 *
86
-			 * The template file contains the HTML code and processing instructions
87
-			 * to generate the result shown in the body of the frontend. The
88
-			 * configuration string is the path to the template file relative
89
-			 * to the templates directory (usually in client/html/templates).
90
-			 *
91
-			 * You can overwrite the template file configuration in extensions and
92
-			 * provide alternative templates. These alternative templates should be
93
-			 * named like the default one but with the string "standard" replaced by
94
-			 * an unique name. You may use the name of your project for this. If
95
-			 * you've implemented an alternative client class as well, "standard"
96
-			 * should be replaced by the name of the new class.
97
-			 *
98
-			 * @param string Relative path to the template creating code for the HTML page body
99
-			 * @since 2014.03
100
-			 * @category Developer
101
-			 * @see client/html/catalog/stock/standard/template-header
102
-			 */
103
-			$tplconf = 'client/html/catalog/stock/standard/template-body';
104
-			$default = 'catalog/stock/body-default.php';
105
-
106
-			return $view->render( $view->config( $tplconf, $default ) );
107
-		}
108
-		catch( \Exception $e )
109
-		{
110
-			$this->getContext()->getLogger()->log( $e->getMessage() . PHP_EOL . $e->getTraceAsString() );
111
-		}
112
-	}
113
-
114
-
115
-	/**
116
-	 * Returns the HTML string for insertion into the header.
117
-	 *
118
-	 * @param string $uid Unique identifier for the output if the content is placed more than once on the same page
119
-	 * @param array &$tags Result array for the list of tags that are associated to the output
120
-	 * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
121
-	 * @return string|null String including HTML tags for the header on error
122
-	 */
123
-	public function getHeader( $uid = '', array &$tags = array(), &$expire = null )
124
-	{
125
-		try
126
-		{
127
-			$view = $this->setViewParams( $this->getView(), $tags, $expire );
128
-
129
-			$html = '';
130
-			foreach( $this->getSubClients() as $subclient ) {
131
-				$html .= $subclient->setView( $view )->getHeader( $uid, $tags, $expire );
132
-			}
133
-			$view->stockHeader = $html;
134
-
135
-			/** client/html/catalog/stock/standard/template-header
136
-			 * Relative path to the HTML header template of the catalog stock client.
137
-			 *
138
-			 * The template file contains the HTML code and processing instructions
139
-			 * to generate the HTML code that is inserted into the HTML page header
140
-			 * of the rendered page in the frontend. The configuration string is the
141
-			 * path to the template file relative to the templates directory (usually
142
-			 * in client/html/templates).
143
-			 *
144
-			 * You can overwrite the template file configuration in extensions and
145
-			 * provide alternative templates. These alternative templates should be
146
-			 * named like the default one but with the string "standard" replaced by
147
-			 * an unique name. You may use the name of your project for this. If
148
-			 * you've implemented an alternative client class as well, "standard"
149
-			 * should be replaced by the name of the new class.
150
-			 *
151
-			 * @param string Relative path to the template creating code for the HTML page head
152
-			 * @since 2014.03
153
-			 * @category Developer
154
-			 * @see client/html/catalog/stock/standard/template-body
155
-			 */
156
-			$tplconf = 'client/html/catalog/stock/standard/template-header';
157
-			$default = 'catalog/stock/header-default.php';
158
-
159
-			return $view->render( $view->config( $tplconf, $default ) );
160
-		}
161
-		catch( \Exception $e )
162
-		{
163
-			$this->getContext()->getLogger()->log( $e->getMessage() . PHP_EOL . $e->getTraceAsString() );
164
-		}
165
-	}
166
-
167
-
168
-	/**
169
-	 * Returns the sub-client given by its name.
170
-	 *
171
-	 * @param string $type Name of the client type
172
-	 * @param string|null $name Name of the sub-client (Default if null)
173
-	 * @return \Aimeos\Client\Html\Iface Sub-client object
174
-	 */
175
-	public function getSubClient( $type, $name = null )
176
-	{
177
-		/** client/html/catalog/stock/decorators/excludes
178
-		 * Excludes decorators added by the "common" option from the catalog stock html client
179
-		 *
180
-		 * Decorators extend the functionality of a class by adding new aspects
181
-		 * (e.g. log what is currently done), executing the methods of the underlying
182
-		 * class only in certain conditions (e.g. only for logged in users) or
183
-		 * modify what is returned to the caller.
184
-		 *
185
-		 * This option allows you to remove a decorator added via
186
-		 * "client/html/common/decorators/default" before they are wrapped
187
-		 * around the html client.
188
-		 *
189
-		 *  client/html/catalog/stock/decorators/excludes = array( 'decorator1' )
190
-		 *
191
-		 * This would remove the decorator named "decorator1" from the list of
192
-		 * common decorators ("\Aimeos\Client\Html\Common\Decorator\*") added via
193
-		 * "client/html/common/decorators/default" to the html client.
194
-		 *
195
-		 * @param array List of decorator names
196
-		 * @since 2014.05
197
-		 * @category Developer
198
-		 * @see client/html/common/decorators/default
199
-		 * @see client/html/catalog/stock/decorators/global
200
-		 * @see client/html/catalog/stock/decorators/local
201
-		 */
202
-
203
-		/** client/html/catalog/stock/decorators/global
204
-		 * Adds a list of globally available decorators only to the catalog stock html client
205
-		 *
206
-		 * Decorators extend the functionality of a class by adding new aspects
207
-		 * (e.g. log what is currently done), executing the methods of the underlying
208
-		 * class only in certain conditions (e.g. only for logged in users) or
209
-		 * modify what is returned to the caller.
210
-		 *
211
-		 * This option allows you to wrap global decorators
212
-		 * ("\Aimeos\Client\Html\Common\Decorator\*") around the html client.
213
-		 *
214
-		 *  client/html/catalog/stock/decorators/global = array( 'decorator1' )
215
-		 *
216
-		 * This would add the decorator named "decorator1" defined by
217
-		 * "\Aimeos\Client\Html\Common\Decorator\Decorator1" only to the html client.
218
-		 *
219
-		 * @param array List of decorator names
220
-		 * @since 2014.05
221
-		 * @category Developer
222
-		 * @see client/html/common/decorators/default
223
-		 * @see client/html/catalog/stock/decorators/excludes
224
-		 * @see client/html/catalog/stock/decorators/local
225
-		 */
226
-
227
-		/** client/html/catalog/stock/decorators/local
228
-		 * Adds a list of local decorators only to the catalog stock html client
229
-		 *
230
-		 * Decorators extend the functionality of a class by adding new aspects
231
-		 * (e.g. log what is currently done), executing the methods of the underlying
232
-		 * class only in certain conditions (e.g. only for logged in users) or
233
-		 * modify what is returned to the caller.
234
-		 *
235
-		 * This option allows you to wrap local decorators
236
-		 * ("\Aimeos\Client\Html\Catalog\Decorator\*") around the html client.
237
-		 *
238
-		 *  client/html/catalog/stock/decorators/local = array( 'decorator2' )
239
-		 *
240
-		 * This would add the decorator named "decorator2" defined by
241
-		 * "\Aimeos\Client\Html\Catalog\Decorator\Decorator2" only to the html client.
242
-		 *
243
-		 * @param array List of decorator names
244
-		 * @since 2014.05
245
-		 * @category Developer
246
-		 * @see client/html/common/decorators/default
247
-		 * @see client/html/catalog/stock/decorators/excludes
248
-		 * @see client/html/catalog/stock/decorators/global
249
-		 */
250
-
251
-		return $this->createSubClient( 'catalog/stock/' . $type, $name );
252
-	}
253
-
254
-
255
-	/**
256
-	 * Processes the input, e.g. store given values.
257
-	 * A view must be available and this method doesn't generate any output
258
-	 * besides setting view variables.
259
-	 */
260
-	public function process()
261
-	{
262
-		try
263
-		{
264
-			parent::process();
265
-		}
266
-		catch( \Exception $e )
267
-		{
268
-			$this->getContext()->getLogger()->log( $e->getMessage() . PHP_EOL . $e->getTraceAsString() );
269
-		}
270
-	}
271
-
272
-
273
-	/**
274
-	 * Returns the list of sub-client names configured for the client.
275
-	 *
276
-	 * @return array List of HTML client names
277
-	 */
278
-	protected function getSubClientNames()
279
-	{
280
-		return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames );
281
-	}
282
-
283
-
284
-	/**
285
-	 * Sets the necessary parameter values in the view.
286
-	 *
287
-	 * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output
288
-	 * @param array &$tags Result array for the list of tags that are associated to the output
289
-	 * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
290
-	 * @return \Aimeos\MW\View\Iface Modified view object
291
-	 */
292
-	protected function setViewParams( \Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null )
293
-	{
294
-		if( !isset( $this->cache ) )
295
-		{
296
-			$context = $this->getContext();
297
-			$siteConfig = $context->getLocale()->getSite()->getConfig();
298
-
299
-			/** client/html/catalog/stock/sort
300
-			 * Sortation key if stock levels for different warehouses exist
301
-			 *
302
-			 * Products can be shipped from several warehouses with a different
303
-			 * stock level for each one. The stock levels for each warehouse will
304
-			 * be shown in the product detail page. To get a consistent sortation
305
-			 * of this list, the configured key of the product warehouse manager
306
-			 * will be used.
307
-			 *
308
-			 * @param string Key for sorting
309
-			 * @since 2014.03
310
-			 * @category Developer
311
-			 * @see client/html/catalog/stock/level/low
312
-			 */
313
-			$sortkey = $context->getConfig()->get( 'client/html/catalog/stock/sort', 'product.stock.warehouseid' );
314
-			$productIds = $view->param( 's_prodid' );
315
-
316
-			if( !is_array( $productIds ) ) {
317
-				$productIds = explode( ' ', $productIds );
318
-			}
319
-
320
-
321
-			$stockManager = \Aimeos\MShop\Factory::createManager( $context, 'product/stock' );
322
-
323
-			$search = $stockManager->createSearch( true );
324
-			$expr = array( $search->compare( '==', 'product.stock.parentid', $productIds ) );
325
-
326
-			if( isset( $siteConfig['warehouse'] ) ) {
327
-				$expr[] = $search->compare( '==', 'product.stock.warehouse.code', $siteConfig['warehouse'] );
328
-			}
329
-
330
-			$expr[] = $search->getConditions();
331
-
332
-			$sortations = array(
333
-				$search->sort( '+', 'product.stock.parentid' ),
334
-				$search->sort( '+', $sortkey ),
335
-			);
336
-
337
-			$search->setConditions( $search->combine( '&&', $expr ) );
338
-			$search->setSortations( $sortations );
339
-			$search->setSlice( 0, 0x7fffffff );
340
-
341
-			$stockItems = $stockManager->searchItems( $search );
342
-
343
-
344
-			if( !empty( $stockItems ) )
345
-			{
346
-				$warehouseIds = $stockItemsByProducts = array();
347
-
348
-				foreach( $stockItems as $item )
349
-				{
350
-					$warehouseIds[$item->getWarehouseId()] = null;
351
-					$stockItemsByProducts[$item->getParentId()][] = $item;
352
-				}
353
-
354
-				$warehouseIds = array_keys( $warehouseIds );
355
-
356
-
357
-				$warehouseManager = \Aimeos\MShop\Factory::createManager( $context, 'product/stock/warehouse' );
358
-
359
-				$search = $warehouseManager->createSearch();
360
-				$search->setConditions( $search->compare( '==', 'product.stock.warehouse.id', $warehouseIds ) );
361
-				$search->setSlice( 0, count( $warehouseIds ) );
362
-
363
-
364
-				$view->stockWarehouseItems = $warehouseManager->searchItems( $search );
365
-				$view->stockItemsByProducts = $stockItemsByProducts;
366
-			}
25
+    /** client/html/catalog/stock/standard/subparts
26
+     * List of HTML sub-clients rendered within the catalog stock 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
+     * @category Developer
57
+     */
58
+    private $subPartPath = 'client/html/catalog/stock/standard/subparts';
59
+    private $subPartNames = array();
60
+    private $cache;
61
+
62
+
63
+    /**
64
+     * Returns the HTML code for insertion into the body.
65
+     *
66
+     * @param string $uid Unique identifier for the output if the content is placed more than once on the same page
67
+     * @param array &$tags Result array for the list of tags that are associated to the output
68
+     * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
69
+     * @return string HTML code
70
+     */
71
+    public function getBody( $uid = '', array &$tags = array(), &$expire = null )
72
+    {
73
+        try
74
+        {
75
+            $view = $this->setViewParams( $this->getView(), $tags, $expire );
76
+
77
+            $html = '';
78
+            foreach( $this->getSubClients() as $subclient ) {
79
+                $html .= $subclient->setView( $view )->getBody( $uid, $tags, $expire );
80
+            }
81
+            $view->stockBody = $html;
82
+
83
+            /** client/html/catalog/stock/standard/template-body
84
+             * Relative path to the HTML body template of the catalog stock client.
85
+             *
86
+             * The template file contains the HTML code and processing instructions
87
+             * to generate the result shown in the body of the frontend. The
88
+             * configuration string is the path to the template file relative
89
+             * to the templates directory (usually in client/html/templates).
90
+             *
91
+             * You can overwrite the template file configuration in extensions and
92
+             * provide alternative templates. These alternative templates should be
93
+             * named like the default one but with the string "standard" replaced by
94
+             * an unique name. You may use the name of your project for this. If
95
+             * you've implemented an alternative client class as well, "standard"
96
+             * should be replaced by the name of the new class.
97
+             *
98
+             * @param string Relative path to the template creating code for the HTML page body
99
+             * @since 2014.03
100
+             * @category Developer
101
+             * @see client/html/catalog/stock/standard/template-header
102
+             */
103
+            $tplconf = 'client/html/catalog/stock/standard/template-body';
104
+            $default = 'catalog/stock/body-default.php';
105
+
106
+            return $view->render( $view->config( $tplconf, $default ) );
107
+        }
108
+        catch( \Exception $e )
109
+        {
110
+            $this->getContext()->getLogger()->log( $e->getMessage() . PHP_EOL . $e->getTraceAsString() );
111
+        }
112
+    }
113
+
114
+
115
+    /**
116
+     * Returns the HTML string for insertion into the header.
117
+     *
118
+     * @param string $uid Unique identifier for the output if the content is placed more than once on the same page
119
+     * @param array &$tags Result array for the list of tags that are associated to the output
120
+     * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
121
+     * @return string|null String including HTML tags for the header on error
122
+     */
123
+    public function getHeader( $uid = '', array &$tags = array(), &$expire = null )
124
+    {
125
+        try
126
+        {
127
+            $view = $this->setViewParams( $this->getView(), $tags, $expire );
128
+
129
+            $html = '';
130
+            foreach( $this->getSubClients() as $subclient ) {
131
+                $html .= $subclient->setView( $view )->getHeader( $uid, $tags, $expire );
132
+            }
133
+            $view->stockHeader = $html;
134
+
135
+            /** client/html/catalog/stock/standard/template-header
136
+             * Relative path to the HTML header template of the catalog stock client.
137
+             *
138
+             * The template file contains the HTML code and processing instructions
139
+             * to generate the HTML code that is inserted into the HTML page header
140
+             * of the rendered page in the frontend. The configuration string is the
141
+             * path to the template file relative to the templates directory (usually
142
+             * in client/html/templates).
143
+             *
144
+             * You can overwrite the template file configuration in extensions and
145
+             * provide alternative templates. These alternative templates should be
146
+             * named like the default one but with the string "standard" replaced by
147
+             * an unique name. You may use the name of your project for this. If
148
+             * you've implemented an alternative client class as well, "standard"
149
+             * should be replaced by the name of the new class.
150
+             *
151
+             * @param string Relative path to the template creating code for the HTML page head
152
+             * @since 2014.03
153
+             * @category Developer
154
+             * @see client/html/catalog/stock/standard/template-body
155
+             */
156
+            $tplconf = 'client/html/catalog/stock/standard/template-header';
157
+            $default = 'catalog/stock/header-default.php';
158
+
159
+            return $view->render( $view->config( $tplconf, $default ) );
160
+        }
161
+        catch( \Exception $e )
162
+        {
163
+            $this->getContext()->getLogger()->log( $e->getMessage() . PHP_EOL . $e->getTraceAsString() );
164
+        }
165
+    }
166
+
167
+
168
+    /**
169
+     * Returns the sub-client given by its name.
170
+     *
171
+     * @param string $type Name of the client type
172
+     * @param string|null $name Name of the sub-client (Default if null)
173
+     * @return \Aimeos\Client\Html\Iface Sub-client object
174
+     */
175
+    public function getSubClient( $type, $name = null )
176
+    {
177
+        /** client/html/catalog/stock/decorators/excludes
178
+         * Excludes decorators added by the "common" option from the catalog stock html client
179
+         *
180
+         * Decorators extend the functionality of a class by adding new aspects
181
+         * (e.g. log what is currently done), executing the methods of the underlying
182
+         * class only in certain conditions (e.g. only for logged in users) or
183
+         * modify what is returned to the caller.
184
+         *
185
+         * This option allows you to remove a decorator added via
186
+         * "client/html/common/decorators/default" before they are wrapped
187
+         * around the html client.
188
+         *
189
+         *  client/html/catalog/stock/decorators/excludes = array( 'decorator1' )
190
+         *
191
+         * This would remove the decorator named "decorator1" from the list of
192
+         * common decorators ("\Aimeos\Client\Html\Common\Decorator\*") added via
193
+         * "client/html/common/decorators/default" to the html client.
194
+         *
195
+         * @param array List of decorator names
196
+         * @since 2014.05
197
+         * @category Developer
198
+         * @see client/html/common/decorators/default
199
+         * @see client/html/catalog/stock/decorators/global
200
+         * @see client/html/catalog/stock/decorators/local
201
+         */
202
+
203
+        /** client/html/catalog/stock/decorators/global
204
+         * Adds a list of globally available decorators only to the catalog stock html client
205
+         *
206
+         * Decorators extend the functionality of a class by adding new aspects
207
+         * (e.g. log what is currently done), executing the methods of the underlying
208
+         * class only in certain conditions (e.g. only for logged in users) or
209
+         * modify what is returned to the caller.
210
+         *
211
+         * This option allows you to wrap global decorators
212
+         * ("\Aimeos\Client\Html\Common\Decorator\*") around the html client.
213
+         *
214
+         *  client/html/catalog/stock/decorators/global = array( 'decorator1' )
215
+         *
216
+         * This would add the decorator named "decorator1" defined by
217
+         * "\Aimeos\Client\Html\Common\Decorator\Decorator1" only to the html client.
218
+         *
219
+         * @param array List of decorator names
220
+         * @since 2014.05
221
+         * @category Developer
222
+         * @see client/html/common/decorators/default
223
+         * @see client/html/catalog/stock/decorators/excludes
224
+         * @see client/html/catalog/stock/decorators/local
225
+         */
226
+
227
+        /** client/html/catalog/stock/decorators/local
228
+         * Adds a list of local decorators only to the catalog stock html client
229
+         *
230
+         * Decorators extend the functionality of a class by adding new aspects
231
+         * (e.g. log what is currently done), executing the methods of the underlying
232
+         * class only in certain conditions (e.g. only for logged in users) or
233
+         * modify what is returned to the caller.
234
+         *
235
+         * This option allows you to wrap local decorators
236
+         * ("\Aimeos\Client\Html\Catalog\Decorator\*") around the html client.
237
+         *
238
+         *  client/html/catalog/stock/decorators/local = array( 'decorator2' )
239
+         *
240
+         * This would add the decorator named "decorator2" defined by
241
+         * "\Aimeos\Client\Html\Catalog\Decorator\Decorator2" only to the html client.
242
+         *
243
+         * @param array List of decorator names
244
+         * @since 2014.05
245
+         * @category Developer
246
+         * @see client/html/common/decorators/default
247
+         * @see client/html/catalog/stock/decorators/excludes
248
+         * @see client/html/catalog/stock/decorators/global
249
+         */
250
+
251
+        return $this->createSubClient( 'catalog/stock/' . $type, $name );
252
+    }
253
+
254
+
255
+    /**
256
+     * Processes the input, e.g. store given values.
257
+     * A view must be available and this method doesn't generate any output
258
+     * besides setting view variables.
259
+     */
260
+    public function process()
261
+    {
262
+        try
263
+        {
264
+            parent::process();
265
+        }
266
+        catch( \Exception $e )
267
+        {
268
+            $this->getContext()->getLogger()->log( $e->getMessage() . PHP_EOL . $e->getTraceAsString() );
269
+        }
270
+    }
271
+
272
+
273
+    /**
274
+     * Returns the list of sub-client names configured for the client.
275
+     *
276
+     * @return array List of HTML client names
277
+     */
278
+    protected function getSubClientNames()
279
+    {
280
+        return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames );
281
+    }
282
+
283
+
284
+    /**
285
+     * Sets the necessary parameter values in the view.
286
+     *
287
+     * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output
288
+     * @param array &$tags Result array for the list of tags that are associated to the output
289
+     * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
290
+     * @return \Aimeos\MW\View\Iface Modified view object
291
+     */
292
+    protected function setViewParams( \Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null )
293
+    {
294
+        if( !isset( $this->cache ) )
295
+        {
296
+            $context = $this->getContext();
297
+            $siteConfig = $context->getLocale()->getSite()->getConfig();
298
+
299
+            /** client/html/catalog/stock/sort
300
+             * Sortation key if stock levels for different warehouses exist
301
+             *
302
+             * Products can be shipped from several warehouses with a different
303
+             * stock level for each one. The stock levels for each warehouse will
304
+             * be shown in the product detail page. To get a consistent sortation
305
+             * of this list, the configured key of the product warehouse manager
306
+             * will be used.
307
+             *
308
+             * @param string Key for sorting
309
+             * @since 2014.03
310
+             * @category Developer
311
+             * @see client/html/catalog/stock/level/low
312
+             */
313
+            $sortkey = $context->getConfig()->get( 'client/html/catalog/stock/sort', 'product.stock.warehouseid' );
314
+            $productIds = $view->param( 's_prodid' );
315
+
316
+            if( !is_array( $productIds ) ) {
317
+                $productIds = explode( ' ', $productIds );
318
+            }
319
+
320
+
321
+            $stockManager = \Aimeos\MShop\Factory::createManager( $context, 'product/stock' );
322
+
323
+            $search = $stockManager->createSearch( true );
324
+            $expr = array( $search->compare( '==', 'product.stock.parentid', $productIds ) );
325
+
326
+            if( isset( $siteConfig['warehouse'] ) ) {
327
+                $expr[] = $search->compare( '==', 'product.stock.warehouse.code', $siteConfig['warehouse'] );
328
+            }
329
+
330
+            $expr[] = $search->getConditions();
331
+
332
+            $sortations = array(
333
+                $search->sort( '+', 'product.stock.parentid' ),
334
+                $search->sort( '+', $sortkey ),
335
+            );
336
+
337
+            $search->setConditions( $search->combine( '&&', $expr ) );
338
+            $search->setSortations( $sortations );
339
+            $search->setSlice( 0, 0x7fffffff );
340
+
341
+            $stockItems = $stockManager->searchItems( $search );
342
+
343
+
344
+            if( !empty( $stockItems ) )
345
+            {
346
+                $warehouseIds = $stockItemsByProducts = array();
347
+
348
+                foreach( $stockItems as $item )
349
+                {
350
+                    $warehouseIds[$item->getWarehouseId()] = null;
351
+                    $stockItemsByProducts[$item->getParentId()][] = $item;
352
+                }
353
+
354
+                $warehouseIds = array_keys( $warehouseIds );
355
+
356
+
357
+                $warehouseManager = \Aimeos\MShop\Factory::createManager( $context, 'product/stock/warehouse' );
358
+
359
+                $search = $warehouseManager->createSearch();
360
+                $search->setConditions( $search->compare( '==', 'product.stock.warehouse.id', $warehouseIds ) );
361
+                $search->setSlice( 0, count( $warehouseIds ) );
362
+
363
+
364
+                $view->stockWarehouseItems = $warehouseManager->searchItems( $search );
365
+                $view->stockItemsByProducts = $stockItemsByProducts;
366
+            }
367 367
 
368 368
 
369
-			$view->stockProductIds = $productIds;
369
+            $view->stockProductIds = $productIds;
370 370
 
371
-			$this->cache = $view;
372
-		}
371
+            $this->cache = $view;
372
+        }
373 373
 
374
-		return $this->cache;
375
-	}
374
+        return $this->cache;
375
+    }
376 376
 }
Please login to merge, or discard this patch.
client/html/src/Client/Html/Catalog/Count/Attribute/Standard.php 1 patch
Indentation   +271 added lines, -271 removed lines patch added patch discarded remove patch
@@ -19,299 +19,299 @@
 block discarded – undo
19 19
  * @subpackage Html
20 20
  */
21 21
 class Standard
22
-	extends \Aimeos\Client\Html\Catalog\Base
23
-	implements \Aimeos\Client\Html\Common\Client\Factory\Iface
22
+    extends \Aimeos\Client\Html\Catalog\Base
23
+    implements \Aimeos\Client\Html\Common\Client\Factory\Iface
24 24
 {
25
-	/** client/html/catalog/count/attribute/standard/subparts
26
-	 * List of HTML sub-clients rendered within the catalog count attribute 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
-	 * @category Developer
57
-	 */
58
-	private $subPartPath = 'client/html/catalog/count/attribute/standard/subparts';
59
-	private $subPartNames = array();
60
-	private $cache;
25
+    /** client/html/catalog/count/attribute/standard/subparts
26
+     * List of HTML sub-clients rendered within the catalog count attribute 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
+     * @category Developer
57
+     */
58
+    private $subPartPath = 'client/html/catalog/count/attribute/standard/subparts';
59
+    private $subPartNames = array();
60
+    private $cache;
61 61
 
62 62
 
63
-	/**
64
-	 * Returns the HTML code for insertion into the body.
65
-	 *
66
-	 * @param string $uid Unique identifier for the output if the content is placed more than once on the same page
67
-	 * @param array &$tags Result array for the list of tags that are associated to the output
68
-	 * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
69
-	 * @return string HTML code
70
-	 */
71
-	public function getBody( $uid = '', array &$tags = array(), &$expire = null )
72
-	{
73
-		$view = $this->setViewParams( $this->getView(), $tags, $expire );
63
+    /**
64
+     * Returns the HTML code for insertion into the body.
65
+     *
66
+     * @param string $uid Unique identifier for the output if the content is placed more than once on the same page
67
+     * @param array &$tags Result array for the list of tags that are associated to the output
68
+     * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
69
+     * @return string HTML code
70
+     */
71
+    public function getBody( $uid = '', array &$tags = array(), &$expire = null )
72
+    {
73
+        $view = $this->setViewParams( $this->getView(), $tags, $expire );
74 74
 
75
-		$html = '';
76
-		foreach( $this->getSubClients() as $subclient ) {
77
-			$html .= $subclient->setView( $view )->getBody( $uid, $tags, $expire );
78
-		}
79
-		$view->attributeBody = $html;
75
+        $html = '';
76
+        foreach( $this->getSubClients() as $subclient ) {
77
+            $html .= $subclient->setView( $view )->getBody( $uid, $tags, $expire );
78
+        }
79
+        $view->attributeBody = $html;
80 80
 
81
-		/** client/html/catalog/count/attribute/standard/template-body
82
-		 * Relative path to the HTML body template of the catalog count attribute client.
83
-		 *
84
-		 * The template file contains the HTML code and processing instructions
85
-		 * to generate the result shown in the body of the frontend. The
86
-		 * configuration string is the path to the template file relative
87
-		 * to the templates directory (usually in client/html/templates).
88
-		 *
89
-		 * You can overwrite the template file configuration in extensions and
90
-		 * provide alternative templates. These alternative templates should be
91
-		 * named like the default one but with the string "standard" replaced by
92
-		 * an unique name. You may use the name of your project for this. If
93
-		 * you've implemented an alternative client class as well, "standard"
94
-		 * should be replaced by the name of the new class.
95
-		 *
96
-		 * @param string Relative path to the template creating code for the HTML page body
97
-		 * @since 2014.03
98
-		 * @category Developer
99
-		 * @see client/html/catalog/count/attribute/standard/template-header
100
-		 */
101
-		$tplconf = 'client/html/catalog/count/attribute/standard/template-body';
102
-		$default = 'catalog/count/attribute-body-default.php';
81
+        /** client/html/catalog/count/attribute/standard/template-body
82
+         * Relative path to the HTML body template of the catalog count attribute client.
83
+         *
84
+         * The template file contains the HTML code and processing instructions
85
+         * to generate the result shown in the body of the frontend. The
86
+         * configuration string is the path to the template file relative
87
+         * to the templates directory (usually in client/html/templates).
88
+         *
89
+         * You can overwrite the template file configuration in extensions and
90
+         * provide alternative templates. These alternative templates should be
91
+         * named like the default one but with the string "standard" replaced by
92
+         * an unique name. You may use the name of your project for this. If
93
+         * you've implemented an alternative client class as well, "standard"
94
+         * should be replaced by the name of the new class.
95
+         *
96
+         * @param string Relative path to the template creating code for the HTML page body
97
+         * @since 2014.03
98
+         * @category Developer
99
+         * @see client/html/catalog/count/attribute/standard/template-header
100
+         */
101
+        $tplconf = 'client/html/catalog/count/attribute/standard/template-body';
102
+        $default = 'catalog/count/attribute-body-default.php';
103 103
 
104
-		return $view->render( $view->config( $tplconf, $default ) );
105
-	}
104
+        return $view->render( $view->config( $tplconf, $default ) );
105
+    }
106 106
 
107 107
 
108
-	/**
109
-	 * Returns the HTML string for insertion into the header.
110
-	 *
111
-	 * @param string $uid Unique identifier for the output if the content is placed more than once on the same page
112
-	 * @param array &$tags Result array for the list of tags that are associated to the output
113
-	 * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
114
-	 * @return string|null String including HTML tags for the header on error
115
-	 */
116
-	public function getHeader( $uid = '', array &$tags = array(), &$expire = null )
117
-	{
118
-		$view = $this->setViewParams( $this->getView(), $tags, $expire );
108
+    /**
109
+     * Returns the HTML string for insertion into the header.
110
+     *
111
+     * @param string $uid Unique identifier for the output if the content is placed more than once on the same page
112
+     * @param array &$tags Result array for the list of tags that are associated to the output
113
+     * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
114
+     * @return string|null String including HTML tags for the header on error
115
+     */
116
+    public function getHeader( $uid = '', array &$tags = array(), &$expire = null )
117
+    {
118
+        $view = $this->setViewParams( $this->getView(), $tags, $expire );
119 119
 
120
-		$html = '';
121
-		foreach( $this->getSubClients() as $subclient ) {
122
-			$html .= $subclient->setView( $view )->getHeader( $uid, $tags, $expire );
123
-		}
124
-		$view->attributeHeader = $html;
120
+        $html = '';
121
+        foreach( $this->getSubClients() as $subclient ) {
122
+            $html .= $subclient->setView( $view )->getHeader( $uid, $tags, $expire );
123
+        }
124
+        $view->attributeHeader = $html;
125 125
 
126
-		/** client/html/catalog/count/attribute/standard/template-header
127
-		 * Relative path to the HTML header template of the catalog count attribute client.
128
-		 *
129
-		 * The template file contains the HTML code and processing instructions
130
-		 * to generate the HTML code that is inserted into the HTML page header
131
-		 * of the rendered page in the frontend. The configuration string is the
132
-		 * path to the template file relative to the templates directory (usually
133
-		 * in client/html/templates).
134
-		 *
135
-		 * You can overwrite the template file configuration in extensions and
136
-		 * provide alternative templates. These alternative templates should be
137
-		 * named like the default one but with the string "standard" replaced by
138
-		 * an unique name. You may use the name of your project for this. If
139
-		 * you've implemented an alternative client class as well, "standard"
140
-		 * should be replaced by the name of the new class.
141
-		 *
142
-		 * @param string Relative path to the template creating code for the HTML page head
143
-		 * @since 2014.03
144
-		 * @category Developer
145
-		 * @see client/html/catalog/count/attribute/standard/template-body
146
-		 */
147
-		$tplconf = 'client/html/catalog/count/attribute/standard/template-header';
148
-		$default = 'catalog/count/attribute-header-default.php';
126
+        /** client/html/catalog/count/attribute/standard/template-header
127
+         * Relative path to the HTML header template of the catalog count attribute client.
128
+         *
129
+         * The template file contains the HTML code and processing instructions
130
+         * to generate the HTML code that is inserted into the HTML page header
131
+         * of the rendered page in the frontend. The configuration string is the
132
+         * path to the template file relative to the templates directory (usually
133
+         * in client/html/templates).
134
+         *
135
+         * You can overwrite the template file configuration in extensions and
136
+         * provide alternative templates. These alternative templates should be
137
+         * named like the default one but with the string "standard" replaced by
138
+         * an unique name. You may use the name of your project for this. If
139
+         * you've implemented an alternative client class as well, "standard"
140
+         * should be replaced by the name of the new class.
141
+         *
142
+         * @param string Relative path to the template creating code for the HTML page head
143
+         * @since 2014.03
144
+         * @category Developer
145
+         * @see client/html/catalog/count/attribute/standard/template-body
146
+         */
147
+        $tplconf = 'client/html/catalog/count/attribute/standard/template-header';
148
+        $default = 'catalog/count/attribute-header-default.php';
149 149
 
150
-		return $view->render( $view->config( $tplconf, $default ) );
151
-	}
150
+        return $view->render( $view->config( $tplconf, $default ) );
151
+    }
152 152
 
153 153
 
154
-	/**
155
-	 * Returns the sub-client given by its name.
156
-	 *
157
-	 * @param string $type Name of the client type
158
-	 * @param string|null $name Name of the sub-client (Default if null)
159
-	 * @return \Aimeos\Client\Html\Iface Sub-client object
160
-	 */
161
-	public function getSubClient( $type, $name = null )
162
-	{
163
-		/** client/html/catalog/count/attribute/decorators/excludes
164
-		 * Excludes decorators added by the "common" option from the catalog count attribute html client
165
-		 *
166
-		 * Decorators extend the functionality of a class by adding new aspects
167
-		 * (e.g. log what is currently done), executing the methods of the underlying
168
-		 * class only in certain conditions (e.g. only for logged in users) or
169
-		 * modify what is returned to the caller.
170
-		 *
171
-		 * This option allows you to remove a decorator added via
172
-		 * "client/html/common/decorators/default" before they are wrapped
173
-		 * around the html client.
174
-		 *
175
-		 *  client/html/catalog/count/attribute/decorators/excludes = array( 'decorator1' )
176
-		 *
177
-		 * This would remove the decorator named "decorator1" from the list of
178
-		 * common decorators ("\Aimeos\Client\Html\Common\Decorator\*") added via
179
-		 * "client/html/common/decorators/default" to the html client.
180
-		 *
181
-		 * @param array List of decorator names
182
-		 * @since 2015.08
183
-		 * @category Developer
184
-		 * @see client/html/common/decorators/default
185
-		 * @see client/html/catalog/count/attribute/decorators/global
186
-		 * @see client/html/catalog/count/attribute/decorators/local
187
-		 */
154
+    /**
155
+     * Returns the sub-client given by its name.
156
+     *
157
+     * @param string $type Name of the client type
158
+     * @param string|null $name Name of the sub-client (Default if null)
159
+     * @return \Aimeos\Client\Html\Iface Sub-client object
160
+     */
161
+    public function getSubClient( $type, $name = null )
162
+    {
163
+        /** client/html/catalog/count/attribute/decorators/excludes
164
+         * Excludes decorators added by the "common" option from the catalog count attribute html client
165
+         *
166
+         * Decorators extend the functionality of a class by adding new aspects
167
+         * (e.g. log what is currently done), executing the methods of the underlying
168
+         * class only in certain conditions (e.g. only for logged in users) or
169
+         * modify what is returned to the caller.
170
+         *
171
+         * This option allows you to remove a decorator added via
172
+         * "client/html/common/decorators/default" before they are wrapped
173
+         * around the html client.
174
+         *
175
+         *  client/html/catalog/count/attribute/decorators/excludes = array( 'decorator1' )
176
+         *
177
+         * This would remove the decorator named "decorator1" from the list of
178
+         * common decorators ("\Aimeos\Client\Html\Common\Decorator\*") added via
179
+         * "client/html/common/decorators/default" to the html client.
180
+         *
181
+         * @param array List of decorator names
182
+         * @since 2015.08
183
+         * @category Developer
184
+         * @see client/html/common/decorators/default
185
+         * @see client/html/catalog/count/attribute/decorators/global
186
+         * @see client/html/catalog/count/attribute/decorators/local
187
+         */
188 188
 
189
-		/** client/html/catalog/count/attribute/decorators/global
190
-		 * Adds a list of globally available decorators only to the catalog count attribute html client
191
-		 *
192
-		 * Decorators extend the functionality of a class by adding new aspects
193
-		 * (e.g. log what is currently done), executing the methods of the underlying
194
-		 * class only in certain conditions (e.g. only for logged in users) or
195
-		 * modify what is returned to the caller.
196
-		 *
197
-		 * This option allows you to wrap global decorators
198
-		 * ("\Aimeos\Client\Html\Common\Decorator\*") around the html client.
199
-		 *
200
-		 *  client/html/catalog/count/attribute/decorators/global = array( 'decorator1' )
201
-		 *
202
-		 * This would add the decorator named "decorator1" defined by
203
-		 * "\Aimeos\Client\Html\Common\Decorator\Decorator1" only to the html client.
204
-		 *
205
-		 * @param array List of decorator names
206
-		 * @since 2015.08
207
-		 * @category Developer
208
-		 * @see client/html/common/decorators/default
209
-		 * @see client/html/catalog/count/attribute/decorators/excludes
210
-		 * @see client/html/catalog/count/attribute/decorators/local
211
-		 */
189
+        /** client/html/catalog/count/attribute/decorators/global
190
+         * Adds a list of globally available decorators only to the catalog count attribute html client
191
+         *
192
+         * Decorators extend the functionality of a class by adding new aspects
193
+         * (e.g. log what is currently done), executing the methods of the underlying
194
+         * class only in certain conditions (e.g. only for logged in users) or
195
+         * modify what is returned to the caller.
196
+         *
197
+         * This option allows you to wrap global decorators
198
+         * ("\Aimeos\Client\Html\Common\Decorator\*") around the html client.
199
+         *
200
+         *  client/html/catalog/count/attribute/decorators/global = array( 'decorator1' )
201
+         *
202
+         * This would add the decorator named "decorator1" defined by
203
+         * "\Aimeos\Client\Html\Common\Decorator\Decorator1" only to the html client.
204
+         *
205
+         * @param array List of decorator names
206
+         * @since 2015.08
207
+         * @category Developer
208
+         * @see client/html/common/decorators/default
209
+         * @see client/html/catalog/count/attribute/decorators/excludes
210
+         * @see client/html/catalog/count/attribute/decorators/local
211
+         */
212 212
 
213
-		/** client/html/catalog/count/attribute/decorators/local
214
-		 * Adds a list of local decorators only to the catalog count attribute html client
215
-		 *
216
-		 * Decorators extend the functionality of a class by adding new aspects
217
-		 * (e.g. log what is currently done), executing the methods of the underlying
218
-		 * class only in certain conditions (e.g. only for logged in users) or
219
-		 * modify what is returned to the caller.
220
-		 *
221
-		 * This option allows you to wrap local decorators
222
-		 * ("\Aimeos\Client\Html\Catalog\Decorator\*") around the html client.
223
-		 *
224
-		 *  client/html/catalog/count/attribute/decorators/local = array( 'decorator2' )
225
-		 *
226
-		 * This would add the decorator named "decorator2" defined by
227
-		 * "\Aimeos\Client\Html\Catalog\Decorator\Decorator2" only to the html client.
228
-		 *
229
-		 * @param array List of decorator names
230
-		 * @since 2015.08
231
-		 * @category Developer
232
-		 * @see client/html/common/decorators/default
233
-		 * @see client/html/catalog/count/attribute/decorators/excludes
234
-		 * @see client/html/catalog/count/attribute/decorators/global
235
-		 */
213
+        /** client/html/catalog/count/attribute/decorators/local
214
+         * Adds a list of local decorators only to the catalog count attribute html client
215
+         *
216
+         * Decorators extend the functionality of a class by adding new aspects
217
+         * (e.g. log what is currently done), executing the methods of the underlying
218
+         * class only in certain conditions (e.g. only for logged in users) or
219
+         * modify what is returned to the caller.
220
+         *
221
+         * This option allows you to wrap local decorators
222
+         * ("\Aimeos\Client\Html\Catalog\Decorator\*") around the html client.
223
+         *
224
+         *  client/html/catalog/count/attribute/decorators/local = array( 'decorator2' )
225
+         *
226
+         * This would add the decorator named "decorator2" defined by
227
+         * "\Aimeos\Client\Html\Catalog\Decorator\Decorator2" only to the html client.
228
+         *
229
+         * @param array List of decorator names
230
+         * @since 2015.08
231
+         * @category Developer
232
+         * @see client/html/common/decorators/default
233
+         * @see client/html/catalog/count/attribute/decorators/excludes
234
+         * @see client/html/catalog/count/attribute/decorators/global
235
+         */
236 236
 
237
-		return $this->createSubClient( 'catalog/count/attribute/' . $type, $name );
238
-	}
237
+        return $this->createSubClient( 'catalog/count/attribute/' . $type, $name );
238
+    }
239 239
 
240 240
 
241
-	/**
242
-	 * Returns the list of sub-client names configured for the client.
243
-	 *
244
-	 * @return array List of HTML client names
245
-	 */
246
-	protected function getSubClientNames()
247
-	{
248
-		return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames );
249
-	}
241
+    /**
242
+     * Returns the list of sub-client names configured for the client.
243
+     *
244
+     * @return array List of HTML client names
245
+     */
246
+    protected function getSubClientNames()
247
+    {
248
+        return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames );
249
+    }
250 250
 
251 251
 
252
-	/**
253
-	 * Sets the necessary parameter values in the view.
254
-	 *
255
-	 * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output
256
-	 * @param array &$tags Result array for the list of tags that are associated to the output
257
-	 * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
258
-	 * @return \Aimeos\MW\View\Iface Modified view object
259
-	 */
260
-	protected function setViewParams( \Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null )
261
-	{
262
-		if( !isset( $this->cache ) )
263
-		{
264
-			$context = $this->getContext();
265
-			$config = $context->getConfig();
252
+    /**
253
+     * Sets the necessary parameter values in the view.
254
+     *
255
+     * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output
256
+     * @param array &$tags Result array for the list of tags that are associated to the output
257
+     * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
258
+     * @return \Aimeos\MW\View\Iface Modified view object
259
+     */
260
+    protected function setViewParams( \Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null )
261
+    {
262
+        if( !isset( $this->cache ) )
263
+        {
264
+            $context = $this->getContext();
265
+            $config = $context->getConfig();
266 266
 
267
-			/** client/html/catalog/count/attribute/aggregate
268
-			 * Enables or disables generating product counts for the attribute catalog filter
269
-			 *
270
-			 * This configuration option allows shop owners to enable or disable product counts
271
-			 * for the attribute section of the catalog filter HTML client.
272
-			 *
273
-			 * @param boolean Disabled if "0", enabled if "1"
274
-			 * @since 2014.03
275
-			 * @see client/html/catalog/count/limit
276
-			 * @category Developer
277
-			 * @category User
278
-			 */
279
-			if( $config->get( 'client/html/catalog/count/attribute/aggregate', true ) == true )
280
-			{
281
-				/** client/html/catalog/count/limit
282
-				 * Limits the number of records that are used for product counts in the catalog filter
283
-				 *
284
-				 * The product counts in the catalog filter are generated by searching for all
285
-				 * products that match the criteria and then counting the number of products
286
-				 * that are available for each attribute or category.
287
-				 *
288
-				 * As counting huge amount of records (several 10 000 records) takes a long time,
289
-				 * the limit can cut down response times so the counts are available more quickly
290
-				 * in the front-end and the server load is reduced.
291
-				 *
292
-				 * Using a low limit can lead to incorrect numbers if the amount of found products
293
-				 * is very high. Approximate product counts are normally not a problem but it can
294
-				 * lead to the situation that visitors see that no products are available for
295
-				 * an attribute or in a category despite the fact that there would be at least
296
-				 * one.
297
-				 *
298
-				 * @param integer Number of records
299
-				 * @since 2014.03
300
-				 * @see client/html/catalog/count/attribute/aggregate
301
-				 * @category Developer
302
-				 * @category User
303
-				 */
304
-				$filter = $this->getProductListFilter( $view );
305
-				$filter->setSlice( 0, $config->get( 'client/html/catalog/count/limit', 10000 ) );
306
-				$filter->setSortations( array() ); // it's not necessary and slows down the query
267
+            /** client/html/catalog/count/attribute/aggregate
268
+             * Enables or disables generating product counts for the attribute catalog filter
269
+             *
270
+             * This configuration option allows shop owners to enable or disable product counts
271
+             * for the attribute section of the catalog filter HTML client.
272
+             *
273
+             * @param boolean Disabled if "0", enabled if "1"
274
+             * @since 2014.03
275
+             * @see client/html/catalog/count/limit
276
+             * @category Developer
277
+             * @category User
278
+             */
279
+            if( $config->get( 'client/html/catalog/count/attribute/aggregate', true ) == true )
280
+            {
281
+                /** client/html/catalog/count/limit
282
+                 * Limits the number of records that are used for product counts in the catalog filter
283
+                 *
284
+                 * The product counts in the catalog filter are generated by searching for all
285
+                 * products that match the criteria and then counting the number of products
286
+                 * that are available for each attribute or category.
287
+                 *
288
+                 * As counting huge amount of records (several 10 000 records) takes a long time,
289
+                 * the limit can cut down response times so the counts are available more quickly
290
+                 * in the front-end and the server load is reduced.
291
+                 *
292
+                 * Using a low limit can lead to incorrect numbers if the amount of found products
293
+                 * is very high. Approximate product counts are normally not a problem but it can
294
+                 * lead to the situation that visitors see that no products are available for
295
+                 * an attribute or in a category despite the fact that there would be at least
296
+                 * one.
297
+                 *
298
+                 * @param integer Number of records
299
+                 * @since 2014.03
300
+                 * @see client/html/catalog/count/attribute/aggregate
301
+                 * @category Developer
302
+                 * @category User
303
+                 */
304
+                $filter = $this->getProductListFilter( $view );
305
+                $filter->setSlice( 0, $config->get( 'client/html/catalog/count/limit', 10000 ) );
306
+                $filter->setSortations( array() ); // it's not necessary and slows down the query
307 307
 
308
-				$controller = \Aimeos\Controller\Frontend\Factory::createController( $context, 'catalog' );
309
-				$view->attributeCountList = $controller->aggregateIndex( $filter, 'index.attribute.id' );
310
-			}
308
+                $controller = \Aimeos\Controller\Frontend\Factory::createController( $context, 'catalog' );
309
+                $view->attributeCountList = $controller->aggregateIndex( $filter, 'index.attribute.id' );
310
+            }
311 311
 
312
-			$this->cache = $view;
313
-		}
312
+            $this->cache = $view;
313
+        }
314 314
 
315
-		return $this->cache;
316
-	}
315
+        return $this->cache;
316
+    }
317 317
 }
318 318
\ No newline at end of file
Please login to merge, or discard this patch.
client/html/src/Client/Html/Catalog/Count/Tree/Standard.php 1 patch
Indentation   +249 added lines, -249 removed lines patch added patch discarded remove patch
@@ -19,277 +19,277 @@
 block discarded – undo
19 19
  * @subpackage Html
20 20
  */
21 21
 class Standard
22
-	extends \Aimeos\Client\Html\Catalog\Base
23
-	implements \Aimeos\Client\Html\Common\Client\Factory\Iface
22
+    extends \Aimeos\Client\Html\Catalog\Base
23
+    implements \Aimeos\Client\Html\Common\Client\Factory\Iface
24 24
 {
25
-	/** client/html/catalog/count/tree/standard/subparts
26
-	 * List of HTML sub-clients rendered within the catalog count tree 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
-	 * @category Developer
57
-	 */
58
-	private $subPartPath = 'client/html/catalog/count/tree/standard/subparts';
59
-	private $subPartNames = array();
60
-	private $cache;
25
+    /** client/html/catalog/count/tree/standard/subparts
26
+     * List of HTML sub-clients rendered within the catalog count tree 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
+     * @category Developer
57
+     */
58
+    private $subPartPath = 'client/html/catalog/count/tree/standard/subparts';
59
+    private $subPartNames = array();
60
+    private $cache;
61 61
 
62 62
 
63
-	/**
64
-	 * Returns the HTML code for insertion into the body.
65
-	 *
66
-	 * @param string $uid Unique identifier for the output if the content is placed more than once on the same page
67
-	 * @param array &$tags Result array for the list of tags that are associated to the output
68
-	 * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
69
-	 * @return string HTML code
70
-	 */
71
-	public function getBody( $uid = '', array &$tags = array(), &$expire = null )
72
-	{
73
-		$view = $this->setViewParams( $this->getView(), $tags, $expire );
63
+    /**
64
+     * Returns the HTML code for insertion into the body.
65
+     *
66
+     * @param string $uid Unique identifier for the output if the content is placed more than once on the same page
67
+     * @param array &$tags Result array for the list of tags that are associated to the output
68
+     * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
69
+     * @return string HTML code
70
+     */
71
+    public function getBody( $uid = '', array &$tags = array(), &$expire = null )
72
+    {
73
+        $view = $this->setViewParams( $this->getView(), $tags, $expire );
74 74
 
75
-		$html = '';
76
-		foreach( $this->getSubClients() as $subclient ) {
77
-			$html .= $subclient->setView( $view )->getBody( $uid, $tags, $expire );
78
-		}
79
-		$view->treeBody = $html;
75
+        $html = '';
76
+        foreach( $this->getSubClients() as $subclient ) {
77
+            $html .= $subclient->setView( $view )->getBody( $uid, $tags, $expire );
78
+        }
79
+        $view->treeBody = $html;
80 80
 
81
-		/** client/html/catalog/count/tree/standard/template-body
82
-		 * Relative path to the HTML body template of the catalog count tree client.
83
-		 *
84
-		 * The template file contains the HTML code and processing instructions
85
-		 * to generate the result shown in the body of the frontend. The
86
-		 * configuration string is the path to the template file relative
87
-		 * to the templates directory (usually in client/html/templates).
88
-		 *
89
-		 * You can overwrite the template file configuration in extensions and
90
-		 * provide alternative templates. These alternative templates should be
91
-		 * named like the default one but with the string "standard" replaced by
92
-		 * an unique name. You may use the name of your project for this. If
93
-		 * you've implemented an alternative client class as well, "standard"
94
-		 * should be replaced by the name of the new class.
95
-		 *
96
-		 * @param string Relative path to the template creating code for the HTML page body
97
-		 * @since 2014.03
98
-		 * @category Developer
99
-		 * @see client/html/catalog/count/tree/standard/template-header
100
-		 */
101
-		$tplconf = 'client/html/catalog/count/tree/standard/template-body';
102
-		$default = 'catalog/count/tree-body-default.php';
81
+        /** client/html/catalog/count/tree/standard/template-body
82
+         * Relative path to the HTML body template of the catalog count tree client.
83
+         *
84
+         * The template file contains the HTML code and processing instructions
85
+         * to generate the result shown in the body of the frontend. The
86
+         * configuration string is the path to the template file relative
87
+         * to the templates directory (usually in client/html/templates).
88
+         *
89
+         * You can overwrite the template file configuration in extensions and
90
+         * provide alternative templates. These alternative templates should be
91
+         * named like the default one but with the string "standard" replaced by
92
+         * an unique name. You may use the name of your project for this. If
93
+         * you've implemented an alternative client class as well, "standard"
94
+         * should be replaced by the name of the new class.
95
+         *
96
+         * @param string Relative path to the template creating code for the HTML page body
97
+         * @since 2014.03
98
+         * @category Developer
99
+         * @see client/html/catalog/count/tree/standard/template-header
100
+         */
101
+        $tplconf = 'client/html/catalog/count/tree/standard/template-body';
102
+        $default = 'catalog/count/tree-body-default.php';
103 103
 
104
-		return $view->render( $view->config( $tplconf, $default ) );
105
-	}
104
+        return $view->render( $view->config( $tplconf, $default ) );
105
+    }
106 106
 
107 107
 
108
-	/**
109
-	 * Returns the HTML string for insertion into the header.
110
-	 *
111
-	 * @param string $uid Unique identifier for the output if the content is placed more than once on the same page
112
-	 * @param array &$tags Result array for the list of tags that are associated to the output
113
-	 * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
114
-	 * @return string|null String including HTML tags for the header on error
115
-	 */
116
-	public function getHeader( $uid = '', array &$tags = array(), &$expire = null )
117
-	{
118
-		$view = $this->setViewParams( $this->getView(), $tags, $expire );
108
+    /**
109
+     * Returns the HTML string for insertion into the header.
110
+     *
111
+     * @param string $uid Unique identifier for the output if the content is placed more than once on the same page
112
+     * @param array &$tags Result array for the list of tags that are associated to the output
113
+     * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
114
+     * @return string|null String including HTML tags for the header on error
115
+     */
116
+    public function getHeader( $uid = '', array &$tags = array(), &$expire = null )
117
+    {
118
+        $view = $this->setViewParams( $this->getView(), $tags, $expire );
119 119
 
120
-		$html = '';
121
-		foreach( $this->getSubClients() as $subclient ) {
122
-			$html .= $subclient->setView( $view )->getHeader( $uid, $tags, $expire );
123
-		}
124
-		$view->treeHeader = $html;
120
+        $html = '';
121
+        foreach( $this->getSubClients() as $subclient ) {
122
+            $html .= $subclient->setView( $view )->getHeader( $uid, $tags, $expire );
123
+        }
124
+        $view->treeHeader = $html;
125 125
 
126
-		/** client/html/catalog/count/tree/standard/template-header
127
-		 * Relative path to the HTML header template of the catalog count tree client.
128
-		 *
129
-		 * The template file contains the HTML code and processing instructions
130
-		 * to generate the HTML code that is inserted into the HTML page header
131
-		 * of the rendered page in the frontend. The configuration string is the
132
-		 * path to the template file relative to the templates directory (usually
133
-		 * in client/html/templates).
134
-		 *
135
-		 * You can overwrite the template file configuration in extensions and
136
-		 * provide alternative templates. These alternative templates should be
137
-		 * named like the default one but with the string "standard" replaced by
138
-		 * an unique name. You may use the name of your project for this. If
139
-		 * you've implemented an alternative client class as well, "standard"
140
-		 * should be replaced by the name of the new class.
141
-		 *
142
-		 * @param string Relative path to the template creating code for the HTML page head
143
-		 * @since 2014.03
144
-		 * @category Developer
145
-		 * @see client/html/catalog/count/tree/standard/template-body
146
-		 */
147
-		$tplconf = 'client/html/catalog/count/tree/standard/template-header';
148
-		$default = 'catalog/count/tree-header-default.php';
126
+        /** client/html/catalog/count/tree/standard/template-header
127
+         * Relative path to the HTML header template of the catalog count tree client.
128
+         *
129
+         * The template file contains the HTML code and processing instructions
130
+         * to generate the HTML code that is inserted into the HTML page header
131
+         * of the rendered page in the frontend. The configuration string is the
132
+         * path to the template file relative to the templates directory (usually
133
+         * in client/html/templates).
134
+         *
135
+         * You can overwrite the template file configuration in extensions and
136
+         * provide alternative templates. These alternative templates should be
137
+         * named like the default one but with the string "standard" replaced by
138
+         * an unique name. You may use the name of your project for this. If
139
+         * you've implemented an alternative client class as well, "standard"
140
+         * should be replaced by the name of the new class.
141
+         *
142
+         * @param string Relative path to the template creating code for the HTML page head
143
+         * @since 2014.03
144
+         * @category Developer
145
+         * @see client/html/catalog/count/tree/standard/template-body
146
+         */
147
+        $tplconf = 'client/html/catalog/count/tree/standard/template-header';
148
+        $default = 'catalog/count/tree-header-default.php';
149 149
 
150
-		return $view->render( $view->config( $tplconf, $default ) );
151
-	}
150
+        return $view->render( $view->config( $tplconf, $default ) );
151
+    }
152 152
 
153 153
 
154
-	/**
155
-	 * Returns the sub-client given by its name.
156
-	 *
157
-	 * @param string $type Name of the client type
158
-	 * @param string|null $name Name of the sub-client (Default if null)
159
-	 * @return \Aimeos\Client\Html\Iface Sub-client object
160
-	 */
161
-	public function getSubClient( $type, $name = null )
162
-	{
163
-		/** client/html/catalog/count/tree/decorators/excludes
164
-		 * Excludes decorators added by the "common" option from the catalog count tree html client
165
-		 *
166
-		 * Decorators extend the functionality of a class by adding new aspects
167
-		 * (e.g. log what is currently done), executing the methods of the underlying
168
-		 * class only in certain conditions (e.g. only for logged in users) or
169
-		 * modify what is returned to the caller.
170
-		 *
171
-		 * This option allows you to remove a decorator added via
172
-		 * "client/html/common/decorators/default" before they are wrapped
173
-		 * around the html client.
174
-		 *
175
-		 *  client/html/catalog/count/tree/decorators/excludes = array( 'decorator1' )
176
-		 *
177
-		 * This would remove the decorator named "decorator1" from the list of
178
-		 * common decorators ("\Aimeos\Client\Html\Common\Decorator\*") added via
179
-		 * "client/html/common/decorators/default" to the html client.
180
-		 *
181
-		 * @param array List of decorator names
182
-		 * @since 2015.08
183
-		 * @category Developer
184
-		 * @see client/html/common/decorators/default
185
-		 * @see client/html/catalog/count/tree/decorators/global
186
-		 * @see client/html/catalog/count/tree/decorators/local
187
-		 */
154
+    /**
155
+     * Returns the sub-client given by its name.
156
+     *
157
+     * @param string $type Name of the client type
158
+     * @param string|null $name Name of the sub-client (Default if null)
159
+     * @return \Aimeos\Client\Html\Iface Sub-client object
160
+     */
161
+    public function getSubClient( $type, $name = null )
162
+    {
163
+        /** client/html/catalog/count/tree/decorators/excludes
164
+         * Excludes decorators added by the "common" option from the catalog count tree html client
165
+         *
166
+         * Decorators extend the functionality of a class by adding new aspects
167
+         * (e.g. log what is currently done), executing the methods of the underlying
168
+         * class only in certain conditions (e.g. only for logged in users) or
169
+         * modify what is returned to the caller.
170
+         *
171
+         * This option allows you to remove a decorator added via
172
+         * "client/html/common/decorators/default" before they are wrapped
173
+         * around the html client.
174
+         *
175
+         *  client/html/catalog/count/tree/decorators/excludes = array( 'decorator1' )
176
+         *
177
+         * This would remove the decorator named "decorator1" from the list of
178
+         * common decorators ("\Aimeos\Client\Html\Common\Decorator\*") added via
179
+         * "client/html/common/decorators/default" to the html client.
180
+         *
181
+         * @param array List of decorator names
182
+         * @since 2015.08
183
+         * @category Developer
184
+         * @see client/html/common/decorators/default
185
+         * @see client/html/catalog/count/tree/decorators/global
186
+         * @see client/html/catalog/count/tree/decorators/local
187
+         */
188 188
 
189
-		/** client/html/catalog/count/tree/decorators/global
190
-		 * Adds a list of globally available decorators only to the catalog count tree html client
191
-		 *
192
-		 * Decorators extend the functionality of a class by adding new aspects
193
-		 * (e.g. log what is currently done), executing the methods of the underlying
194
-		 * class only in certain conditions (e.g. only for logged in users) or
195
-		 * modify what is returned to the caller.
196
-		 *
197
-		 * This option allows you to wrap global decorators
198
-		 * ("\Aimeos\Client\Html\Common\Decorator\*") around the html client.
199
-		 *
200
-		 *  client/html/catalog/count/tree/decorators/global = array( 'decorator1' )
201
-		 *
202
-		 * This would add the decorator named "decorator1" defined by
203
-		 * "\Aimeos\Client\Html\Common\Decorator\Decorator1" only to the html client.
204
-		 *
205
-		 * @param array List of decorator names
206
-		 * @since 2015.08
207
-		 * @category Developer
208
-		 * @see client/html/common/decorators/default
209
-		 * @see client/html/catalog/count/tree/decorators/excludes
210
-		 * @see client/html/catalog/count/tree/decorators/local
211
-		 */
189
+        /** client/html/catalog/count/tree/decorators/global
190
+         * Adds a list of globally available decorators only to the catalog count tree html client
191
+         *
192
+         * Decorators extend the functionality of a class by adding new aspects
193
+         * (e.g. log what is currently done), executing the methods of the underlying
194
+         * class only in certain conditions (e.g. only for logged in users) or
195
+         * modify what is returned to the caller.
196
+         *
197
+         * This option allows you to wrap global decorators
198
+         * ("\Aimeos\Client\Html\Common\Decorator\*") around the html client.
199
+         *
200
+         *  client/html/catalog/count/tree/decorators/global = array( 'decorator1' )
201
+         *
202
+         * This would add the decorator named "decorator1" defined by
203
+         * "\Aimeos\Client\Html\Common\Decorator\Decorator1" only to the html client.
204
+         *
205
+         * @param array List of decorator names
206
+         * @since 2015.08
207
+         * @category Developer
208
+         * @see client/html/common/decorators/default
209
+         * @see client/html/catalog/count/tree/decorators/excludes
210
+         * @see client/html/catalog/count/tree/decorators/local
211
+         */
212 212
 
213
-		/** client/html/catalog/count/tree/decorators/local
214
-		 * Adds a list of local decorators only to the catalog count tree html client
215
-		 *
216
-		 * Decorators extend the functionality of a class by adding new aspects
217
-		 * (e.g. log what is currently done), executing the methods of the underlying
218
-		 * class only in certain conditions (e.g. only for logged in users) or
219
-		 * modify what is returned to the caller.
220
-		 *
221
-		 * This option allows you to wrap local decorators
222
-		 * ("\Aimeos\Client\Html\Catalog\Decorator\*") around the html client.
223
-		 *
224
-		 *  client/html/catalog/count/tree/decorators/local = array( 'decorator2' )
225
-		 *
226
-		 * This would add the decorator named "decorator2" defined by
227
-		 * "\Aimeos\Client\Html\Catalog\Decorator\Decorator2" only to the html client.
228
-		 *
229
-		 * @param array List of decorator names
230
-		 * @since 2015.08
231
-		 * @category Developer
232
-		 * @see client/html/common/decorators/default
233
-		 * @see client/html/catalog/count/tree/decorators/excludes
234
-		 * @see client/html/catalog/count/tree/decorators/global
235
-		 */
213
+        /** client/html/catalog/count/tree/decorators/local
214
+         * Adds a list of local decorators only to the catalog count tree html client
215
+         *
216
+         * Decorators extend the functionality of a class by adding new aspects
217
+         * (e.g. log what is currently done), executing the methods of the underlying
218
+         * class only in certain conditions (e.g. only for logged in users) or
219
+         * modify what is returned to the caller.
220
+         *
221
+         * This option allows you to wrap local decorators
222
+         * ("\Aimeos\Client\Html\Catalog\Decorator\*") around the html client.
223
+         *
224
+         *  client/html/catalog/count/tree/decorators/local = array( 'decorator2' )
225
+         *
226
+         * This would add the decorator named "decorator2" defined by
227
+         * "\Aimeos\Client\Html\Catalog\Decorator\Decorator2" only to the html client.
228
+         *
229
+         * @param array List of decorator names
230
+         * @since 2015.08
231
+         * @category Developer
232
+         * @see client/html/common/decorators/default
233
+         * @see client/html/catalog/count/tree/decorators/excludes
234
+         * @see client/html/catalog/count/tree/decorators/global
235
+         */
236 236
 
237
-		return $this->createSubClient( 'catalog/count/tree/' . $type, $name );
238
-	}
237
+        return $this->createSubClient( 'catalog/count/tree/' . $type, $name );
238
+    }
239 239
 
240 240
 
241
-	/**
242
-	 * Returns the list of sub-client names configured for the client.
243
-	 *
244
-	 * @return array List of HTML client names
245
-	 */
246
-	protected function getSubClientNames()
247
-	{
248
-		return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames );
249
-	}
241
+    /**
242
+     * Returns the list of sub-client names configured for the client.
243
+     *
244
+     * @return array List of HTML client names
245
+     */
246
+    protected function getSubClientNames()
247
+    {
248
+        return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames );
249
+    }
250 250
 
251 251
 
252
-	/**
253
-	 * Sets the necessary parameter values in the view.
254
-	 *
255
-	 * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output
256
-	 * @param array &$tags Result array for the list of tags that are associated to the output
257
-	 * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
258
-	 * @return \Aimeos\MW\View\Iface Modified view object
259
-	 */
260
-	protected function setViewParams( \Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null )
261
-	{
262
-		if( !isset( $this->cache ) )
263
-		{
264
-			$context = $this->getContext();
265
-			$config = $context->getConfig();
252
+    /**
253
+     * Sets the necessary parameter values in the view.
254
+     *
255
+     * @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output
256
+     * @param array &$tags Result array for the list of tags that are associated to the output
257
+     * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
258
+     * @return \Aimeos\MW\View\Iface Modified view object
259
+     */
260
+    protected function setViewParams( \Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null )
261
+    {
262
+        if( !isset( $this->cache ) )
263
+        {
264
+            $context = $this->getContext();
265
+            $config = $context->getConfig();
266 266
 
267
-			/** client/html/catalog/count/tree/aggregate
268
-			 * Enables or disables generating product counts for the category catalog filter
269
-			 *
270
-			 * This configuration option allows shop owners to enable or disable product counts
271
-			 * for the tree section of the catalog filter HTML client.
272
-			 *
273
-			 * @param boolean Disabled if "0", enabled if "1"
274
-			 * @since 2014.03
275
-			 * @see client/html/catalog/count/limit
276
-			 */
277
-			if( $config->get( 'client/html/catalog/count/tree/aggregate', true ) == true )
278
-			{
279
-				/** client/html/catalog/count/limit
280
-				 * @see client/html/catalog/count/tree/aggregate
281
-				 */
282
-				$filter = $this->getProductListFilter( $view, false );
283
-				$filter->setSlice( 0, $config->get( 'client/html/catalog/count/limit', 10000 ) );
284
-				$filter->setSortations( array() ); // it's not necessary and slows down the query
267
+            /** client/html/catalog/count/tree/aggregate
268
+             * Enables or disables generating product counts for the category catalog filter
269
+             *
270
+             * This configuration option allows shop owners to enable or disable product counts
271
+             * for the tree section of the catalog filter HTML client.
272
+             *
273
+             * @param boolean Disabled if "0", enabled if "1"
274
+             * @since 2014.03
275
+             * @see client/html/catalog/count/limit
276
+             */
277
+            if( $config->get( 'client/html/catalog/count/tree/aggregate', true ) == true )
278
+            {
279
+                /** client/html/catalog/count/limit
280
+                 * @see client/html/catalog/count/tree/aggregate
281
+                 */
282
+                $filter = $this->getProductListFilter( $view, false );
283
+                $filter->setSlice( 0, $config->get( 'client/html/catalog/count/limit', 10000 ) );
284
+                $filter->setSortations( array() ); // it's not necessary and slows down the query
285 285
 
286
-				$controller = \Aimeos\Controller\Frontend\Factory::createController( $context, 'catalog' );
287
-				$view->treeCountList = $controller->aggregateIndex( $filter, 'index.catalog.id' );
288
-			}
286
+                $controller = \Aimeos\Controller\Frontend\Factory::createController( $context, 'catalog' );
287
+                $view->treeCountList = $controller->aggregateIndex( $filter, 'index.catalog.id' );
288
+            }
289 289
 
290
-			$this->cache = $view;
291
-		}
290
+            $this->cache = $view;
291
+        }
292 292
 
293
-		return $this->cache;
294
-	}
293
+        return $this->cache;
294
+    }
295 295
 }
Please login to merge, or discard this patch.