00001 <?php
00002 require_once('PageHeader.php');
00003
00009 class TourSearchPageHeader extends PageHeader {
00010
00016 private static $DEPARTURE_TIME = array (
00017 "" => "指定なし",
00018 "1" => "午前",
00019 "2" => "午後"
00020 );
00021
00027 private static $SORT_BY_OPTIONS = array (
00028 "" => "指定なし",
00029 "minprice" => "価格の安い順",
00030 "maxprice" => "価格の高い順"
00031 );
00032
00033 private static $TERM_MAX_OPTIONS = array (
00034 "" => "指定なし",
00035 "1" => "1日間",
00036 "2" => "2日間",
00037 "3" => "3日間",
00038 "4" => "4日間",
00039 "5" => "5日間"
00040 );
00041
00043 protected $dept_city_cd = null;
00044
00046 protected $region_cd = null;
00047
00049 protected $ctry_cd = null;
00050
00052 protected $dept_time_cd = null;
00053
00055 protected $term_max = null;
00056
00058 protected $online_book = null;
00059
00061 protected $transp_serv = null;
00062
00064 protected $child_disc = null;
00065
00067 protected $mile = null;
00068
00074 public function __construct($fileName) {
00075 parent::__construct($fileName);
00076
00077 if (array_key_exists('dept_city_cd',$_GET) && $_GET['dept_city_cd'] != '') {
00078 $this->dept_city_cd = $_GET['dept_city_cd'];
00079 }
00080
00081 if (array_key_exists('region_cd',$_GET) && $_GET['region_cd'] != '') {
00082 $this->region_cd = $_GET['region_cd'];
00083 }
00084
00085 if (array_key_exists('ctry_cd',$_GET) && $_GET['ctry_cd'] != '') {
00086 $this->ctry_cd = $_GET['ctry_cd'];
00087 }
00088
00089 if (array_key_exists('dept_time_cd',$_GET) && is_numeric($_GET['dept_time_cd'])) {
00090 $this->dept_time_cd = $_GET['dept_time_cd'];
00091 }
00092
00093 if (array_key_exists('term_max',$_GET) && is_numeric($_GET['term_max'])) {
00094 $this->term_max = $_GET['term_max'];
00095 }
00096
00097 if (array_key_exists('online_book',$_GET) && $_GET['online_book'] != '') {
00098 $this->online_book = $_GET['online_book'];
00099 }
00100
00101 if (array_key_exists('transp_serv',$_GET) && $_GET['transp_serv'] != '') {
00102 $this->transp_serv = $_GET['transp_serv'];
00103 }
00104
00105 if (array_key_exists('child_disc',$_GET) && $_GET['child_disc'] != '') {
00106 $this->child_disc = $_GET['child_disc'];
00107 }
00108
00109 if (array_key_exists('mile',$_GET) && $_GET['mile'] != '') {
00110 $this->mile = $_GET['mile'];
00111 }
00112 }
00113
00120 public function assignParams($tour) {
00121 parent::assignParams($tour);
00122
00123 if ($this->dept_city_cd) {
00124 $tour->setParam('dept_city_cd', $this->dept_city_cd);
00125 }
00126
00127 if ($this->region_cd) {
00128 $tour->setParam('region_cd', $this->region_cd);
00129 }
00130
00131 if ($this->ctry_cd) {
00132 $tour->setParam('ctry_cd', $this->ctry_cd);
00133 }
00134
00135 if ($this->dept_time_cd) {
00136 $tour->setParam('dept_time_cd', $this->dept_time_cd);
00137 }
00138
00139 if ($this->term_max) {
00140 $tour->setParam('term_max', $this->term_max);
00141 }
00142
00143 if ($this->online_book) {
00144 $tour->setParam('ticket_kodawari', 'online_book');
00145 }
00146
00147 if ($this->mile) {
00148 $tour->setParam('ticket_kodawari', 'mile');
00149 }
00150
00151 if ($this->transp_serv) {
00152 $tour->setParam('tour_kodawari', 'transp_serv');
00153 }
00154
00155 if ($this->child_disc) {
00156 $tour->setParam('tour_kodawari', 'child_disc');
00157 }
00158 }
00159
00165 protected function isAdvancedSearchOptionOn() {
00166 return $this->dept_time_cd || $this->price_max
00167 || $this->online_book || $this->transp_serv
00168 || $this->child_disc || $this->mile
00169 || $this->sort_by;
00170 }
00171
00177 protected function getSortByOptions() {
00178 return self::$SORT_BY_OPTIONS;
00179 }
00180
00187 protected function renderTermMaxOptions($itemHtml) {
00188 $options = '';
00189
00190 foreach (self::$TERM_MAX_OPTIONS as $code => $name) {
00191 $options .= '<option value="' . $code . '" ';
00192 if (($this->term_max && $code == $this->term_max)
00193 || (!$this->term_max && $code == '')) {
00194 $options .= 'selected';
00195 }
00196
00197 $options .= '>' . $name . '</option>';
00198 }
00199
00200 $itemHtml = str_replace('${TERM_MAX_OPTION}',$options,$itemHtml);
00201
00202 return $itemHtml;
00203 }
00204
00211 protected function renderDepartureCity($itemHtml) {
00212 $itemHtml = str_replace('${DEPARTURE_CITY}',
00213 $this->dept_city_cd? htmlspecialchars($this->dept_city_cd) : '', $itemHtml);
00214
00215 return $itemHtml;
00216 }
00217
00224 protected function renderDepartureTime($itemHtml) {
00225 $options = '';
00226
00227 foreach (self::$DEPARTURE_TIME as $code => $name) {
00228 $options .= '<option value="' . $code . '" ';
00229 if (($this->dept_time_cd && $code == $this->dept_time_cd)
00230 || (!$this->dept_time_cd && $code == '')) {
00231 $options .= 'selected';
00232 }
00233
00234 $options .= '>' . $name . '</option>';
00235 }
00236
00237 $itemHtml = str_replace('${DEPARTURE_TIME}',$options,$itemHtml);
00238
00239 return $itemHtml;
00240 }
00241
00248 protected function renderKodawariOptions($itemHtml) {
00249 $itemHtml = str_replace('${ONLINE_BOOK}',$this->online_book?'checked':'',$itemHtml);
00250 $itemHtml = str_replace('${TRANSP_SERV}',$this->transp_serv?'checked':'',$itemHtml);
00251 $itemHtml = str_replace('${CHILD_DISC}',$this->child_disc?'checked':'',$itemHtml);
00252 $itemHtml = str_replace('${MILE}',$this->mile?'checked':'',$itemHtml);
00253
00254 return $itemHtml;
00255 }
00256
00262 protected function render() {
00263 global $_GET;
00264
00265
00266
00267
00268 $itemHtml = $this->view;
00269
00270 $itemHtml = $this->renderDepartureCity($itemHtml);
00271 $itemHtml = $this->renderRegion($itemHtml, $this->region_cd);
00272 $itemHtml = $this->renderCountry($itemHtml, $this->region_cd, $this->ctry_cd, '国・地域', array('JP'));
00273 $itemHtml = $this->renderCityByCountry($itemHtml, $this->ctry_cd, $this->city_cd);
00274 $itemHtml = $this->renderPrice($itemHtml);
00275 $itemHtml = $this->renderLocationCodes($itemHtml);
00276
00277 $itemHtml = $this->renderTermMaxOptions($itemHtml);
00278 $itemHtml = $this->renderDepartureTime($itemHtml);
00279 $itemHtml = $this->renderKodawariOptions($itemHtml);
00280 $itemHtml = $this->renderSortBy($itemHtml);
00281 $itemHtml = $this->renderSortOrder($itemHtml);
00282 $itemHtml = $this->renderFlippering($itemHtml);
00283
00284 return $itemHtml;
00285 }
00286 }
00287 ?>