public function init() { parent::init(); $this->filter = array('country_id' => 0, 'region_id' => 0, 'city_id' => 0, 'type' => 0, 'obj_type_id' => 0, 'rooms' => 0, 'ot' => 0, 'wp' => 0); $addedFields = InfoPages::getAddedFields(); if ($addedFields) { $this->addedFields = $addedFields; foreach ($addedFields as $field) { $this->filter[$field['field']] = ''; } } }
public function getCriteriaForAdList() { $criteria = new CDbCriteria(); if ($this->widget_data) { $this->_filter = CJSON::decode($this->widget_data); if (issetModule('location')) { $this->setForCriteria($criteria, 'country_id', 'loc_country'); $this->setForCriteria($criteria, 'region_id', 'loc_region'); $this->setForCriteria($criteria, 'city_id', 'loc_city'); if (isset($this->_filter['country_id']) && $this->_filter['country_id']) { Yii::app()->controller->selectedCountry = $this->_filter['country_id']; } if (isset($this->_filter['region_id']) && $this->_filter['region_id']) { Yii::app()->controller->selectedRegion = $this->_filter['region_id']; } if (isset($this->_filter['city_id']) && $this->_filter['city_id']) { Yii::app()->controller->selectedCity = $this->_filter['city_id']; } } else { $this->setForCriteria($criteria, 'city_id', 'city_id'); if (isset($this->_filter['city_id']) && $this->_filter['city_id']) { Yii::app()->controller->selectedCity = $this->_filter['city_id']; } } $this->setForCriteria($criteria, 'type', 't.price_type'); $this->setForCriteria($criteria, 'obj_type_id', 't.obj_type_id'); if (!(issetModule('selecttoslider') && param('useRoomSlider') == 1)) { $this->setForCriteria($criteria, 'rooms', 't.num_of_rooms'); } $this->setForCriteria($criteria, 'ot', 't.ot'); $this->setForCriteria($criteria, 'wp', 't.count_img'); if (isset($this->_filter['type']) && $this->_filter['type']) { Yii::app()->controller->apType = $this->_filter['type']; } if (isset($this->_filter['obj_type_id']) && $this->_filter['obj_type_id']) { Yii::app()->controller->objType = $this->_filter['obj_type_id']; } if (isset($this->_filter['rooms']) && $this->_filter['rooms']) { Yii::app()->controller->roomsCount = $this->_filter['rooms']; } if (isset($this->_filter['ot']) && $this->_filter['ot']) { Yii::app()->controller->ot = $this->_filter['ot']; } if (isset($this->_filter['wp']) && $this->_filter['wp']) { Yii::app()->controller->wp = $this->_filter['wp']; } # new fields $newFieldsAll = InfoPages::getAddedFields(); if ($newFieldsAll) { foreach ($newFieldsAll as $field) { $this->setForCriteria($criteria, $field['field'], 't.' . $field['field'], true, $field); if (isset($this->_filter[$field['field']]) && $this->_filter[$field['field']]) { Yii::app()->controller->newFields[$field['field']] = $this->_filter[$field['field']]; } } } } //deb($criteria); return $criteria; }