Completed
Push — master ( 96da4e...7c5656 )
by Michael
04:52
created

view.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
// This program is free software; you can redistribute it and/or modify     //
5
// it under the terms of the GNU General Public License as published by     //
6
// the Free Software Foundation; either version 2 of the License, or        //
7
// (at your option) any later version.                                      //
8
//                                                                          //
9
// You may not change or alter any portion of this comment or credits       //
10
// of supporting developers from this source code or any supporting         //
11
// source code which is considered copyrighted (c) material of the          //
12
// original comment or credit authors.                                      //
13
//                                                                          //
14
// This program is distributed in the hope that it will be useful,          //
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of           //
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
17
// GNU General Public License for more details.                             //
18
//                                                                          //
19
// You should have received a copy of the GNU General Public License        //
20
// along with this program; if not, write to the Free Software              //
21
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
22
// ------------------------------------------------------------------------ //
23
// Author: phppp (D.J., [email protected])                                  //
24
// URL: http://xoops.org                         //
25
// Project: Article Project                                                 //
26
// ------------------------------------------------------------------------ //
27
include __DIR__ . '/header.php';
28
29
/**
30
 * The comment detection scripts should be removed once absolute url is used in comment_view.php
31
 * The notification detection scripts should be removed once absolute url is used in notification_select.php
32
 *
33
 */
34
if (preg_match("/(\/comment_[^\.]*\.php\?.*=.*)/i", $_SERVER['REQUEST_URI'], $matches)) {
35
    header('location: ' . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . $matches[1]);
36
    exit();
37
}
38
if (preg_match("/\/notification_update\.php/i", $_SERVER['REQUEST_URI'], $matches)) {
39
    include XOOPS_ROOT_PATH . '/include/notification_update.php';
40
    exit();
41
}
42
43 View Code Duplication
if ($REQUEST_URI_parsed = planet_parse_args($args_num, $args, $args_str)) {
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...
44
    $args['article'] = @$args_num[0];
45
    $args['blog']    = @$args['blog'];
46
}
47
48
$article_id = (int)(empty($_GET['article']) ? @$args['article'] : $_GET['article']);
49
$blog_id    = (int)(empty($_GET['blog']) ? @$args['blog'] : $_GET['blog']);
50
51
$article_handler = xoops_getModuleHandler('article', $GLOBALS['moddirname']);
52
$blog_handler    = xoops_getModuleHandler('blog', $GLOBALS['moddirname']);
53
$article_obj     =& $article_handler->get($article_id);
54
$blog_obj        =& $blog_handler->get($article_obj->getVar('blog_id'));
55
56
// restore $_SERVER['REQUEST_URI']
57
if (!empty($REQUEST_URI_parsed)) {
58
    $_SERVER['REQUEST_URI'] = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php'
59
                              . (empty($article_id) ? '' : '?article=' . $article_id);
60
}
61
62
$xoopsOption['xoops_pagetitle'] = $xoopsModule->getVar('name') . ' - ' . $article_obj->getVar('art_title');
63
$xoopsOption['template_main']   = planet_getTemplate('article');
64
include_once XOOPS_ROOT_PATH . '/header.php';
65
include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/vars.php';
66
67
$article_data = array(
68
    'id'       => $article_id,
69
    'title'    => $article_obj->getVar('art_title'),
70
    'content'  => $article_obj->getVar('art_content'),
71
    'author'   => $article_obj->getVar('art_author'),
72
    'time'     => $article_obj->getTime(),
73
    'link'     => $article_obj->getVar('art_link'),
74
    'views'    => $article_obj->getVar('art_views'),
75
    'comments' => $article_obj->getVar('art_comments'),
76
    'star'     => $article_obj->getStar(),
77
    'rates'    => $article_obj->getVar('art_rates'),
78
    'blog'     => array('id' => $article_obj->getVar('blog_id'), 'title' => $blog_obj->getVar('blog_title'))
79
);
80
81
if (!empty($xoopsModuleConfig['do_sibling'])) {
82
    $articles_sibling =& $article_handler->getSibling($article_obj, $blog_id);
83 View Code Duplication
    if (!empty($articles_sibling['previous'])) {
84
        $articles_sibling['previous']['url']   = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php'
85
                                                 . URL_DELIMITER . '' . $articles_sibling['previous']['id'] . '/b'
86
                                                 . $blog_id;
87
        $articles_sibling['previous']['title'] = $articles_sibling['previous']['title'];
88
    }
89 View Code Duplication
    if (!empty($articles_sibling['next'])) {
90
        $articles_sibling['next']['url']   = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php'
91
                                             . URL_DELIMITER . '' . $articles_sibling['next']['id'] . '/b' . $blog_id;
92
        $articles_sibling['next']['title'] = $articles_sibling['next']['title'];
93
    }
94
}
95
96
$xoopsTpl->assign('modulename', $xoopsModule->getVar('name'));
97
98
$xoopsTpl->assign('article', $article_data);
99
$xoopsTpl->assign('sibling', $articles_sibling);
100
101
$xoopsTpl->assign('user_level', !is_object($xoopsUser) ? 0 : ($xoopsUser->isAdmin() ? 2 : 1));
102
if (empty($xoopsModuleConfig['anonymous_rate']) && !is_object($xoopsUser)) {
103
} else {
104
    $xoopsTpl->assign('canrate', 1);
105
}
106
107
if ($transferbar = @include XOOPS_ROOT_PATH . '/Frameworks/transfer/bar.transfer.php') {
108
    $xoopsTpl->assign('transfer', $transferbar);
109
}
110
111
// Loading module meta data, NOT THE RIGHT WAY DOING IT
112
$xoopsTpl->assign('xoops_pagetitle', $xoopsOption['xoops_pagetitle']);
113
114
// for comment and notification
115
//$_SERVER['REQUEST_URI'] = XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/view.article.php";
116
$_GET['article'] = $article_id;
117
include XOOPS_ROOT_PATH . '/include/comment_view.php';
118
119
include_once __DIR__ . '/footer.php';
120