Пример #1
0
 /**
  * Return field class
  *
  * @param \XLite\Model\Attribute $attribute Attribute
  * @param string                 $value     Value
  *
  * @return string
  */
 protected function getFieldClass(\XLite\Model\Attribute $attribute, $value)
 {
     $class = str_replace(' ', '-', strtolower($attribute->getTypes($attribute->getType())));
     if (\XLite\Model\Attribute::TYPE_CHECKBOX == $attribute->getType()) {
         $class .= ' ' . (static::t('Yes') == $value ? 'checked' : 'no-checked');
     }
     return $class;
 }
Пример #2
0
 /**
  * Assign attribute condition
  *
  * @param \XLite\Model\Attribute $attribute Attribute
  * @param mixed                  $value     Value
  *
  * @return void
  */
 public function assignAttributeCondition(\XLite\Model\Attribute $attribute, $value)
 {
     $result = null;
     $alias = 'av' . $attribute->getId();
     $getConditionFunc = 'getCondition' . $attribute->getTypes($attribute->getType(), true);
     $where = $this->{$getConditionFunc}($attribute, $value, $alias);
     if ($where) {
         if (is_array($where)) {
             foreach ($where as $w) {
                 $this->andWhere($w);
             }
         } else {
             $this->andWhere($where);
         }
         $attr = 'attribute' . $attribute->getId();
         $this->leftJoin('p.attributeValue' . $attribute->getType(), $alias, 'WITH', $alias . '.attribute = :' . $attr);
         $this->setParameter($attr, $attribute);
         if ($attribute::TYPE_SELECT == $attribute->getType()) {
             $this->leftJoin($alias . '.attribute_option', $alias . 'o');
         }
     }
 }
Пример #3
0
 /**
  * Return true if attribute allows tags in its values
  *
  * @param \XLite\Model\Attribute $attr Attribute
  *
  * @return boolean
  */
 protected function isAttributeValueAllowsTags(\XLite\Model\Attribute $attr)
 {
     return $attr->getType() == \XLite\Model\Attribute::TYPE_TEXT;
 }
Пример #4
0
 /**
  * Prepare attribute element 
  * 
  * @param \XLite\Model\Attribute $attribute    Attribute
  * @param array                  $filterValues Filter values defined in prepareAttributesList()
  *  
  * @return array
  */
 protected function prepareAttributeElement(\XLite\Model\Attribute $attribute, array $filterValues)
 {
     $result = null;
     if ($attribute::TYPE_SELECT == $attribute->getType()) {
         $category = \XLite\Core\Database::getRepo('XLite\\Model\\Category')->find($this->getCategoryId());
         if ($category) {
             $options = $category->getAttributeOptionsByAttribute($attribute);
         }
     }
     if ($attribute::TYPE_SELECT != $attribute->getType() || 0 < count($options)) {
         $params = array('fieldName' => 'filter[attribute][' . $attribute->getId() . ']', 'label' => $attribute->getName(), 'attribute' => $attribute, 'useColon' => false, 'value' => isset($filterValues[$attribute->getId()]) ? $filterValues[$attribute->getId()] : '');
         $class = 'type-' . strtolower($attribute->getType());
         if ($attribute::TYPE_CHECKBOX == $attribute->getType() && $params['value']) {
             $class .= ' checked';
         } elseif ($attribute::TYPE_SELECT == $attribute->getType()) {
             $params['options'] = $options;
         }
         $result = array('class' => $class, 'widjet' => $this->getWidget($params, $attribute->getFilterWidgetClass()));
     }
     return $result;
 }
 /**
  * {@inheritDoc}
  */
 public function getType()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getType', array());
     return parent::getType();
 }