Completed
Push — master ( b384ce...7658b0 )
by Aimeos
05:56
created
client/html/src/Client/Html/Basket/Standard/Standard.php 1 patch
Spacing   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * @since 2014.03
79 79
 	 * @category Developer
80 80
 	 */
81
-	private $subPartNames = array( 'detail', 'coupon' );
81
+	private $subPartNames = array('detail', 'coupon');
82 82
 	private $cache;
83 83
 
84 84
 
@@ -90,42 +90,42 @@  discard block
 block discarded – undo
90 90
 	 * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
91 91
 	 * @return string HTML code
92 92
 	 */
93
-	public function getBody( $uid = '', array &$tags = array(), &$expire = null )
93
+	public function getBody($uid = '', array &$tags = array(), &$expire = null)
94 94
 	{
95 95
 		$context = $this->getContext();
96 96
 		$view = $this->getView();
97 97
 
98 98
 		try
99 99
 		{
100
-			$view = $this->setViewParams( $view, $tags, $expire );
100
+			$view = $this->setViewParams($view, $tags, $expire);
101 101
 
102 102
 			$html = '';
103
-			foreach( $this->getSubClients() as $subclient ) {
104
-				$html .= $subclient->setView( $view )->getBody( $uid, $tags, $expire );
103
+			foreach ($this->getSubClients() as $subclient) {
104
+				$html .= $subclient->setView($view)->getBody($uid, $tags, $expire);
105 105
 			}
106 106
 			$view->standardBody = $html;
107 107
 		}
108
-		catch( \Aimeos\Client\Html\Exception $e )
108
+		catch (\Aimeos\Client\Html\Exception $e)
109 109
 		{
110
-			$error = array( $this->getContext()->getI18n()->dt( 'client', $e->getMessage() ) );
111
-			$view->standardErrorList = $view->get( 'standardErrorList', array() ) + $error;
110
+			$error = array($this->getContext()->getI18n()->dt('client', $e->getMessage()));
111
+			$view->standardErrorList = $view->get('standardErrorList', array()) + $error;
112 112
 		}
113
-		catch( \Aimeos\Controller\Frontend\Exception $e )
113
+		catch (\Aimeos\Controller\Frontend\Exception $e)
114 114
 		{
115
-			$error = array( $this->getContext()->getI18n()->dt( 'controller/frontend', $e->getMessage() ) );
116
-			$view->standardErrorList = $view->get( 'standardErrorList', array() ) + $error;
115
+			$error = array($this->getContext()->getI18n()->dt('controller/frontend', $e->getMessage()));
116
+			$view->standardErrorList = $view->get('standardErrorList', array()) + $error;
117 117
 		}
118
-		catch( \Aimeos\MShop\Exception $e )
118
+		catch (\Aimeos\MShop\Exception $e)
119 119
 		{
120
-			$error = array( $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ) );
121
-			$view->standardErrorList = $view->get( 'standardErrorList', array() ) + $error;
120
+			$error = array($this->getContext()->getI18n()->dt('mshop', $e->getMessage()));
121
+			$view->standardErrorList = $view->get('standardErrorList', array()) + $error;
122 122
 		}
123
-		catch( \Exception $e )
123
+		catch (\Exception $e)
124 124
 		{
125
-			$context->getLogger()->log( $e->getMessage() . PHP_EOL . $e->getTraceAsString() );
125
+			$context->getLogger()->log($e->getMessage().PHP_EOL.$e->getTraceAsString());
126 126
 
127
-			$error = array( $context->getI18n()->dt( 'client', 'A non-recoverable error occured' ) );
128
-			$view->standardErrorList = $view->get( 'standardErrorList', array() ) + $error;
127
+			$error = array($context->getI18n()->dt('client', 'A non-recoverable error occured'));
128
+			$view->standardErrorList = $view->get('standardErrorList', array()) + $error;
129 129
 		}
130 130
 
131 131
 		/** client/html/basket/standard/standard/template-body
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 		$tplconf = 'client/html/basket/standard/standard/template-body';
152 152
 		$default = 'basket/standard/body-default.php';
153 153
 
154
-		return $view->render( $view->config( $tplconf, $default ) );
154
+		return $view->render($view->config($tplconf, $default));
155 155
 	}
156 156
 
157 157
 
@@ -163,21 +163,21 @@  discard block
 block discarded – undo
163 163
 	 * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
164 164
 	 * @return string|null String including HTML tags for the header on error
165 165
 	 */
166
-	public function getHeader( $uid = '', array &$tags = array(), &$expire = null )
166
+	public function getHeader($uid = '', array &$tags = array(), &$expire = null)
167 167
 	{
168 168
 		try
169 169
 		{
170
-			$view = $this->setViewParams( $this->getView(), $tags, $expire );
170
+			$view = $this->setViewParams($this->getView(), $tags, $expire);
171 171
 
172 172
 			$html = '';
173
-			foreach( $this->getSubClients() as $subclient ) {
174
-				$html .= $subclient->setView( $view )->getHeader( $uid, $tags, $expire );
173
+			foreach ($this->getSubClients() as $subclient) {
174
+				$html .= $subclient->setView($view)->getHeader($uid, $tags, $expire);
175 175
 			}
176 176
 			$view->standardHeader = $html;
177 177
 		}
178
-		catch( \Exception $e )
178
+		catch (\Exception $e)
179 179
 		{
180
-			$this->getContext()->getLogger()->log( $e->getMessage() . PHP_EOL . $e->getTraceAsString() );
180
+			$this->getContext()->getLogger()->log($e->getMessage().PHP_EOL.$e->getTraceAsString());
181 181
 			return '';
182 182
 		}
183 183
 
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 		$tplconf = 'client/html/basket/standard/standard/template-header';
206 206
 		$default = 'basket/standard/header-default.php';
207 207
 
208
-		return $view->render( $view->config( $tplconf, $default ) );
208
+		return $view->render($view->config($tplconf, $default));
209 209
 	}
210 210
 
211 211
 
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	 * @param string|null $name Name of the sub-client (Default if null)
217 217
 	 * @return \Aimeos\Client\Html\Iface Sub-client object
218 218
 	 */
219
-	public function getSubClient( $type, $name = null )
219
+	public function getSubClient($type, $name = null)
220 220
 	{
221 221
 		/** client/html/basket/standard/decorators/excludes
222 222
 		 * Excludes decorators added by the "common" option from the basket standard html client
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 		 * @see client/html/basket/standard/decorators/global
293 293
 		 */
294 294
 
295
-		return $this->createSubClient( 'basket/standard/' . $type, $name );
295
+		return $this->createSubClient('basket/standard/'.$type, $name);
296 296
 	}
297 297
 
298 298
 
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 				 * @category Developer
321 321
 				 * @category User
322 322
 				 */
323
-				'stock' => $view->config( 'client/html/basket/require-stock', true ),
323
+				'stock' => $view->config('client/html/basket/require-stock', true),
324 324
 
325 325
 				/** client/html/basket/require-variant
326 326
 				 * A variant of a selection product must be chosen
@@ -338,55 +338,55 @@  discard block
 block discarded – undo
338 338
 				 * @category Developer
339 339
 				 * @category User
340 340
 				 */
341
-				'variant' => $view->config( 'client/html/basket/require-variant', true ),
341
+				'variant' => $view->config('client/html/basket/require-variant', true),
342 342
 			);
343 343
 
344
-			switch( $view->param( 'b_action' ) )
344
+			switch ($view->param('b_action'))
345 345
 			{
346 346
 				case 'add':
347
-					$this->addProducts( $view, $options );
347
+					$this->addProducts($view, $options);
348 348
 					break;
349 349
 				case 'delete':
350
-					$this->deleteProducts( $view );
350
+					$this->deleteProducts($view);
351 351
 					break;
352 352
 				default:
353
-					$this->editProducts( $view, $options );
353
+					$this->editProducts($view, $options);
354 354
 			}
355 355
 
356 356
 			parent::process();
357 357
 
358
-			$controller = \Aimeos\Controller\Frontend\Factory::createController( $context, 'basket' );
359
-			$controller->get()->check( \Aimeos\MShop\Order\Item\Base\Base::PARTS_PRODUCT );
358
+			$controller = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket');
359
+			$controller->get()->check(\Aimeos\MShop\Order\Item\Base\Base::PARTS_PRODUCT);
360 360
 		}
361
-		catch( \Aimeos\Client\Html\Exception $e )
361
+		catch (\Aimeos\Client\Html\Exception $e)
362 362
 		{
363
-			$error = array( $context->getI18n()->dt( 'client', $e->getMessage() ) );
364
-			$view->standardErrorList = $view->get( 'standardErrorList', array() ) + $error;
363
+			$error = array($context->getI18n()->dt('client', $e->getMessage()));
364
+			$view->standardErrorList = $view->get('standardErrorList', array()) + $error;
365 365
 		}
366
-		catch( \Aimeos\Controller\Frontend\Exception $e )
366
+		catch (\Aimeos\Controller\Frontend\Exception $e)
367 367
 		{
368
-			$error = array( $context->getI18n()->dt( 'controller/frontend', $e->getMessage() ) );
369
-			$view->standardErrorList = $view->get( 'standardErrorList', array() ) + $error;
368
+			$error = array($context->getI18n()->dt('controller/frontend', $e->getMessage()));
369
+			$view->standardErrorList = $view->get('standardErrorList', array()) + $error;
370 370
 		}
371
-		catch( \Aimeos\MShop\Plugin\Provider\Exception $e )
371
+		catch (\Aimeos\MShop\Plugin\Provider\Exception $e)
372 372
 		{
373
-			$errors = array( $context->getI18n()->dt( 'mshop', $e->getMessage() ) );
374
-			$errors = array_merge( $errors, $this->translatePluginErrorCodes( $e->getErrorCodes() ) );
373
+			$errors = array($context->getI18n()->dt('mshop', $e->getMessage()));
374
+			$errors = array_merge($errors, $this->translatePluginErrorCodes($e->getErrorCodes()));
375 375
 
376 376
 			$view->summaryErrorCodes = $e->getErrorCodes();
377
-			$view->standardErrorList = $view->get( 'standardErrorList', array() ) + $errors;
377
+			$view->standardErrorList = $view->get('standardErrorList', array()) + $errors;
378 378
 		}
379
-		catch( \Aimeos\MShop\Exception $e )
379
+		catch (\Aimeos\MShop\Exception $e)
380 380
 		{
381
-			$error = array( $context->getI18n()->dt( 'mshop', $e->getMessage() ) );
382
-			$view->standardErrorList = $view->get( 'standardErrorList', array() ) + $error;
381
+			$error = array($context->getI18n()->dt('mshop', $e->getMessage()));
382
+			$view->standardErrorList = $view->get('standardErrorList', array()) + $error;
383 383
 		}
384
-		catch( \Exception $e )
384
+		catch (\Exception $e)
385 385
 		{
386
-			$context->getLogger()->log( $e->getMessage() . PHP_EOL . $e->getTraceAsString() );
386
+			$context->getLogger()->log($e->getMessage().PHP_EOL.$e->getTraceAsString());
387 387
 
388
-			$error = array( $context->getI18n()->dt( 'client', 'A non-recoverable error occured' ) );
389
-			$view->standardErrorList = $view->get( 'standardErrorList', array() ) + $error;
388
+			$error = array($context->getI18n()->dt('client', 'A non-recoverable error occured'));
389
+			$view->standardErrorList = $view->get('standardErrorList', array()) + $error;
390 390
 		}
391 391
 	}
392 392
 
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 	 */
399 399
 	protected function getSubClientNames()
400 400
 	{
401
-		return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames );
401
+		return $this->getContext()->getConfig()->get($this->subPartPath, $this->subPartNames);
402 402
 	}
403 403
 
404 404
 
@@ -410,38 +410,38 @@  discard block
 block discarded – undo
410 410
 	 * @param string|null &$expire Result variable for the expiration date of the output (null for no expiry)
411 411
 	 * @return \Aimeos\MW\View\Iface Modified view object
412 412
 	 */
413
-	protected function setViewParams( \Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null )
413
+	protected function setViewParams(\Aimeos\MW\View\Iface $view, array &$tags = array(), &$expire = null)
414 414
 	{
415
-		if( !isset( $this->cache ) )
415
+		if (!isset($this->cache))
416 416
 		{
417 417
 			$context = $this->getContext();
418 418
 			$site = $context->getLocale()->getSite()->getCode();
419 419
 
420
-			if( ( $params = $context->getSession()->get( 'aimeos/catalog/detail/params/last' . $site ) ) !== null )
420
+			if (($params = $context->getSession()->get('aimeos/catalog/detail/params/last'.$site)) !== null)
421 421
 			{
422
-				$target = $view->config( 'client/html/catalog/detail/url/target' );
423
-				$controller = $view->config( 'client/html/catalog/detail/url/controller', 'catalog' );
424
-				$action = $view->config( 'client/html/catalog/detail/url/action', 'detail' );
425
-				$config = $view->config( 'client/html/catalog/detail/url/config', array() );
422
+				$target = $view->config('client/html/catalog/detail/url/target');
423
+				$controller = $view->config('client/html/catalog/detail/url/controller', 'catalog');
424
+				$action = $view->config('client/html/catalog/detail/url/action', 'detail');
425
+				$config = $view->config('client/html/catalog/detail/url/config', array());
426 426
 			}
427 427
 			else
428 428
 			{
429
-				$params = $context->getSession()->get( 'aimeos/catalog/lists/params/last' . $site, array() );
429
+				$params = $context->getSession()->get('aimeos/catalog/lists/params/last'.$site, array());
430 430
 
431
-				$target = $view->config( 'client/html/catalog/lists/url/target' );
432
-				$controller = $view->config( 'client/html/catalog/lists/url/controller', 'catalog' );
433
-				$action = $view->config( 'client/html/catalog/lists/url/action', 'list' );
434
-				$config = $view->config( 'client/html/catalog/lists/url/config', array() );
431
+				$target = $view->config('client/html/catalog/lists/url/target');
432
+				$controller = $view->config('client/html/catalog/lists/url/controller', 'catalog');
433
+				$action = $view->config('client/html/catalog/lists/url/action', 'list');
434
+				$config = $view->config('client/html/catalog/lists/url/config', array());
435 435
 
436 436
 			}
437 437
 
438
-			if( empty( $params ) === false )
438
+			if (empty($params) === false)
439 439
 			{
440
-				$view->standardParams = $this->getClientParams( $view->param() );
441
-				$view->standardBackUrl = $view->url( $target, $controller, $action, $params, array(), $config );
440
+				$view->standardParams = $this->getClientParams($view->param());
441
+				$view->standardBackUrl = $view->url($target, $controller, $action, $params, array(), $config);
442 442
 			}
443 443
 
444
-			$view->standardBasket = \Aimeos\Controller\Frontend\Factory::createController( $context, 'basket' )->get();
444
+			$view->standardBasket = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket')->get();
445 445
 
446 446
 			$this->cache = $view;
447 447
 		}
@@ -456,27 +456,27 @@  discard block
 block discarded – undo
456 456
 	 * @param \Aimeos\MW\View\Iface $view View object
457 457
 	 * @param array $options List of options for addProducts() in basket controller
458 458
 	 */
459
-	protected function addProducts( \Aimeos\MW\View\Iface $view, array $options )
459
+	protected function addProducts(\Aimeos\MW\View\Iface $view, array $options)
460 460
 	{
461 461
 		$this->clearCached();
462
-		$products = (array) $view->param( 'b_prod', array() );
463
-		$controller = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'basket' );
462
+		$products = (array) $view->param('b_prod', array());
463
+		$controller = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'basket');
464 464
 
465
-		if( ( $prodid = $view->param( 'b_prodid', '' ) ) !== '' )
465
+		if (($prodid = $view->param('b_prodid', '')) !== '')
466 466
 		{
467 467
 			$products[] = array(
468 468
 				'prodid' => $prodid,
469
-				'quantity' => $view->param( 'b_quantity', 1 ),
470
-				'attrvarid' => array_filter( (array) $view->param( 'b_attrvarid', array() ) ),
471
-				'attrconfid' => array_filter( (array) $view->param( 'b_attrconfid', array() ) ),
472
-				'attrhideid' => array_filter( (array) $view->param( 'b_attrhideid', array() ) ),
473
-				'attrcustid' => array_filter( (array) $view->param( 'b_attrcustid', array() ) ),
474
-				'warehouse' => $view->param( 'b_warehouse', 'default' ),
469
+				'quantity' => $view->param('b_quantity', 1),
470
+				'attrvarid' => array_filter((array) $view->param('b_attrvarid', array())),
471
+				'attrconfid' => array_filter((array) $view->param('b_attrconfid', array())),
472
+				'attrhideid' => array_filter((array) $view->param('b_attrhideid', array())),
473
+				'attrcustid' => array_filter((array) $view->param('b_attrcustid', array())),
474
+				'warehouse' => $view->param('b_warehouse', 'default'),
475 475
 			);
476 476
 		}
477 477
 
478
-		foreach( $products as $values ) {
479
-			$this->addProduct( $controller, $values, $options );
478
+		foreach ($products as $values) {
479
+			$this->addProduct($controller, $values, $options);
480 480
 		}
481 481
 	}
482 482
 
@@ -488,17 +488,17 @@  discard block
 block discarded – undo
488 488
 	 * @param array $values Associative list of key/value pairs from the view specifying the product
489 489
 	 * @param array $options List of options for addProducts() in basket frontend controller
490 490
 	 */
491
-	protected function addProduct( \Aimeos\Controller\Frontend\Basket\Iface $controller, array $values, array $options )
491
+	protected function addProduct(\Aimeos\Controller\Frontend\Basket\Iface $controller, array $values, array $options)
492 492
 	{
493 493
 		$controller->addProduct(
494
-			( isset( $values['prodid'] ) ? (string) $values['prodid'] : '' ),
495
-			( isset( $values['quantity'] ) ? (int) $values['quantity'] : 1 ),
494
+			(isset($values['prodid']) ? (string) $values['prodid'] : ''),
495
+			(isset($values['quantity']) ? (int) $values['quantity'] : 1),
496 496
 			$options,
497
-			( isset( $values['attrvarid'] ) ? array_filter( (array) $values['attrvarid'] ) : array() ),
498
-			( isset( $values['attrconfid'] ) ? array_filter( (array) $values['attrconfid'] ) : array() ),
499
-			( isset( $values['attrhideid'] ) ? array_filter( (array) $values['attrhideid'] ) : array() ),
500
-			( isset( $values['attrcustid'] ) ? array_filter( (array) $values['attrcustid'] ) : array() ),
501
-			( isset( $values['warehouse'] ) ? (string) $values['warehouse'] : 'default' )
497
+			(isset($values['attrvarid']) ? array_filter((array) $values['attrvarid']) : array()),
498
+			(isset($values['attrconfid']) ? array_filter((array) $values['attrconfid']) : array()),
499
+			(isset($values['attrhideid']) ? array_filter((array) $values['attrhideid']) : array()),
500
+			(isset($values['attrcustid']) ? array_filter((array) $values['attrcustid']) : array()),
501
+			(isset($values['warehouse']) ? (string) $values['warehouse'] : 'default')
502 502
 		);
503 503
 	}
504 504
 
@@ -508,14 +508,14 @@  discard block
 block discarded – undo
508 508
 	 *
509 509
 	 * @param \Aimeos\MW\View\Iface $view View object
510 510
 	 */
511
-	protected function deleteProducts( \Aimeos\MW\View\Iface $view )
511
+	protected function deleteProducts(\Aimeos\MW\View\Iface $view)
512 512
 	{
513 513
 		$this->clearCached();
514
-		$products = (array) $view->param( 'b_position', array() );
515
-		$controller = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'basket' );
514
+		$products = (array) $view->param('b_position', array());
515
+		$controller = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'basket');
516 516
 
517
-		foreach( $products as $position ) {
518
-			$controller->deleteProduct( $position );
517
+		foreach ($products as $position) {
518
+			$controller->deleteProduct($position);
519 519
 		}
520 520
 	}
521 521
 
@@ -526,28 +526,28 @@  discard block
 block discarded – undo
526 526
 	 * @param \Aimeos\MW\View\Iface $view View object
527 527
 	 * @param array $options List of options for editProducts() in basket controller
528 528
 	 */
529
-	protected function editProducts( \Aimeos\MW\View\Iface $view, array $options )
529
+	protected function editProducts(\Aimeos\MW\View\Iface $view, array $options)
530 530
 	{
531 531
 		$this->clearCached();
532
-		$products = (array) $view->param( 'b_prod', array() );
533
-		$controller = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'basket' );
532
+		$products = (array) $view->param('b_prod', array());
533
+		$controller = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'basket');
534 534
 
535
-		if( ( $position = $view->param( 'b_position', '' ) ) !== '' )
535
+		if (($position = $view->param('b_position', '')) !== '')
536 536
 		{
537 537
 			$products[] = array(
538 538
 				'position' => $position,
539
-				'quantity' => $view->param( 'b_quantity', 1 ),
540
-				'attrconf-code' => array_filter( (array) $view->param( 'b_attrconfcode', array() ) )
539
+				'quantity' => $view->param('b_quantity', 1),
540
+				'attrconf-code' => array_filter((array) $view->param('b_attrconfcode', array()))
541 541
 			);
542 542
 		}
543 543
 
544
-		foreach( $products as $values )
544
+		foreach ($products as $values)
545 545
 		{
546 546
 			$controller->editProduct(
547
-				( isset( $values['position'] ) ? (int) $values['position'] : 0 ),
548
-				( isset( $values['quantity'] ) ? (int) $values['quantity'] : 1 ),
547
+				(isset($values['position']) ? (int) $values['position'] : 0),
548
+				(isset($values['quantity']) ? (int) $values['quantity'] : 1),
549 549
 				$options,
550
-				( isset( $values['attrconf-code'] ) ? array_filter( (array) $values['attrconf-code'] ) : array() )
550
+				(isset($values['attrconf-code']) ? array_filter((array) $values['attrconf-code']) : array())
551 551
 			);
552 552
 		}
553 553
 	}
Please login to merge, or discard this patch.