|
1
|
|
|
<?php |
|
2
|
|
|
global $xoopsModuleConfig, $xoopsModule, $xoopsTpl, $hotel_handler; |
|
3
|
|
|
|
|
4
|
|
|
$isNewsModule = false; |
|
5
|
|
|
//新闻 |
|
6
|
|
|
if ($xoopsModule->dirname() !== 'martin') { |
|
7
|
|
|
if (!is_array($aliasurl)) { |
|
8
|
|
|
$isNewsModule = true; |
|
9
|
|
|
} |
|
10
|
|
|
$xoopsModule =& $module_handler->getByDirname('martin'); |
|
11
|
|
|
$xoopsModuleConfig =& $config_handler->getConfigsByCat(0, $xoopsModule->getVar('mid')); |
|
12
|
|
|
} |
|
13
|
|
|
|
|
14
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/martin/include/functions.php'; |
|
15
|
|
|
if (empty($hotel_handler)) { |
|
16
|
|
|
$hotel_handler =& xoops_getmodulehandler("hotel", 'martin'); |
|
17
|
|
|
} |
|
18
|
|
|
//$room_handler =& xoops_getmodulehandler("room", 'martin'); |
|
19
|
|
|
//$promotion_handler =& xoops_getmodulehandler("hotelpromotion", 'martin'); |
|
20
|
|
|
//$service_handler =& xoops_getmodulehandler("hotelservice", 'martin'); |
|
21
|
|
|
$group_handler =& xoops_getmodulehandler("group", 'martin'); |
|
22
|
|
|
$auction_handler =& xoops_getmodulehandler("auction", 'martin'); |
|
23
|
|
|
$news_handler =& xoops_getmodulehandler("hotelnews", 'martin'); |
|
24
|
|
|
|
|
25
|
|
|
$ViewedhotelIDs = array_filter(explode(',', $_COOKIE['ViewedHotels'])); |
|
26
|
|
|
if (is_array($ViewedhotelArr)) { |
|
27
|
|
|
$ViewedHotels = array(); |
|
28
|
|
|
foreach ($ViewedhotelArr as $key => $value) { |
|
29
|
|
|
$ViewedhotelIDs[$key] = explode("||", $value); |
|
30
|
|
|
$ViewedhotelIDs[$key][1] = XOOPS_URL . urldecode($ViewedhotelIDs[$key][1]); |
|
31
|
|
|
$ViewedHotels[] = $value; |
|
32
|
|
|
if ($key == 5) { |
|
33
|
|
|
break; |
|
34
|
|
|
} |
|
35
|
|
|
} |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
$hotel_guide = explode(",", $xoopsModuleConfig['hotel_guide']); |
|
39
|
|
|
$hotel_today_special = explode(",", $xoopsModuleConfig['hotel_today_special']); |
|
40
|
|
|
$hotel_news_ids = (is_array($hotel_guide) && is_array($hotel_today_special)) ? array_merge($hotel_guide, $hotel_today_special) : null; |
|
41
|
|
|
$hotel_news_ids = array_filter($hotel_news_ids); |
|
42
|
|
|
$hotelnews = $news_handler->GetHotelNews($hotel_news_ids); |
|
43
|
|
|
|
|
44
|
|
|
$hotel_guide_rows = array(); |
|
45
|
|
|
$hotel_today_special_rows = array(); |
|
46
|
|
View Code Duplication |
foreach ($hotelnews as $key => $row) { |
|
|
|
|
|
|
47
|
|
|
if (in_array($key, $hotel_guide) && count($hotel_guide_rows) < 8) { |
|
48
|
|
|
$hotel_guide_rows[] = $row; |
|
49
|
|
|
} |
|
50
|
|
|
if (in_array($key, $hotel_today_special) && count($hotel_today_special_rows) < 8) { |
|
51
|
|
|
$hotel_today_special_rows[] = $row; |
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
ob_start(); |
|
56
|
|
|
$Tpl = new xoopsTpl(); |
|
57
|
|
|
$Tpl->assign('module_url', XOOPS_URL . '/modules/martin/'); |
|
58
|
|
|
$Tpl->assign("hotelrank", getModuleArray('hotelrank', 'hotelrank', true)); |
|
59
|
|
|
$Tpl->assign('hotelrankcount', $hotel_handler->getHotelRankCount()); |
|
60
|
|
|
$Tpl->assign('ViewedHotels', $hotel_handler->GetViewedHotels($ViewedhotelIDs)); |
|
61
|
|
|
$Tpl->assign('groupList', $group_handler->GetGroupList()); |
|
62
|
|
|
$Tpl->assign('auctionList', $auction_handler->GetAuctionList()); |
|
63
|
|
|
$Tpl->assign('hotel_guide_rows', $hotel_guide_rows); |
|
64
|
|
|
$Tpl->assign('hotel_today_special_rows', $hotel_today_special_rows); |
|
65
|
|
|
$Tpl->assign('cityList', $hotel_handler->GetCityList('WHERE city_parentid = 0')); |
|
66
|
|
|
$Tpl->assign('hotel_static_prefix', $xoopsModuleConfig['hotel_static_prefix']); |
|
67
|
|
|
$Tpl->assign('isNewsModule', $isNewsModule); |
|
68
|
|
|
$Tpl->assign("module_config", $xoopsModuleConfig); |
|
69
|
|
|
$Tpl->display('db:martin_hotel_search_left.tpl'); |
|
70
|
|
|
$xoopsTpl->assign('martin_hotel_search_left', ob_get_contents()); |
|
71
|
|
|
|
|
72
|
|
|
ob_end_clean(); |
|
73
|
|
|
|
|
74
|
|
|
unset($Tpl, $news_handler, $hotel_guide_rows, $hotel_today_special_rows); |
|
75
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.