Exemple #1
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;
 }
 public static function getChildrenSIDBySID($item_sid, $field_sid = null)
 {
     $children_sids = array();
     if ($field_sid) {
         $children = SJB_DB::query('SELECT sid FROM listing_field_tree WHERE parent_sid = ?n AND	`field_sid` = ?n', $item_sid);
     } else {
         $children = SJB_DB::query("SELECT sid FROM listing_field_tree WHERE parent_sid = ?n", $item_sid);
     }
     if (!empty($children)) {
         foreach ($children as $child) {
             $children_sids[] = $child['sid'];
             $children_sids = array_merge($children_sids, SJB_ListingFieldTreeManager::getChildrenSIDBySID($child['sid']));
         }
     }
     return $children_sids;
 }
Exemple #3
0
 function setValue($value)
 {
     //	in order to search child items also
     if (!empty($value) && !is_array($value) && $this->property && $this->property->type->getDisplayAsSelectBoxes()) {
         $values = explode(',', $value);
         $valuesWithChild = $values;
         foreach ($values as $parentNode) {
             $childSIDs = SJB_ListingFieldTreeManager::getChildrenSIDBySID($parentNode);
             $valuesWithChild = array_merge($valuesWithChild, $childSIDs);
         }
         $value = implode(',', $valuesWithChild);
     }
     $this->value = $value;
 }