| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 | 
							- <?php
 
- /**
 
-  *
 
-  * PHP Pro Bid $Id$ /VukK0Hre6WTrofQaK8GMWWb9OA4n6/hc5mCM+ioXXA=
 
-  *
 
-  * @link        http://www.phpprobid.com
 
-  * @copyright   Copyright (c) 2015 Online Ventures Software & CodeCube SRL
 
-  * @license     http://www.phpprobid.com/license Commercial License
 
-  *
 
-  * @version     7.6
 
-  */
 
- /**
 
-  * product attributes view helper class
 
-  */
 
- namespace Ppb\View\Helper;
 
- use Cube\View\Helper\AbstractHelper,
 
-     Ppb\Service\CustomFields as CustomFieldsService;
 
- class ProductAttributes extends AbstractHelper
 
- {
 
-     /**
 
-      *
 
-      * custom fields service
 
-      *
 
-      * @var \Ppb\Service\CustomFields
 
-      */
 
-     protected $_customFieldsService;
 
-     /**
 
-      *
 
-      * product attributes input array
 
-      *
 
-      * @var array
 
-      */
 
-     protected $_productAttributes;
 
-     /**
 
-      *
 
-      * get custom fields table service
 
-      *
 
-      * @return \Ppb\Service\CustomFields
 
-      */
 
-     public function getCustomFieldsService()
 
-     {
 
-         if (!$this->_customFieldsService instanceof CustomFieldsService) {
 
-             $this->setCustomFieldsService(
 
-                 new CustomFieldsService());
 
-         }
 
-         return $this->_customFieldsService;
 
-     }
 
-     /**
 
-      *
 
-      * set custom fields table service
 
-      *
 
-      * @param \Ppb\Service\CustomFields $customFieldsService
 
-      *
 
-      * @return $this
 
-      */
 
-     public function setCustomFieldsService(CustomFieldsService $customFieldsService)
 
-     {
 
-         $this->_customFieldsService = $customFieldsService;
 
-         return $this;
 
-     }
 
-     /**
 
-      *
 
-      * main helper method
 
-      *
 
-      * @param mixed $productAttributes
 
-      *
 
-      * @return $this
 
-      */
 
-     public function productAttributes($productAttributes = null)
 
-     {
 
-         if ($productAttributes !== null) {
 
-             $this->setProductAttributes(
 
-                 $productAttributes);
 
-         }
 
-         return $this;
 
-     }
 
-     /**
 
-      *
 
-      * set product attributes input array
 
-      *
 
-      * @param mixed $productAttributes
 
-      *
 
-      * @return $this
 
-      */
 
-     public function setProductAttributes($productAttributes)
 
-     {
 
-         $this->_productAttributes = \Ppb\Utility::unserialize($productAttributes);
 
-         return $this;
 
-     }
 
-     /**
 
-      *
 
-      * get product attributes input array
 
-      *
 
-      * @return array
 
-      */
 
-     public function getProductAttributes()
 
-     {
 
-         return $this->_productAttributes;
 
-     }
 
-     /**
 
-      *
 
-      * format product attributes corresponding for the sale listing for display purposes
 
-      *
 
-      * @param string $separator
 
-      *
 
-      * @return string|null
 
-      */
 
-     public function display($separator = '; ')
 
-     {
 
-         $productAttributes = $this->getProductAttributes();
 
-         if (count($productAttributes) > 0) {
 
-             $output = array();
 
-             $customFieldsService = $this->getCustomFieldsService();
 
-             $translate = $this->getTranslate();
 
-             foreach ($productAttributes as $key => $value) {
 
-                 $customField = $customFieldsService->findBy('id', $key);
 
-                 $multiOptions = \Ppb\Utility::unserialize($customField['multiOptions']);
 
-                 $multiOptions = array_filter(array_combine($multiOptions['key'], $multiOptions['value']));
 
-                 $multiOptionsValue = (isset($multiOptions[$value])) ? $multiOptions[$value] : 'N/A';
 
-                 $output[] = $translate->_($customField['label']) . ': ' . $translate->_($multiOptionsValue);
 
-             }
 
-             return implode($separator, $output);
 
-         }
 
-         return null;
 
-     }
 
- }
 
 
  |