|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @订房搜索 |
|
4
|
|
|
* @license http://www.blags.org/ |
|
5
|
|
|
* @created :2010年05月19日 22时38分 |
|
6
|
|
|
* @copyright 1997-2010 The Martin Group |
|
7
|
|
|
* @author Martin <[email protected]> |
|
8
|
|
|
* */ |
|
9
|
|
|
if (!defined('XOOPS_ROOT_PATH')) { |
|
10
|
|
|
exit(); |
|
11
|
|
|
} |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* hoel search show function |
|
15
|
|
|
* @param $options |
|
16
|
|
|
* @return |
|
17
|
|
|
*/ |
|
18
|
|
|
function martin_hotel_search_show($options) |
|
19
|
|
|
{ |
|
20
|
|
|
global $xoopsModuleConfig, $xoopsModule, $xoopsTpl; |
|
21
|
|
|
//新闻 |
|
22
|
|
|
/*if($xoopsModule->dirname() != 'martin') |
|
23
|
|
|
{*/ |
|
24
|
|
|
$module_handler =& xoops_gethandler('module'); |
|
25
|
|
|
$config_handler =& xoops_gethandler('config'); |
|
26
|
|
|
$xoopsModule =& $module_handler->getByDirname('martin'); |
|
27
|
|
|
$xoopsModuleConfig =& $config_handler->getConfigsByCat(0, $xoopsModule->getVar('mid')); |
|
28
|
|
|
/*}*/ |
|
29
|
|
|
//var_dump($xoopsModuleConfig); |
|
30
|
|
|
|
|
31
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/martin/include/functions.php'; |
|
32
|
|
|
$hotel_handler =& xoops_getmodulehandler("hotel", 'martin'); |
|
33
|
|
|
$group_handler =& xoops_getmodulehandler("group", 'martin'); |
|
34
|
|
|
$auction_handler =& xoops_getmodulehandler("auction", 'martin'); |
|
35
|
|
|
$news_handler =& xoops_getmodulehandler("hotelnews", 'martin'); |
|
36
|
|
|
|
|
37
|
|
|
$hotel_guide = explode(",", $xoopsModuleConfig['hotel_guide']); |
|
38
|
|
|
$hotel_today_special = explode(",", $xoopsModuleConfig['hotel_today_special']); |
|
39
|
|
|
$hotel_news_ids = (is_array($hotel_guide) && is_array($hotel_today_special)) ? array_merge($hotel_guide, $hotel_today_special) : null; |
|
40
|
|
|
$hotelnews = $news_handler->GetHotelNews($hotel_news_ids); |
|
41
|
|
|
|
|
42
|
|
|
$hotel_guide_rows = array(); |
|
43
|
|
|
$hotel_today_special_rows = array(); |
|
44
|
|
View Code Duplication |
foreach ($hotelnews as $key => $row) { |
|
45
|
|
|
if (in_array($key, $hotel_guide) && count($hotel_guide_rows) < 6) { |
|
46
|
|
|
$hotel_guide_rows[] = $row; |
|
47
|
|
|
} |
|
48
|
|
|
if (in_array($key, $hotel_today_special) && count($hotel_today_special_rows) < 6) { |
|
49
|
|
|
$hotel_today_special_rows[] = $row; |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
$block['module_url'] = XOOPS_URL . '/modules/martin/'; |
|
|
|
|
|
|
54
|
|
|
$block['hotelrank'] = getModuleArray('hotelrank', 'hotelrank', true, null, $xoopsModuleConfig); |
|
55
|
|
|
$block['groupList'] = $group_handler->GetGroupList(); |
|
56
|
|
|
$block['auctionList'] = $auction_handler->GetAuctionList(); |
|
57
|
|
|
$block['hotel_guide_rows'] = $hotel_guide_rows; |
|
58
|
|
|
$block['hotel_today_special_rows'] = $hotel_today_special_rows; |
|
59
|
|
|
$block['cityList'] = $hotel_handler->GetCityList('WHERE city_parentid = 0'); |
|
60
|
|
|
$block['hotel_static_prefix'] = $xoopsModuleConfig['hotel_static_prefix']; |
|
61
|
|
|
|
|
62
|
|
|
unset($hotel_handler, $group_handler, $auction_handler, $news_handler, $hotel_guide_rows, $hotel_today_special_rows); |
|
63
|
|
|
|
|
64
|
|
|
//var_dump($block); |
|
65
|
|
|
return $block; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* hoel search edit function |
|
70
|
|
|
* @param $options |
|
71
|
|
|
* @return string |
|
72
|
|
|
*/ |
|
73
|
|
|
function martin_hotel_search_edit($options) |
|
74
|
|
|
{ |
|
75
|
|
|
return ''; |
|
76
|
|
|
} |
|
77
|
|
|
|
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.
Let’s take a look at an example:
As you can see in this example, the array
$myArrayis initialized the first time when the foreach loop is entered. You can also see that the value of thebarkey is only written conditionally; thus, its value might result from a previous iteration.This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.