• メインページ
  • データ構造
  • ファイル
  • ファイル一覧

AdvancedHotelSearchPageHeader.php

00001 <?php
00002 require_once('PageHeader.php');
00003 
00007 class AdvancedHotelSearchPageHeader extends PageHeader {
00008 
00009         const AREA_INPUT_ERROR_MESSAGE = 'エリアを選択してください';
00010         
00016         private static $HOTEL_TYPES = array (
00017                 "" => "すべて", 
00018         "1" =>"旅館", 
00019                 "2" => "ペンション", 
00020         "3" => "ホテル", 
00021                 "4" => "コンドミニアム", 
00022                 "5" => "トレーラーハウス", 
00023                 "6" => "ユースホステル", 
00024                 "7" => "ロッジ", 
00025                 "8" => "貸別荘", 
00026                 "9" => "民宿"
00027         );
00028                 
00030         private $hotel_type = null;     
00031         
00033         private $serv_id = null;        
00034         
00036         private $recommend_results_per_page = 5;                
00037 
00039         private $near_results_per_page = 5;     
00040         
00042         private $error_flg;
00043         
00045         private $error_message;
00046         
00052         public function __construct($fileName) {
00053                 parent::__construct($fileName);
00054                 
00055                 /*
00056                  * ホテルの形式
00057                  */
00058                 if (array_key_exists('hotel_type',$_GET) && is_numeric($_GET['hotel_type'])) {
00059                         $this->hotel_type = $_GET['hotel_type'];
00060                 }
00061                 /*
00062                  * ホテルIDの形式
00063                  */
00064                 if (array_key_exists('serv_id',$_GET) && is_numeric($_GET['serv_id'])) {
00065                         $this->serv_id = $_GET['serv_id'];
00066                 }
00067 
00068                 /*
00069                  * エラーフラグ
00070                  */
00071                 if (array_key_exists('error_flg',$_GET) && is_numeric($_GET['error_flg'])) {
00072                         $this->error_flg = $_GET['error_flg'];
00073                 }
00074                 
00075         }
00076 
00077         
00084         public function assignParams($hotel, $recommend_flag = false, $near_flag = false) {
00085                 parent::assignParams($hotel);
00086 
00087                 /*
00088                  * 検索結果の1ページ当たりの表示件数
00089                  */
00090                 $hotel->setParam('results_per_page', VC_RESULTPAERPAGE);
00091                 
00092                 /*
00093                  * ホテルの形式
00094                  */
00095                 if ($this->hotel_type) {
00096                         $hotel->setParam('hotel_type',$this->hotel_type);
00097                 }
00098 
00099                 /*
00100                  * ホテルIDの形式
00101                  */
00102                 if ($this->serv_id) {
00103                         $hotel->setParam('serv_id',$this->serv_id);
00104                 }
00105                 
00106                 /*
00107                  * おすすめ検索をする
00108                  */
00109                 if($recommend_flag == true){
00110                         if($this->error_flg){
00111                                 $hotel->setParam('larea_cd', '');
00112                                 $hotel->setParam('sarea_cd', '');
00113                                 $hotel->setParam('city_cd', '');
00114                                 $hotel->setParam('hotel_type', '');
00115                                 $hotel->setParam('price_min', '');
00116                                 $hotel->setParam('price_max', '');
00117                         }
00118                         /*
00119                          * 都市は検索しない
00120                          */
00121                         $hotel->setParam('city_cd', '');
00122                         /*
00123                          * 検索条件をセット
00124                          */
00125                         $hotel->setParam('keyword', $this->getOneSpecialKeyword());
00126                         $hotel->setParam('results_per_page', $this->recommend_results_per_page);
00127                 }
00128                 
00129                 /*
00130                  * エラーメッセージをセット
00131                  */
00132                 if ($this->error_flg) {
00133                         if($this->error_flg == 1){
00134                                 $this->error_message = self::AREA_INPUT_ERROR_MESSAGE;
00135                         }
00136                 }
00137         }
00138 
00139         
00146         public function assignDetailParams($hotel) {
00147                 parent::assignParams($hotel);
00148                         
00149                 /*
00150                  * パラメータ初期化
00151                  */
00152                 $hotel->setParam('serv_name', '');
00153                 $hotel->setParam('larea_cd', '');
00154                 $hotel->setParam('sarea_cd', '');       
00155                 
00156                 /*
00157                  * 検索結果の1ページ当たりの表示件数
00158                  */
00159                 $hotel->setParam('results_per_page', '1');
00160                 
00161                 /*
00162                  * ホテルの形式
00163                  */
00164                 if ($this->hotel_type) {
00165                         $hotel->setParam('hotel_type',$this->hotel_type);
00166                 }
00167 
00168                 /*
00169                  * ホテルIDの形式
00170                  */
00171                 if ($this->serv_id) {
00172                         $hotel->setParam('serv_id',$this->serv_id);
00173                 }
00174                 
00175         }
00176 
00177         
00184         public function assignNearParams($hotel) {
00185                 parent::assignParams($hotel);
00186 
00187                 /*
00188                  * 不要パラメータ初期化
00189                  */
00190                 $hotel->setParam('serv_id', '');
00191                 $hotel->setParam('larea_cd', '');
00192 
00193                 /*
00194                  * ホテルの形式
00195                  */
00196                 if ($this->hotel_type) {
00197                         $hotel->setParam('hotel_type',$this->hotel_type);
00198                 }
00199                                 
00200                 /*
00201                  * パラメータセット
00202                  */
00203                 $hotel->setParam('sort_by', 'distance');
00204                 $hotel->setParam('results_per_page', $this->near_results_per_page + 1); // +1は出力時に中心ホテルの情報を後で除外するため
00205                 $hotel->setParam('lat', $_SESSION['LAT_DETAIL']);
00206                 $hotel->setParam('lng', $_SESSION['LNG_DETAIL']);
00207                 $hotel->setParam('ladius', '100000');
00208         }
00209         
00216         public function assignRecommendParams($hotel) {
00217                 $this->assignParams($hotel);
00218                 
00219                 /*
00220                  * ホテルの形式
00221                  */
00222                 if ($this->hotel_type) {
00223                         $hotel->setParam('hotel_type',$this->hotel_type);
00224                 }               
00225         }
00226 
00234         public function getOneSpecialKeyword() {
00235                 
00236                 $specialkey_array = explode(',' , VC_SPECIALSKEYWORD);
00237                 $array_randkey = array_rand($specialkey_array);
00238                 
00239                 if(0 <= $array_randkey){
00240                         $specialkey = $specialkey_array[$array_randkey];
00241                         return $specialkey;
00242                 }
00243                 else
00244                 {
00245                         return false;   
00246                 }
00247                 
00248         }
00249         
00250         
00256         public function isAdvancedSearchOptionOn() {
00257                 return $this->sort_by || $this->c_card 
00258                                 || $this->price_min || $this->price_max
00259                                 || $this->hotel_type || $this->sort_by;
00260         }               
00261         
00268         protected function renderHotelType($itemHtml) {
00269                 $options = '';
00270                 
00271                 foreach (self::$HOTEL_TYPES as $code => $name) {
00272                         $options .= '<label>' . '<input type="radio" name="hotel_type" value="' . $code . '" '; 
00273                         if (($this->hotel_type && $code == $this->hotel_type)
00274                                 || (!$this->hotel_type && $code == '')) {
00275                                 $options .= 'checked'; 
00276                         }
00277                         $options .= '>'. '&nbsp;'. $name. '</label>';
00278                 }
00279                 
00280                 $itemHtml = str_replace('${HOTEL_TYPES}',$options,$itemHtml);
00281                 
00282                 return $itemHtml;
00283         }
00284 
00291         protected function renderErrorMessage($itemHtml) {
00292                 
00293                 /*
00294                  * エラーメッセージがなければ初期化
00295                  */
00296                 if(!$this->error_flg){
00297                         $this->error_message = '';      
00298                 }
00299                 $itemHtml = str_replace('${ERROR_MESSAGE}', $this->error_message, $itemHtml);
00300                 return $itemHtml;       
00301         }       
00302         
00308         function render() {
00309                 global $_GET;
00310 
00311                 /*
00312                  * 元ネタとなるビュー部分を取得する。
00313                  */
00314             $itemHtml = $this->view;
00315 
00316                 $itemHtml = $this->renderKeyword($itemHtml);            
00317                 
00318                 $itemHtml = $this->renderLArea($itemHtml, 'JP', '地方');
00319                 $itemHtml = $this->renderSArea($itemHtml, $this->larea_cd);
00320                 $itemHtml = $this->renderCityBySArea($itemHtml, $this->sarea_cd, $this->city_cd);
00321                 
00322                 $itemHtml = $this->renderFlippering($itemHtml);         
00323                 $itemHtml = $this->renderHotelType($itemHtml);
00324                 $itemHtml = $this->renderSortBy($itemHtml);
00325                 $itemHtml = $this->renderSortOrder($itemHtml);
00326                 $itemHtml = $this->renderPrice($itemHtml);
00327                 $itemHtml = $this->renderCreditCardOption($itemHtml);                                   
00328                 $itemHtml = $this->renderLocationCodes($itemHtml);
00329 
00330                 $itemHtml = $this->renderErrorMessage($itemHtml);
00331                 
00332                 
00333                 return $itemHtml;
00334         }
00335 }
00336 ?>

バリューコマース ウェブサービス トラベルAPIサンプル ドキュメンテーションに対してTue Jan 11 2011 19:25:14に生成されました。  doxygen 1.7.2