1
|
|
|
<?php |
|
|
|
|
2
|
|
|
// |
3
|
|
|
// ------------------------------------------------------------------------ // |
4
|
|
|
// XOOPS - PHP Content Management System // |
5
|
|
|
// Copyright (c) 2000-2016 XOOPS.org // |
6
|
|
|
// <http://xoops.org/> // |
7
|
|
|
// ------------------------------------------------------------------------- // |
8
|
|
|
// This program is free software; you can redistribute it and/or modify // |
9
|
|
|
// it under the terms of the GNU General Public License as published by // |
10
|
|
|
// the Free Software Foundation; either version 2 of the License, or // |
11
|
|
|
// (at your option) any later version. // |
12
|
|
|
// // |
13
|
|
|
// You may not change or alter any portion of this comment or credits // |
14
|
|
|
// of supporting developers from this source code or any supporting // |
15
|
|
|
// source code which is considered copyrighted (c) material of the // |
16
|
|
|
// original comment or credit authors. // |
17
|
|
|
// // |
18
|
|
|
// This program is distributed in the hope that it will be useful, // |
19
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
20
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
21
|
|
|
// GNU General Public License for more details. // |
22
|
|
|
// // |
23
|
|
|
// You should have received a copy of the GNU General Public License // |
24
|
|
|
// along with this program; if not, write to the Free Software // |
25
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
26
|
|
|
// ------------------------------------------------------------------------ // |
27
|
|
|
// defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
28
|
|
|
|
29
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/news/class/class.newsstory.php'; |
30
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/news/class/class.newstopic.php'; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Notes about the spotlight : |
34
|
|
|
* If you have restricted topics on index page (in fact if the program must completly respect the permissions) and if |
35
|
|
|
* the news you have selected to be viewed in the spotlight can't be viewed by someone then the spotlight is not visible ! |
36
|
|
|
* This is available in the classical and in the tabbed view. |
37
|
|
|
* But if you have uncheck the option "Restrict topics on index page", then the news will be visible but users without |
38
|
|
|
* permissions will be rejected when they will try to read news content. |
39
|
|
|
* |
40
|
|
|
* Also, if you have selected a tabbed view and wanted to use the Spotlight but did not choosed a story, then the block |
41
|
|
|
* will switch to the "most recent news" mode (the visible news will be searched according to the permissions) |
42
|
|
|
* @param $options |
43
|
|
|
* @return array |
|
|
|
|
44
|
|
|
*/ |
45
|
|
|
function b_news_top_show($options) |
|
|
|
|
46
|
|
|
{ |
47
|
|
|
global $xoopsConfig; |
|
|
|
|
48
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/news/include/functions.php'; |
49
|
|
|
$myts = MyTextSanitizer::getInstance(); |
50
|
|
|
$block = array(); |
51
|
|
|
$displayname = news_getmoduleoption('displayname'); |
52
|
|
|
$tabskin = news_getmoduleoption('tabskin'); |
53
|
|
|
|
54
|
|
View Code Duplication |
if (file_exists(XOOPS_ROOT_PATH . '/modules/news/language/' . $xoopsConfig['language'] . '/main.php')) { |
|
|
|
|
55
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/news/language/' . $xoopsConfig['language'] . '/main.php'; |
56
|
|
|
} else { |
57
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/news/language/english/main.php'; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
$block['displayview'] = $options[8]; |
61
|
|
|
$block['tabskin'] = $tabskin; |
62
|
|
|
$block['imagesurl'] = XOOPS_URL . '/modules/news/assets/images/'; |
63
|
|
|
|
64
|
|
|
$restricted = news_getmoduleoption('restrictindex'); |
65
|
|
|
$dateformat = news_getmoduleoption('dateformat'); |
66
|
|
|
$infotips = news_getmoduleoption('infotips'); |
67
|
|
|
$newsrating = news_getmoduleoption('ratenews'); |
68
|
|
|
if ($dateformat == '') { |
69
|
|
|
$dateformat = 's'; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
$perm_verified = false; |
73
|
|
|
$news_visible = true; |
74
|
|
|
// Is the spotlight visible ? |
75
|
|
|
if ($options[4] == 1 && $restricted && $options[5] == 0) { |
76
|
|
|
$perm_verified = true; |
77
|
|
|
$permittedtopics = news_MygetItemIds(); |
78
|
|
|
$permstory = new NewsStory($options[6]); |
79
|
|
|
if (!in_array($permstory->topicid(), $permittedtopics)) { |
80
|
|
|
$usespotlight = false; |
|
|
|
|
81
|
|
|
$news_visible = false; |
82
|
|
|
$topicstitles = array(); |
|
|
|
|
83
|
|
|
} |
84
|
|
|
$options[4] == 0; |
85
|
|
|
} |
86
|
|
|
// Try to see what tabs are visibles (if we are in restricted view of course) |
87
|
|
|
if ($options[8] == 2 && $restricted && $options[14] != 0) { |
88
|
|
|
$topics2 = array(); |
89
|
|
|
$permittedtopics = news_MygetItemIds(); |
90
|
|
|
$topics = array_slice($options, 14); |
91
|
|
|
foreach ($topics as $onetopic) { |
92
|
|
|
if (in_array($onetopic, $permittedtopics)) { |
93
|
|
|
$topics2[] = $onetopic; |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
$before = array_slice($options, 0, 14); |
97
|
|
|
$options = array_merge($before, $topics2); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
if ($options[8] == 2) { // Tabbed view ******************************************************************************************** |
101
|
|
|
$defcolors[1] = array('#F90', '#FFFFFF', '#F90', '#C60', '#999'); // Bar Style |
|
|
|
|
102
|
|
|
$defcolors[2] = array('#F90', '#FFFFFF', '#F90', '#AAA', '#666'); // Beveled |
103
|
|
|
$defcolors[3] = array('#F90', '#FFFFFF', '', '#789', '#789'); // Classic |
104
|
|
|
$defcolors[4] = array('#F90', '#FFFFFF', '', '', ''); // Folders |
105
|
|
|
$defcolors[5] = array('#F90', '#FFFFFF', '#CCC', 'inherit', '#999'); // MacOs |
106
|
|
|
$defcolors[6] = array('#F90', '#FFFFFF', '#FFF', '#DDD', '#999'); // Plain |
107
|
|
|
$defcolors[7] = array('#F90', '#FFFFFF', '', '', ''); // Rounded |
108
|
|
|
$defcolors[8] = array('#F90', '#FFFFFF', '#F90', '#930', '#C60'); // ZDnet |
109
|
|
|
|
110
|
|
|
$myurl = $_SERVER['PHP_SELF']; |
111
|
|
|
if (substr($myurl, strlen($myurl) - 1, 1) === '/') { |
112
|
|
|
$myurl .= 'index.php'; |
113
|
|
|
} |
114
|
|
|
$myurl .= '?'; |
115
|
|
|
|
116
|
|
|
foreach ($_GET as $key => $value) { |
117
|
|
|
if ($key !== 'NewsTab') { |
118
|
|
|
$myurl .= $key . '=' . $value . '&'; |
119
|
|
|
} |
120
|
|
|
} |
121
|
|
|
$block['url'] = $myurl; |
122
|
|
|
|
123
|
|
|
$tabscount = 0; |
124
|
|
|
$usespotlight = false; |
125
|
|
|
|
126
|
|
|
if (isset($_GET['NewsTab'])) { |
127
|
|
|
$_SESSION['NewsTab'] = (int)$_GET['NewsTab']; |
128
|
|
|
$currenttab = (int)$_GET['NewsTab']; |
129
|
|
|
} elseif (isset($_SESSION['NewsTab'])) { |
130
|
|
|
$currenttab = (int)$_SESSION['NewsTab']; |
131
|
|
|
} else { |
132
|
|
|
$currenttab = 0; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
$tmpstory = new NewsStory(); |
136
|
|
|
$topic = new NewsTopic(); |
137
|
|
|
$topicstitles = array(); |
138
|
|
|
if ($options[4] == 1) { // Spotlight enabled |
139
|
|
|
$topicstitles[0] = _MB_NEWS_SPOTLIGHT_TITLE; |
140
|
|
|
++$tabscount; |
141
|
|
|
$usespotlight = true; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
if ($options[5] == 0 && $restricted) { // Use a specific news and we are in restricted mode |
145
|
|
|
if (!$perm_verified) { |
146
|
|
|
$permittedtopics = news_MygetItemIds(); |
147
|
|
|
$permstory = new NewsStory($options[6]); |
148
|
|
|
if (!in_array($permstory->topicid(), $permittedtopics)) { |
149
|
|
|
$usespotlight = false; |
150
|
|
|
$topicstitles = array(); |
151
|
|
|
} |
152
|
|
|
//unset($permstory); |
153
|
|
|
} else { |
154
|
|
|
if (!$news_visible) { |
155
|
|
|
$usespotlight = false; |
156
|
|
|
$topicstitles = array(); |
157
|
|
|
} |
158
|
|
|
} |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
$block['use_spotlight'] = $usespotlight; |
162
|
|
|
|
163
|
|
|
if (isset($options[14]) && $options[14] != 0) { // Topic to use |
164
|
|
|
$topics = array_slice($options, 14); |
165
|
|
|
$tabscount += count($topics); |
166
|
|
|
$topicstitles = $topic->getTopicTitleFromId($topics, $topicstitles); |
167
|
|
|
} |
168
|
|
|
$tabs = array(); |
169
|
|
|
if ($usespotlight) { |
170
|
|
|
$tabs[] = array('id' => 0, 'title' => _MB_NEWS_SPOTLIGHT_TITLE); |
171
|
|
|
} |
172
|
|
|
if (count($topics) > 0) { |
173
|
|
|
foreach ($topics as $onetopic) { |
|
|
|
|
174
|
|
|
if (isset($topicstitles[$onetopic])) { |
175
|
|
|
$tabs[] = array('id' => $onetopic, 'title' => $topicstitles[$onetopic]['title'], 'picture' => $topicstitles[$onetopic]['picture']); |
176
|
|
|
} |
177
|
|
|
} |
178
|
|
|
} |
179
|
|
|
$block['tabs'] = $tabs; |
180
|
|
|
$block['current_is_spotlight'] = false; |
181
|
|
|
$block['current_tab'] = $currenttab; |
182
|
|
|
$block['use_rating'] = $newsrating; |
183
|
|
|
|
184
|
|
|
if ($currenttab == 0 && $usespotlight) { // Spotlight or not ? |
185
|
|
|
$block['current_is_spotlight'] = true; |
186
|
|
|
if ($options[5] == 0 && $options[6] == 0) { // If the story to use was no selected then we switch to the "recent news" mode. |
187
|
|
|
$options[5] = 1; |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
if ($options[5] == 0) { // Use a specific news |
191
|
|
|
if (!isset($permstory)) { |
192
|
|
|
$tmpstory->NewsStory($options[6]); |
|
|
|
|
193
|
|
|
} else { |
194
|
|
|
$tmpstory = $permstory; |
195
|
|
|
} |
196
|
|
View Code Duplication |
} else { // Use the most recent news |
|
|
|
|
197
|
|
|
$stories = array(); |
|
|
|
|
198
|
|
|
$stories = NewsStory::getAllPublished(1, 0, $restricted, 0, 1, true, $options[0]); |
199
|
|
|
if (count($stories) > 0) { |
200
|
|
|
$firststory = $stories[0]; |
201
|
|
|
$tmpstory->NewsStory($firststory->storyid()); |
|
|
|
|
202
|
|
|
} else { |
203
|
|
|
$block['use_spotlight'] = false; |
204
|
|
|
} |
205
|
|
|
} |
206
|
|
|
$spotlight = array(); |
207
|
|
|
$spotlight['title'] = $tmpstory->title(); |
208
|
|
View Code Duplication |
if ($options[7] !== '') { |
|
|
|
|
209
|
|
|
$spotlight['image'] = sprintf("<a href='%s'>%s</a>", XOOPS_URL . '/modules/news/article.php?storyid=' . $tmpstory->storyid(), $myts->displayTarea($options[7], $tmpstory->nohtml)); |
210
|
|
|
} |
211
|
|
|
$spotlight['text'] = $tmpstory->hometext(); |
212
|
|
|
|
213
|
|
|
// Added 16 february 2007 ***************************************** |
214
|
|
|
$story_user = null; |
|
|
|
|
215
|
|
|
$story_user = new XoopsUser($tmpstory->uid()); |
216
|
|
View Code Duplication |
if (is_object($story_user)) { |
|
|
|
|
217
|
|
|
$spotlight['avatar'] = XOOPS_UPLOAD_URL . '/' . $story_user->getVar('user_avatar'); |
218
|
|
|
} |
219
|
|
|
// **************************************************************** |
220
|
|
|
$spotlight['id'] = $tmpstory->storyid(); |
221
|
|
|
$spotlight['date'] = formatTimestamp($tmpstory->published(), $dateformat); |
222
|
|
|
$spotlight['hits'] = $tmpstory->counter(); |
223
|
|
|
$spotlight['rating'] = number_format($tmpstory->rating(), 2); |
224
|
|
|
$spotlight['votes'] = $tmpstory->votes(); |
225
|
|
View Code Duplication |
if (strlen(xoops_trim($tmpstory->bodytext())) > 0) { |
|
|
|
|
226
|
|
|
$spotlight['read_more'] = true; |
227
|
|
|
} else { |
228
|
|
|
$spotlight['read_more'] = false; |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
$spotlight['readmore'] = sprintf("<a href='%s'>%s</a>", XOOPS_URL . '/modules/news/article.php?storyid=' . $tmpstory->storyid(), _MB_READMORE); |
232
|
|
|
$spotlight['title_with_link'] = sprintf("<a href='%s'>%s</a>", XOOPS_URL . '/modules/news/article.php?storyid=' . $tmpstory->storyid(), $tmpstory->title()); |
233
|
|
View Code Duplication |
if ($tmpstory->votes() == 1) { |
|
|
|
|
234
|
|
|
$spotlight['number_votes'] = _NW_ONEVOTE; |
235
|
|
|
} else { |
236
|
|
|
$spotlight['number_votes'] = sprintf(_NW_NUMVOTES, $tmpstory->votes()); |
237
|
|
|
} |
238
|
|
|
|
239
|
|
|
$spotlight['votes_with_text'] = sprintf(_NW_NUMVOTES, $tmpstory->votes()); |
240
|
|
|
$spotlight['topicid'] = $tmpstory->topicid(); |
241
|
|
|
$spotlight['topic_title'] = $tmpstory->topic_title(); |
242
|
|
|
// Added, topic's image and description |
243
|
|
|
$spotlight['topic_image'] = XOOPS_URL . '/modules/news/assets/images/topics/' . $tmpstory->topic_imgurl(); |
244
|
|
|
$spotlight['topic_description'] = $myts->displayTarea($tmpstory->topic_description, 1); |
|
|
|
|
245
|
|
|
|
246
|
|
|
if ($displayname != 3) { |
247
|
|
|
$spotlight['author'] = sprintf('%s %s', _POSTEDBY, $tmpstory->uname()); |
248
|
|
|
$spotlight['author_with_link'] = sprintf("%s <a href='%s'>%s</a>", _POSTEDBY, XOOPS_URL . '/userinfo.php?uid=' . $tmpstory->uid(), $tmpstory->uname()); |
249
|
|
|
} else { |
250
|
|
|
$spotlight['author'] = ''; |
251
|
|
|
$spotlight['author_with_link'] = ''; |
252
|
|
|
} |
253
|
|
|
$spotlight['author_id'] = $tmpstory->uid(); |
254
|
|
|
|
255
|
|
|
// Create the summary table under the spotlight text |
256
|
|
View Code Duplication |
if (isset($options[14]) && $options[14] == 0) { // Use all topics |
|
|
|
|
257
|
|
|
$stories = NewsStory::getAllPublished($options[1], 0, $restricted, 0, 1, true, $options[0]); |
258
|
|
|
} else { // Use some topics |
259
|
|
|
$topics = array_slice($options, 14); |
260
|
|
|
$stories = NewsStory::getAllPublished($options[1], 0, $restricted, $topics, 1, true, $options[0]); |
|
|
|
|
261
|
|
|
} |
262
|
|
|
if (count($stories) > 0) { |
263
|
|
|
foreach ($stories as $key => $story) { |
|
|
|
|
264
|
|
|
$news = array(); |
265
|
|
|
$title = $story->title(); |
266
|
|
View Code Duplication |
if (strlen($title) > $options[2]) { |
|
|
|
|
267
|
|
|
$title = xoops_substr($title, 0, $options[2] + 3); |
268
|
|
|
} |
269
|
|
|
$news['title'] = $title; |
270
|
|
|
$news['id'] = $story->storyid(); |
271
|
|
|
$news['date'] = formatTimestamp($story->published(), $dateformat); |
272
|
|
|
$news['hits'] = $story->counter(); |
273
|
|
|
$news['rating'] = number_format($story->rating(), 2); |
274
|
|
|
$news['votes'] = $story->votes(); |
275
|
|
|
$news['topicid'] = $story->topicid(); |
276
|
|
|
$news['topic_title'] = $story->topic_title(); |
277
|
|
|
$news['topic_color'] = '#' . $myts->displayTarea($story->topic_color); |
278
|
|
|
$news['picture'] = XOOPS_URL . '/uploads/news/image/' . $story->picture(); |
279
|
|
|
$news['pictureinfo'] = $story->pictureinfo(); |
280
|
|
View Code Duplication |
if ($displayname != 3) { |
|
|
|
|
281
|
|
|
$news['author'] = sprintf('%s %s', _POSTEDBY, $story->uname()); |
282
|
|
|
} else { |
283
|
|
|
$news['author'] = ''; |
284
|
|
|
} |
285
|
|
View Code Duplication |
if ($options[3] > 0) { |
|
|
|
|
286
|
|
|
$html = $story->nohtml() == 1 ? 0 : 1; |
287
|
|
|
$news['teaser'] = news_truncate_tagsafe($myts->displayTarea($story->hometext(), $html), $options[3] + 3); |
288
|
|
|
} else { |
289
|
|
|
$news['teaser'] = ''; |
290
|
|
|
} |
291
|
|
|
if ($infotips > 0) { |
292
|
|
|
$news['infotips'] = ' title="' . news_make_infotips($story->hometext()) . '"'; |
293
|
|
|
} else { |
294
|
|
|
$news['infotips'] = ''; |
295
|
|
|
} |
296
|
|
|
|
297
|
|
|
$news['title_with_link'] = sprintf("<a href='%s'%s>%s</a>", XOOPS_URL . '/modules/news/article.php?storyid=' . $story->storyid(), $news['infotips'], $title); |
298
|
|
|
$spotlight['news'][] = $news; |
299
|
|
|
} |
300
|
|
|
} |
301
|
|
|
|
302
|
|
|
$block['spotlight'] = $spotlight; |
303
|
|
|
} else { |
304
|
|
|
if ($tabscount > 0) { |
305
|
|
|
$topics = array_slice($options, 14); |
|
|
|
|
306
|
|
|
$thetopic = $currenttab; |
307
|
|
|
$stories = NewsStory::getAllPublished($options[1], 0, $restricted, $thetopic, 1, true, $options[0]); |
308
|
|
|
|
309
|
|
|
$topic->getTopic($thetopic); |
310
|
|
|
// Added, topic's image and description |
311
|
|
|
$block['topic_image'] = XOOPS_URL . '/modules/news/assets/images/topics/' . $topic->topic_imgurl(); |
312
|
|
|
$block['topic_description'] = $topic->topic_description(); |
313
|
|
|
|
314
|
|
|
$smallheader = array(); |
315
|
|
|
$stats = $topic->getTopicMiniStats($thetopic); |
316
|
|
|
$smallheader[] = sprintf("<a href='%s'>%s</a>", XOOPS_URL . '/modules/news/index.php?storytopic=' . $thetopic, _MB_READMORE); |
317
|
|
|
$smallheader[] = sprintf('%u %s', $stats['count'], _NW_ARTICLES); |
318
|
|
|
$smallheader[] = sprintf('%u %s', $stats['reads'], _READS); |
319
|
|
|
if (count($stories) > 0) { |
320
|
|
|
foreach ($stories as $key => $story) { |
|
|
|
|
321
|
|
|
$news = array(); |
322
|
|
|
$title = $story->title(); |
323
|
|
|
if (strlen($title) > $options[2]) { |
324
|
|
|
$title = news_truncate_tagsafe($title, $options[2] + 3); |
325
|
|
|
} |
326
|
|
View Code Duplication |
if ($options[7] !== '') { |
|
|
|
|
327
|
|
|
$news['image'] = sprintf("<a href='%s'>%s</a>", XOOPS_URL . '/modules/news/article.php?storyid=' . $story->storyid(), $myts->displayTarea($options[7], $story->nohtml)); |
328
|
|
|
} |
329
|
|
View Code Duplication |
if ($options[3] > 0) { |
|
|
|
|
330
|
|
|
$html = $story->nohtml() == 1 ? 0 : 1; |
331
|
|
|
$news['text'] = news_truncate_tagsafe($myts->displayTarea($story->hometext(), $html), $options[3] + 3); |
332
|
|
|
} else { |
333
|
|
|
$news['text'] = ''; |
334
|
|
|
} |
335
|
|
|
|
336
|
|
View Code Duplication |
if ($story->votes() == 1) { |
|
|
|
|
337
|
|
|
$news['number_votes'] = _NW_ONEVOTE; |
338
|
|
|
} else { |
339
|
|
|
$news['number_votes'] = sprintf(_NW_NUMVOTES, $story->votes()); |
340
|
|
|
} |
341
|
|
|
if ($infotips > 0) { |
342
|
|
|
$news['infotips'] = ' title="' . news_make_infotips($story->hometext()) . '"'; |
343
|
|
|
} else { |
344
|
|
|
$news['infotips'] = ''; |
345
|
|
|
} |
346
|
|
|
$news['title'] = sprintf("<a href='%s' %s>%s</a>", XOOPS_URL . '/modules/news/article.php?storyid=' . $story->storyid(), $news['infotips'], $title); |
347
|
|
|
$news['id'] = $story->storyid(); |
348
|
|
|
$news['date'] = formatTimestamp($story->published(), $dateformat); |
349
|
|
|
$news['hits'] = $story->counter(); |
350
|
|
|
$news['rating'] = number_format($story->rating(), 2); |
351
|
|
|
$news['votes'] = $story->votes(); |
352
|
|
|
$news['topicid'] = $story->topicid(); |
353
|
|
|
$news['topic_title'] = $story->topic_title(); |
354
|
|
|
$news['topic_color'] = '#' . $myts->displayTarea($story->topic_color); |
355
|
|
|
$news['picture'] = XOOPS_URL . '/uploads/news/image/' . $story->picture(); |
356
|
|
|
$news['pictureinfo'] = $story->pictureinfo(); |
357
|
|
|
|
358
|
|
View Code Duplication |
if ($displayname != 3) { |
|
|
|
|
359
|
|
|
$news['author'] = sprintf('%s %s', _POSTEDBY, $story->uname()); |
360
|
|
|
} else { |
361
|
|
|
$news['author'] = ''; |
362
|
|
|
} |
363
|
|
|
$news['title_with_link'] = sprintf("<a href='%s'%s>%s</a>", XOOPS_URL . '/modules/news/article.php?storyid=' . $story->storyid(), $news['infotips'], $title); |
364
|
|
|
$block['news'][] = $news; |
365
|
|
|
} |
366
|
|
|
$block['smallheader'] = $smallheader; |
367
|
|
|
} |
368
|
|
|
} |
369
|
|
|
} |
370
|
|
|
$block['lang_on'] = _ON; // on |
371
|
|
|
$block['lang_reads'] = _READS; // reads |
372
|
|
|
// Default values |
373
|
|
|
$block['color1'] = $defcolors[$tabskin][0]; |
374
|
|
|
$block['color2'] = $defcolors[$tabskin][1]; |
375
|
|
|
$block['color3'] = $defcolors[$tabskin][2]; |
376
|
|
|
$block['color4'] = $defcolors[$tabskin][3]; |
377
|
|
|
$block['color5'] = $defcolors[$tabskin][4]; |
378
|
|
|
|
379
|
|
|
if (xoops_trim($options[9]) !== '') { |
380
|
|
|
$block['color1'] = $options[9]; |
381
|
|
|
} |
382
|
|
|
if (xoops_trim($options[10]) !== '') { |
383
|
|
|
$block['color2'] = $options[10]; |
384
|
|
|
} |
385
|
|
|
if (xoops_trim($options[11]) !== '') { |
386
|
|
|
$block['color3'] = $options[11]; |
387
|
|
|
} |
388
|
|
|
if (xoops_trim($options[12]) !== '') { |
389
|
|
|
$block['color4'] = $options[12]; |
390
|
|
|
} |
391
|
|
|
if (xoops_trim($options[13]) !== '') { |
392
|
|
|
$block['color5'] = $options[13]; |
393
|
|
|
} |
394
|
|
|
} else { // ************************ Classical view ************************************************************************************************************** |
395
|
|
|
$tmpstory = new NewsStory; |
|
|
|
|
396
|
|
View Code Duplication |
if (isset($options[14]) && $options[14] == 0) { |
|
|
|
|
397
|
|
|
$stories = NewsStory::getAllPublished($options[1], 0, $restricted, 0, 1, true, $options[0]); |
398
|
|
|
} else { |
399
|
|
|
$topics = array_slice($options, 14); |
400
|
|
|
$stories = NewsStory::getAllPublished($options[1], 0, $restricted, $topics, 1, true, $options[0]); |
|
|
|
|
401
|
|
|
} |
402
|
|
|
|
403
|
|
|
if (!count($stories)) { |
404
|
|
|
return ''; |
405
|
|
|
} |
406
|
|
|
$topic = new NewsTopic(); |
|
|
|
|
407
|
|
|
|
408
|
|
|
foreach ($stories as $key => $story) { |
|
|
|
|
409
|
|
|
$news = array(); |
410
|
|
|
$title = $story->title(); |
411
|
|
View Code Duplication |
if (strlen($title) > $options[2]) { |
|
|
|
|
412
|
|
|
$title = xoops_substr($title, 0, $options[2] + 3); |
413
|
|
|
} |
414
|
|
|
|
415
|
|
|
//if spotlight is enabled and this is either the first article or the selected one |
416
|
|
|
if (($options[5] == 0) && ($options[4] == 1) && (($options[6] > 0 && $options[6] == $story->storyid()) || ($options[6] == 0 && $key == 0))) { |
417
|
|
|
$spotlight = array(); |
418
|
|
|
$visible = true; |
419
|
|
|
if ($restricted) { |
420
|
|
|
$permittedtopics = news_MygetItemIds(); |
421
|
|
|
if (!in_array($story->topicid(), $permittedtopics)) { |
422
|
|
|
$visible = false; |
423
|
|
|
} |
424
|
|
|
} |
425
|
|
|
|
426
|
|
|
if ($visible) { |
427
|
|
|
$spotlight['title'] = $title; |
428
|
|
View Code Duplication |
if ($options[7] !== '') { |
|
|
|
|
429
|
|
|
$spotlight['image'] = sprintf("<a href='%s'>%s</a>", XOOPS_URL . '/modules/news/article.php?storyid=' . $story->storyid(), $myts->displayTarea($options[7], $story->nohtml)); |
430
|
|
|
} |
431
|
|
|
// Added 16 february 2007 ***************************************** |
432
|
|
|
$story_user = null; |
|
|
|
|
433
|
|
|
$story_user = new XoopsUser($story->uid()); |
434
|
|
View Code Duplication |
if (is_object($story_user)) { |
|
|
|
|
435
|
|
|
$spotlight['avatar'] = XOOPS_UPLOAD_URL . '/' . $story_user->getVar('user_avatar'); |
436
|
|
|
} |
437
|
|
|
// **************************************************************** |
438
|
|
|
$spotlight['text'] = $story->hometext(); |
439
|
|
|
$spotlight['id'] = $story->storyid(); |
440
|
|
|
$spotlight['date'] = formatTimestamp($story->published(), $dateformat); |
441
|
|
|
$spotlight['hits'] = $story->counter(); |
442
|
|
|
$spotlight['rating'] = $story->rating(); |
443
|
|
|
$spotlight['votes'] = $story->votes(); |
444
|
|
|
$spotlight['topicid'] = $story->topicid(); |
445
|
|
|
$spotlight['topic_title'] = $story->topic_title(); |
446
|
|
|
$spotlight['topic_color'] = '#' . $myts->displayTarea($story->topic_color); |
447
|
|
|
// Added, topic's image and description |
448
|
|
|
$spotlight['topic_image'] = XOOPS_URL . '/modules/news/assets/images/topics/' . $story->topic_imgurl(); |
449
|
|
|
$spotlight['topic_description'] = $myts->displayTarea($story->topic_description, 1); |
450
|
|
View Code Duplication |
if (strlen(xoops_trim($story->bodytext())) > 0) { |
|
|
|
|
451
|
|
|
$spotlight['read_more'] = true; |
452
|
|
|
} else { |
453
|
|
|
$spotlight['read_more'] = false; |
454
|
|
|
} |
455
|
|
|
|
456
|
|
View Code Duplication |
if ($displayname != 3) { |
|
|
|
|
457
|
|
|
$spotlight['author'] = sprintf('%s %s', _POSTEDBY, $story->uname()); |
458
|
|
|
} else { |
459
|
|
|
$spotlight['author'] = ''; |
460
|
|
|
} |
461
|
|
|
} |
462
|
|
|
$block['spotlight'] = $spotlight; |
463
|
|
|
} else { |
464
|
|
|
$news['title'] = $title; |
465
|
|
|
$news['id'] = $story->storyid(); |
466
|
|
|
$news['date'] = formatTimestamp($story->published(), $dateformat); |
467
|
|
|
$news['hits'] = $story->counter(); |
468
|
|
|
$news['rating'] = $story->rating(); |
469
|
|
|
$news['votes'] = $story->votes(); |
470
|
|
|
$news['topicid'] = $story->topicid(); |
471
|
|
|
$news['topic_title'] = $story->topic_title(); |
472
|
|
|
$news['topic_color'] = '#' . $myts->displayTarea($story->topic_color); |
473
|
|
|
$news['picture'] = XOOPS_URL . '/uploads/news/image/' . $story->picture(); |
474
|
|
|
$news['pictureinfo'] = $story->pictureinfo(); |
475
|
|
|
|
476
|
|
View Code Duplication |
if ($displayname != 3) { |
|
|
|
|
477
|
|
|
$news['author'] = sprintf('%s %s', _POSTEDBY, $story->uname()); |
478
|
|
|
} else { |
479
|
|
|
$news['author'] = ''; |
480
|
|
|
} |
481
|
|
|
if ($options[3] > 0) { |
482
|
|
|
$html = $story->nohtml() == 1 ? 0 : 1; |
483
|
|
|
$news['teaser'] = news_truncate_tagsafe($myts->displayTarea($story->hometext(), $html), $options[3] + 3); |
484
|
|
|
$news['infotips'] = ''; |
485
|
|
|
} else { |
486
|
|
|
$news['teaser'] = ''; |
487
|
|
|
if ($infotips > 0) { |
488
|
|
|
$news['infotips'] = ' title="' . news_make_infotips($story->hometext()) . '"'; |
489
|
|
|
} else { |
490
|
|
|
$news['infotips'] = ''; |
491
|
|
|
} |
492
|
|
|
} |
493
|
|
|
$block['stories'][] = $news; |
494
|
|
|
} |
495
|
|
|
} |
496
|
|
|
|
497
|
|
|
// If spotlight article was not in the fetched stories |
498
|
|
|
if (!isset($spotlight) && $options[4]) { |
499
|
|
|
$block['use_spotlight'] = true; |
500
|
|
|
$visible = true; |
501
|
|
|
if ($options[5] == 0 && $restricted) { // Use a specific news and we are in restricted mode |
502
|
|
|
$permittedtopics = news_MygetItemIds(); |
503
|
|
|
$permstory = new NewsStory($options[6]); |
504
|
|
|
if (!in_array($permstory->topicid(), $permittedtopics)) { |
505
|
|
|
$visible = false; |
506
|
|
|
} |
507
|
|
|
unset($permstory); |
508
|
|
|
} |
509
|
|
|
|
510
|
|
|
if ($options[5] == 0) { // Use a specific news |
511
|
|
|
if ($visible) { |
512
|
|
|
$spotlightArticle = new NewsStory($options[6]); |
513
|
|
|
} else { |
514
|
|
|
$block['use_spotlight'] = false; |
515
|
|
|
} |
516
|
|
View Code Duplication |
} else { // Use the most recent news |
|
|
|
|
517
|
|
|
$stories = array(); |
|
|
|
|
518
|
|
|
$stories = NewsStory::getAllPublished(1, 0, $restricted, 0, 1, true, $options[0]); |
519
|
|
|
if (count($stories) > 0) { |
520
|
|
|
$firststory = $stories[0]; |
521
|
|
|
$spotlightArticle = new NewsStory($firststory->storyid()); |
522
|
|
|
} else { |
523
|
|
|
$block['use_spotlight'] = false; |
524
|
|
|
} |
525
|
|
|
} |
526
|
|
|
if ($block['use_spotlight'] == true) { |
|
|
|
|
527
|
|
|
$spotlight = array(); |
528
|
|
|
$spotlight['title'] = xoops_substr($spotlightArticle->title(), 0, $options[2] - 1); |
|
|
|
|
529
|
|
View Code Duplication |
if ($options[7] !== '') { |
|
|
|
|
530
|
|
|
$spotlight['image'] = |
531
|
|
|
sprintf("<a href='%s'>%s</a>", XOOPS_URL . '/modules/news/article.php?storyid=' . $spotlightArticle->storyid(), $myts->displayTarea($options[7], $spotlightArticle->nohtml)); |
532
|
|
|
} |
533
|
|
|
// Added 16 february 2007 ***************************************** |
534
|
|
|
$story_user = null; |
|
|
|
|
535
|
|
|
$story_user = new XoopsUser($spotlightArticle->uid()); |
536
|
|
View Code Duplication |
if (is_object($story_user)) { |
|
|
|
|
537
|
|
|
$spotlight['avatar'] = XOOPS_UPLOAD_URL . '/' . $story_user->getVar('user_avatar'); |
538
|
|
|
} |
539
|
|
|
// **************************************************************** |
540
|
|
|
$spotlight['topicid'] = $spotlightArticle->topicid(); |
541
|
|
|
$spotlight['topic_title'] = $spotlightArticle->topic_title(); |
542
|
|
|
$spotlight['topic_color'] = '#' . $myts->displayTarea($spotlightArticle->topic_color); |
|
|
|
|
543
|
|
|
$spotlight['text'] = $spotlightArticle->hometext(); |
544
|
|
|
$spotlight['id'] = $spotlightArticle->storyid(); |
545
|
|
|
$spotlight['date'] = formatTimestamp($spotlightArticle->published(), $dateformat); |
546
|
|
|
$spotlight['hits'] = $spotlightArticle->counter(); |
547
|
|
|
$spotlight['rating'] = $spotlightArticle->rating(); |
548
|
|
|
$spotlight['votes'] = $spotlightArticle->votes(); |
549
|
|
|
// Added, topic's image and description |
550
|
|
|
$spotlight['topic_image'] = XOOPS_URL . '/modules/news/assets/images/topics/' . $spotlightArticle->topic_imgurl(); |
551
|
|
|
$spotlight['topic_description'] = $myts->displayTarea($spotlightArticle->topic_description, 1); |
|
|
|
|
552
|
|
View Code Duplication |
if ($displayname != 3) { |
|
|
|
|
553
|
|
|
$spotlight['author'] = sprintf('%s %s', _POSTEDBY, $spotlightArticle->uname()); |
554
|
|
|
} else { |
555
|
|
|
$spotlight['author'] = ''; |
556
|
|
|
} |
557
|
|
View Code Duplication |
if (strlen(xoops_trim($spotlightArticle->bodytext())) > 0) { |
|
|
|
|
558
|
|
|
$spotlight['read_more'] = true; |
559
|
|
|
} else { |
560
|
|
|
$spotlight['read_more'] = false; |
561
|
|
|
} |
562
|
|
|
$block['spotlight'] = $spotlight; |
563
|
|
|
} |
564
|
|
|
} |
565
|
|
|
} |
566
|
|
|
if (isset($permstory)) { |
567
|
|
|
unset($permstory); |
568
|
|
|
} |
569
|
|
|
$block['lang_read_more'] = $myts->htmlSpecialChars(_MB_READMORE); // Read More... |
570
|
|
|
$block['lang_orderby'] = $myts->htmlSpecialChars(_MB_NEWS_ORDER); // "Order By" |
571
|
|
|
$block['lang_orderby_date'] = $myts->htmlSpecialChars(_MB_NEWS_DATE); // Published date |
572
|
|
|
$block['lang_orderby_hits'] = $myts->htmlSpecialChars(_MB_NEWS_HITS); // Number of Hits |
573
|
|
|
$block['lang_orderby_rating'] = $myts->htmlSpecialChars(_MB_NEWS_RATE); // Rating |
574
|
|
|
$block['sort'] = $options[0]; // "published" or "counter" or "rating" |
|
|
|
|
575
|
|
|
|
576
|
|
|
return $block; |
577
|
|
|
} |
578
|
|
|
|
579
|
|
|
/** |
580
|
|
|
* Function used to edit the block |
581
|
|
|
* @param $options |
582
|
|
|
* @return string |
583
|
|
|
*/ |
584
|
|
|
function b_news_top_edit($options) |
585
|
|
|
{ |
586
|
|
|
global $xoopsDB; |
|
|
|
|
587
|
|
|
$tmpstory = new NewsStory; |
|
|
|
|
588
|
|
|
$form = _MB_NEWS_ORDER . " <select name='options[]'>"; |
589
|
|
|
$form .= "<option value='published'"; |
590
|
|
|
if ($options[0] === 'published') { |
591
|
|
|
$form .= " selected='selected'"; |
592
|
|
|
} |
593
|
|
|
$form .= '>' . _MB_NEWS_DATE . "</option>\n"; |
594
|
|
|
|
595
|
|
|
$form .= "<option value='counter'"; |
596
|
|
|
if ($options[0] === 'counter') { |
597
|
|
|
$form .= " selected='selected'"; |
598
|
|
|
} |
599
|
|
|
$form .= '>' . _MB_NEWS_HITS . '</option>'; |
600
|
|
|
$form .= "<option value='rating'"; |
601
|
|
|
if ($options[0] === 'rating') { |
602
|
|
|
$form .= " selected='selected'"; |
603
|
|
|
} |
604
|
|
|
$form .= '>' . _MB_NEWS_RATE . '</option>'; |
605
|
|
|
$form .= "</select>\n"; |
606
|
|
|
|
607
|
|
|
$form .= ' ' . _MB_NEWS_DISP . " <input type='text' name='options[]' value='" . $options[1] . "'/> " . _MB_NEWS_ARTCLS; |
608
|
|
|
$form .= ' <br><br>' . _MB_NEWS_CHARS . " <input type='text' name='options[]' value='" . $options[2] . "'/> " . _MB_NEWS_LENGTH . '<br><br>'; |
609
|
|
|
|
610
|
|
|
$form .= _MB_NEWS_TEASER . " <input type='text' name='options[]' value='" . $options[3] . "' />" . _MB_NEWS_LENGTH; |
611
|
|
|
$form .= '<br><br>'; |
612
|
|
|
|
613
|
|
|
$form .= _MB_NEWS_SPOTLIGHT . " <input type='radio' name='options[]' value='1'"; |
614
|
|
|
if ($options[4] == 1) { |
615
|
|
|
$form .= " checked='checked'"; |
616
|
|
|
} |
617
|
|
|
$form .= ' />' . _YES; |
618
|
|
|
$form .= "<input type='radio' name='options[]' value='0'"; |
619
|
|
|
if ($options[4] == 0) { |
620
|
|
|
$form .= " checked='checked'"; |
621
|
|
|
} |
622
|
|
|
$form .= ' />' . _NO . '<br><br>'; |
623
|
|
|
|
624
|
|
|
$form .= _MB_NEWS_WHAT_PUBLISH . " <select name='options[]'><option value='1'"; |
625
|
|
|
if ($options[5] == 1) { |
626
|
|
|
$form .= ' selected'; |
627
|
|
|
} |
628
|
|
|
$form .= ' />' . _MB_NEWS_RECENT_NEWS; |
629
|
|
|
$form .= "</option><option value='0'"; |
630
|
|
|
if ($options[5] == 0) { |
631
|
|
|
$form .= ' selected'; |
632
|
|
|
} |
633
|
|
|
$form .= ' />' . _MB_NEWS_RECENT_SPECIFIC . '</option></select>'; |
634
|
|
|
|
635
|
|
|
$form .= '<br><br>' . _MB_NEWS_SPOTLIGHT_ARTICLE . '<br>'; |
636
|
|
|
$articles = NewsStory::getAllPublished(200, 0, false, 0, 0, false); // I have limited the listbox to the last 200 articles |
637
|
|
|
$form .= "<select name ='options[]'>"; |
638
|
|
|
$form .= "<option value='0'>" . _MB_NEWS_FIRST . '</option>'; |
639
|
|
|
foreach ($articles as $storyid => $storytitle) { |
|
|
|
|
640
|
|
|
$sel = ''; |
641
|
|
|
if ($options[6] == $storyid) { |
642
|
|
|
$sel = " selected='selected'"; |
643
|
|
|
} |
644
|
|
|
$form .= "<option value='$storyid'$sel>" . $storytitle . '</option>'; |
645
|
|
|
} |
646
|
|
|
$form .= '</select><br><br>'; |
647
|
|
|
|
648
|
|
|
$form .= _MB_NEWS_IMAGE . " <input type='text' id='spotlightimage' name='options[]' value='" . $options[7] . "' size='50'/>"; |
649
|
|
|
$form .= " <img align='middle' onmouseover='style.cursor=\"hand\"' onclick='javascript:openWithSelfMain(\"" |
650
|
|
|
. XOOPS_URL |
651
|
|
|
. "/imagemanager.php?target=spotlightimage\",\"imgmanager\",400,430);' src='" |
652
|
|
|
. XOOPS_URL |
653
|
|
|
. "/images/image.gif' alt='image' title='image' />"; |
654
|
|
|
$form .= '<br><br>' . _MB_NEWS_DISP . " <select name='options[]'><option value='1' "; |
655
|
|
|
if ($options[8] == 1) { |
656
|
|
|
$form .= 'selected'; |
657
|
|
|
} |
658
|
|
|
$form .= '>' . _MB_NEWS_VIEW_TYPE1 . "</option><option value='2' "; |
659
|
|
|
if ($options[8] == 2) { |
660
|
|
|
$form .= 'selected'; |
661
|
|
|
} |
662
|
|
|
$form .= '>' . _MB_NEWS_VIEW_TYPE2 . '</option></select><br><br>'; |
663
|
|
|
|
664
|
|
|
$form .= "<table border=0>\n"; |
665
|
|
|
$form .= "<tr><td colspan='2' align='center'><u>" . _MB_NEWS_DEFAULT_COLORS . '</u></td></tr>'; |
666
|
|
|
$form .= '<tr><td>' . _MB_NEWS_TAB_COLOR1 . "</td><td><input type='text' name='options[]' value='" . $options[9] . "' size=7></td></tr>"; |
667
|
|
|
$form .= '<tr><td>' . _MB_NEWS_TAB_COLOR2 . "</td><td><input type='text' name='options[]' value='" . $options[10] . "' size=7></td></tr>"; |
668
|
|
|
$form .= '<tr><td>' . _MB_NEWS_TAB_COLOR3 . "</td><td><input type='text' name='options[]' value='" . $options[11] . "' size=7></td></tr>"; |
669
|
|
|
$form .= '<tr><td>' . _MB_NEWS_TAB_COLOR4 . "</td><td><input type='text' name='options[]' value='" . $options[12] . "' size=7></td></tr>"; |
670
|
|
|
$form .= '<tr><td>' . _MB_NEWS_TAB_COLOR5 . "</td><td><input type='text' name='options[]' value='" . $options[13] . "' size=7></td></tr>"; |
671
|
|
|
$form .= "</table>\n"; |
672
|
|
|
|
673
|
|
|
$form .= '<br><br>' . _MB_SPOTLIGHT_TOPIC . "<br><select name='options[]' multiple='multiple'>"; |
674
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/news/class/class.newstopic.php'; |
675
|
|
|
$topics_arr = array(); |
|
|
|
|
676
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/news/class/xoopstree.php'; |
677
|
|
|
$xt = new MyXoopsTree($xoopsDB->prefix('news_topics'), 'topic_id', 'topic_pid'); |
678
|
|
|
$topics_arr = $xt->getChildTreeArray(0, 'topic_title'); |
679
|
|
|
$size = count($options); |
680
|
|
|
foreach ($topics_arr as $onetopic) { |
681
|
|
|
$sel = ''; |
682
|
|
View Code Duplication |
if ($onetopic['topic_pid'] != 0) { |
|
|
|
|
683
|
|
|
$onetopic['prefix'] = str_replace('.', '-', $onetopic['prefix']) . ' '; |
684
|
|
|
} else { |
685
|
|
|
$onetopic['prefix'] = str_replace('.', '', $onetopic['prefix']); |
686
|
|
|
} |
687
|
|
|
for ($i = 14; $i < $size; ++$i) { |
688
|
|
|
if ($options[$i] == $onetopic['topic_id']) { |
689
|
|
|
$sel = " selected='selected'"; |
690
|
|
|
} |
691
|
|
|
} |
692
|
|
|
$form .= "<option value='" . $onetopic['topic_id'] . "'$sel>" . $onetopic['prefix'] . $onetopic['topic_title'] . '</option>'; |
693
|
|
|
} |
694
|
|
|
$form .= '</select><br>'; |
695
|
|
|
|
696
|
|
|
return $form; |
697
|
|
|
} |
698
|
|
|
|
699
|
|
|
/** |
700
|
|
|
* @param $options |
701
|
|
|
*/ |
702
|
|
View Code Duplication |
function b_news_top_onthefly($options) |
|
|
|
|
703
|
|
|
{ |
704
|
|
|
$options = explode('|', $options); |
705
|
|
|
$block = &b_news_top_show($options); |
706
|
|
|
|
707
|
|
|
$tpl = new XoopsTpl(); |
708
|
|
|
$tpl->assign('block', $block); |
709
|
|
|
$tpl->display('db:news_block_top.tpl'); |
710
|
|
|
} |
711
|
|
|
|
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.