Conditions | 102 |
Paths | > 20000 |
Total Lines | 537 |
Code Lines | 399 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
42 | function b_news_top_show($options) |
||
43 | { |
||
44 | global $xoopsConfig; |
||
45 | |||
46 | /** @var Helper $helper */ |
||
47 | if (!class_exists(Helper::class)) { |
||
48 | return false; |
||
|
|||
49 | } |
||
50 | |||
51 | $helper = Helper::getInstance(); |
||
52 | |||
53 | $helper->loadLanguage('main'); |
||
54 | |||
55 | $myts = \MyTextSanitizer::getInstance(); |
||
56 | $block = []; |
||
57 | $displayname = News\Utility::getModuleOption('displayname'); |
||
58 | $tabskin = News\Utility::getModuleOption('tabskin'); |
||
59 | |||
60 | $block['displayview'] = $options[8]; |
||
61 | $block['tabskin'] = $tabskin; |
||
62 | $block['imagesurl'] = XOOPS_URL . '/modules/news/assets/images/'; |
||
63 | |||
64 | $restricted = News\Utility::getModuleOption('restrictindex'); |
||
65 | $dateformat = News\Utility::getModuleOption('dateformat'); |
||
66 | $infotips = News\Utility::getModuleOption('infotips'); |
||
67 | $newsrating = News\Utility::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 (1 == $options[4] && $restricted && 0 == $options[5]) { |
||
76 | $perm_verified = true; |
||
77 | $permittedtopics = News\Utility::getMyItemIds(); |
||
78 | $permstory = new NewsStory($options[6]); |
||
79 | if (!in_array($permstory->topicid(), $permittedtopics)) { |
||
80 | $usespotlight = false; |
||
81 | $news_visible = false; |
||
82 | $topicstitles = []; |
||
83 | } |
||
84 | 0 == $options[4]; |
||
85 | } |
||
86 | // Try to see what tabs are visibles (if we are in restricted view of course) |
||
87 | if (2 == $options[8] && $restricted && 0 != $options[14]) { |
||
88 | $topics2 = []; |
||
89 | $permittedtopics = News\Utility::getMyItemIds(); |
||
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 (2 == $options[8]) { // Tabbed view ******************************************************************************************** |
||
101 | $defcolors[1] = ['#F90', '#FFFFFF', '#F90', '#C60', '#999']; // Bar Style |
||
102 | $defcolors[2] = ['#F90', '#FFFFFF', '#F90', '#AAA', '#666']; // Beveled |
||
103 | $defcolors[3] = ['#F90', '#FFFFFF', '', '#789', '#789']; // Classic |
||
104 | $defcolors[4] = ['#F90', '#FFFFFF', '', '', '']; // Folders |
||
105 | $defcolors[5] = ['#F90', '#FFFFFF', '#CCC', 'inherit', '#999']; // MacOs |
||
106 | $defcolors[6] = ['#F90', '#FFFFFF', '#FFF', '#DDD', '#999']; // Plain |
||
107 | $defcolors[7] = ['#F90', '#FFFFFF', '', '', '']; // Rounded |
||
108 | $defcolors[8] = ['#F90', '#FFFFFF', '#F90', '#930', '#C60']; // ZDnet |
||
109 | |||
110 | $myurl = $_SERVER['SCRIPT_NAME']; |
||
111 | if ('/' === mb_substr($myurl, mb_strlen($myurl) - 1, 1)) { |
||
112 | $myurl .= 'index.php'; |
||
113 | } |
||
114 | $myurl .= '?'; |
||
115 | |||
116 | foreach ($_GET as $key => $value) { |
||
117 | if ('NewsTab' !== $key) { |
||
118 | $myurl .= $key . '=' . $value . '&'; |
||
119 | } |
||
120 | } |
||
121 | $block['url'] = $myurl; |
||
122 | |||
123 | $tabscount = 0; |
||
124 | $usespotlight = false; |
||
125 | |||
126 | if (Request::hasVar('NewsTab', 'GET')) { |
||
127 | $_SESSION['NewsTab'] = Request::getInt('NewsTab', 0, 'GET'); |
||
128 | $currenttab = Request::getInt('NewsTab', 0, 'GET'); |
||
129 | } elseif (Request::hasVar('NewsTab', 'SESSION')) { |
||
130 | $currenttab = Request::getInt('NewsTab', 0, 'SESSION'); |
||
131 | } else { |
||
132 | $currenttab = 0; |
||
133 | } |
||
134 | |||
135 | $tmpstory = new NewsStory(); |
||
136 | $topic = new NewsTopic(); |
||
137 | $topicstitles = []; |
||
138 | if (1 == $options[4]) { // Spotlight enabled |
||
139 | $topicstitles[0] = _MB_NEWS_SPOTLIGHT_TITLE; |
||
140 | ++$tabscount; |
||
141 | $usespotlight = true; |
||
142 | } |
||
143 | |||
144 | if (0 == $options[5] && $restricted) { // Use a specific news and we are in restricted mode |
||
145 | if (!$perm_verified) { |
||
146 | $permittedtopics = News\Utility::getMyItemIds(); |
||
147 | $permstory = new NewsStory($options[6]); |
||
148 | if (!in_array($permstory->topicid(), $permittedtopics)) { |
||
149 | $usespotlight = false; |
||
150 | $topicstitles = []; |
||
151 | } |
||
152 | //unset($permstory); |
||
153 | } elseif (!$news_visible) { |
||
154 | $usespotlight = false; |
||
155 | $topicstitles = []; |
||
156 | } |
||
157 | } |
||
158 | |||
159 | $block['use_spotlight'] = $usespotlight; |
||
160 | |||
161 | if (isset($options[14]) && 0 != $options[14]) { // Topic to use |
||
162 | $topics = array_slice($options, 14); |
||
163 | $tabscount += count($topics); |
||
164 | $topicstitles = $topic->getTopicTitleFromId($topics, $topicstitles); |
||
165 | } |
||
166 | $tabs = []; |
||
167 | if ($usespotlight) { |
||
168 | $tabs[] = ['id' => 0, 'title' => _MB_NEWS_SPOTLIGHT_TITLE]; |
||
169 | } |
||
170 | if (count($topics) > 0) { |
||
171 | foreach ($topics as $onetopic) { |
||
172 | if (isset($topicstitles[$onetopic])) { |
||
173 | $tabs[] = [ |
||
174 | 'id' => $onetopic, |
||
175 | 'title' => $topicstitles[$onetopic]['title'], |
||
176 | 'picture' => $topicstitles[$onetopic]['picture'], |
||
177 | ]; |
||
178 | } |
||
179 | } |
||
180 | } |
||
181 | $block['tabs'] = $tabs; |
||
182 | $block['current_is_spotlight'] = false; |
||
183 | $block['current_tab'] = $currenttab; |
||
184 | $block['use_rating'] = $newsrating; |
||
185 | |||
186 | if (0 == $currenttab && $usespotlight) { // Spotlight or not ? |
||
187 | $block['current_is_spotlight'] = true; |
||
188 | if (0 == $options[5] |
||
189 | && 0 == $options[6]) { // If the story to use was no selected then we switch to the "recent news" mode. |
||
190 | $options[5] = 1; |
||
191 | } |
||
192 | |||
193 | if (0 == $options[5]) { // Use a specific news |
||
194 | if (!isset($permstory)) { |
||
195 | $tmpstory = new NewsStory($options[6]); |
||
196 | } else { |
||
197 | $tmpstory = $permstory; |
||
198 | } |
||
199 | } else { // Use the most recent news |
||
200 | $stories = []; |
||
201 | $stories = NewsStory::getAllPublished(1, 0, $restricted, 0, 1, true, $options[0]); |
||
202 | if (count($stories) > 0) { |
||
203 | $firststory = $stories[0]; |
||
204 | $tmpstory = new NewsStory($firststory->storyid()); |
||
205 | } else { |
||
206 | $block['use_spotlight'] = false; |
||
207 | } |
||
208 | } |
||
209 | $spotlight = []; |
||
210 | $spotlight['title'] = $tmpstory->title(); |
||
211 | if ('' !== $options[7]) { |
||
212 | $spotlight['image'] = sprintf("<a href='%s'>%s</a>", XOOPS_URL . '/modules/news/article.php?storyid=' . $tmpstory->storyid(), $myts->displayTarea($options[7], $tmpstory->nohtml)); |
||
213 | } |
||
214 | $spotlight['text'] = $tmpstory->hometext(); |
||
215 | |||
216 | // Added 16 february 2007 ***************************************** |
||
217 | $story_user = null; |
||
218 | $story_user = new \XoopsUser($tmpstory->uid()); |
||
219 | if (is_object($story_user)) { |
||
220 | $spotlight['avatar'] = XOOPS_UPLOAD_URL . '/' . $story_user->getVar('user_avatar'); |
||
221 | } |
||
222 | // **************************************************************** |
||
223 | $spotlight['id'] = $tmpstory->storyid(); |
||
224 | $spotlight['date'] = formatTimestamp($tmpstory->published(), $dateformat); |
||
225 | $spotlight['hits'] = $tmpstory->counter(); |
||
226 | $spotlight['rating'] = number_format($tmpstory->rating(), 2); |
||
227 | $spotlight['votes'] = $tmpstory->votes(); |
||
228 | if ('' !== xoops_trim($tmpstory->bodytext())) { |
||
229 | $spotlight['read_more'] = true; |
||
230 | } else { |
||
231 | $spotlight['read_more'] = false; |
||
232 | } |
||
233 | |||
234 | $spotlight['readmore'] = sprintf("<a href='%s'>%s</a>", XOOPS_URL . '/modules/news/article.php?storyid=' . $tmpstory->storyid(), _MB_READMORE); |
||
235 | $spotlight['title_with_link'] = sprintf("<a href='%s'>%s</a>", XOOPS_URL . '/modules/news/article.php?storyid=' . $tmpstory->storyid(), $tmpstory->title()); |
||
236 | if (1 == $tmpstory->votes()) { |
||
237 | $spotlight['number_votes'] = _NW_ONEVOTE; |
||
238 | } else { |
||
239 | $spotlight['number_votes'] = sprintf(_NW_NUMVOTES, $tmpstory->votes()); |
||
240 | } |
||
241 | |||
242 | $spotlight['votes_with_text'] = sprintf(_NW_NUMVOTES, $tmpstory->votes()); |
||
243 | $spotlight['topicid'] = $tmpstory->topicid(); |
||
244 | $spotlight['topic_title'] = $tmpstory->topic_title(); |
||
245 | // Added, topic's image and description |
||
246 | $spotlight['topic_image'] = XOOPS_URL . '/modules/news/assets/images/topics/' . $tmpstory->topic_imgurl(); |
||
247 | $spotlight['topic_description'] = $myts->displayTarea($tmpstory->topic_description, 1); |
||
248 | |||
249 | if (3 != $displayname) { |
||
250 | $spotlight['author'] = sprintf('%s %s', _POSTEDBY, $tmpstory->uname()); |
||
251 | $spotlight['author_with_link'] = sprintf("%s <a href='%s'>%s</a>", _POSTEDBY, XOOPS_URL . '/userinfo.php?uid=' . $tmpstory->uid(), $tmpstory->uname()); |
||
252 | } else { |
||
253 | $spotlight['author'] = ''; |
||
254 | $spotlight['author_with_link'] = ''; |
||
255 | } |
||
256 | $spotlight['author_id'] = $tmpstory->uid(); |
||
257 | |||
258 | // Create the summary table under the spotlight text |
||
259 | if (isset($options[14]) && 0 == $options[14]) { // Use all topics |
||
260 | $stories = NewsStory::getAllPublished($options[1], 0, $restricted, 0, 1, true, $options[0]); |
||
261 | } else { // Use some topics |
||
262 | $topics = array_slice($options, 14); |
||
263 | $stories = NewsStory::getAllPublished($options[1], 0, $restricted, $topics, 1, true, $options[0]); |
||
264 | } |
||
265 | if (count($stories) > 0) { |
||
266 | foreach ($stories as $key => $story) { |
||
267 | $news = []; |
||
268 | $title = $story->title(); |
||
269 | if (mb_strlen($title) > $options[2]) { |
||
270 | $title = xoops_substr($title, 0, $options[2] + 3); |
||
271 | } |
||
272 | $news['title'] = $title; |
||
273 | $news['id'] = $story->storyid(); |
||
274 | $news['date'] = formatTimestamp($story->published(), $dateformat); |
||
275 | $news['hits'] = $story->counter(); |
||
276 | $news['rating'] = number_format($story->rating(), 2); |
||
277 | $news['votes'] = $story->votes(); |
||
278 | $news['topicid'] = $story->topicid(); |
||
279 | $news['topic_title'] = $story->topic_title(); |
||
280 | $news['topic_color'] = '#' . $myts->displayTarea($story->topic_color); |
||
281 | $news['picture'] = XOOPS_URL . '/uploads/news/image/' . $story->picture(); |
||
282 | $news['pictureinfo'] = $story->pictureinfo(); |
||
283 | if (3 != $displayname) { |
||
284 | $news['author'] = sprintf('%s %s', _POSTEDBY, $story->uname()); |
||
285 | } else { |
||
286 | $news['author'] = ''; |
||
287 | } |
||
288 | if ($options[3] > 0) { |
||
289 | $html = 1 == $story->nohtml() ? 0 : 1; |
||
290 | $news['teaser'] = News\Utility::truncateTagSafe($myts->displayTarea($story->hometext(), $html), $options[3] + 3); |
||
291 | } else { |
||
292 | $news['teaser'] = ''; |
||
293 | } |
||
294 | if ($infotips > 0) { |
||
295 | $news['infotips'] = ' title="' . News\Utility::makeInfotips($story->hometext()) . '"'; |
||
296 | } else { |
||
297 | $news['infotips'] = ''; |
||
298 | } |
||
299 | |||
300 | $news['title_with_link'] = sprintf("<a href='%s'%s>%s</a>", XOOPS_URL . '/modules/news/article.php?storyid=' . $story->storyid(), $news['infotips'], $title); |
||
301 | $spotlight['news'][] = $news; |
||
302 | } |
||
303 | } |
||
304 | |||
305 | $block['spotlight'] = $spotlight; |
||
306 | } elseif ($tabscount > 0) { |
||
307 | $topics = array_slice($options, 14); |
||
308 | $thetopic = $currenttab; |
||
309 | $stories = NewsStory::getAllPublished($options[1], 0, $restricted, $thetopic, 1, true, $options[0]); |
||
310 | |||
311 | $topic->getTopic($thetopic); |
||
312 | // Added, topic's image and description |
||
313 | $block['topic_image'] = XOOPS_URL . '/modules/news/assets/images/topics/' . $topic->topic_imgurl(); |
||
314 | $block['topic_description'] = $topic->topic_description(); |
||
315 | |||
316 | $smallheader = []; |
||
317 | $stats = $topic->getTopicMiniStats($thetopic); |
||
318 | $smallheader[] = sprintf("<a href='%s'>%s</a>", XOOPS_URL . '/modules/news/index.php?storytopic=' . $thetopic, _MB_READMORE); |
||
319 | $smallheader[] = sprintf('%u %s', $stats['count'], _NW_ARTICLES); |
||
320 | $smallheader[] = sprintf('%u %s', $stats['reads'], _READS); |
||
321 | if (count($stories) > 0) { |
||
322 | foreach ($stories as $key => $story) { |
||
323 | $news = []; |
||
324 | $title = $story->title(); |
||
325 | if (mb_strlen($title) > $options[2]) { |
||
326 | $title = News\Utility::truncateTagSafe($title, $options[2] + 3); |
||
327 | } |
||
328 | if ('' !== $options[7]) { |
||
329 | $news['image'] = sprintf("<a href='%s'>%s</a>", XOOPS_URL . '/modules/news/article.php?storyid=' . $story->storyid(), $myts->displayTarea($options[7], $story->nohtml)); |
||
330 | } |
||
331 | if ($options[3] > 0) { |
||
332 | $html = 1 == $story->nohtml() ? 0 : 1; |
||
333 | $news['text'] = News\Utility::truncateTagSafe($myts->displayTarea($story->hometext(), $html), $options[3] + 3); |
||
334 | } else { |
||
335 | $news['text'] = ''; |
||
336 | } |
||
337 | |||
338 | if (1 == $story->votes()) { |
||
339 | $news['number_votes'] = _NW_ONEVOTE; |
||
340 | } else { |
||
341 | $news['number_votes'] = sprintf(_NW_NUMVOTES, $story->votes()); |
||
342 | } |
||
343 | if ($infotips > 0) { |
||
344 | $news['infotips'] = ' title="' . News\Utility::makeInfotips($story->hometext()) . '"'; |
||
345 | } else { |
||
346 | $news['infotips'] = ''; |
||
347 | } |
||
348 | $news['title'] = sprintf("<a href='%s' %s>%s</a>", XOOPS_URL . '/modules/news/article.php?storyid=' . $story->storyid(), $news['infotips'], $title); |
||
349 | $news['id'] = $story->storyid(); |
||
350 | $news['date'] = formatTimestamp($story->published(), $dateformat); |
||
351 | $news['hits'] = $story->counter(); |
||
352 | $news['rating'] = number_format($story->rating(), 2); |
||
353 | $news['votes'] = $story->votes(); |
||
354 | $news['topicid'] = $story->topicid(); |
||
355 | $news['topic_title'] = $story->topic_title(); |
||
356 | $news['topic_color'] = '#' . $myts->displayTarea($story->topic_color); |
||
357 | $news['picture'] = XOOPS_URL . '/uploads/news/image/' . $story->picture(); |
||
358 | $news['pictureinfo'] = $story->pictureinfo(); |
||
359 | |||
360 | if (3 != $displayname) { |
||
361 | $news['author'] = sprintf('%s %s', _POSTEDBY, $story->uname()); |
||
362 | } else { |
||
363 | $news['author'] = ''; |
||
364 | } |
||
365 | $news['title_with_link'] = sprintf("<a href='%s'%s>%s</a>", XOOPS_URL . '/modules/news/article.php?storyid=' . $story->storyid(), $news['infotips'], $title); |
||
366 | $block['news'][] = $news; |
||
367 | } |
||
368 | $block['smallheader'] = $smallheader; |
||
369 | } |
||
370 | } |
||
371 | $block['lang_on'] = _ON; // on |
||
372 | $block['lang_reads'] = _READS; // reads |
||
373 | // Default values |
||
374 | $block['color1'] = $defcolors[$tabskin][0]; |
||
375 | $block['color2'] = $defcolors[$tabskin][1]; |
||
376 | $block['color3'] = $defcolors[$tabskin][2]; |
||
377 | $block['color4'] = $defcolors[$tabskin][3]; |
||
378 | $block['color5'] = $defcolors[$tabskin][4]; |
||
379 | |||
380 | if ('' !== xoops_trim($options[9])) { |
||
381 | $block['color1'] = $options[9]; |
||
382 | } |
||
383 | if ('' !== xoops_trim($options[10])) { |
||
384 | $block['color2'] = $options[10]; |
||
385 | } |
||
386 | if ('' !== xoops_trim($options[11])) { |
||
387 | $block['color3'] = $options[11]; |
||
388 | } |
||
389 | if ('' !== xoops_trim($options[12])) { |
||
390 | $block['color4'] = $options[12]; |
||
391 | } |
||
392 | if ('' !== xoops_trim($options[13])) { |
||
393 | $block['color5'] = $options[13]; |
||
394 | } |
||
395 | } else { // ************************ Classical view ************************************************************************************************************** |
||
396 | $tmpstory = new NewsStory(); |
||
397 | if (isset($options[14]) && 0 == $options[14]) { |
||
398 | $stories = NewsStory::getAllPublished($options[1], 0, $restricted, 0, 1, true, $options[0]); |
||
399 | } else { |
||
400 | $topics = array_slice($options, 14); |
||
401 | $stories = NewsStory::getAllPublished($options[1], 0, $restricted, $topics, 1, true, $options[0]); |
||
402 | } |
||
403 | |||
404 | if (!count($stories)) { |
||
405 | return ''; |
||
406 | } |
||
407 | $topic = new NewsTopic(); |
||
408 | |||
409 | foreach ($stories as $key => $story) { |
||
410 | $news = []; |
||
411 | $title = $story->title(); |
||
412 | if (mb_strlen($title) > $options[2]) { |
||
413 | $title = xoops_substr($title, 0, $options[2] + 3); |
||
414 | } |
||
415 | |||
416 | //if spotlight is enabled and this is either the first article or the selected one |
||
417 | if ((0 == $options[5]) && (1 == $options[4]) |
||
418 | && (($options[6] > 0 && $options[6] == $story->storyid()) |
||
419 | || (0 == $options[6] && 0 == $key))) { |
||
420 | $spotlight = []; |
||
421 | $visible = true; |
||
422 | if ($restricted) { |
||
423 | $permittedtopics = News\Utility::getMyItemIds(); |
||
424 | if (!in_array($story->topicid(), $permittedtopics)) { |
||
425 | $visible = false; |
||
426 | } |
||
427 | } |
||
428 | |||
429 | if ($visible) { |
||
430 | $spotlight['title'] = $title; |
||
431 | if ('' !== $options[7]) { |
||
432 | $spotlight['image'] = sprintf("<a href='%s'>%s</a>", XOOPS_URL . '/modules/news/article.php?storyid=' . $story->storyid(), $myts->displayTarea($options[7], $story->nohtml)); |
||
433 | } |
||
434 | // Added 16 february 2007 ***************************************** |
||
435 | $story_user = null; |
||
436 | $story_user = new \XoopsUser($story->uid()); |
||
437 | if (is_object($story_user)) { |
||
438 | $spotlight['avatar'] = XOOPS_UPLOAD_URL . '/' . $story_user->getVar('user_avatar'); |
||
439 | } |
||
440 | // **************************************************************** |
||
441 | $spotlight['text'] = $story->hometext(); |
||
442 | $spotlight['id'] = $story->storyid(); |
||
443 | $spotlight['date'] = formatTimestamp($story->published(), $dateformat); |
||
444 | $spotlight['hits'] = $story->counter(); |
||
445 | $spotlight['rating'] = $story->rating(); |
||
446 | $spotlight['votes'] = $story->votes(); |
||
447 | $spotlight['topicid'] = $story->topicid(); |
||
448 | $spotlight['topic_title'] = $story->topic_title(); |
||
449 | $spotlight['topic_color'] = '#' . $myts->displayTarea($story->topic_color); |
||
450 | // Added, topic's image and description |
||
451 | $spotlight['topic_image'] = XOOPS_URL . '/modules/news/assets/images/topics/' . $story->topic_imgurl(); |
||
452 | $spotlight['topic_description'] = $myts->displayTarea($story->topic_description, 1); |
||
453 | if ('' !== xoops_trim($story->bodytext())) { |
||
454 | $spotlight['read_more'] = true; |
||
455 | } else { |
||
456 | $spotlight['read_more'] = false; |
||
457 | } |
||
458 | |||
459 | if (3 != $displayname) { |
||
460 | $spotlight['author'] = sprintf('%s %s', _POSTEDBY, $story->uname()); |
||
461 | } else { |
||
462 | $spotlight['author'] = ''; |
||
463 | } |
||
464 | } |
||
465 | $block['spotlight'] = $spotlight; |
||
466 | } else { |
||
467 | $news['title'] = $title; |
||
468 | $news['id'] = $story->storyid(); |
||
469 | $news['date'] = formatTimestamp($story->published(), $dateformat); |
||
470 | $news['hits'] = $story->counter(); |
||
471 | $news['rating'] = $story->rating(); |
||
472 | $news['votes'] = $story->votes(); |
||
473 | $news['topicid'] = $story->topicid(); |
||
474 | $news['topic_title'] = $story->topic_title(); |
||
475 | $news['topic_color'] = '#' . $myts->displayTarea($story->topic_color); |
||
476 | $news['picture'] = XOOPS_URL . '/uploads/news/image/' . $story->picture(); |
||
477 | $news['pictureinfo'] = $story->pictureinfo(); |
||
478 | |||
479 | if (3 != $displayname) { |
||
480 | $news['author'] = sprintf('%s %s', _POSTEDBY, $story->uname()); |
||
481 | } else { |
||
482 | $news['author'] = ''; |
||
483 | } |
||
484 | if ($options[3] > 0) { |
||
485 | $html = 1 == $story->nohtml() ? 0 : 1; |
||
486 | $news['teaser'] = News\Utility::truncateTagSafe($myts->displayTarea($story->hometext(), $html), $options[3] + 3); |
||
487 | $news['infotips'] = ''; |
||
488 | } else { |
||
489 | $news['teaser'] = ''; |
||
490 | if ($infotips > 0) { |
||
491 | $news['infotips'] = ' title="' . News\Utility::makeInfotips($story->hometext()) . '"'; |
||
492 | } else { |
||
493 | $news['infotips'] = ''; |
||
494 | } |
||
495 | } |
||
496 | $block['stories'][] = $news; |
||
497 | } |
||
498 | } |
||
499 | |||
500 | // If spotlight article was not in the fetched stories |
||
501 | if (!isset($spotlight) && $options[4]) { |
||
502 | $block['use_spotlight'] = true; |
||
503 | $visible = true; |
||
504 | if (0 == $options[5] && $restricted) { // Use a specific news and we are in restricted mode |
||
505 | $permittedtopics = News\Utility::getMyItemIds(); |
||
506 | $permstory = new NewsStory($options[6]); |
||
507 | if (!in_array($permstory->topicid(), $permittedtopics)) { |
||
508 | $visible = false; |
||
509 | } |
||
510 | unset($permstory); |
||
511 | } |
||
512 | |||
513 | if (0 == $options[5]) { // Use a specific news |
||
514 | if ($visible) { |
||
515 | $spotlightArticle = new NewsStory($options[6]); |
||
516 | } else { |
||
517 | $block['use_spotlight'] = false; |
||
518 | } |
||
519 | } else { // Use the most recent news |
||
520 | $stories = []; |
||
521 | $stories = NewsStory::getAllPublished(1, 0, $restricted, 0, 1, true, $options[0]); |
||
522 | if (count($stories) > 0) { |
||
523 | $firststory = $stories[0]; |
||
524 | $spotlightArticle = new NewsStory($firststory->storyid()); |
||
525 | } else { |
||
526 | $block['use_spotlight'] = false; |
||
527 | } |
||
528 | } |
||
529 | if (true === $block['use_spotlight']) { |
||
530 | $spotlight = []; |
||
531 | $spotlight['title'] = xoops_substr($spotlightArticle->title(), 0, $options[2] - 1); |
||
532 | if ('' !== $options[7]) { |
||
533 | $spotlight['image'] = sprintf("<a href='%s'>%s</a>", XOOPS_URL . '/modules/news/article.php?storyid=' . $spotlightArticle->storyid(), $myts->displayTarea($options[7], $spotlightArticle->nohtml)); |
||
534 | } |
||
535 | // Added 16 february 2007 ***************************************** |
||
536 | $story_user = null; |
||
537 | $story_user = new \XoopsUser($spotlightArticle->uid()); |
||
538 | if (is_object($story_user)) { |
||
539 | $spotlight['avatar'] = XOOPS_UPLOAD_URL . '/' . $story_user->getVar('user_avatar'); |
||
540 | } |
||
541 | // **************************************************************** |
||
542 | $spotlight['topicid'] = $spotlightArticle->topicid(); |
||
543 | $spotlight['topic_title'] = $spotlightArticle->topic_title(); |
||
544 | $spotlight['topic_color'] = '#' . $myts->displayTarea($spotlightArticle->topic_color); |
||
545 | $spotlight['text'] = $spotlightArticle->hometext(); |
||
546 | $spotlight['id'] = $spotlightArticle->storyid(); |
||
547 | $spotlight['date'] = formatTimestamp($spotlightArticle->published(), $dateformat); |
||
548 | $spotlight['hits'] = $spotlightArticle->counter(); |
||
549 | $spotlight['rating'] = $spotlightArticle->rating(); |
||
550 | $spotlight['votes'] = $spotlightArticle->votes(); |
||
551 | // Added, topic's image and description |
||
552 | $spotlight['topic_image'] = XOOPS_URL . '/modules/news/assets/images/topics/' . $spotlightArticle->topic_imgurl(); |
||
553 | $spotlight['topic_description'] = $myts->displayTarea($spotlightArticle->topic_description, 1); |
||
554 | if (3 != $displayname) { |
||
555 | $spotlight['author'] = sprintf('%s %s', _POSTEDBY, $spotlightArticle->uname()); |
||
556 | } else { |
||
557 | $spotlight['author'] = ''; |
||
558 | } |
||
559 | if ('' !== xoops_trim($spotlightArticle->bodytext())) { |
||
560 | $spotlight['read_more'] = true; |
||
561 | } else { |
||
562 | $spotlight['read_more'] = false; |
||
563 | } |
||
564 | $block['spotlight'] = $spotlight; |
||
565 | } |
||
566 | } |
||
567 | } |
||
568 | if (isset($permstory)) { |
||
569 | unset($permstory); |
||
570 | } |
||
571 | $block['lang_read_more'] = htmlspecialchars(_MB_READMORE, ENT_QUOTES | ENT_HTML5); // Read More... |
||
572 | $block['lang_orderby'] = htmlspecialchars(_MB_NEWS_ORDER, ENT_QUOTES | ENT_HTML5); // "Order By" |
||
573 | $block['lang_orderby_date'] = htmlspecialchars(_MB_NEWS_DATE, ENT_QUOTES | ENT_HTML5); // Published date |
||
574 | $block['lang_orderby_hits'] = htmlspecialchars(_MB_NEWS_HITS, ENT_QUOTES | ENT_HTML5); // Number of Hits |
||
575 | $block['lang_orderby_rating'] = htmlspecialchars(_MB_NEWS_RATE, ENT_QUOTES | ENT_HTML5); // Rating |
||
576 | $block['sort'] = $options[0]; // "published" or "counter" or "rating" |
||
577 | |||
578 | return $block; |
||
579 | } |
||
709 |