-
Notifications
You must be signed in to change notification settings - Fork 0
/
e_sitelink.php
157 lines (117 loc) · 3.1 KB
/
e_sitelink.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2009 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Sitelinks configuration module - News
*
* $URL$
* $Id$
*
*/
if (!defined('e107_INIT')) { exit; }
//TODO Lans
class news_sitelink // include plugin-folder in the name.
{
function config()
{
$links = array();
$links[] = array(
'name' => "News Category List",
'function' => "news_category_list",
'description' => ""
);
$links[] = array(
'name' => "News Category Pages",
'function' => "news_category_page",
'description' => ""
);
$links[] = array(
'name' => "Last 10 News Items",
'function' => "last_ten",
'description' => ""
);
return $links;
}
function news_category_page()
{
return $this->news_category_list('category');
}
function news_cats() // BC
{
return $this->news_category_list();
}
function news_category_list($type=null)
{
$ctree = e107::getSingleton(NEWS_DEF_CATEGORY_MODEL_TREE, e_PLUGIN . NEWS_DEF_PLUGIN_FOLDER . '/ehandlers/' . NEWS_DEF_CATEGORY_MODEL_FILE);
$data = $ctree->loadActive();
$sublinks = array();
foreach ($ctree->getTree() as $cat)
{
//$row = (array) $cat;
//$row['id'] = $cat->getId();
$sublinks[] = array(
'link_name' => $cat->sc_news_category_title(),
'link_url' => $cat->sc_news_category_url(),
'link_description' => $cat->sc_news_category_description(),
'link_button' => '',
'link_category' => '',
'link_order' => $cat->sc_news_category_order(),
'link_parent' => '',
'link_open' => '',
'link_class' => 0
);
}
$sublinks[] = array(
'link_name' => LAN_MORE,
'link_url' => e107::url('news', 'all'),
'link_description' => '',
'link_button' => '',
'link_category' => '',
'link_order' => '',
'link_parent' => '',
'link_open' => '',
'link_class' => 0
);
return $sublinks;
}
function last_ten()
{
$sql = e107::getDb();
$sublinks = array();
$nobody_regexp = "'(^|,)(".str_replace(",", "|", e_UC_NOBODY).")(,|$)'";
$query = "SELECT * FROM #news WHERE news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (news_class REGEXP ".$nobody_regexp.") ORDER BY news_datestamp DESC LIMIT 10";
if($sql->gen($query))
{
while($row = $sql->fetch())
{
$sublinks[] = array(
'link_name' => $row['news_title'],
'link_url' => e107::url('news', 'item', $row, array('full' => 1)),
'link_description' => $row['news_summary'],
'link_button' => '',
'link_category' => '',
'link_order' => '',
'link_parent' => '',
'link_open' => '',
'link_class' => intval($row['news_class'])
);
}
$sublinks[] = array(
'link_name' => LAN_MORE,
'link_url' => e107::getUrl()->create('news/list/all'),
'link_description' => '',
'link_button' => '',
'link_category' => '',
'link_order' => '',
'link_parent' => '',
'link_open' => '',
'link_class' => 0
);
return $sublinks;
};
}
}