00001 <?php
00002
00003
00004
00005
00006
00007 session_start();
00008 require_once('VCSDBDriver/VCSDBDriverLocationCodes.php');
00009 require_once('VCSDBDriver/VCSDBDriverHotel.php');
00010 require_once('FormattedItem.php');
00011 require_once('PageFrameConfig.php');
00012 require_once('PageSectionBase.php');
00013
00023 class PageFrame extends PageSectionBase {
00024
00026 protected $view;
00027
00029 protected $keyword = null;
00030
00032 protected $page = null;
00033
00035 protected $larea_cd = null;
00036
00038 protected $sarea_cd = null;
00039
00041 protected $city_cd = null;
00042
00048 private static $HOTEL_TYPES = array (
00049 "1" =>"旅館",
00050 "2" => "ペンション",
00051 "3" => "ホテル",
00052 "4" => "コンドミニアム",
00053 "5" => "トレーラーハウス",
00054 "6" => "ユースホステル",
00055 "7" => "ロッジ",
00056 "8" => "貸別荘",
00057 "9" => "民宿"
00058 );
00059
00061 private $hotel_type = null;
00062
00064 private $serv_id = null;
00065
00067 private $serv_name = null;
00068
00069
00071 protected $hotelsearchform_flag = null;
00072
00074 protected $hotelsearchform_html = null;
00075
00077 protected $hotelsearchresults_flag = null;
00078
00080 protected $hotelsearchresults_html = null;
00081
00083 protected $hotelrecommendation_flag = null;
00084
00086 protected $hotelrecommendation_html = null;
00087
00089 protected $hoteldetail_flag = null;
00090
00092 protected $hoteldetail_html = null;
00093
00095 protected $nearhotels_flag = null;
00096
00098 protected $nearhotels_html = null;
00099
00101 protected $googlemap_flag = null;
00102
00104 protected $googlemap_html = null;
00105
00109 protected $pagekeywords = null;
00110
00112 private $items;
00113
00114
00116 private $errorMessage;
00117
00123 public function __construct($fileName) {
00124 global $_GET;
00125
00126
00127
00128
00129 $this->view = $this->loadFile($fileName);
00130
00131
00132
00133
00134 if (array_key_exists('keyword',$_GET) && $_GET['keyword'] != '') {
00135 $this->keyword = $_GET['keyword'];
00136 }
00137
00138
00139
00140
00141 if (array_key_exists('page',$_GET) && is_numeric($_GET['page'])) {
00142 $this->page = $_GET['page'];
00143 }
00144
00145
00146
00147
00148 if (array_key_exists('larea_cd',$_GET) && is_numeric($_GET['larea_cd'])) {
00149 $this->larea_cd = $_GET['larea_cd'];
00150 }
00151
00152
00153
00154
00155 if (array_key_exists('sarea_cd',$_GET) && is_numeric($_GET['sarea_cd'])) {
00156 $this->sarea_cd = $_GET['sarea_cd'];
00157 }
00158
00159
00160
00161
00162 if (array_key_exists('city_cd',$_GET) && $_GET['city_cd'] != '') {
00163 $this->city_cd = $_GET['city_cd'];
00164 }
00165
00166
00167
00168
00169 if (array_key_exists('hotel_type',$_GET) && $_GET['hotel_type'] != '') {
00170 $this->hotel_type = $_GET['hotel_type'];
00171 }
00172
00173
00174
00175 if (array_key_exists('serv_id',$_GET) && $_GET['serv_id'] != '') {
00176 $this->serv_id = $_GET['serv_id'];
00177 }
00178
00179
00180
00181 if (array_key_exists('serv_name',$_GET) && $_GET['serv_name'] != '') {
00182 $this->serv_name = $_GET['serv_name'];
00183 }
00184
00185
00186
00187 if(strstr($this->view,'${VC_AREA_HOTELTYPE_SEARCHFORM}')){
00188 $this->setHotelSearchFormFlag(true);
00189 }
00190
00191
00192
00193
00194 if(strstr($this->view,'${VC_RETRIEVALLIST}')){
00195 $this->setHotelSearchResultsFlag(true);
00196 }
00197
00198
00199
00200
00201 if(strstr($this->view,'${VC_RECOMMENDATION}')){
00202 $this->setHotelRecommendationFlag(true);
00203 }
00204
00205
00206
00207
00208 if(strstr($this->view,'${VC_HOTELINFO}')){
00209 $this->setHotelDetailFlag(true);
00210 }
00211
00212
00213
00214
00215 if(strstr($this->view,'${VC_NEARHOTELS}')){
00216 $this->setNearHotelsFlag(true);
00217 }
00218
00219
00220
00221 if(strstr($this->view,'${VC_HOTELMAP}')){
00222 $this->setGoogleMapFlag(true);
00223 }
00224
00225
00226 }
00227
00228
00229 public function setHotelSearchFormFlag($flag){
00230 $this->hotelsearchform_flag = $flag;
00231 }
00232
00233 public function isHotelSearchFormFlag(){
00234 return $this->hotelsearchform_flag;
00235 }
00236
00237 public function setHotelSearchFormHTML($innerHTML){
00238 $this->hotelsearchform_html = $innerHTML;
00239 }
00240 public function getHotelSearchFormHTML(){
00241 return $this->hotelsearchform_html;
00242 }
00243
00244 public function setHotelSearchResultsFlag($flag){
00245 $this->hotelsearchresults_flag = $flag;
00246 }
00247
00248 public function isHotelSearchResultsFlag(){
00249 return $this->hotelsearchresults_flag;
00250 }
00251
00252 public function setHotelSearchResultsHTML($innerHTML){
00253 $this->hotelsearchresults_html = $innerHTML;
00254 }
00255 public function getHotelSearchResultsHTML(){
00256 return $this->hotelsearchresults_html;
00257 }
00258
00259 public function setHotelRecommendationFlag($flag){
00260 $this->hotelrecommendation_flag = $flag;
00261 }
00262
00263 public function isHotelRecommendationFlag(){
00264 return $this->hotelrecommendation_flag;
00265 }
00266
00267 public function setHotelRecommendationHTML($innerHTML){
00268 $this->hotelrecommendation_html = $innerHTML;
00269 }
00270 public function getHotelRecommendationHTML(){
00271 return $this->hotelrecommendation_html;
00272 }
00273
00274
00275 public function setHotelDetailFlag($flag){
00276 $this->hoteldetail_flag = $flag;
00277 }
00278
00279 public function isHotelDetailFlag(){
00280 return $this->hoteldetail_flag;
00281 }
00282
00283 public function setHotelDetailHTML($innerHTML){
00284 $this->hoteldetail_html = $innerHTML;
00285 }
00286 public function getHotelDetailHTML(){
00287 return $this->hoteldetail_html;
00288 }
00289
00290 public function setNearHotelsFlag($flag){
00291 $this->nearhotels_flag = $flag;
00292 }
00293
00294 public function isNearHotelsFlag(){
00295 return $this->nearhotels_flag;
00296 }
00297
00298 public function setNearHotelsHTML($innerHTML){
00299 $this->nearhotels_html = $innerHTML;
00300 }
00301 public function getNearHotelsHTML(){
00302 return $this->nearhotels_html;
00303 }
00304
00305 public function setGoogleMapFlag($flag){
00306 $this->googlemap_flag = $flag;
00307 }
00308
00309 public function isGoogleMapFlag(){
00310 return $this->googlemap_flag;
00311 }
00312 public function setGoogleMapHTML($innerHTML){
00313 $this->googlemap_html = $innerHTML;
00314 }
00315 public function getGoogleMapHTML(){
00316 return $this->googlemap_html;
00317 }
00318
00319
00326 private function makeSearchParam($text, $extra = null) {
00327 global $_GET;
00328
00330 foreach($_GET as $name => $value) {
00331 if ($name == 'page'
00332 || ($extra && array_key_exists($name, $extra))) {
00333 continue;
00334 }
00335
00336 $link .= '&' . $name . '=' . $value;
00337 }
00338 if ($extra) {
00339 foreach ($extra as $name => $value) {
00340 $link .= '&' . $name . '=' . $value;
00341 }
00342 }
00343 return '<a href="' . $link . '">' . $text . '</a> ';
00344 }
00345
00351 private function makePageKeywords() {
00352 $page_keywords = '';
00353 $page_keywords = $this->getLAreaName('JP') . " ";
00354 $page_keywords .= $this->getSAreaName($this->larea_cd) . " ";
00355 $page_keywords .= $this->getCityNameBySArea($this->sarea_cd, $this->city_cd) . "";
00356 $page_keywords .= $this->getHotelTypeName();
00357 return $page_keywords;
00358 }
00359
00367 private function makeATag($lareacd, $text, $extra = null) {
00368 global $_GET;
00369
00370 $link = 'hotel_results.php?larea_cd=' . (string)$lareacd;
00371
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388 return '<a href="' . $link . '">' . $text . '</a>';
00389 }
00390
00396 private function makeDisabledATag($text) {
00397 return '<a class="disabled">' . $text . '</a>';
00398 }
00399
00400
00406 private function makeLAreaLinkList() {
00407 $controls = '';
00408
00409 $larea_list = $this->getLAreaList();
00410
00411 foreach($larea_list as $larea_cd => $larea_name){
00412
00413 if($larea_cd == $this->larea_cd){
00414 $controls .= $this->makeDisabledATag($larea_name);
00415 }
00416 else
00417 {
00418 $controls .= $this->makeATag($larea_cd, $larea_name);
00419 }
00420 $controls .= " | ";
00421 }
00422
00423 $controls = substr($controls , 0, -3);
00424
00425 return $controls;
00426 }
00427
00428
00435 public function getLAreaList($countryCode = 'JP') {
00436
00437 $larea_array = array();
00438
00439 if ($countryCode) {
00440 $larea_codes = VCSDBDriverLocationCodes::getLAreasInCountry($countryCode);
00441 if ($larea_codes) {
00442 foreach ($larea_codes as $larea_code) {
00443 $code = (string)$larea_code->cd;
00444 $name = (string)$larea_code->name;
00445 $larea_array[$code] = $name;
00446 }
00447 }
00448 }
00449 return $larea_array;
00450
00451 }
00452
00461
00462
00463
00464 public function getLAreaSAreaList($countryCode = 'JP') {
00465
00466 $area_array = array();
00467
00468 $i = 0;
00469 $j = 0;
00470
00471 if ($countryCode) {
00472
00473 $larea_codes = VCSDBDriverLocationCodes::getLAreasInCountry($countryCode);
00474 if ($larea_codes) {
00475
00476 foreach ($larea_codes as $larea_code) {
00477 $j = 0;
00478 $lAreaCode = (string)$larea_code->cd;
00479
00480 if ($lAreaCode != '') {
00481
00482 $sarea_codes = VCSDBDriverLocationCodes::getSAreasInLArea($lAreaCode);
00483
00484 if ($sarea_codes) {
00485 foreach ($sarea_codes as $sarea_code) {
00486 $code = (string)$sarea_code->cd;
00487 $name = (string)$sarea_code->name;
00488
00489 $area_array[$lAreaCode][$code] = $name;
00490 $j++;
00491 }
00492 }
00493 }
00494 $i++;
00495 }
00496 }
00497 }
00498 return $area_array;
00499
00500 }
00501
00508 protected function getSAreaList($lAreaCode) {
00509
00510 $sarea_name = '';
00511
00512 if ($lAreaCode) {
00513 $sarea_codes = VCSDBDriverLocationCodes::getSAreasInLArea($lAreaCode);
00514 if ($sarea_codes) {
00515 foreach ($sarea_codes as $sarea_code) {
00516 $code = (string)$sarea_code->cd;
00517 $name = (string)$sarea_code->name;
00518 if (($this->sarea_cd && $code == $this->sarea_cd)
00519 || (!$this->sarea_cd && $code == '')) {
00520 $sarea_name = $name;
00521 break;
00522 }
00523 }
00524 }
00525 }
00526 return $sarea_name;
00527 }
00528
00535 protected function getLAreaName($countryCode = 'JP') {
00536
00537 $larea_name = '';
00538
00539 if ($countryCode) {
00540 $larea_codes = VCSDBDriverLocationCodes::getLAreasInCountry($countryCode);
00541 if ($larea_codes) {
00542 foreach ($larea_codes as $larea_code) {
00543 $code = (string)$larea_code->cd;
00544 $name = (string)$larea_code->name;
00545 if ($code != '') {
00546 if (($this->larea_cd && $code == $this->larea_cd)
00547 || (!$this->larea_cd && $code == '')) {
00548 $larea_name = $name;
00549 break;
00550 }
00551 }
00552 }
00553 }
00554 }
00555 return $larea_name;
00556
00557
00558 }
00559
00566 protected function getSAreaName($lAreaCode) {
00567
00568 $sarea_name = '';
00569
00570 if ($lAreaCode) {
00571 $sarea_codes = VCSDBDriverLocationCodes::getSAreasInLArea($lAreaCode);
00572 if ($sarea_codes) {
00573 foreach ($sarea_codes as $sarea_code) {
00574 $code = (string)$sarea_code->cd;
00575 $name = (string)$sarea_code->name;
00576 if (($this->sarea_cd && $code == $this->sarea_cd)
00577 || (!$this->sarea_cd && $code == '')) {
00578 $sarea_name = $name;
00579 break;
00580 }
00581 }
00582 }
00583 }
00584 return $sarea_name;
00585 }
00586
00593 protected function getCityName($cities, $selectedCity) {
00594
00595 $city_name = '';
00596
00597 if ($cities) {
00598 foreach ($cities as $city) {
00599 $code =(string)$city->cd;
00600 $name =(string)$city->name;
00601 if (($selectedCity && $code == $selectedCity)
00602 || (!$selectedCity && $code == '')) {
00603 $city_name = $name;
00604 break;
00605 }
00606 }
00607 }
00608 return $city_name;
00609 }
00610
00618 protected function getCityNameBySArea($sAreaCode, $selectedCity = null){
00619 return $this->getCityName(VCSDBDriverLocationCodes::getCitiesInSArea($sAreaCode), $selectedCity);
00620 }
00621
00628 protected function getHotelTypeName(){
00629
00630 $hotel_type_name = '';
00631
00632 foreach (self::$HOTEL_TYPES as $code => $name) {
00633 if (($this->hotel_type && $code == $this->hotel_type)
00634 || (!$this->hotel_type && $code == '')) {
00635 $hotel_type_name = $name;
00636 break;
00637 }
00638 }
00639 return $hotel_type_name;
00640 }
00641
00647 public function getGetURLParams(){
00648 global $_GET;
00649
00650 $link = '';
00651
00653 foreach($_GET as $name => $value) {
00654 if ($name == 'page' || $name == 'submit' || $name == 'x' || $name == 'y' || $name == 'error_flg') {
00655 continue;
00656 }
00657 $link .= '&' . $name . '=' . $value;
00658 }
00659
00660 return $link;
00661 }
00662
00669 public function assignParams($service) {
00670 global $_GET;
00671
00672
00673
00674
00675 if ($this->keyword) {
00676 $service->setParam('keyword',$this->keyword);
00677 }
00678
00679
00680
00681
00682 if ($this->page) {
00683 $service->setParam('page',$this->page);
00684 }
00685
00686
00687
00688
00689 if ($this->larea_cd) {
00690 $service->setParam('larea_cd',$this->larea_cd);
00691 }
00692
00693
00694
00695
00696 if ($this->sarea_cd) {
00697 $service->setParam('sarea_cd',$this->sarea_cd);
00698 }
00699
00700
00701
00702
00703 if ($this->city_cd) {
00704 $service->setParam('city_cd',$this->city_cd);
00705 }
00706
00707
00708
00709
00710 if ($this->price_min) {
00711 $service->setParam('price_min',$this->price_min);
00712 }
00713
00714
00715
00716
00717 if ($this->price_max) {
00718 $service->setParam('price_max',$this->price_max);
00719 }
00720
00721
00722
00723
00724 if ($this->c_card) {
00725 $service->setParam('c_card',$this->c_card);
00726 }
00727
00728
00729
00730
00731 if ($this->sort_by) {
00732 $service->setParam('sort_by',$this->sort_by);
00733 }
00734
00735 if ($this->sort_order) {
00736 $service->setParam('sort_order', $this->sort_order);
00737 }
00738 }
00739
00746 protected function renderConfig($itemHtml) {
00747
00748
00749
00750 $itemHtml = str_replace('${VC_SITETITLE}', VC_SITETITLE, $itemHtml);
00751 $itemHtml = str_replace('${VC_SITEKEYWORDS}', VC_SITEKEYWORDS, $itemHtml);
00752 $itemHtml = str_replace('${VC_SITEDESCRIPTION}', VC_SITEDESCRIPTION, $itemHtml);
00753 $itemHtml = str_replace('${VC_TOPPAGETITLE}', VC_TOPPAGETITLE, $itemHtml);
00754 $itemHtml = str_replace('${VC_SITECOMMENT}', VC_SITECOMMENT, $itemHtml);
00755 $itemHtml = str_replace('${VC_HOMETITLE}', VC_HOMETITLE, $itemHtml);
00756 $itemHtml = str_replace('${VC_COPYRIGHTTEXT}', VC_COPYRIGHTTEXT, $itemHtml);
00757 $itemHtml = str_replace('${VC_COPYRIGHTLINK}', VC_COPYRIGHTLINK, $itemHtml);
00758 $itemHtml = str_replace('${VC_SPECIALSKEYWORD}', VC_SPECIALSKEYWORD, $itemHtml);
00759 $itemHtml = str_replace('${VC_GOODSKEYWORD}', VC_GOODSKEYWORD, $itemHtml);
00760
00761 return $itemHtml;
00762 }
00763
00764
00765
00772 protected function renderHotelsearchform($itemHtml) {
00773
00774
00775
00776 $itemHtml = str_replace('${VC_AREA_HOTELTYPE_SEARCHFORM}', $this->hotelsearchform_html, $itemHtml);
00777
00778 return $itemHtml;
00779 }
00780
00787 protected function renderHotelsearchresults($itemHtml) {
00788
00789
00790
00791 $itemHtml = str_replace('${VC_RETRIEVALLIST}', $this->hotelsearchresults_html, $itemHtml);
00792
00793 return $itemHtml;
00794 }
00795
00796
00803 protected function renderHotelRecommendation($itemHtml) {
00804
00805
00806
00807 $itemHtml = str_replace('${VC_RECOMMENDATION}', $this->hotelrecommendation_html, $itemHtml);
00808
00809 return $itemHtml;
00810 }
00811
00818 protected function renderHotelDetail($itemHtml) {
00819
00820
00821
00822 $itemHtml = str_replace('${VC_HOTELINFO}', $this->hoteldetail_html, $itemHtml);
00823
00824 return $itemHtml;
00825 }
00826
00833 protected function renderNearHotels($itemHtml) {
00834
00835
00836
00837 $itemHtml = str_replace('${VC_NEARHOTELS}', $this->nearhotels_html, $itemHtml);
00838
00839 return $itemHtml;
00840 }
00841
00848 protected function renderGoogleMap($itemHtml) {
00849
00850
00851
00852 $itemHtml = str_replace('${VC_HOTELMAP}', $this->googlemap_html, $itemHtml);
00853
00854 return $itemHtml;
00855 }
00856
00857
00864 protected function renderPageKeywords($itemHtml) {
00865
00866
00867
00868 $itemHtml = str_replace('${VC_PAGEKEYWORDS}', $this->makePageKeywords(), $itemHtml);
00869
00870 if(trim($this->makePageKeywords()) != ''){
00871 $itemHtml = str_replace('${VC_PAGEKEYWORDS_WITH_SPLIT}', ' > <a href="./hotel_results.php?larea_cd='.$this->larea_cd.'&sarea_cd='.$this->sarea_cd.'&city_cd='.$this->city_cd.'">' . $this->makePageKeywords() .'</a>', $itemHtml);
00872 }
00873 else
00874 {
00875 $itemHtml = str_replace('${VC_PAGEKEYWORDS_WITH_SPLIT}', '', $itemHtml);
00876 }
00877 return $itemHtml;
00878 }
00879
00886 protected function renderPageHotelname($itemHtml) {
00887
00888
00889
00890 $itemHtml = str_replace('${VC_PAGEHOTELNAME}', $this->serv_name, $itemHtml);
00891
00892 return $itemHtml;
00893 }
00894
00901 protected function renderLAreaLinkList($itemHtml) {
00902
00903 $itemHtml = str_replace('${VC_LAREA_LINK_LIST}', $this->makeLAreaLinkList(), $itemHtml);
00904
00905 return $itemHtml;
00906 }
00907
00914 protected function renderSideNaviCode($itemHtml) {
00915
00916 $sidenavicode = "";
00917
00918 if($this->larea_cd != ""){
00919 $sidenavicode .= (string)$this->larea_cd;
00920 }
00921 else
00922 {
00923 $sidenavicode .= "00";
00924 }
00925 if($this->sarea_cd != ""){
00926 $sidenavicode .= (string)$this->sarea_cd;
00927 }
00928 else
00929 {
00930 $sidenavicode .= "00000";
00931 }
00932
00933
00934 $itemHtml = str_replace('${VC_SIDENAVICODE}', $sidenavicode, $itemHtml);
00935
00936 return $itemHtml;
00937 }
00938
00945 public function render() {
00946
00947
00948
00949
00950 $itemHtml = $this->view;
00951 $itemHtml = $this->renderConfig($itemHtml);
00952 $itemHtml = $this->renderPageKeywords($itemHtml);
00953 $itemHtml = $this->renderPageHotelname($itemHtml);
00954 $itemHtml = $this->renderHotelsearchform($itemHtml);
00955 $itemHtml = $this->renderHotelsearchresults($itemHtml);
00956 $itemHtml = $this->renderHotelRecommendation($itemHtml);
00957 $itemHtml = $this->renderGoogleMap($itemHtml);
00958 $itemHtml = $this->renderLAreaLinkList($itemHtml);
00959 $itemHtml = $this->renderSideNaviCode($itemHtml);
00960 $itemHtml = $this->renderHotelDetail($itemHtml);
00961 $itemHtml = $this->renderNearHotels($itemHtml);
00962
00963 return $itemHtml;
00964
00965 }
00966
00972 public final function show() {
00973 print $this->render();
00974 }
00975 }
00976 ?>