protected function _decorateItems($items)
 {
     $listingFieldListItemManager = SJB_ObjectMother::createListingFieldListItemManager();
     $values = $listingFieldListItemManager->getHashedListItemsByFieldSID($this->field['sid']);
     $values = $this->getSortedValues($values);
     $listData = array();
     foreach ($values as $id => $value) {
         $listData[$value] = isset($items[$id]) ? $items[$id] : 0;
     }
     return $listData;
 }
Exemplo n.º 2
0
 protected function _decorateItems($items)
 {
     if (!empty($this->field['parent']) && in_array($this->field['field'], array($this->field['parent'] . '_State', $this->field['parent'] . '_Country'))) {
         $fieldInfo = SJB_ListingFieldManager::getFieldInfoBySID($this->field['sid']);
         if ($this->field['field'] == $this->field['parent'] . '_State') {
             $values = SJB_StatesManager::getHashedListItems($fieldInfo['display_as']);
         } elseif ($this->field['field'] == $this->field['parent'] . '_Country') {
             $values = SJB_CountriesManager::getHashedListItems($fieldInfo['display_as']);
         }
     } else {
         $listingFieldListItemManager = SJB_ObjectMother::createListingFieldListItemManager();
         $values = $listingFieldListItemManager->getHashedListItemsByFieldSID($this->field['sid']);
     }
     $values = $this->getSortedValues($values);
     $listData = array();
     foreach ($values as $id => $value) {
         $listData[$value] = isset($items[$id]) ? $items[$id] : 0;
     }
     return $listData;
 }
Exemplo n.º 3
0
 private function _getRequestdata(array $parameters)
 {
     $res = array();
     for ($i = 0; $i < $this->getLevel(); $i++) {
         $value = $this->_getValue($i);
         $filterItem = $this->schema[$i];
         $field = $filterItem['field'];
         $parent = isset($parameters['parent']) ? $parameters['parent'] : false;
         $this->type = $filterItem['type'];
         switch ($filterItem['type']) {
             case 'tree':
                 $sids = SJB_ListingFieldTreeManager::getChildrenSIDBySID($value);
                 $sids = array_merge($sids, array($value));
                 $sids = implode(",", $sids);
                 $res[$field]['tree'] = $sids;
                 break;
             case 'string':
             case 'integer':
                 $res[$field]['equal'] = $value;
             case 'list':
             case 'multilist':
                 if ($parent && in_array($field, array($parent . '_State', $parent . '_Country'))) {
                     $fieldInfo = SJB_ListingFieldManager::getFieldInfoBySID($filterItem['sid']);
                     if ($field == $parent . '_State') {
                         $listValues = SJB_StatesManager::getHashedListItems($fieldInfo['display_as']);
                     } elseif ($field == $parent . '_Country') {
                         $listValues = SJB_CountriesManager::getHashedListItems($fieldInfo['display_as']);
                     }
                 } else {
                     $listingFieldListItemManager = SJB_ObjectMother::createListingFieldListItemManager();
                     $listValues = $listingFieldListItemManager->getHashedListItemsByFieldSID($filterItem['sid']);
                 }
                 foreach ($listValues as $id => $val) {
                     if (strtolower($val) == strtolower($value)) {
                         $value = $id;
                     }
                 }
                 if ($filterItem['type'] == 'multilist') {
                     $res[$field]['multi_like'][] = $value;
                 } else {
                     $res[$field]['equal'] = $value;
                 }
                 break;
         }
     }
     $res['active']['equal'] = 1;
     if (!empty($this->listing_type_id)) {
         $listing_type_sid = SJB_ListingTypeManager::getListingTypeSIDByID($this->listing_type_id);
         if (!$listing_type_sid) {
             trigger_error("Can't set filter by listing type for unknown type: '" . $this->listing_type_id . "'.", E_USER_WARNING);
         }
         $res['listing_type_sid']['equal'] = $listing_type_sid;
         if (SJB_ListingTypeManager::getWaitApproveSettingByListingType($listing_type_sid)) {
             $res['status']['equal'] = 'approved';
         }
     }
     return $res;
 }