1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
/* |
3
|
|
|
* You may not change or alter any portion of this comment or credits |
4
|
|
|
* of supporting developers from this source code or any supporting source code |
5
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
6
|
|
|
* |
7
|
|
|
* This program is distributed in the hope that it will be useful, |
8
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
9
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
14
|
|
|
* @license {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
15
|
|
|
* @author XOOPS Development Team |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Article's page |
20
|
|
|
* |
21
|
|
|
* This page is used to see an article (or story) and is mainly called from |
22
|
|
|
* the module's index page. |
23
|
|
|
* |
24
|
|
|
* If no story Id has been placed on the URL or if the story is not yet published |
25
|
|
|
* then the page will redirect user to the module's index. |
26
|
|
|
* If the user does not have the permissions to see the article, they are also redirected |
27
|
|
|
* to the module's index page but with an error message saying : |
28
|
|
|
* "Sorry, you don't have the permission to access this area" |
29
|
|
|
* |
30
|
|
|
* Each time a page is seen, and only if we are on the first page, its counter of hits is |
31
|
|
|
* updated |
32
|
|
|
* |
33
|
|
|
* Each file(s) attached to the article is visible at the bottom of the article and can |
34
|
|
|
* be downloaded |
35
|
|
|
* |
36
|
|
|
* Notes : |
37
|
|
|
* - To create more than one page in your story, use the tag [pagebreak] |
38
|
|
|
* - If you are a module's admin, you have the possibility to see two links at the bottom |
39
|
|
|
* of the article, "Edit & Delete" |
40
|
|
|
* |
41
|
|
|
* @param int $matches storyid Id of the story we want to see |
42
|
|
|
* @param int page page's number (in the case where there are more than one page) |
43
|
|
|
* |
44
|
|
|
* @page_title Article's title - Topic's title - Module's name |
45
|
|
|
* |
46
|
|
|
* @template_name news_article.html wich will call news_item.html |
47
|
|
|
* |
48
|
|
|
* Template's variables : |
49
|
|
|
* @template_var string pagenav some links to navigate thru pages |
50
|
|
|
* @template_var array story Contains all the information about the story |
51
|
|
|
* Structure : |
52
|
|
|
* @template_var int id Story's ID |
53
|
|
|
* @template_var string posttime Story's date of publication |
54
|
|
|
* @template_var string title A link to go and see all the articles in the same topic and the story's title |
55
|
|
|
* @template_var string news_title Just the news title |
56
|
|
|
* @template_var string topic_title Just the topic's title |
57
|
|
|
* @template_var string text Defined as "The scoop" |
58
|
|
|
* @template_var string poster A link to see the author's profile and their name or "Anonymous" |
59
|
|
|
* @template_var int posterid Author's uid (or 0 if it's an anonymous or a user wich does not exist any more) |
60
|
|
|
* @template_var string morelink Never used ???? May be it could be deleted |
61
|
|
|
* @template_var string adminlink A link to Edit or Delete the story or a blank string if you are not the module's admin |
62
|
|
|
* @template_var string topicid News topic's Id |
63
|
|
|
* @template_var string topic_color Topic's color |
64
|
|
|
* @template_var string imglink A link to go and see the topic of the story with the topic's picture (if it exists) |
65
|
|
|
* @template_var string align Topic's image alignement |
66
|
|
|
* @template_var int hits Story's counter of visits |
67
|
|
|
* @template_var string mail_link A link (with a mailto) to email the story's URL to someone |
68
|
|
|
* @template_var string lang_printerpage Used in the link and picture to have a "printable version" (fixed text) |
69
|
|
|
* @template_var string lang_on Fixed text "On" ("published on") |
70
|
|
|
* @template_var string lang_postedby Fixed text "Posted by" |
71
|
|
|
* @template_var string lang_reads Fixed text "Reads" |
72
|
|
|
* @template_var string news_by_the_same_author_link According the the module's option named "newsbythisauthor", it contains a link to see all the article's stories |
73
|
|
|
* @template_var int summary_count Number of stories really visibles in the summary table |
74
|
|
|
* @template_var boolean showsummary According to the module's option named "showsummarytable", this contains "True" of "False" |
75
|
|
|
* @template_var array summary Contains the required information to create a summary table at the bottom of the article. Note, we use the module's option "storyhome" to determine the maximum number of stories visibles in this summary table |
76
|
|
|
* Structure : |
77
|
|
|
* @template_var int story_id Story's ID |
78
|
|
|
* @template_var string story_title Story's title |
79
|
|
|
* @template_var int story_hits Counter of hits |
80
|
|
|
* @template_var string story_published Story's date of creation |
81
|
|
|
* @template_var string lang_attached_files Fixed text "Attached Files:" |
82
|
|
|
* @template_var int attached_files_count Number of files attached to the story |
83
|
|
|
* @template_var array attached_files Contains the list of all the files attached to the story |
84
|
|
|
* Structure : |
85
|
|
|
* @template_var int file_id File's ID |
86
|
|
|
* @template_var string visitlink Link to download the file |
87
|
|
|
* @template_var string file_realname Original filename (not the real one use to store the file but the one it have when it was on the user hard disk) |
88
|
|
|
* @template_var string file_attacheddate Date to wich the file was attached to the story (in general that's equal to the article's creation date) |
89
|
|
|
* @template_var string file_mimetype File's mime type |
90
|
|
|
* @template_var string file_downloadname Real name of the file on the webserver's disk (changed by the module) |
91
|
|
|
* @template_var boolean nav_links According to the module's option named "showprevnextlink" it contains "True" or "False" to know if we have to show two links to go to the previous and next article |
92
|
|
|
* @template_var int previous_story_id Id of the previous story (according to the published date and to the perms) |
93
|
|
|
* @template_var int next_story_id Id of the next story (according to the published date and to the perms) |
94
|
|
|
* @template_var string previous_story_title Title of the previous story |
95
|
|
|
* @template_var string next_story_title Title of the next story |
96
|
|
|
* @template_var string lang_previous_story Fixed text "Previous article" |
97
|
|
|
* @template_var string lang_next_story Fixed text "Next article" |
98
|
|
|
* @template_var string lang_other_story Fixed text "Other articles" |
99
|
|
|
* @template_var boolean rates To know if rating is enable or not |
100
|
|
|
* @template_var string lang_ratingc Fixed text "Rating: " |
101
|
|
|
* @template_var string lang_ratethisnews Fixed text "Rate this News" |
102
|
|
|
* @template_var float rating Article's rating |
103
|
|
|
* @template_var string votes "1 vote" or "X votes" |
104
|
|
|
* @template_var string topic_path A path from the root to the current topic (of the current news) |
105
|
|
|
* @copyright (c) XOOPS Project (https://xoops.org) |
106
|
|
|
* |
107
|
|
|
* Parameters received by this page : |
108
|
|
|
* |
109
|
|
|
* @author Xoops Modules Dev Team |
110
|
|
|
*/ |
111
|
|
|
|
112
|
|
|
use Xmf\Request; |
|
|
|
|
113
|
|
|
use XoopsModules\News\{ |
114
|
|
|
Files, |
115
|
|
|
Helper, |
116
|
|
|
Keyhighlighter, |
117
|
|
|
NewsStory, |
118
|
|
|
XoopsTree, |
119
|
|
|
PageNav, |
120
|
|
|
Utility |
121
|
|
|
}; |
122
|
|
|
|
123
|
|
|
|
124
|
|
|
require_once \dirname(__DIR__, 2) . '/mainfile.php'; |
125
|
|
|
//require_once XOOPS_ROOT_PATH . '/modules/news/class/class.newsstory.php'; |
126
|
|
|
//require_once XOOPS_ROOT_PATH . '/modules/news/class/class.sfiles.php'; |
127
|
|
|
//require_once XOOPS_ROOT_PATH . '/modules/news/class/tree.php'; |
128
|
|
|
//; |
129
|
|
|
//require_once XOOPS_ROOT_PATH . '/modules/news/class/class.newstopic.php'; |
130
|
|
|
//require_once XOOPS_ROOT_PATH . '/modules/news/class/Keyhighlighter.php'; |
131
|
|
|
require_once XOOPS_ROOT_PATH . '/modules/news/config.php'; |
132
|
|
|
|
133
|
|
|
/** @var Helper $helper */ |
134
|
|
|
$helper = Helper::getInstance(); |
135
|
|
|
|
136
|
|
|
$storyid = Request::getInt('storyid', 0, 'GET'); |
137
|
|
|
|
138
|
|
|
if (empty($storyid)) { |
139
|
|
|
redirect_header(XOOPS_URL . '/modules/news/index.php', 2, _NW_NOSTORY); |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
$myts = \MyTextSanitizer::getInstance(); |
143
|
|
|
|
144
|
|
|
// Not yet published |
145
|
|
|
$article = new NewsStory($storyid); |
146
|
|
|
if (0 == $article->published() || $article->published() > time()) { |
147
|
|
|
redirect_header(XOOPS_URL . '/modules/news/index.php', 2, _NW_NOTYETSTORY); |
148
|
|
|
} |
149
|
|
|
// Expired |
150
|
|
|
if (0 != $article->expired() && $article->expired() < time()) { |
151
|
|
|
redirect_header(XOOPS_URL . '/modules/news/index.php', 2, _NW_NOSTORY); |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
/** @var \XoopsGroupPermHandler $grouppermHandler */ |
155
|
|
|
$grouppermHandler = xoops_getHandler('groupperm'); |
156
|
|
|
if (is_object($xoopsUser)) { |
157
|
|
|
$groups = $xoopsUser->getGroups(); |
158
|
|
|
} else { |
159
|
|
|
$groups = XOOPS_GROUP_ANONYMOUS; |
160
|
|
|
} |
161
|
|
|
if (!$grouppermHandler->checkRight('news_view', $article->topicid(), $groups, $xoopsModule->getVar('mid'))) { |
162
|
|
|
redirect_header(XOOPS_URL . '/modules/news/index.php', 3, _NOPERM); |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
$storypage = Request::getInt('page', 0, 'GET'); |
166
|
|
|
$dateformat = Utility::getModuleOption('dateformat'); |
167
|
|
|
$hcontent = ''; |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* update counter only when viewing top page and when you are not the author or an admin |
171
|
|
|
*/ |
172
|
|
|
if (empty($_GET['com_id']) && 0 == $storypage) { |
173
|
|
|
if (is_object($xoopsUser)) { |
174
|
|
|
if (($xoopsUser->getVar('uid') == $article->uid()) || Utility::isAdminGroup()) { |
175
|
|
|
// nothing ! ;-) |
176
|
|
|
} else { |
177
|
|
|
$article->updateCounter(); |
178
|
|
|
} |
179
|
|
|
} else { |
180
|
|
|
$article->updateCounter(); |
181
|
|
|
} |
182
|
|
|
} |
183
|
|
|
$GLOBALS['xoopsOption']['template_main'] = 'news_article.tpl'; |
184
|
|
|
require_once XOOPS_ROOT_PATH . '/header.php'; |
185
|
|
|
|
186
|
|
|
$story['id'] = $storyid; |
187
|
|
|
$story['posttime'] = formatTimestamp($article->published(), $dateformat); |
188
|
|
|
$story['news_title'] = $article->title(); |
189
|
|
|
$story['title'] = $article->textlink() . ' : ' . $article->title(); |
190
|
|
|
$story['subtitle'] = $article->subtitle(); |
191
|
|
|
$story['topic_title'] = $article->textlink(); |
192
|
|
|
|
193
|
|
|
$story['text'] = $article->hometext(); |
194
|
|
|
$bodytext = $article->bodytext(); |
195
|
|
|
|
196
|
|
|
if ('' !== xoops_trim($bodytext)) { |
197
|
|
|
$articletext = []; |
198
|
|
|
if (Utility::getModuleOption('enhanced_pagenav')) { |
199
|
|
|
$articletext = preg_split('/(\[pagebreak:|\[pagebreak)(.*)(\])/iU', $bodytext); |
200
|
|
|
$arr_titles = []; |
201
|
|
|
$auto_summary = $article->auto_summary($bodytext, $arr_titles); |
202
|
|
|
$bodytext = str_replace('[summary]', $auto_summary, $bodytext); |
203
|
|
|
$articletext[$storypage] = str_replace('[summary]', $auto_summary, $articletext[$storypage]); |
204
|
|
|
$story['text'] = str_replace('[summary]', $auto_summary, $story['text']); |
205
|
|
|
} else { |
206
|
|
|
$articletext = explode('[pagebreak]', $bodytext); |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
$story_pages = count($articletext); |
210
|
|
|
|
211
|
|
|
if ($story_pages > 1) { |
212
|
|
|
// require_once XOOPS_ROOT_PATH . '/modules/news/include/pagenav.php'; |
213
|
|
|
$pagenav = new PageNav($story_pages, 1, $storypage, 'page', 'storyid=' . $storyid); |
214
|
|
|
if (Utility::isBot()) { // A bot is reading the articles, we are going to show him all the links to the pages |
215
|
|
|
$xoopsTpl->assign('pagenav', $pagenav->renderNav($story_pages)); |
216
|
|
|
} elseif (Utility::getModuleOption('enhanced_pagenav')) { |
217
|
|
|
$xoopsTpl->assign('pagenav', $pagenav->renderEnhancedSelect(true, $arr_titles)); |
218
|
|
|
} else { |
219
|
|
|
$xoopsTpl->assign('pagenav', $pagenav->renderNav()); |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
if (0 == $storypage) { |
223
|
|
|
$story['text'] .= '<br>' . Utility::getModuleOption('advertisement') . '<br>' . $articletext[$storypage]; |
224
|
|
|
} else { |
225
|
|
|
$story['text'] = $articletext[$storypage]; |
226
|
|
|
} |
227
|
|
|
} else { |
228
|
|
|
$story['text'] .= '<br>' . Utility::getModuleOption('advertisement') . '<br>' . $bodytext; |
229
|
|
|
} |
230
|
|
|
} |
231
|
|
|
// Publicit� |
232
|
|
|
$xoopsTpl->assign('advertisement', Utility::getModuleOption('advertisement')); |
233
|
|
|
|
234
|
|
|
// **************************************************************************************************************** |
235
|
|
|
/** |
236
|
|
|
* @param $matches |
237
|
|
|
* |
238
|
|
|
* @return string |
239
|
|
|
*/ |
240
|
|
|
function my_highlighter($matches) |
241
|
|
|
{ |
242
|
|
|
$color = Utility::getModuleOption('highlightcolor'); |
243
|
|
|
if (0 !== mb_strpos($color, '#')) { |
|
|
|
|
244
|
|
|
$color = '#' . $color; |
245
|
|
|
} |
246
|
|
|
|
247
|
|
|
return '<span style="font-weight: bolder; background-color: ' . $color . ';">' . $matches[0] . '</span>'; |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
$highlight = false; |
251
|
|
|
$highlight = Utility::getModuleOption('keywordshighlight'); |
252
|
|
|
|
253
|
|
|
if ($highlight && isset($_GET['keywords'])) { |
254
|
|
|
$keywords = htmlspecialchars(trim(urldecode($_GET['keywords'])), ENT_QUOTES | ENT_HTML5); |
255
|
|
|
$h = new Keyhighlighter($keywords, true, 'my_highlighter'); |
256
|
|
|
$story['text'] = $h->highlight($story['text']); |
257
|
|
|
} |
258
|
|
|
// **************************************************************************************************************** |
259
|
|
|
|
260
|
|
|
$story['poster'] = $article->uname(); |
261
|
|
|
if ($story['poster']) { |
262
|
|
|
$story['posterid'] = $article->uid(); |
263
|
|
|
$story['poster'] = '<a href="' . XOOPS_URL . '/userinfo.php?uid=' . $story['posterid'] . '">' . $story['poster'] . '</a>'; |
264
|
|
|
$tmp_user = new \XoopsUser($article->uid()); |
265
|
|
|
$story['poster_avatar'] = XOOPS_UPLOAD_URL . '/' . $tmp_user->getVar('user_avatar'); |
266
|
|
|
$story['poster_signature'] = $tmp_user->getVar('user_sig'); |
267
|
|
|
$story['poster_email'] = $tmp_user->getVar('email'); |
268
|
|
|
$story['poster_url'] = $tmp_user->getVar('url'); |
269
|
|
|
$story['poster_from'] = $tmp_user->getVar('user_from'); |
270
|
|
|
unset($tmp_user); |
271
|
|
|
} else { |
272
|
|
|
$story['poster'] = ''; |
273
|
|
|
$story['posterid'] = 0; |
274
|
|
|
$story['poster_avatar'] = ''; |
275
|
|
|
$story['poster_signature'] = ''; |
276
|
|
|
$story['poster_email'] = ''; |
277
|
|
|
$story['poster_url'] = ''; |
278
|
|
|
$story['poster_from'] = ''; |
279
|
|
|
if (3 != Utility::getModuleOption('displayname')) { |
280
|
|
|
$story['poster'] = $xoopsConfig['anonymous']; |
281
|
|
|
} |
282
|
|
|
} |
283
|
|
|
$story['morelink'] = ''; |
284
|
|
|
$story['adminlink'] = ''; |
285
|
|
|
unset($isadmin); |
286
|
|
|
|
287
|
|
|
if (is_object($xoopsUser)) { |
288
|
|
|
if ($xoopsUser->isAdmin($xoopsModule->getVar('mid')) |
289
|
|
|
|| (Utility::getModuleOption('authoredit') |
290
|
|
|
&& $article->uid() == $xoopsUser->getVar('uid'))) { |
291
|
|
|
$isadmin = true; |
292
|
|
|
// $story['adminlink'] = $article->adminlink(); |
293
|
|
|
} |
294
|
|
|
} |
295
|
|
|
$story['topicid'] = $article->topicid(); |
296
|
|
|
$story['topic_color'] = '#' . $myts->displayTarea($article->topic_color); |
297
|
|
|
|
298
|
|
|
$story['imglink'] = ''; |
299
|
|
|
$story['align'] = ''; |
300
|
|
|
if ($article->topicdisplay()) { |
301
|
|
|
$story['imglink'] = $article->imglink(); |
302
|
|
|
$story['align'] = $article->topicalign(); |
303
|
|
|
} |
304
|
|
|
$story['hits'] = $article->counter(); |
305
|
|
|
$story['mail_link'] = 'mailto:?subject=' . sprintf(_NW_INTARTICLE, $xoopsConfig['sitename']) . '&body=' . sprintf(_NW_INTARTFOUND, $xoopsConfig['sitename']) . ': ' . XOOPS_URL . '/modules/news/article.php?storyid=' . $article->storyid(); |
306
|
|
|
$xoopsTpl->assign('lang_printerpage', _NW_PRINTERFRIENDLY); |
307
|
|
|
$xoopsTpl->assign('lang_sendstory', _NW_SENDSTORY); |
308
|
|
|
$xoopsTpl->assign('lang_pdfstory', _NW_MAKEPDF); |
309
|
|
|
$xoopsTpl->assign('lang_on', _ON); |
310
|
|
|
$xoopsTpl->assign('lang_postedby', _POSTEDBY); |
311
|
|
|
$xoopsTpl->assign('lang_reads', _READS); |
312
|
|
|
$xoopsTpl->assign('mail_link', 'mailto:?subject=' . sprintf(_NW_INTARTICLE, $xoopsConfig['sitename']) . '&body=' . sprintf(_NW_INTARTFOUND, $xoopsConfig['sitename']) . ': ' . XOOPS_URL . '/modules/news/article.php?storyid=' . $article->storyid()); |
313
|
|
|
|
314
|
|
|
if ('' !== xoops_trim($article->picture())) { |
315
|
|
|
$story['picture'] = XOOPS_URL . '/uploads/news/image/' . $article->picture(); |
316
|
|
|
$story['pictureinfo'] = $article->pictureinfo(); |
317
|
|
|
} else { |
318
|
|
|
$story['picture'] = ''; |
319
|
|
|
$story['pictureinfo'] = ''; |
320
|
|
|
} |
321
|
|
|
|
322
|
|
|
$xoopsTpl->assign('lang_attached_files', _NW_ATTACHEDFILES); |
323
|
|
|
$sfiles = new Files(); |
324
|
|
|
$filesarr = $newsfiles = []; |
325
|
|
|
$filesarr = $sfiles->getAllbyStory($storyid); |
326
|
|
|
$filescount = count($filesarr); |
327
|
|
|
$xoopsTpl->assign('attached_files_count', $filescount); |
328
|
|
|
if ($filescount > 0) { |
329
|
|
|
foreach ($filesarr as $onefile) { |
330
|
|
|
$newsfiles[] = [ |
331
|
|
|
'file_id' => $onefile->getFileid(), |
332
|
|
|
'visitlink' => XOOPS_URL . '/modules/news/visit.php?fileid=' . $onefile->getFileid(), |
333
|
|
|
'file_realname' => $onefile->getFileRealName(), |
334
|
|
|
'file_attacheddate' => formatTimestamp($onefile->getDate(), $dateformat), |
335
|
|
|
'file_mimetype' => $onefile->getMimetype(), |
336
|
|
|
'file_downloadname' => XOOPS_UPLOAD_URL . '/' . $onefile->getDownloadname(), |
337
|
|
|
]; |
338
|
|
|
} |
339
|
|
|
$xoopsTpl->assign('attached_files', $newsfiles); |
340
|
|
|
} |
341
|
|
|
|
342
|
|
|
/** |
343
|
|
|
* Create page's title |
344
|
|
|
*/ |
345
|
|
|
$complement = ''; |
346
|
|
|
if (Utility::getModuleOption('enhanced_pagenav') |
347
|
|
|
&& (isset($arr_titles) && is_array($arr_titles) |
348
|
|
|
&& isset($arr_titles, $storypage) |
349
|
|
|
&& $storypage > 0)) { |
350
|
|
|
$complement = ' - ' . $arr_titles[$storypage]; |
351
|
|
|
} |
352
|
|
|
$xoopsTpl->assign('xoops_pagetitle', $article->title() . $complement . ' - ' . $article->topic_title() . ' - ' . $xoopsModule->name('s')); |
353
|
|
|
|
354
|
|
|
if (Utility::getModuleOption('newsbythisauthor')) { |
355
|
|
|
$xoopsTpl->assign('news_by_the_same_author_link', sprintf("<a href='%s?uid=%d'>%s</a>", XOOPS_URL . '/modules/news/newsbythisauthor.php', $article->uid(), _NW_NEWSSAMEAUTHORLINK)); |
356
|
|
|
} |
357
|
|
|
|
358
|
|
|
/** |
359
|
|
|
* Create a clickable path from the root to the current topic (if we are viewing a topic) |
360
|
|
|
* Actually this is not used in the default's templates but you can use it as you want |
361
|
|
|
* Uncomment the code to be able to use it |
362
|
|
|
*/ |
363
|
|
|
if ($cfg['create_clickable_path']) { |
364
|
|
|
$mytree = new XoopsTree($xoopsDB->prefix('news_topics'), 'topic_id', 'topic_pid'); |
365
|
|
|
$topicpath = $mytree->getNicePathFromId($article->topicid(), 'topic_title', 'index.php?op=1'); |
366
|
|
|
$xoopsTpl->assign('topic_path', $topicpath); |
367
|
|
|
unset($mytree); |
368
|
|
|
} |
369
|
|
|
|
370
|
|
|
/** |
371
|
|
|
* Summary table |
372
|
|
|
* |
373
|
|
|
* When you are viewing an article, you can see a summary table containing |
374
|
|
|
* the first n links to the last published news. |
375
|
|
|
* This summary table is visible according to a module's option (showsummarytable) |
376
|
|
|
* The number of items is equal to the module's option "storyhome" ("Select the number |
377
|
|
|
* of news items to display on top page") |
378
|
|
|
* We also use the module's option "restrictindex" ("Restrict Topics on Index Page"), like |
379
|
|
|
* this you (the webmaster) select if users can see restricted stories or not. |
380
|
|
|
*/ |
381
|
|
|
if (Utility::getModuleOption('showsummarytable')) { |
382
|
|
|
$xoopsTpl->assign('showsummary', true); |
383
|
|
|
$xoopsTpl->assign('lang_other_story', _NW_OTHER_ARTICLES); |
384
|
|
|
$count = 0; |
385
|
|
|
$tmparticle = new NewsStory(); |
386
|
|
|
$infotips = Utility::getModuleOption('infotips'); |
387
|
|
|
$sarray = NewsStory::getAllPublished($cfg['article_summary_items_count'], 0, $helper->getConfig('restrictindex')); |
388
|
|
|
if (count($sarray) > 0) { |
|
|
|
|
389
|
|
|
foreach ($sarray as $onearticle) { |
390
|
|
|
++$count; |
391
|
|
|
$htmltitle = ''; |
392
|
|
|
$tooltips = ''; |
393
|
|
|
$htmltitle = ''; |
394
|
|
|
if ($infotips > 0) { |
395
|
|
|
$tooltips = Utility::makeInfotips($onearticle->hometext()); |
396
|
|
|
$htmltitle = ' title="' . $tooltips . '"'; |
397
|
|
|
} |
398
|
|
|
$xoopsTpl->append( |
399
|
|
|
'summary', |
400
|
|
|
[ |
401
|
|
|
'story_id' => $onearticle->storyid(), |
402
|
|
|
'htmltitle' => $htmltitle, |
403
|
|
|
'infotips' => $tooltips, |
404
|
|
|
'story_title' => $onearticle->title(), |
405
|
|
|
'story_hits' => $onearticle->counter(), |
406
|
|
|
'story_published' => formatTimestamp($onearticle->published, $dateformat), |
407
|
|
|
] |
408
|
|
|
); |
409
|
|
|
} |
410
|
|
|
} |
411
|
|
|
$xoopsTpl->assign('summary_count', $count); |
412
|
|
|
unset($tmparticle); |
413
|
|
|
} else { |
414
|
|
|
$xoopsTpl->assign('showsummary', false); |
415
|
|
|
} |
416
|
|
|
|
417
|
|
|
/** |
418
|
|
|
* Show a link to go to the previous article and to the next article |
419
|
|
|
* |
420
|
|
|
* According to a module's option "showprevnextlink" ("Show Previous and Next link?") |
421
|
|
|
* you can display, at the bottom of each article, two links used to navigate thru stories. |
422
|
|
|
* This feature uses the module's option "restrictindex" so that we can, or can't see |
423
|
|
|
* restricted stories |
424
|
|
|
*/ |
425
|
|
|
if (Utility::getModuleOption('showprevnextlink')) { |
426
|
|
|
$xoopsTpl->assign('nav_links', true); |
427
|
|
|
$tmparticle = new NewsStory(); |
428
|
|
|
$nextId = $previousId = -1; |
429
|
|
|
$next = $previous = []; |
430
|
|
|
$previousTitle = $nextTitle = ''; |
431
|
|
|
|
432
|
|
|
$next = $tmparticle->getNextArticle($storyid, $helper->getConfig('restrictindex')); |
433
|
|
|
if (count($next) > 0) { |
434
|
|
|
$nextId = $next['storyid']; |
435
|
|
|
$nextTitle = $next['title']; |
436
|
|
|
} |
437
|
|
|
|
438
|
|
|
$previous = $tmparticle->getPreviousArticle($storyid, $helper->getConfig('restrictindex')); |
439
|
|
|
if (count($previous) > 0) { |
440
|
|
|
$previousId = $previous['storyid']; |
441
|
|
|
$previousTitle = $previous['title']; |
442
|
|
|
} |
443
|
|
|
|
444
|
|
|
$xoopsTpl->assign('previous_story_id', $previousId); |
445
|
|
|
$xoopsTpl->assign('next_story_id', $nextId); |
446
|
|
|
if ($previousId > 0) { |
447
|
|
|
$xoopsTpl->assign('previous_story_title', $previousTitle); |
448
|
|
|
$hcontent .= sprintf("<link rel=\"Prev\" title=\"%s\" href=\"%s/\">\n", $previousTitle, XOOPS_URL . '/modules/news/article.php?storyid=' . $previousId); |
449
|
|
|
} |
450
|
|
|
|
451
|
|
|
if ($nextId > 0) { |
452
|
|
|
$xoopsTpl->assign('next_story_title', $nextTitle); |
453
|
|
|
$hcontent .= sprintf("<link rel=\"Next\" title=\"%s\" href=\"%s/\">\n", $nextTitle, XOOPS_URL . '/modules/news/article.php?storyid=' . $nextId); |
454
|
|
|
} |
455
|
|
|
$xoopsTpl->assign('lang_previous_story', _NW_PREVIOUS_ARTICLE); |
456
|
|
|
$xoopsTpl->assign('lang_next_story', _NW_NEXT_ARTICLE); |
457
|
|
|
unset($tmparticle); |
458
|
|
|
} else { |
459
|
|
|
$xoopsTpl->assign('nav_links', false); |
460
|
|
|
} |
461
|
|
|
|
462
|
|
|
/** |
463
|
|
|
* Manage all the meta datas |
464
|
|
|
*/ |
465
|
|
|
Utility::createMetaDatas($article); |
466
|
|
|
|
467
|
|
|
/** |
468
|
|
|
* Show a "Bookmark this article at these sites" block ? |
469
|
|
|
*/ |
470
|
|
|
if (Utility::getModuleOption('bookmarkme')) { |
471
|
|
|
$xoopsTpl->assign('bookmarkme', true); |
472
|
|
|
$xoopsTpl->assign('encoded_title', rawurlencode($article->title())); |
473
|
|
|
} else { |
474
|
|
|
$xoopsTpl->assign('bookmarkme', false); |
475
|
|
|
} |
476
|
|
|
|
477
|
|
|
/** |
478
|
|
|
* Use Facebook Comments Box? |
479
|
|
|
*/ |
480
|
|
|
if (Utility::getModuleOption('fbcomments')) { |
481
|
|
|
$xoopsTpl->assign('fbcomments', true); |
482
|
|
|
} else { |
483
|
|
|
$xoopsTpl->assign('fbcomments', false); |
484
|
|
|
} |
485
|
|
|
|
486
|
|
|
/** |
487
|
|
|
* Enable users to vote |
488
|
|
|
* |
489
|
|
|
* According to a module's option, "ratenews", you can display a link to rate the current news |
490
|
|
|
* The actual rate in showed (and the number of votes) |
491
|
|
|
* Possible modification, restrict votes to registred users |
492
|
|
|
*/ |
493
|
|
|
$other_test = true; |
494
|
|
|
if ($cfg['config_rating_registred_only']) { |
495
|
|
|
if (isset($xoopsUser) && is_object($xoopsUser)) { |
496
|
|
|
$other_test = true; |
497
|
|
|
} else { |
498
|
|
|
$other_test = false; |
499
|
|
|
} |
500
|
|
|
} |
501
|
|
|
|
502
|
|
|
if (Utility::getModuleOption('ratenews') && $other_test) { |
503
|
|
|
$xoopsTpl->assign('rates', true); |
504
|
|
|
$xoopsTpl->assign('lang_ratingc', _NW_RATINGC); |
505
|
|
|
$xoopsTpl->assign('lang_ratethisnews', _NW_RATETHISNEWS); |
506
|
|
|
$story['rating'] = number_format($article->rating(), 2); |
507
|
|
|
if (1 == $article->votes) { |
508
|
|
|
$story['votes'] = _NW_ONEVOTE; |
509
|
|
|
} else { |
510
|
|
|
$story['votes'] = sprintf(_NW_NUMVOTES, $article->votes); |
511
|
|
|
} |
512
|
|
|
} else { |
513
|
|
|
$xoopsTpl->assign('rates', false); |
514
|
|
|
} |
515
|
|
|
|
516
|
|
|
$xoopsTpl->assign('story', $story); |
517
|
|
|
|
518
|
|
|
// Added in version 1.63, TAGS |
519
|
|
|
$helper = Helper::getInstance(); |
520
|
|
|
$xoopsTpl->assign('tags', false); |
521
|
|
|
if (1 == $helper->getConfig('tags') && \class_exists(\XoopsModules\Tag\Tagbar::class) && \xoops_isActiveModule('tag')) { |
522
|
|
|
$xoopsTpl->assign('tags', true); |
523
|
|
|
$tagbarObj = new \XoopsModules\Tag\Tagbar(); |
524
|
|
|
$xoopsTpl->assign('tagbar', $tagbarObj->getTagbar($storyid, 0)); |
525
|
|
|
} |
526
|
|
|
|
527
|
|
|
$xoopsTpl->assign('share', $helper->getConfig('share')); |
528
|
|
|
$xoopsTpl->assign('showicons', $helper->getConfig('showicons')); |
529
|
|
|
|
530
|
|
|
$canPdf = 1; |
531
|
|
|
if (!is_object($GLOBALS['xoopsUser']) && 0 == $helper->getConfig('show_pdficon')) { |
|
|
|
|
532
|
|
|
$canPdf = 0; |
533
|
|
|
} |
534
|
|
|
$xoopsTpl->assign('showPdfIcon', $canPdf); |
535
|
|
|
|
536
|
|
|
if (1 == Utility::getModuleOption('displaytopictitle')) { |
537
|
|
|
$xoopsTpl->assign('displaytopictitle', true); |
538
|
|
|
} else { |
539
|
|
|
$xoopsTpl->assign('displaytopictitle', false); |
540
|
|
|
} |
541
|
|
|
|
542
|
|
|
//Add style css |
543
|
|
|
$xoTheme->addStylesheet('modules/news/assets/css/style.css'); |
544
|
|
|
|
545
|
|
|
require XOOPS_ROOT_PATH . '/include/comment_view.php'; |
546
|
|
|
require_once XOOPS_ROOT_PATH . '/footer.php'; |
547
|
|
|
|
Let?s assume that you have a directory layout like this:
and let?s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: