1
|
|
|
<?php |
|
|
|
|
2
|
|
|
/** |
3
|
|
|
* Article management |
4
|
|
|
* |
5
|
|
|
* @copyright The XOOPS project http://www.xoops.org/ |
6
|
|
|
* @license http://www.fsf.org/copyleft/gpl.html GNU public license |
7
|
|
|
* @author Taiwen Jiang (phppp or D.J.) <[email protected]> |
8
|
|
|
* @since 1.00 |
9
|
|
|
* @version $Id$ |
10
|
|
|
* @package module::article |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
if (!defined('XOOPS_ROOT_PATH')) { |
14
|
|
|
exit(); |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @用于头部 |
19
|
|
|
* @method: |
20
|
|
|
* @license http://www.blags.org/ |
21
|
|
|
* @created :2010年05月20日 21时59分 |
22
|
|
|
* @copyright 1997-2010 The Martin Group |
23
|
|
|
* @author Martin <[email protected]> |
24
|
|
|
* */ |
25
|
|
|
if (!function_exists('martin_adminMenu')) { |
26
|
|
|
/** |
27
|
|
|
* @param int $currentoption |
28
|
|
|
* @param string $breadcrumb |
29
|
|
|
*/ |
30
|
|
|
function martin_adminMenu($currentoption = 0, $breadcrumb = '') |
31
|
|
|
{ |
32
|
|
|
include_once XOOPS_ROOT_PATH . '/class/template.php'; |
33
|
|
|
|
34
|
|
|
// global $xoopsDB, $xoopsModule, $xoopsConfig, $xoopsModuleConfig; |
|
|
|
|
35
|
|
|
global $xoopsModule, $xoopsConfig; |
|
|
|
|
36
|
|
|
|
37
|
|
View Code Duplication |
if (file_exists(MARTIN_ROOT_PATH . 'language/' . $xoopsConfig['language'] . '/modinfo.php')) { |
|
|
|
|
38
|
|
|
include_once MARTIN_ROOT_PATH . 'language/' . $xoopsConfig['language'] . '/modinfo.php'; |
39
|
|
|
} else { |
40
|
|
|
include_once MARTIN_ROOT_PATH . 'language/english/modinfo.php'; |
41
|
|
|
} |
42
|
|
View Code Duplication |
if (file_exists(MARTIN_ROOT_PATH . 'language/' . $xoopsConfig['language'] . '/admin.php')) { |
|
|
|
|
43
|
|
|
include_once MARTIN_ROOT_PATH . 'language/' . $xoopsConfig['language'] . '/admin.php'; |
44
|
|
|
} else { |
45
|
|
|
include_once MARTIN_ROOT_PATH . 'language/english/admin.php'; |
46
|
|
|
} |
47
|
|
|
include MARTIN_ROOT_PATH . 'admin/menu.php'; |
48
|
|
|
|
49
|
|
|
$tpl = new XoopsTpl(); |
50
|
|
|
$tpl->assign(array( |
51
|
|
|
'headermenu' => $headermenu, |
|
|
|
|
52
|
|
|
'adminmenu' => $adminmenu, |
|
|
|
|
53
|
|
|
'current' => $currentoption, |
54
|
|
|
'breadcrumb' => $breadcrumb, |
55
|
|
|
'headermenucount' => count($headermenu))); |
56
|
|
|
$tpl->display('db:martin_admin_menu.tpl'); |
57
|
|
|
echo "<br />\n"; |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @用于区块 |
63
|
|
|
* @method: |
64
|
|
|
* @license http://www.blags.org/ |
65
|
|
|
* @created :2010年05月20日 21时59分 |
66
|
|
|
* @copyright 1997-2010 The Martin Group |
67
|
|
|
* @author Martin <[email protected]> |
68
|
|
|
* */ |
69
|
|
|
if (!function_exists('martin_collapsableBar')) { |
70
|
|
|
/** |
71
|
|
|
* @param string $tablename |
72
|
|
|
* @param string $iconname |
73
|
|
|
* @param string $tabletitle |
74
|
|
|
* @param string $tabledsc |
75
|
|
|
*/ |
76
|
|
|
function martin_collapsableBar($tablename = '', $iconname = '', $tabletitle = '', $tabledsc = '') |
77
|
|
|
{ |
78
|
|
|
global $xoopsModule; |
|
|
|
|
79
|
|
|
|
80
|
|
|
// echo '<script type="text/javascript" src="' . XOOPS_URL . '/themes/default/jquery-1.3.2.min.js"></script>'; |
81
|
|
|
echo '<script type="text/javascript" src="' . XOOPS_URL . '/browse.php?Frameworks/jquery/jquery.js"></script>'; |
82
|
|
|
echo "<h3 style=\"color: #2F5376; font-weight: bold; font-size: 14px; margin: 6px 0 0 0; \"><a href='javascript:;' class='tabclose'>"; |
83
|
|
|
echo "<img id='$iconname' src=" . XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/images/icon/close12.gif class='tab_img' /> " . $tabletitle . "</a></h3>"; |
84
|
|
|
echo "<div id='$tablename' class='open'>"; |
85
|
|
|
if ($tabledsc != '') { |
86
|
|
|
echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . $tabledsc . "</span>"; |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @创建button |
93
|
|
|
* @method:array('add' => array('url' => '?action=add', 'value' => '添加'),) |
94
|
|
|
* @license http://www.blags.org/ |
95
|
|
|
* @created :2010年05月21日 20时40分 |
96
|
|
|
* @copyright 1997-2010 The Martin Group |
97
|
|
|
* @author Martin <[email protected]> |
98
|
|
|
* */ |
99
|
|
|
if (!function_exists('Create_button')) { |
100
|
|
|
/** |
101
|
|
|
* @param $ButtonArr |
102
|
|
|
* @return string |
|
|
|
|
103
|
|
|
*/ |
104
|
|
|
function Create_button($ButtonArr) |
105
|
|
|
{ |
106
|
|
|
if (!is_array($ButtonArr)) { |
107
|
|
|
return ''; |
108
|
|
|
} |
109
|
|
|
echo '<div style="margin-bottom: 12px;">'; |
110
|
|
|
if (is_array($ButtonArr)) { |
111
|
|
|
foreach ($ButtonArr as $key => $button) { |
112
|
|
|
echo " <input type='button' value='{$button['value']}' onclick='location=\"{$button['url']}\"' name='$key'>"; |
113
|
|
|
} |
114
|
|
|
} |
115
|
|
|
echo '</div>'; |
116
|
|
|
} |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
if (!function_exists('martin_close_collapsable')) { |
120
|
|
|
/** |
121
|
|
|
* @param $name |
122
|
|
|
* @param $icon |
123
|
|
|
*/function martin_close_collapsable($name, $icon) |
|
|
|
|
124
|
|
|
{ |
125
|
|
|
?> |
126
|
|
|
</div> |
127
|
|
|
<script type='text/javascript'> |
128
|
|
|
/*jQuery.noconflict(); |
129
|
|
|
jQuery(function($){*/ |
130
|
|
|
$(".tabclose").click(function(){ |
131
|
|
|
var div = $(this).parent("h3").next('div').attr('id'); |
132
|
|
|
var div_class = $("#"+div).attr('class'); |
133
|
|
|
if(div_class == 'open') |
134
|
|
|
{ |
135
|
|
|
$("#"+div).hide(); |
136
|
|
|
$(".tab_img").attr('src','../images/icon/open12.gif'); |
137
|
|
|
$("#"+div).attr('class','close'); |
138
|
|
|
}else if(div_class == 'close'){ |
139
|
|
|
$("#"+div).show(); |
140
|
|
|
$(".tab_img").attr('src','../images/icon/close12.gif'); |
141
|
|
|
$("#"+div).attr('class','open'); |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
}); |
145
|
|
|
|
146
|
|
|
$(".existimage").click(function(){ |
147
|
|
|
var filename = this.id; |
148
|
|
|
if(!confirm("确定删除吗?")) return false; |
149
|
|
|
$.post('martin.hotel.php',{action:'deleteimg',img:filename}); |
150
|
|
|
$(this).parent("div").remove(); |
151
|
|
|
}); |
152
|
|
|
function go(url) |
153
|
|
|
{ |
154
|
|
|
window.location.href = url; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/*});*/ |
158
|
|
|
</script> |
159
|
|
|
<?php |
160
|
|
|
|
161
|
|
|
} |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* @get order js |
166
|
|
|
* @license http://www.blags.org/ |
167
|
|
|
* @created :2010年06月10日 21时25分 |
168
|
|
|
* @copyright 1997-2010 The Martin Group |
169
|
|
|
* @author Martin <[email protected]> |
170
|
|
|
* */ |
171
|
|
|
if (!function_exists('martin_order_list_js')) { |
172
|
|
|
function martin_order_list_js() |
173
|
|
|
{ |
174
|
|
|
echo <<<EndHTML |
175
|
|
|
<script type='text/javascript'> |
176
|
|
|
$("#hotel_city_id").change(function(){ |
177
|
|
|
var params = $("#orderSearch").serialize(); |
178
|
|
|
var rate = $('#hotel_city_id option:selected').text(); |
179
|
|
|
/*if(rate.indexOf('----') == -1 || rate.length == 4) |
180
|
|
|
{ |
181
|
|
|
alert("请选取三级类目! please select correct regoin!");return false; |
182
|
|
|
}*/ |
183
|
|
|
$.get('martin.ajax.php?action=gethotellist',params,function(data){ |
184
|
|
|
$("#hotel_name_div").html(data); |
185
|
|
|
$("#hotel_name").html(''); |
186
|
|
|
}); |
187
|
|
|
}); |
188
|
|
|
$("#hotel_star").change(function(){ |
189
|
|
|
var params = $("#orderSearch").serialize(); |
190
|
|
|
var rate = $('#hotel_star option:selected').text(); |
191
|
|
|
/*if(rate.indexOf('----') == -1 || rate.length == 4) |
192
|
|
|
{ |
193
|
|
|
alert("请选取三级类目! please select correct regoin!");return false; |
194
|
|
|
}*/ |
195
|
|
|
$.get('martin.ajax.php?action=gethotellist',params,function(data){ |
196
|
|
|
$("#hotel_name_div").html(data); |
197
|
|
|
$("#hotel_name").html(''); |
198
|
|
|
}); |
199
|
|
|
}); |
200
|
|
|
function hotel_select(event) |
201
|
|
|
{ |
202
|
|
|
var hotel_name = $(event).find('option:selected').text(); |
203
|
|
|
$("#hotel_name").html('<input type="hidden" name="hotel_name" value="'+hotel_name+'">'); |
204
|
|
|
} |
205
|
|
|
</script> |
206
|
|
|
EndHTML; |
207
|
|
|
} |
208
|
|
|
} |
209
|
|
|
|
210
|
|
|
/** |
211
|
|
|
* @method: 得到酒店星级 |
212
|
|
|
* @license http://www.blags.org/ |
213
|
|
|
* @created :2010年05月24日 19时55分 |
214
|
|
|
* @copyright 1997-2010 The Martin Group |
215
|
|
|
* @author Martin <[email protected]> |
216
|
|
|
**/ |
217
|
|
|
if (!function_exists('GetRanks')) { |
218
|
|
|
/** |
219
|
|
|
* @param $xoopsModuleConfig |
220
|
|
|
* @return mixed |
221
|
|
|
*/ |
222
|
|
|
function GetRanks(&$xoopsModuleConfig) |
223
|
|
|
{ |
224
|
|
|
$HotelRanks = $xoopsModuleConfig['hotelrank']; |
225
|
|
|
$HotelRanks = array_filter(explode(chr(13), $HotelRanks)); |
226
|
|
|
if (is_array($HotelRanks)) { |
227
|
|
|
foreach ($HotelRanks as $hotelrank) { |
228
|
|
|
$Rank = array_filter(explode("-", $hotelrank)); |
229
|
|
|
$Ranks[(int)(str_replace("\n", "", $Rank[0]))] = trim(str_replace("\n", "", $Rank[1])); |
|
|
|
|
230
|
|
|
unset($Rank); |
231
|
|
|
} |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
return $Ranks; |
|
|
|
|
235
|
|
|
} |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
/** |
239
|
|
|
* @method delete path files |
240
|
|
|
* @license http://www.blags.org/ |
241
|
|
|
* @created :2010年05月27日 22时04分 |
242
|
|
|
* @copyright 1997-2010 The Martin Group |
243
|
|
|
* @author Martin <[email protected]> |
244
|
|
|
* */ |
245
|
|
|
if (!function_exists('deldir')) { |
246
|
|
|
/** |
247
|
|
|
* @param $dir |
248
|
|
|
*/ |
249
|
|
|
function deldir($dir) |
250
|
|
|
{ |
251
|
|
|
$dh = opendir($dir); |
252
|
|
|
while ($file = readdir($dh)) { |
253
|
|
|
if ($file !== "." && $file !== "..") { |
254
|
|
|
$fullpath = $dir . "/" . $file; |
255
|
|
|
if (!is_dir($fullpath)) { |
256
|
|
|
unlink($fullpath); |
257
|
|
|
} else { |
258
|
|
|
deldir($fullpath); |
259
|
|
|
} |
260
|
|
|
} |
261
|
|
|
} |
262
|
|
|
closedir($dh); |
263
|
|
|
/*if(rmdir($dir)) |
|
|
|
|
264
|
|
|
{ |
265
|
|
|
return true; |
266
|
|
|
} else { |
267
|
|
|
return false; |
268
|
|
|
}*/ |
269
|
|
|
} |
270
|
|
|
} |
271
|
|
|
|
272
|
|
|
/** |
273
|
|
|
* @get module config array |
274
|
|
|
* @license http://www.blags.org/ |
275
|
|
|
* @created :2010年06月06日 20时05分 |
276
|
|
|
* @copyright 1997-2010 The Martin Group |
277
|
|
|
* @author Martin <[email protected]> |
278
|
|
|
* */ |
279
|
|
|
if (!function_exists('getModuleArray')) { |
280
|
|
|
/** |
281
|
|
|
* @param $module_key |
282
|
|
|
* @param null $keyName |
283
|
|
|
* @param bool $is_get_arr |
284
|
|
|
* @param null $selected |
285
|
|
|
* @param null $ModuleConfig |
286
|
|
|
* @return array|string |
287
|
|
|
*/ |
288
|
|
|
function getModuleArray($module_key, $keyName = null, $is_get_arr = false, $selected = null, $ModuleConfig = null) |
289
|
|
|
{ |
290
|
|
|
global $xoopsModuleConfig; |
|
|
|
|
291
|
|
|
if (empty($xoopsModuleConfig)) { |
292
|
|
|
$xoopsModuleConfig = &$ModuleConfig; |
293
|
|
|
} |
294
|
|
|
//var_dump($xoopsModuleConfig); |
295
|
|
|
$keyName = is_null($keyName) ? $module_key : $keyName; |
296
|
|
|
if (isset($xoopsModuleConfig[$module_key]) && !empty($xoopsModuleConfig[$module_key])) { |
297
|
|
|
$Arrs = $xoopsModuleConfig[$module_key]; |
298
|
|
|
$Arrs = array_filter(explode(chr(13), $Arrs)); |
299
|
|
|
$ModuleArr = array(); |
300
|
|
|
if (is_array($Arrs)) { |
301
|
|
|
foreach ($Arrs as $Arr) { |
302
|
|
|
$TmpArr = array_filter(explode("-", $Arr)); |
303
|
|
|
//var_dump($TmpArr); |
304
|
|
|
if (!empty($TmpArr[0]) && !empty($TmpArr[1])) { |
305
|
|
|
$ModuleKey = (str_replace("\n", "", $TmpArr[0])); |
306
|
|
|
$ModuleKey = is_numeric($ModuleKey) ? (int)($ModuleKey) : trim($ModuleKey); |
307
|
|
|
$ModuleArr[$ModuleKey] = trim(str_replace("\n", "", $TmpArr[1])); |
308
|
|
|
} else { |
309
|
|
|
$ModuleArr[] = trim(str_replace("\n", "", $TmpArr[0])); |
310
|
|
|
} |
311
|
|
|
unset($TmpArr); |
312
|
|
|
} |
313
|
|
|
} |
314
|
|
|
if ($is_get_arr) { |
315
|
|
|
return $ModuleArr; |
316
|
|
|
} |
317
|
|
|
|
318
|
|
|
//var_dump($ModuleArr); |
319
|
|
|
return is_null($keyName) ? $ModuleArr : WriteHtmlSelect($ModuleArr, $keyName, $selected); |
320
|
|
|
} |
321
|
|
|
|
322
|
|
|
return $module_key; |
323
|
|
|
} |
324
|
|
|
} |
325
|
|
|
|
326
|
|
|
/** |
327
|
|
|
* @write html select |
328
|
|
|
* @method: |
329
|
|
|
* @license http://www.blags.org/ |
330
|
|
|
* @created :2010年06月07日 20时25分 |
331
|
|
|
* @copyright 1997-2010 The Martin Group |
332
|
|
|
* @author Martin <[email protected]> |
333
|
|
|
* */ |
334
|
|
|
if (!function_exists('WriteHtmlSelect')) { |
335
|
|
|
/** |
336
|
|
|
* @param $ModuleArr |
337
|
|
|
* @param $keyName |
338
|
|
|
* @param null $selected |
339
|
|
|
* @return string |
340
|
|
|
*/ |
341
|
|
|
function WriteHtmlSelect($ModuleArr, $keyName, $selected = null) |
342
|
|
|
{ |
343
|
|
|
if (empty($keyName)) { |
344
|
|
|
return $keyName; |
345
|
|
|
} |
346
|
|
|
$Str = "<select name='$keyName' id='$keyName' >\n"; |
347
|
|
|
$Str .= "<option value=''>----</option>"; |
348
|
|
|
if (is_array($ModuleArr)) { |
349
|
|
|
foreach ($ModuleArr as $key => $value) { |
350
|
|
|
$selectedStr = ($selected === $key) ? " selected='selected'" : ""; |
351
|
|
|
$Str .= "<option value='$key' $selectedStr>$value</option>"; |
352
|
|
|
unset($selectedStr); |
353
|
|
|
} |
354
|
|
|
} |
355
|
|
|
$Str .= "</select>"; |
356
|
|
|
|
357
|
|
|
return $Str; |
358
|
|
|
} |
359
|
|
|
} |
360
|
|
|
|
361
|
|
|
/** |
362
|
|
|
* @get mouth last day |
363
|
|
|
* @license http://www.blags.org/ |
364
|
|
|
* @created :2010年06月24日 22时04分 |
365
|
|
|
* @copyright 1997-2010 The Martin Group |
366
|
|
|
* @author Martin <[email protected]> |
367
|
|
|
* */ |
368
|
|
|
if (!function_exists('MouthLastDay')) { |
369
|
|
|
/** |
370
|
|
|
* @param null $mouth |
371
|
|
|
* @return array|bool|int|string |
372
|
|
|
*/ |
373
|
|
|
function MouthLastDay($mouth = null) |
374
|
|
|
{ |
375
|
|
|
$mouth = is_null($mouth) ? date('m') : $mouth; |
376
|
|
|
$date = date('Y') . '-' . $mouth . '-' . date('d'); |
377
|
|
|
$firstday = date('Y-m-01', strtotime($date)); |
378
|
|
|
$lastday = date('Y-m-d', strtotime("$firstday +1 month -1 day")); |
379
|
|
|
$lastday = explode('-', $lastday); |
380
|
|
|
$lastday = array_reverse($lastday); |
381
|
|
|
$lastday = (int)$lastday[0]; |
382
|
|
|
|
383
|
|
|
return $lastday; |
384
|
|
|
} |
385
|
|
|
} |
386
|
|
|
|
387
|
|
|
/** |
388
|
|
|
* @get check in date arr |
389
|
|
|
* @license http://www.blags.org/ |
390
|
|
|
* @created :2010年07月01日 22时08分 |
391
|
|
|
* @copyright 1997-2010 The Martin Group |
392
|
|
|
* @author Martin <[email protected]> |
393
|
|
|
* */ |
394
|
|
|
if (!function_exists('GetCheckDateArr')) { |
395
|
|
|
/** |
396
|
|
|
* @param $check_in_date |
397
|
|
|
* @param $check_out_date |
398
|
|
|
* @return array |
399
|
|
|
*/ |
400
|
|
|
function GetCheckDateArr($check_in_date, $check_out_date) |
401
|
|
|
{ |
402
|
|
|
$check_arr = array(); |
403
|
|
|
$check_date_count = (int)(($check_out_date - $check_in_date) / (3600 * 24)); |
404
|
|
|
if ($check_date_count > 0) { |
405
|
|
|
$ini_y = date('Y', $check_in_date); |
406
|
|
|
$ini_m = date('m', $check_in_date); |
407
|
|
|
$ini_d = date('d', $check_in_date); |
408
|
|
|
$last_d = MouthLastDay($ini_y); |
409
|
|
|
for ($i = 0; $i < $check_date_count; $i++) { |
410
|
|
|
$d = $ini_d + $i; |
411
|
|
|
$m = $d > $last_d ? $ini_m + 1 : $ini_m; |
412
|
|
|
$d = $d > $last_d ? $d - $last_d : $d; |
413
|
|
|
$y = $m > 12 ? $ini_y + 1 : $ini_y; |
414
|
|
|
$m = $m > 12 ? $m - 12 : $m; |
415
|
|
|
$check_arr[] = strtotime($y . '-' . $m . '-' . $d); |
416
|
|
|
} |
417
|
|
|
} |
418
|
|
|
|
419
|
|
|
return $check_arr; |
420
|
|
|
} |
421
|
|
|
} |
422
|
|
|
|
423
|
|
|
?> |
424
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.