-
Notifications
You must be signed in to change notification settings - Fork 0
/
other_news_menu.php
212 lines (164 loc) · 4.77 KB
/
other_news_menu.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<?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)
*
*
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/news/other_news_menu.php,v $
* $Revision$
* $Date$
* $Author$
*/
if (!defined('e107_INIT')) { exit; }
// Load Data
if($cacheData = e107::getCache()->retrieve("nq_othernews"))
{
echo $cacheData;
return;
}
require_once(e_PLUGIN . 'news/ehandlers/news_class.php');
unset($text);
global $OTHERNEWS_STYLE;
$ix = new news;
$caption = TD_MENU_L1;
if(!empty($parm))
{
if(is_string($parm))
{
parse_str($parm, $parms);
}
else
{
$parms = $parm;
}
}
if(!$OTHERNEWS_STYLE)
{
if(THEME_LEGACY !== true) // v2.x
{
if(!defined("OTHERNEWS_COLS"))
{
define("OTHERNEWS_COLS",false);
}
$template = e107::getTemplate('news', 'news_menu', 'other', true, true);
$item_selector = '<div class="btn-group pull-right float-right float-end"><a class="btn btn-mini btn-sm btn-xs btn-default btn-secondary" href="#otherNews" data-slide="prev" data-bs-slide="prev">‹</a>
<a class="btn btn-sm btn-mini btn-xs btn-default btn-secondary" href="#otherNews" data-slide="next" data-bs-slide="next">›</a></div>';
if(!empty($parms['caption']))
{
$template['caption'] = e107::getParser()->toHTML($parms['caption'],true,'TITLE');
}
$caption = "<div class='inline-text'>".$template['caption']." ".$item_selector."</div>";
$OTHERNEWS_STYLE = $template['item'];
}
else //v1.x
{
if(!empty($parms['caption']))
{
$caption = e107::getParser()->toHTML($parms['caption'], true,'TITLE');
}
$template['start'] = '';
$template['end'] = '';
$OTHERNEWS_STYLE = "
<div style='padding:3px;width:100%'>
<table style='border-bottom:1px solid black;width:100%' cellpadding='0' cellspacing='0'>
<tr>
<td style='vertical-align:top;padding:3px;width:20px'>
{NEWSCATICON}
</td><td style='text-align:left;padding:3px;vertical-align:top'>
{NEWSTITLELINK}
</td></tr></table>
</div>\n";
}
}
if(!defined("OTHERNEWS_LIMIT")){
define("OTHERNEWS_LIMIT",10);
}
if(!defined("OTHERNEWS_ITEMLINK")){
define("OTHERNEWS_ITEMLINK","");
}
if(!defined("OTHERNEWS_CATLINK")){
define("OTHERNEWS_CATLINK","");
}
if(!defined("OTHERNEWS_THUMB")){
define("OTHERNEWS_THUMB","border:0px");
}
if(!defined("OTHERNEWS_CATICON")){
define("OTHERNEWS_CATICON","border:0px");
}
if(!defined("OTHERNEWS_COLS")){
define("OTHERNEWS_COLS","1");
}
if(!defined("OTHERNEWS_CELL")){
define("OTHERNEWS_CELL","padding:0px;vertical-align:top");
}
if(!defined("OTHERNEWS_SPACING")){
define("OTHERNEWS_SPACING","0");
}
if(!isset($param))
{
$param = array();
}
$param['itemlink'] = defset('OTHERNEWS_ITEMLINK');
$param['thumbnail'] = defset('OTHERNEWS_THUMB');
$param['catlink'] = defset('OTHERNEWS_CATLINK');
$param['caticon'] = defset('OTHERNEWS_CATICON');
$param['template_key'] = 'news_menu/other/item';
$style = defset('OTHERNEWS_CELL');
$nbr_cols = defset('OTHERNEWS_COLS');
$_t = time();
$query = "SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_id, nc.category_name, nc.category_sef, nc.category_icon FROM #news AS n
LEFT JOIN #user AS u ON n.news_author = u.user_id
LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
WHERE n.news_class IN (".USERCLASS_LIST.") AND n.news_start < ".$_t." AND (n.news_end=0 || n.news_end>".$_t.") AND FIND_IN_SET(2, n.news_render_type) ORDER BY n.news_datestamp DESC LIMIT 0,".OTHERNEWS_LIMIT;
if ($sql->gen($query))
{
$text = $tp->parseTemplate($template['start'],true);
if(OTHERNEWS_COLS !== false)
{
$text .= "<table style='width:100%' cellpadding='0' cellspacing='".OTHERNEWS_SPACING."'>";
$t = 0;
$wid = floor(100/$nbr_cols);
while ($row = $sql->fetch())
{
$text .= ($t % $nbr_cols == 0) ? "<tr>" : "";
$text .= "\n<td style='$style ; width:$wid%;'>\n";
$text .= $ix->render_newsitem($row, 'return', '', $OTHERNEWS_STYLE, $param);
$text .= "\n</td>\n";
if (($t+1) % $nbr_cols == 0) {
$text .= "</tr>";
$t++;
}
else {
$t++;
}
}
while ($t % $nbr_cols != 0)
{
$text .= "<td style='width:$wid'> </td>\n";
$text .= (($t+1) % $nbr_cols == 0) ? "</tr>" : "";
$t++;
}
$text .= "</table>";
}
else // perfect for divs.
{
$loop = 0;
while ($row = $sql->fetch())
{
$active = ($loop == 0) ? 'active' : '';
$TMPL = str_replace("{ACTIVE}", $active, $OTHERNEWS_STYLE);
$text .= $ix->render_newsitem($row, 'return', '', $TMPL, $param);
$loop++;
}
}
$text .= $tp->parseTemplate($template['end'], true);
// Save Data
ob_start();
$ns->tablerender($caption, $text, 'other_news');
$cache_data = ob_get_flush();
e107::getCache()->set("nq_othernews", $cache_data);
}