/**
  * @param string city
  * @param string checkIn d.m.Y date
  * @param int duration # of nights inside hotel
  * @param array $rooms
  *  [Х][adt] - amount of adults inside room,
  *  [Х][chd] - amount of childs inside room,
  *  [Х][chdAge] - age of child inside room,
  *  [Х][cots] - cots inside room (0 or 1),
  */
 public function actionDefault($city, $checkIn, $duration, array $rooms, $format = 'json')
 {
     $hotelSearchParams = new HotelSearchParams();
     $hotelSearchParams->checkIn = date('Y-m-d', strtotime($checkIn));
     $possibleCities = CityManager::getCitiesWithHotels($city);
     if (!empty($possibleCities)) {
         $hotelSearchParams->city = City::model()->findByPk($possibleCities[0]['id']);
     } else {
         $city = CityManager::getCities($city);
         if (!empty($city)) {
             $hotelSearchParams->city = City::model()->findByPk($city[0]['id']);
         }
     }
     $hotelSearchParams->duration = $duration;
     foreach ($rooms as $i => $room) {
         if ($room['chd'] == 1) {
             $hotelSearchParams->addRoom($room['adt'], $room['cots'], $room['chdAge']);
         } elseif ($room['chd'] == 0) {
             $hotelSearchParams->addRoom($room['adt'], $room['cots'], false);
         } else {
             $this->sendError(200, 'Only 0 or 1 child at one hotel room accepted');
             Yii::app()->end();
         }
     }
     if (empty($possibleCities)) {
         $this->results = array('hotels' => array(), 'hotelsDetails' => array());
     } else {
         $this->results = HotelManager::sendRequestToHotelProvider($hotelSearchParams);
         if (!$this->results) {
             $this->results = array();
         }
     }
     $cacheId = md5(serialize($hotelSearchParams));
     $this->results['cacheId'] = $cacheId;
     $this->results['searchParams'] = $hotelSearchParams->getJsonObject();
     if ($format == 'json') {
         $this->sendJson($this->results);
     } elseif ($format == 'xml') {
         $this->sendXml($this->results, 'hotelSearchResults');
     } else {
         $this->sendError(400, 'Incorrect response format');
         Yii::app()->end();
     }
 }
 /**
  * Disables the feature
  */
 public static function disable()
 {
     remove_action('add_meta_boxes', array(__CLASS__, 'register_metaboxes'));
     remove_action('save_post', array(__CLASS__, 'save_metabox_data'));
     self::$enabled = false;
 }
 /**
  * Gets images from the first post marked as 'hotel' by HotelManager in default language
  * @return Ambigous <Ambigous, multitype:, boolean, multitype:Ambigous <NULL> >
  */
 public static function get_images_from_closest_hotel_in_default_language($args = array())
 {
     $args['post_parent'] = HotelManager::get_hotel_id(null, true);
     return self::get_images_from_post($args);
 }