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: https://xoops.org // |
25
|
|
|
// Project: Article Project // |
26
|
|
|
// ------------------------------------------------------------------------ // |
27
|
|
|
use Xmf\Request; |
28
|
|
|
use XoopsModules\Planet; |
29
|
|
|
/** @var Planet\Helper $helper */ |
30
|
|
|
$helper = Planet\Helper::getInstance(); |
31
|
|
|
|
32
|
|
|
include __DIR__ . '/header.php'; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* The comment detection scripts should be removed once absolute url is used in comment_view.php |
36
|
|
|
* The notification detection scripts should be removed once absolute url is used in notification_select.php |
37
|
|
|
* |
38
|
|
|
*/ |
39
|
|
|
if (preg_match("/(\/comment_[^\.]*\.php\?.*=.*)/i", Request::getUrl('REQUEST_URI', '', 'SERVER'), $matches)) {//$_SERVER['REQUEST_URI'] |
40
|
|
|
header('location: ' . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . $matches[1]); |
41
|
|
|
exit(); |
42
|
|
|
} |
43
|
|
View Code Duplication |
if (preg_match("/\/notification_update\.php/i", Request::getUrl('REQUEST_URI', '', 'SERVER'), $matches)) { |
|
|
|
|
44
|
|
|
include XOOPS_ROOT_PATH . '/include/notification_update.php'; |
45
|
|
|
exit(); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
View Code Duplication |
if ($REQUEST_URI_parsed = PlanetUtility::planetParseArguments($args_num, $args, $args_str)) { |
|
|
|
|
49
|
|
|
$args['article'] = @$args_num[0]; |
50
|
|
|
$args['blog'] = @$args['blog']; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
$article_id = Request::getInt('article', @$args['article'], 'POST');//(int)(empty($_GET['article']) ? @$args['article'] : $_GET['article']); |
54
|
|
|
$blog_id = Request::getInt('blog', @$args['blog'], 'POST');//(int)(empty($_GET['blog']) ? @$args['blog'] : $_GET['blog']); |
55
|
|
|
|
56
|
|
|
$articleHandler = xoops_getModuleHandler('article', $GLOBALS['moddirname']); |
57
|
|
|
$blogHandler = xoops_getModuleHandler('blog', $GLOBALS['moddirname']); |
58
|
|
|
$article_obj = $articleHandler->get($article_id); |
59
|
|
|
$blog_obj = $blogHandler->get($article_obj->getVar('blog_id')); |
60
|
|
|
|
61
|
|
|
// restore $_SERVER['REQUEST_URI'] |
62
|
|
|
if (!empty($REQUEST_URI_parsed)) { |
63
|
|
|
$_SERVER['REQUEST_URI'] = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . (empty($article_id) ? '' : '?article=' . $article_id); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
$xoopsOption['xoops_pagetitle'] = $xoopsModule->getVar('name') . ' - ' . $article_obj->getVar('art_title'); |
67
|
|
|
$xoopsOption['template_main'] = PlanetUtility::planetGetTemplate('article'); |
68
|
|
|
require_once XOOPS_ROOT_PATH . '/header.php'; |
69
|
|
|
include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/vars.php'; |
70
|
|
|
|
71
|
|
|
$article_data = [ |
72
|
|
|
'id' => $article_id, |
73
|
|
|
'title' => $article_obj->getVar('art_title'), |
74
|
|
|
'content' => $article_obj->getVar('art_content'), |
75
|
|
|
'author' => $article_obj->getVar('art_author'), |
76
|
|
|
'time' => $article_obj->getTime(), |
77
|
|
|
'link' => $article_obj->getVar('art_link'), |
78
|
|
|
'views' => $article_obj->getVar('art_views'), |
79
|
|
|
'comments' => $article_obj->getVar('art_comments'), |
80
|
|
|
'star' => $article_obj->getStar(), |
81
|
|
|
'rates' => $article_obj->getVar('art_rates'), |
82
|
|
|
'blog' => ['id' => $article_obj->getVar('blog_id'), 'title' => $blog_obj->getVar('blog_title')] |
83
|
|
|
]; |
84
|
|
|
|
85
|
|
|
if (!empty($helper->getConfig('do_sibling'))) { |
86
|
|
|
$articles_sibling = $articleHandler->getSibling($article_obj, $blog_id); |
87
|
|
View Code Duplication |
if (!empty($articles_sibling['previous'])) { |
|
|
|
|
88
|
|
|
$articles_sibling['previous']['url'] = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . URL_DELIMITER . '' . $articles_sibling['previous']['id'] . '/b' . $blog_id; |
89
|
|
|
$articles_sibling['previous']['title'] = $articles_sibling['previous']['title']; |
90
|
|
|
} |
91
|
|
View Code Duplication |
if (!empty($articles_sibling['next'])) { |
|
|
|
|
92
|
|
|
$articles_sibling['next']['url'] = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . URL_DELIMITER . '' . $articles_sibling['next']['id'] . '/b' . $blog_id; |
93
|
|
|
$articles_sibling['next']['title'] = $articles_sibling['next']['title']; |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
$xoopsTpl->assign('modulename', $xoopsModule->getVar('name')); |
98
|
|
|
|
99
|
|
|
$xoopsTpl->assign('article', $article_data); |
100
|
|
|
$xoopsTpl->assign('sibling', $articles_sibling); |
101
|
|
|
|
102
|
|
|
$xoopsTpl->assign('user_level', !is_object($xoopsUser) ? 0 : ($xoopsUser->isAdmin() ? 2 : 1)); |
103
|
|
|
if (empty($helper->getConfig('anonymous_rate')) && !is_object($xoopsUser)) { |
104
|
|
|
} else { |
105
|
|
|
$xoopsTpl->assign('canrate', 1); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
if ($transferbar = @include XOOPS_ROOT_PATH . '/Frameworks/transfer/bar.transfer.php') { |
109
|
|
|
$xoopsTpl->assign('transfer', $transferbar); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
// Loading module meta data, NOT THE RIGHT WAY DOING IT |
113
|
|
|
$xoopsTpl->assign('xoops_pagetitle', $xoopsOption['xoops_pagetitle']); |
114
|
|
|
|
115
|
|
|
// for comment and notification |
116
|
|
|
//$_SERVER['REQUEST_URI'] = XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/view.article.php"; |
117
|
|
|
$_GET['article'] = $article_id; |
118
|
|
|
include XOOPS_ROOT_PATH . '/include/comment_view.php'; |
119
|
|
|
|
120
|
|
|
require_once __DIR__ . '/footer.php'; |
121
|
|
|
|
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.