|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @get martin hotel news |
|
5
|
|
|
* @license http://www.blags.org/ |
|
6
|
|
|
* @created :2010年06月29日 20时38分 |
|
7
|
|
|
* @copyright 1997-2010 The Martin Group |
|
8
|
|
|
* @author Martin <[email protected]> |
|
9
|
|
|
* */ |
|
10
|
|
|
class MartinHotelNews extends XoopsObject |
|
|
|
|
|
|
11
|
|
|
{ |
|
12
|
|
|
} |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* @get martin hotel news handler |
|
16
|
|
|
* @license http://www.blags.org/ |
|
17
|
|
|
* @created :2010年06月29日 20时38分 |
|
18
|
|
|
* @copyright 1997-2010 The Martin Group |
|
19
|
|
|
* @author Martin <[email protected]> |
|
20
|
|
|
* */ |
|
21
|
|
|
class MartinHotelNewsHandler extends XoopsObjectHandler |
|
|
|
|
|
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* @get rows |
|
25
|
|
|
* @license http://www.blags.org/ |
|
26
|
|
|
* @created :2010年06月20日 13时09分 |
|
27
|
|
|
* @copyright 1997-2010 The Martin Group |
|
28
|
|
|
* @author Martin <[email protected]> |
|
29
|
|
|
* @param $sql |
|
30
|
|
|
* @param null $key |
|
31
|
|
|
* @return array |
|
32
|
|
|
*/ |
|
33
|
|
View Code Duplication |
public function GetRows($sql, $key = null) |
|
|
|
|
|
|
34
|
|
|
{ |
|
35
|
|
|
global $xoopsDB; |
|
|
|
|
|
|
36
|
|
|
$result = $xoopsDB->query($sql); |
|
37
|
|
|
$rows = array(); |
|
38
|
|
|
while ($row = $xoopsDB->fetchArray($result)) { |
|
39
|
|
|
if (is_null($key)) { |
|
40
|
|
|
$rows[] = $row; |
|
41
|
|
|
} else { |
|
42
|
|
|
$rows[$row[$key]] = $row; |
|
43
|
|
|
} |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
return $rows; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @get hotel news |
|
51
|
|
|
* @method: |
|
52
|
|
|
* @license http://www.blags.org/ |
|
53
|
|
|
* @created :2010年06月29日 20时38分 |
|
54
|
|
|
* @copyright 1997-2010 The Martin Group |
|
55
|
|
|
* @author Martin <[email protected]> |
|
56
|
|
|
* @param $artids |
|
57
|
|
|
* @return array|string |
|
58
|
|
|
*/ |
|
59
|
|
|
public function GetHotelNews($artids) |
|
60
|
|
|
{ |
|
61
|
|
|
global $xoopsDB; |
|
|
|
|
|
|
62
|
|
|
if (empty($artids) || !is_array($artids)) { |
|
63
|
|
|
return $artids; |
|
64
|
|
|
} |
|
65
|
|
|
$artids = implode(",", $artids); |
|
66
|
|
|
$sql = "SELECT text_id,alias FROM " . $xoopsDB->prefix("news_text") . " WHERE art_id IN ($artids)"; |
|
67
|
|
|
$text_rows = $this->GetRows($sql, 'text_id'); |
|
68
|
|
|
|
|
69
|
|
|
$sql = "SELECT art_id,cat_alias,art_title,art_pages FROM " . $xoopsDB->prefix("news_article") . " WHERE art_id IN ($artids) ORDER BY art_time_publish DESC"; |
|
70
|
|
|
$result = $xoopsDB->query($sql); |
|
71
|
|
|
$rows = array(); |
|
72
|
|
|
while ($row = $xoopsDB->fetchArray($result)) { |
|
73
|
|
|
$text_id = unserialize($row['art_pages']); |
|
74
|
|
|
$text_id = $text_id[0]; |
|
75
|
|
|
$url = $text_rows[$text_id]['alias']; |
|
76
|
|
|
$url = XOOPS_URL . $row['cat_alias'] . $url; |
|
77
|
|
|
$rows[$row['art_id']] = array('url' => $url, 'title' => $row['art_title']); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
return $rows; |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.