コード例 #1
0
ファイル: TopLocation.php プロジェクト: romeo14/wallfeet
 protected function renderContent()
 {
     yii::beginProfile('loc');
     $session = new CHttpSession();
     $session->open();
     $newCountry = $this->newCountry ? $this->newCountry : ($session['top-country'] ? $session['top-country'] : $this->defaultCountry);
     $session['top-country'] = $newCountry;
     $newCity = $this->newCity ? $this->newCity : ($session['top-city'] ? $session['top-city'] : $this->defaultCity);
     $session['top-location'] = $newCity;
     if ($newCountry == "international") {
         $country = 'international';
         $city = GeoCityApi::getCityByName($newCity);
         if ($city) {
             $cities = GeoCityApi::getTopPrioritiesInternational($city->id);
         } else {
             $cities = GeoCityApi::getTopPrioritiesInternational();
         }
     } else {
         $country = GeoCountryApi::getCountryByName($newCountry);
         $city = GeoCityApi::getCityByName($newCity);
         if ($country && $city) {
             $cities = GeoCityApi::getTopPrioritiesByCountry($country->id, $city->id);
         } elseif ($country) {
             $cities = GeoCityApi::getTopPrioritiesByCountry($country->id);
         }
     }
     if ($country && $cities) {
         $this->render('topLocation', array('city' => $city, 'country' => $country, 'current' => $this->current, 'cities' => $cities));
     }
     yii::endProfile('loc');
 }
コード例 #2
0
 public static function getFeaturedBuilder($count, $location = null)
 {
     if ($location) {
         $city = GeoCityApi::getCityByName($location['city']);
         $criteria = new CDbCriteria();
         $criteria->condition = 'featured=:featured AND city_id=:city';
         $criteria->params = array(':featured' => 1, ':city' => $city->id);
         if ($count) {
             $criteria->limit = $count;
         }
         $criteria->order = 'rand()';
         $builders = UserBuilderProfile::model()->findAll($criteria);
         $countBuilders = count($builders);
         if ($countBuilders < $count) {
             $total = $count - $countBuilders;
             $criteria = new CDbCriteria();
             $criteria->condition = 'featured=:featured AND state_id=:state AND city_id!=:city';
             $criteria->params = array(':featured' => 1, ':state' => $city->state_id, ':city' => $city->id);
             if ($count) {
                 $criteria->limit = $total;
             }
             $criteria->order = 'rand()';
             $buildersState = UserBuilderProfile::model()->findAll($criteria);
             $builders = ArrayUtils::joinArray($builders, $buildersState);
             $countBuilders = count($builders);
             if ($countBuilders < $count) {
                 $total = $count - $countBuilders;
                 $country = GeoCountryApi::getCountryByName($location['country']);
                 $criteria = new CDbCriteria();
                 $criteria->condition = 'featured=:featured AND state_id!=:state AND city_id!=:city AND country_id=:country';
                 $criteria->params = array(':featured' => 1, ':state' => $city->state_id, ':city' => $city->id, ':country' => $country->id);
                 if ($count) {
                     $criteria->limit = $total;
                 }
                 $criteria->order = 'rand()';
                 $buildersCountry = UserBuilderProfile::model()->findAll($criteria);
                 $builders = ArrayUtils::joinArray($builders, $buildersCountry);
             }
         }
         if ($builders) {
             return $builders;
         } else {
             return false;
         }
     } else {
         $criteria = new CDbCriteria();
         $criteria->condition = 'featured=:featured';
         $criteria->params = array(':featured' => 1);
         if ($count) {
             $criteria->limit = $count;
         }
         $criteria->order = 'rand()';
         $builders = UserBuilderProfile::model()->findAll($criteria);
         if ($builders) {
             return $builders;
         } else {
             return false;
         }
     }
 }
コード例 #3
0
ファイル: GeoCityApi.php プロジェクト: romeo14/wallfeet
 public static function getTopPrioritiesInternational($excludeCityId = '', $count = '', $metroOnly = true)
 {
     $dependencyState = new CDbCacheDependency('SELECT MAX(updated_time) FROM geo_state');
     $india = GeoCountryApi::getCountryByName('india');
     if ($india) {
         $stateModels = GeoState::model()->cache(1000, $dependencyState)->findAll('country_id!=:countryId', array(':countryId' => $india->id));
         if (empty($stateModels)) {
             return false;
         }
         foreach ($stateModels as $state) {
             $states[] = $state->id;
         }
         $criteria = new CDbCriteria();
         $criteria->addInCondition('state_id', $states);
         if ($metroOnly) {
             $criteria->addCondition('metro=1');
         }
         if ($count) {
             $criteria->limit = $count;
         }
         if ($excludeCityId) {
             //$criteria->addCondition('id=!id',array(':id'=>$excludeCityId));
             $criteria->addCondition("id!={$excludeCityId}");
         }
         $criteria->order = 'priority ASC';
         $dependencyCity = new CDbCacheDependency('SELECT MAX(updated_time) FROM geo_city');
         $cities = GeoCity::model()->cache(1000, $dependencyCity)->findAll($criteria);
         if (!empty($cities)) {
             return $cities;
         } else {
             return false;
         }
     }
 }
コード例 #4
0
ファイル: TopCities.php プロジェクト: romeo14/wallfeet
 protected function renderContent()
 {
     yii::beginProfile('top-cities');
     $country = GeoCountryApi::getCountryByName($this->country);
     $cities = GeoCityApi::getTopPrioritiesByCountry($country->id);
     $this->render('topCities', array('cities' => $cities));
     yii::endProfile('top-cities');
 }
コード例 #5
0
ファイル: StateController.php プロジェクト: romeo14/wallfeet
 public function actionGetStateList($country = 'india', $model = '')
 {
     if ($country) {
         $country = GeoCountryApi::getCountryByName('india');
         if ($country) {
             $country_id = $country->id;
             $list = GeoStateApi::getList($country_id);
         }
     }
     if (!$model) {
         $model = new GeoState();
     }
     $this->renderPartial('getStateList', array('list' => $list, 'model' => $model));
 }
コード例 #6
0
ファイル: GeoCity.php プロジェクト: romeo14/wallfeet
 public function searchInternational()
 {
     // Warning: Please modify the following code to remove attributes that
     // should not be searched.
     $criteria = new CDbCriteria();
     $criteria->compare('id', $this->id);
     $criteria->compare('city', $this->city, true);
     $criteria->compare('metro', $this->metro);
     $criteria->compare('priority', $this->priority);
     $criteria->compare('state_id', $this->state_id);
     $criteria->compare('updated_time', $this->updated_time, true);
     $criteria->compare('updated_by', $this->updated_by, true);
     $criteria->compare('created_time', $this->created_time, true);
     $criteria->compare('created_by', $this->created_by, true);
     $criteria->order = 'priority ASC';
     $criteria->with = 'state';
     $criteria->alias = 't';
     $india = GeoCountryApi::getCountryByName('india');
     $criteria->addCondition("state.country_id!={$india->id}");
     return new CActiveDataProvider($this, array('criteria' => $criteria));
 }
コード例 #7
0
ファイル: PropertyApi.php プロジェクト: romeo14/wallfeet
 /**
  * This method gets the count and returns the featured properties
  * Returns the model if found.
  * Returns false if not found.
  *
  * @param string $count
  * @return model || boolean
  */
 public static function getFeaturedProperties($count, $location = null)
 {
     if ($location) {
         $city = GeoCityApi::getCityByName($location['city']);
         $criteria = new CDbCriteria();
         $criteria->condition = 'featured=:featured  AND city_id=:city';
         $criteria->params = array(':featured' => 1, ':city' => $city->id);
         if ($count) {
             $criteria->limit = $count;
         }
         $criteria->order = 'rand()';
         $properties = Property::model()->findAll($criteria);
         $countProperties = count($properties);
         if ($countProperties < $count) {
             $total = $count - $countProperties;
             $country = GeoCountryApi::getCountryByName($location['country']);
             $criteria = new CDbCriteria();
             $criteria->condition = 'featured=:featured  AND state_id=:state AND city_id!=:cityId';
             $criteria->params = array(':featured' => 1, ':state' => $city->state_id, ':cityId' => $city->id);
             $criteria->limit = $total;
             $criteria->order = 'rand()';
             $propertiesState = Property::model()->findAll($criteria);
             $properties = ArrayUtils::joinArray($properties, $propertiesState);
             $countProperties = count($properties);
             if ($countProperties < $count) {
                 $total = $count - $countProperties;
                 $criteria = new CDbCriteria();
                 $criteria->condition = 'featured=:featured  AND state_id!=:state AND city_id!=:cityId';
                 $criteria->params = array(':featured' => 1, ':state' => $city->state_id, ':cityId' => $city->id);
                 $criteria->limit = $total;
                 $criteria->order = 'rand()';
                 $propertiesState = Property::model()->findAll($criteria);
                 $properties = ArrayUtils::joinArray($properties, $propertiesState);
             }
         }
         if ($properties) {
             return $properties;
         } else {
             return false;
         }
     } else {
         $criteria = new CDbCriteria();
         $criteria->condition = 'featured=:featured';
         $criteria->params = array(':featured' => 1);
         if ($count) {
             $criteria->limit = $count;
         }
         $criteria->order = 'rand()';
         $properties = Property::model()->findAll($criteria);
         if ($properties) {
             return $properties;
         } else {
             return false;
         }
     }
 }