Completed
Push — master ( 741c06...b610c1 )
by Michael
10s
created

article.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
550
       $xoopsTpl->assign('displaytopictitle',true);
551
} else {
552
       $xoopsTpl->assign('displaytopictitle',false);
553
}
554
555
//Add style css
556
$xoTheme->addStylesheet('modules/news/assets/css/style.css');
557
558
include_once XOOPS_ROOT_PATH . '/include/comment_view.php';
559
include_once XOOPS_ROOT_PATH . '/footer.php';
560