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 | // <https://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 | // Author: phppp (D.J., [email protected]) // |
||
28 | // URL: https://xoops.org // |
||
29 | // Project: Article Project // |
||
30 | // ------------------------------------------------------------------------ // |
||
31 | // irmtfan enhance include |
||
32 | |||
33 | use Xmf\Request; |
||
34 | use XoopsModules\Newbb; |
||
35 | |||
36 | include_once __DIR__ . '/header.php'; |
||
37 | $xoopsLogger->startTime('newBB_viewtopic'); |
||
38 | include_once __DIR__ . '/include/functions.read.php'; |
||
39 | include_once __DIR__ . '/include/functions.render.php'; |
||
40 | xoops_loadLanguage('user'); |
||
41 | |||
42 | /*Build the page query*/ |
||
43 | $query_vars = ['post_id', 'topic_id', 'status', 'order', 'start', 'move', 'mode']; |
||
44 | $query_array = []; |
||
45 | foreach ($query_vars as $var) { |
||
46 | if (Request::getString($var, '', 'GET')) { |
||
47 | $query_array[$var] = "{$var}=" . Request::getString($var, '', 'GET'); |
||
48 | } |
||
49 | } |
||
50 | $page_query = htmlspecialchars(implode('&', array_values($query_array))); |
||
51 | unset($query_array); |
||
52 | |||
53 | $forum_id = Request::getInt('forum', 0, 'GET'); |
||
54 | $read = (Request::getString('read', '', 'GET') |
||
55 | && 'new' === Request::getString('read', '', 'GET')) ? Request::getString('read', '', 'GET') : ''; |
||
56 | $topic_id = Request::getInt('topic_id', 0, 'GET'); // isset($_GET['topic_id']) ? (int)($_GET['topic_id']) : 0; |
||
57 | $post_id = Request::getInt('post_id', 0, 'GET'); // !empty($_GET['post_id']) ? (int)($_GET['post_id']) : 0; |
||
58 | $move = strtolower(Request::getString('move', '', 'GET')); // isset($_GET['move']) ? strtolower($_GET['move']) : ''; |
||
59 | $start = Request::getInt('start', 0, 'GET'); // !empty($_GET['start']) ? (int)($_GET['start']) : 0; |
||
60 | $status = (Request::getString('status', '', 'GET') |
||
61 | && in_array(Request::getString('status', '', 'GET'), ['active', 'pending', 'deleted'], true)) ? Request::getString('status', '', 'GET') : ''; |
||
62 | $mode = Request::getInt('mode', (!empty($status) ? 2 : 0), 'GET'); // !empty($_GET['mode']) ? (int)($_GET['mode']) : (!empty($status) ? 2 : 0); |
||
63 | $order = (Request::getString('order', '', 'GET') |
||
64 | && in_array(Request::getString('order', '', 'GET'), ['ASC', 'DESC'], true)) ? Request::getString('order', '', 'GET') : ''; |
||
65 | |||
66 | if ('' === $order) { |
||
67 | if (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->isActive()) { |
||
68 | $order = (1 == $GLOBALS['xoopsUser']->getVar('uorder')) ? 'DESC' : 'ASC'; |
||
69 | } else { |
||
70 | $order = (1 == $GLOBALS['xoopsConfig']['com_order']) ? 'DESC' : 'ASC'; |
||
71 | } |
||
72 | } |
||
73 | |||
74 | View Code Duplication | if (!$topic_id && !$post_id) { |
|
75 | $redirect = empty($forum_id) ? XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/index.php' : XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/viewforum.php?forum={$forum_id}"; |
||
76 | redirect_header($redirect, 2, _MD_NEWBB_ERRORTOPIC); |
||
77 | } |
||
78 | |||
79 | ///** @var Newbb\TopicHandler $topicHandler */ |
||
80 | //$topicHandler = Newbb\Helper::getInstance()->getHandler('Topic'); |
||
81 | if (!empty($post_id)) { |
||
82 | $topicObject = $topicHandler->getByPost($post_id); |
||
83 | $topic_id = $topicObject->getVar('topic_id'); |
||
84 | } elseif (!empty($move)) { |
||
85 | $topicObject = $topicHandler->getByMove($topic_id, ('prev' === $move) ? -1 : 1, $forum_id); |
||
86 | $topic_id = $topicObject->getVar('topic_id'); |
||
87 | } else { |
||
88 | $topicObject = $topicHandler->get($topic_id); |
||
89 | } |
||
90 | |||
91 | View Code Duplication | if (!is_object($topicObject) || !$topic_id = $topicObject->getVar('topic_id')) { |
|
92 | $redirect = empty($forum_id) ? XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/index.php' : XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/viewforum.php?forum={$forum_id}"; |
||
93 | redirect_header($redirect, 2, _MD_NEWBB_ERRORTOPIC); |
||
94 | } |
||
95 | $forum_id = $topicObject->getVar('forum_id'); |
||
96 | ///** @var Newbb\ForumHandler $forumHandler */ |
||
97 | //$forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
||
98 | $forumObject = $forumHandler->get($forum_id); |
||
99 | |||
100 | $isAdmin = newbbIsAdmin($forumObject); |
||
101 | |||
102 | if ((!$isAdmin && $topicObject->getVar('approved') < 0) || (!$forumHandler->getPermission($forumObject)) |
||
103 | || (!$topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'view'))) { |
||
104 | redirect_header(XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewforum.php?forum=' . $forum_id, 2, _MD_NEWBB_NORIGHTTOVIEW); |
||
105 | } |
||
106 | |||
107 | // START irmtfan - find if topic is read or unread - for all users (member and anon) |
||
108 | $topic_is_unread = true; |
||
109 | /* if $GLOBALS['xoopsModuleConfig']["read_mode"] === 0 || |
||
110 | * never read && $GLOBALS['xoopsModuleConfig']["read_mode"] === 1 || |
||
111 | * never read && $GLOBALS['xoopsModuleConfig']["read_mode"] === 2 || |
||
112 | * => $topic_last_post_time_or_id_read = NULL |
||
113 | * if !$GLOBALS['xoopsUser'] && $GLOBALS['xoopsModuleConfig']["read_mode"] === 2 |
||
114 | * => $topic_last_post_time_or_id_read = false |
||
115 | * if !$GLOBALS['xoopsUser'] && $GLOBALS['xoopsModuleConfig']["read_mode"] === 1 |
||
116 | * => $topic_last_post_time_or_id_read = lastview(newbb_IP{ip}LT) |
||
117 | */ |
||
118 | $topic_last_post_time_or_id_read = newbbGetRead('topic', $topic_id); |
||
119 | if (!empty($topic_last_post_time_or_id_read)) { |
||
120 | if (1 == $GLOBALS['xoopsModuleConfig']['read_mode']) { |
||
121 | // $postHandler = Newbb\Helper::getInstance()->getHandler('Post'); |
||
122 | $postObject = $postHandler->get($topicObject->getVar('topic_last_post_id')); |
||
123 | $topic_is_unread = ($topic_last_post_time_or_id_read < $postObject->getVar('post_time')); |
||
124 | } |
||
125 | if (2 == $GLOBALS['xoopsModuleConfig']['read_mode']) { |
||
126 | $topic_is_unread = ($topic_last_post_time_or_id_read < $topicObject->getVar('topic_last_post_id')); |
||
127 | // hack jump to last post read if post_id is empty - is there any better way? |
||
128 | if (empty($post_id) && $topic_is_unread |
||
129 | && !empty($GLOBALS['xoopsModuleConfig']['jump_to_topic_last_post_read_enabled'])) { |
||
130 | header('Location: ' . Request::getString('REQUEST_URI', '', 'SERVER') . '&post_id=' . $topic_last_post_time_or_id_read); |
||
131 | } |
||
132 | } |
||
133 | } |
||
134 | // END irmtfan - find if topic is read or unread - for all users (member and anon) |
||
135 | |||
136 | /* Only admin has access to admin mode */ |
||
137 | if (!$isAdmin) { |
||
138 | $status = ''; |
||
139 | $mode = 0; |
||
140 | } |
||
141 | |||
142 | if (!empty($GLOBALS['xoopsModuleConfig']['enable_karma'])) { |
||
143 | // /** @var Newbb\KarmaHandler $karmaHandler */ |
||
144 | // $karmaHandler = Newbb\Helper::getInstance()->getHandler('Karma'); |
||
145 | $user_karma = $karmaHandler->getUserKarma(); |
||
146 | } |
||
147 | |||
148 | //$viewmode = "flat"; |
||
149 | |||
150 | $total_posts = $topicHandler->getPostCount($topicObject, $status); |
||
151 | $postsArray = []; |
||
152 | $postsArray = $topicHandler->getAllPosts($topicObject, $order, $GLOBALS['xoopsModuleConfig']['posts_per_page'], $start, $post_id, $status); |
||
153 | |||
154 | //irmtfan - increment topic_views only if the topic is unread |
||
155 | if ($topic_is_unread) { |
||
156 | $topicObject->incrementCounter(); |
||
157 | } |
||
158 | newbbSetRead('topic', $topic_id, $topicObject->getVar('topic_last_post_id')); |
||
159 | |||
160 | $GLOBALS['xoopsOption']['template_main'] = 'newbb_viewtopic.tpl'; |
||
161 | // irmtfan remove and move to footer.php |
||
162 | //$xoopsOption['xoops_module_header']= $xoops_module_header; |
||
163 | // irmtfan include header.php after defining $xoopsOption['template_main'] |
||
164 | include_once $GLOBALS['xoops']->path('header.php'); |
||
165 | //$xoopsTpl->assign('xoops_module_header', $xoops_module_header); |
||
166 | // irmtfan new method |
||
167 | View Code Duplication | if (!empty($GLOBALS['xoopsModuleConfig']['rss_enable'])) { |
|
168 | $xoopsTpl->assign('xoops_module_header', ' |
||
169 | <link rel="alternate" type="application/rss+xml" title="' . $xoopsModule->getVar('name') . '-' . $forumObject->getVar('forum_name') . '" href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/rss.php?f=' . $forumObject->getVar('forum_id') . '" /> |
||
170 | ' . @$xoopsTpl->get_template_vars('xoops_module_header')); |
||
171 | } |
||
172 | |||
173 | if ($GLOBALS['xoopsModuleConfig']['wol_enabled']) { |
||
174 | /** @var Newbb\OnlineHandler $onlineHandler */ |
||
175 | $onlineHandler = Newbb\Helper::getInstance()->getHandler('Online'); |
||
176 | $onlineHandler->init($forumObject, $topicObject); |
||
177 | $xoopsTpl->assign('online', $onlineHandler->showOnline()); |
||
178 | } |
||
179 | $xoopsTpl->assign('parentforum', $forumHandler->getParents($forumObject)); |
||
180 | // irmtfan - remove icon_path and use newbbDisplayImage |
||
181 | $xoopsTpl->assign('anonym_avatar', newbbDisplayImage('anonym')); |
||
182 | |||
183 | // START irmtfan improve infobox |
||
184 | $infobox = []; |
||
185 | $infobox['show'] = (int)$GLOBALS['xoopsModuleConfig']['show_infobox']; //4.05 |
||
186 | // irmtfan removed then define after array |
||
187 | //$xoopsTpl->assign('infobox', $infobox); //4.05 |
||
188 | $iconHandler = newbbGetIconHandler(); // can be use in the follwing codes in this file |
||
189 | |||
190 | if ($infobox['show'] > 0) { |
||
191 | // irmtfan - remove icon_path and use newbbDisplayImage |
||
192 | $infobox['icon'] = [ |
||
193 | 'expand' => $iconHandler->getImageSource('less'), |
||
194 | 'collapse' => $iconHandler->getImageSource('more') |
||
195 | ]; |
||
196 | if (1 == $infobox['show']) { |
||
197 | $infobox['style'] = 'none'; //irmtfan move semicolon |
||
198 | $infobox['alt'] = _MD_NEWBB_SEEUSERDATA; |
||
199 | $infobox['src'] = 'more'; |
||
200 | } else { |
||
201 | $infobox['style'] = 'block'; //irmtfan move semicolon |
||
202 | $infobox['alt'] = _MD_NEWBB_HIDEUSERDATA; |
||
203 | $infobox['src'] = 'less'; |
||
204 | } |
||
205 | $infobox['displayImage'] = newbbDisplayImage($infobox['src'], $infobox['alt']); |
||
206 | } |
||
207 | $xoopsTpl->assign('infobox', $infobox); |
||
208 | // END irmtfan improve infobox |
||
209 | |||
210 | $xoopsTpl->assign([ |
||
211 | 'topic_title' => '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewtopic.php?topic_id=' . $topic_id . '">' . $topicObject->getFullTitle() . '</a>', |
||
212 | 'forum_name' => $forumObject->getVar('forum_name'), |
||
213 | 'lang_nexttopic' => _MD_NEWBB_NEXTTOPIC, |
||
214 | 'lang_prevtopic' => _MD_NEWBB_PREVTOPIC, |
||
215 | 'topic_status' => $topicObject->getVar('topic_status') |
||
216 | ]); |
||
217 | |||
218 | //$categoryHandler = Newbb\Helper::getInstance()->getHandler('Category'); |
||
219 | $categoryObject = $categoryHandler->get($forumObject->getVar('cat_id'), ['cat_title']); |
||
220 | $xoopsTpl->assign('category', ['id' => $forumObject->getVar('cat_id'), 'title' => $categoryObject->getVar('cat_title')]); |
||
221 | |||
222 | $xoopsTpl->assign('post_id', $post_id); |
||
223 | $xoopsTpl->assign('topic_id', $topic_id); |
||
224 | $xoopsTpl->assign('forum_id', $forum_id); |
||
225 | |||
226 | $order_current = ('DESC' === $order) ? 'DESC' : 'ASC'; |
||
227 | $xoopsTpl->assign('order_current', $order_current); |
||
228 | |||
229 | $t_new = newbbDisplayImage('t_new', _MD_NEWBB_POSTNEW); |
||
230 | $t_reply = newbbDisplayImage('t_reply', _MD_NEWBB_REPLY); |
||
231 | // irmtfan show topic status if show reg is 0 and revise forum_post_or_register |
||
232 | if ($topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'post')) { |
||
233 | $xoopsTpl->assign('forum_post', '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/newtopic.php?forum=' . $forum_id . '"> ' . $t_new . '</a>'); |
||
234 | } else { |
||
235 | if ($topicObject->getVar('topic_status')) { |
||
236 | $xoopsTpl->assign('topic_lock', _MD_NEWBB_TOPICLOCKED); |
||
237 | } |
||
238 | if (!is_object($GLOBALS['xoopsUser']) && !empty($GLOBALS['xoopsModuleConfig']['show_reg'])) { |
||
239 | $xoopsTpl->assign('forum_register', '<a href="' . XOOPS_URL . '/user.php?xoops_redirect=' . htmlspecialchars($xoopsRequestUri) . '">' . _MD_NEWBB_REGTOPOST . '</a>'); |
||
240 | } |
||
241 | } |
||
242 | // irmtfan for backward compatibility assign forum_post_or_register smarty again. |
||
243 | $xoopsTpl->assign('forum_post_or_register', @$xoopsTpl->get_template_vars('forum_post') . @$xoopsTpl->get_template_vars('forum_register') . @$xoopsTpl->get_template_vars('topic_lock')); |
||
244 | |||
245 | if ($topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'reply')) { |
||
246 | $xoopsTpl->assign('forum_reply', '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/reply.php?topic_id=' . $topic_id . '"> ' . $t_reply . '</a>'); |
||
247 | } |
||
248 | |||
249 | $poster_array = []; |
||
250 | $require_reply = false; |
||
251 | /** @var Post $eachpost */ |
||
252 | foreach ($postsArray as $eachpost) { |
||
253 | if ($eachpost->getVar('uid') > 0) { |
||
254 | $poster_array[$eachpost->getVar('uid')] = 1; |
||
255 | } |
||
256 | if ($eachpost->getVar('require_reply') > 0) { |
||
257 | $require_reply = true; |
||
258 | } |
||
259 | } |
||
260 | |||
261 | $userid_array = []; |
||
262 | $online = []; |
||
263 | View Code Duplication | if (is_array($poster_array) && count($poster_array) > 0) { |
|
264 | /** @var \XoopsMemberHandler $memberHandler */ |
||
265 | $memberHandler = xoops_getHandler('member'); |
||
266 | $userid_array = array_keys($poster_array); |
||
267 | $user_criteria = '(' . implode(',', $userid_array) . ')'; |
||
268 | $users = $memberHandler->getUsers(new \Criteria('uid', $user_criteria, 'IN'), true); |
||
269 | } else { |
||
270 | $users = []; |
||
271 | } |
||
272 | |||
273 | $viewtopic_users = []; |
||
274 | View Code Duplication | if (is_array($userid_array) && count($userid_array) > 0) { |
|
0 ignored issues
–
show
|
|||
275 | require $GLOBALS['xoops']->path('modules/' . $xoopsModule->getVar('dirname', 'n') . '/class/user.php'); |
||
276 | $userHandler = new Newbb\UserHandler($GLOBALS['xoopsModuleConfig']['groupbar_enabled'], $GLOBALS['xoopsModuleConfig']['wol_enabled']); |
||
277 | $userHandler->users = $users; |
||
278 | $userHandler->online = $online; |
||
279 | $viewtopic_users = $userHandler->getUsers(); |
||
280 | } |
||
281 | unset($users); |
||
282 | |||
283 | if ($GLOBALS['xoopsModuleConfig']['allow_require_reply'] && $require_reply) { |
||
284 | if (!empty($GLOBALS['xoopsModuleConfig']['cache_enabled'])) { |
||
285 | $viewtopic_posters = newbbGetSession('t' . $topic_id, true); |
||
286 | if (!is_array($viewtopic_posters) || 0 === count($viewtopic_posters)) { |
||
287 | $viewtopic_posters = $topicHandler->getAllPosters($topicObject); |
||
288 | newbbSetSession('t' . $topic_id, $viewtopic_posters); |
||
289 | } |
||
290 | } else { |
||
291 | $viewtopic_posters = $topicHandler->getAllPosters($topicObject); |
||
292 | } |
||
293 | } else { |
||
294 | $viewtopic_posters = []; |
||
295 | } |
||
296 | |||
297 | if ($GLOBALS['xoopsModuleConfig']['show_advertising']) { |
||
298 | $post_werbung = [ |
||
299 | 'post_id' => 0, |
||
300 | 'post_parent_id' => 0, |
||
301 | 'post_date' => 0, |
||
302 | 'post_image' => '', |
||
303 | 'post_title' => '', |
||
304 | 'post_text' => '<div style="text-align: center;vertical-align: middle;"><br>' . xoops_getbanner() . '</div>', |
||
305 | 'post_attachment' => '', |
||
306 | 'post_edit' => 0, |
||
307 | 'post_no' => 0, |
||
308 | 'post_signature' => _MD_NEWBB_ADVERTISING_BLOCK, |
||
309 | 'poster_ip' => '', |
||
310 | 'thread_action' => '', |
||
311 | 'thread_buttons' => '', |
||
312 | 'mod_buttons' => '', |
||
313 | 'poster' => [ |
||
314 | 'uid' => -1, |
||
315 | 'link' => _MD_NEWBB_ADVERTISING_USER, |
||
316 | 'avatar' => 'avatars/blank.gif', |
||
317 | 'regdate' => 0, |
||
318 | 'last_login' => 0, |
||
319 | 'rank' => ['title' => ''] |
||
320 | ], |
||
321 | // irmtfan add last_login |
||
322 | 'post_permalink' => '' |
||
323 | ]; |
||
324 | } |
||
325 | |||
326 | $i = 0; |
||
327 | /** @var Post $eachpost */ |
||
328 | foreach ($postsArray as $eachpost) { |
||
329 | if ($GLOBALS['xoopsModuleConfig']['show_advertising']) { |
||
330 | if (2 === $i) { |
||
331 | $xoopsTpl->append('topic_posts', $post_werbung); |
||
332 | } |
||
333 | ++$i; |
||
334 | } |
||
335 | $xoopsTpl->append('topic_posts', $eachpost->showPost($isAdmin)); |
||
336 | } |
||
337 | |||
338 | if ($total_posts > $GLOBALS['xoopsModuleConfig']['posts_per_page']) { |
||
339 | include $GLOBALS['xoops']->path('class/pagenav.php'); |
||
340 | |||
341 | $nav = new \XoopsPageNav($total_posts, $GLOBALS['xoopsModuleConfig']['posts_per_page'], $start, 'start', 'topic_id=' . $topic_id . '&order=' . $order . '&status=' . $status . '&mode=' . $mode); |
||
342 | //if (isset($GLOBALS['xoopsModuleConfig']['do_rewrite']) && $GLOBALS['xoopsModuleConfig']['do_rewrite'] === 1) $nav->url = XOOPS_URL . $nav->url; |
||
343 | View Code Duplication | if ('select' === $GLOBALS['xoopsModuleConfig']['pagenav_display']) { |
|
344 | $navi = $nav->renderSelect(); |
||
345 | } elseif ('image' === $GLOBALS['xoopsModuleConfig']['pagenav_display']) { |
||
346 | $navi = $nav->renderImageNav(4); |
||
347 | } else { |
||
348 | $navi = $nav->renderNav(4); |
||
349 | } |
||
350 | $xoopsTpl->assign('forum_page_nav', $navi); |
||
351 | } else { |
||
352 | $xoopsTpl->assign('forum_page_nav', ''); |
||
353 | } |
||
354 | |||
355 | if (empty($post_id)) { |
||
356 | $first = array_keys($postsArray); |
||
357 | $post_id = !empty($first[0]) ? $first[0] : 0; |
||
358 | } |
||
359 | |||
360 | if (!empty($postsArray[$post_id])) { |
||
361 | $xoops_pagetitle = $postsArray[$post_id]->getVar('subject') . ' [' . $forumObject->getVar('forum_name') . ']'; |
||
362 | $xoopsTpl->assign('xoops_pagetitle', $xoops_pagetitle); |
||
363 | $xoopsOption['xoops_pagetitle'] = $xoops_pagetitle; |
||
364 | $kw = array_unique(explode(' ', strip_tags($postsArray[$post_id]->getVar('post_text')), 150)); |
||
365 | asort($kw); |
||
366 | $kwort = ''; |
||
367 | $z = 0; |
||
368 | foreach ($kw as $k) { |
||
369 | if ($z < 30 && strlen(trim($k)) > 5) { |
||
370 | $kwort .= trim($k) . ' '; |
||
371 | ++$z; |
||
372 | } |
||
373 | } |
||
374 | $xoTheme->addMeta('meta', 'keywords', $kwort); |
||
375 | $xoTheme->addMeta('meta', 'description', substr(strip_tags($postsArray[$post_id]->getVar('post_text')), 0, 120)); |
||
376 | } |
||
377 | unset($postsArray); |
||
378 | |||
379 | $xoopsTpl->assign('topic_print_link', "print.php?form=1&{$page_query}"); |
||
380 | |||
381 | $admin_actions = []; |
||
382 | $ad_merge = ''; |
||
383 | $ad_move = ''; |
||
384 | $ad_delete = ''; |
||
385 | // irmtfan add restore to viewtopic |
||
386 | $ad_restore = ''; |
||
387 | $ad_lock = ''; |
||
388 | $ad_unlock = ''; |
||
389 | $ad_sticky = ''; |
||
390 | $ad_unsticky = ''; |
||
391 | $ad_digest = ''; |
||
392 | $ad_undigest = ''; |
||
393 | |||
394 | // START irmtfan add restore to viewtopic |
||
395 | // if the topic is active |
||
396 | if ($topicObject->getVar('approved') > 0) { |
||
397 | $admin_actions['merge'] = [ |
||
398 | 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=merge&topic_id=' . $topic_id, |
||
399 | 'name' => _MD_NEWBB_MERGETOPIC, |
||
400 | 'image' => $ad_merge |
||
401 | ]; |
||
402 | $admin_actions['move'] = [ |
||
403 | 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=move&topic_id=' . $topic_id, |
||
404 | 'name' => _MD_NEWBB_MOVETOPIC, |
||
405 | 'image' => $ad_move |
||
406 | ]; |
||
407 | $admin_actions['delete'] = [ |
||
408 | 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=delete&topic_id=' . $topic_id, |
||
409 | 'name' => _MD_NEWBB_DELETETOPIC, |
||
410 | 'image' => $ad_delete |
||
411 | ]; |
||
412 | View Code Duplication | if (!$topicObject->getVar('topic_status')) { |
|
413 | $admin_actions['lock'] = [ |
||
414 | 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=lock&topic_id=' . $topic_id, |
||
415 | 'image' => $ad_lock, |
||
416 | 'name' => _MD_NEWBB_LOCKTOPIC |
||
417 | ]; |
||
418 | } else { |
||
419 | $admin_actions['unlock'] = [ |
||
420 | 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=unlock&topic_id=' . $topic_id, |
||
421 | 'image' => $ad_unlock, |
||
422 | 'name' => _MD_NEWBB_UNLOCKTOPIC |
||
423 | ]; |
||
424 | } |
||
425 | View Code Duplication | if (!$topicObject->getVar('topic_sticky')) { |
|
426 | $admin_actions['sticky'] = [ |
||
427 | 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=sticky&topic_id=' . $topic_id, |
||
428 | 'image' => $ad_sticky, |
||
429 | 'name' => _MD_NEWBB_STICKYTOPIC |
||
430 | ]; |
||
431 | } else { |
||
432 | $admin_actions['unsticky'] = [ |
||
433 | 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=unsticky&topic_id=' . $topic_id, |
||
434 | 'image' => $ad_unsticky, |
||
435 | 'name' => _MD_NEWBB_UNSTICKYTOPIC |
||
436 | ]; |
||
437 | } |
||
438 | View Code Duplication | if (!$topicObject->getVar('topic_digest')) { |
|
439 | $admin_actions['digest'] = [ |
||
440 | 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=digest&topic_id=' . $topic_id, |
||
441 | 'image' => $ad_digest, |
||
442 | 'name' => _MD_NEWBB_DIGESTTOPIC |
||
443 | ]; |
||
444 | } else { |
||
445 | $admin_actions['undigest'] = [ |
||
446 | 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=undigest&topic_id=' . $topic_id, |
||
447 | 'image' => $ad_undigest, |
||
448 | 'name' => _MD_NEWBB_UNDIGESTTOPIC |
||
449 | ]; |
||
450 | } |
||
451 | // if the topic is pending/deleted then restore/approve |
||
452 | } else { |
||
453 | $admin_actions['restore'] = [ |
||
454 | 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=restore&topic_id=' . $topic_id, |
||
455 | 'name' => _MD_NEWBB_RESTORETOPIC, |
||
456 | 'image' => $ad_restore |
||
457 | ]; |
||
458 | } |
||
459 | // END irmtfan add restore to viewtopic |
||
460 | |||
461 | $xoopsTpl->assign_by_ref('admin_actions', $admin_actions); |
||
462 | $xoopsTpl->assign('viewer_level', (int)($isAdmin ? 2 : is_object($GLOBALS['xoopsUser']))); |
||
463 | |||
464 | View Code Duplication | if ($GLOBALS['xoopsModuleConfig']['show_permissiontable']) { |
|
465 | // /** var Newbb\PermissionHandler $permHandler */ |
||
466 | // $permHandler = Newbb\Helper::getInstance()->getHandler('Permission'); |
||
467 | $permission_table = $permHandler->getPermissionTable($forumObject, $topicObject->getVar('topic_status'), $isAdmin); |
||
468 | $xoopsTpl->assign_by_ref('permission_table', $permission_table); |
||
469 | } |
||
470 | |||
471 | /////////////////////////////// |
||
472 | // show Poll |
||
473 | // START irmtfan poll_module |
||
474 | // irmtfan remove |
||
475 | /* |
||
476 | $pollmodul = false; |
||
477 | $moduleHandler = xoops_getHandler( 'module' ); |
||
478 | $PollModule = $moduleHandler->getByDirname('xoopspoll'); |
||
479 | if ($PollModule && $PollModule->getVar('isactive')) { |
||
480 | $pollmodul = 'xoopspoll'; |
||
481 | } else { |
||
482 | $PollModule = $moduleHandler->getByDirname('umfrage'); |
||
483 | if ($PollModule && $PollModule->getVar('isactive')) { |
||
484 | $pollmodul = 'umfrage'; |
||
485 | } |
||
486 | } |
||
487 | */ |
||
488 | //irmtfan remove |
||
489 | $pollModuleHandler = $moduleHandler->getByDirname($GLOBALS['xoopsModuleConfig']['poll_module']); |
||
490 | if (is_object($pollModuleHandler) && $pollModuleHandler->getVar('isactive')) { |
||
491 | $poll_id = $topicObject->getVar('poll_id'); |
||
492 | // can vote in poll |
||
493 | $pollVote = ($topicObject->getVar('topic_haspoll') && $poll_id > 0 |
||
494 | && $topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'vote')); |
||
495 | // can add poll |
||
496 | $pollAdd = $topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'addpoll'); |
||
497 | if ($pollVote || $pollAdd) { |
||
498 | $pollModuleHandler = $moduleHandler->getByDirname($GLOBALS['xoopsModuleConfig']['poll_module']); |
||
499 | // new xoopspoll module |
||
500 | if ($pollModuleHandler->getVar('version') >= 140) { |
||
501 | xoops_load('renderer', $GLOBALS['xoopsModuleConfig']['poll_module']); |
||
502 | xoops_loadLanguage('main', $GLOBALS['xoopsModuleConfig']['poll_module']); |
||
503 | // old xoopspoll or umfrage or any clone from them |
||
504 | } else { |
||
505 | $classPoll = $topicObject->loadOldPoll(); |
||
506 | } |
||
507 | } |
||
508 | // START can vote in poll |
||
509 | if ($pollVote) { |
||
510 | $xoopsTpl->assign('topic_poll', 1); |
||
511 | $uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; |
||
512 | // new xoopspoll module |
||
513 | if ($pollModuleHandler->getVar('version') >= 140) { |
||
514 | $xpollHandler = xoops_getModuleHandler('poll', $GLOBALS['xoopsModuleConfig']['poll_module']); |
||
515 | /** @var \XoopsPoll $pollObject */ |
||
516 | $pollObject = $xpollHandler->get($poll_id); |
||
517 | if (is_object($pollObject)) { |
||
518 | |||
519 | /* check to see if user has rights to view the results */ |
||
520 | $vis_return = $pollObject->isResultVisible(); |
||
521 | $isVisible = $vis_return; |
||
522 | $visibleMsg = $isVisible ? '' : $vis_return; |
||
523 | |||
524 | /* setup the module config handler */ |
||
525 | /** @var \XoopsConfigHandler $configHandler */ |
||
526 | $configHandler = xoops_getHandler('config'); |
||
527 | $xp_config = $configHandler->getConfigsByCat(0, $pollModuleHandler->getVar('mid')); |
||
528 | |||
529 | $GLOBALS['xoopsTpl']->assign([ |
||
530 | 'is_visible' => $isVisible, |
||
531 | 'visible_message' => $visibleMsg, |
||
532 | 'disp_votes' => $xp_config['disp_vote_nums'], |
||
533 | 'lang_vote' => constant('_MD_' . strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . '_VOTE'), |
||
534 | 'lang_results' => constant('_MD_' . strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . '_RESULTS'), |
||
535 | 'back_link' => '' |
||
536 | ]); |
||
537 | $classRenderer = ucfirst($GLOBALS['xoopsModuleConfig']['poll_module']) . 'Renderer'; |
||
538 | /** @var \XoopsPollRenderer $renderer */ |
||
539 | $renderer = new $classRenderer($pollObject); |
||
540 | // check to see if user has voted, show form if not, otherwise get results for form |
||
541 | |||
542 | /** @var \XoopspollLogHandler $logHandler */ |
||
543 | $logHandler = xoops_getModuleHandler('log', $GLOBALS['xoopsModuleConfig']['poll_module']); |
||
544 | if ($pollObject->isAllowedToVote() |
||
545 | && (!$logHandler->hasVoted($poll_id, xoops_getenv('REMOTE_ADDR'), $uid))) { |
||
546 | $myTpl = new \XoopsTpl(); |
||
547 | $renderer->assignForm($myTpl); |
||
548 | $myTpl->assign('action', $GLOBALS['xoops']->url("modules/newbb/votepolls.php?topic_id={$topic_id}&poll_id={$poll_id}")); |
||
549 | $topic_pollform = $myTpl->fetch($GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/templates/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '_view.tpl')); |
||
550 | $GLOBALS['xoopsTpl']->assign('topic_pollform', $topic_pollform); |
||
551 | } else { |
||
552 | $GLOBALS['xoopsTpl']->assign('can_vote', false); |
||
553 | $xoopsTpl->assign('topic_pollresult', 1); |
||
554 | $GLOBALS['xoopsTpl']->assign('topic_resultform', $renderer->renderResults()); |
||
555 | } |
||
556 | } |
||
557 | // old xoopspoll or umfrage or any clone from them |
||
558 | } else { |
||
559 | $pollObject = new $classPoll($poll_id); |
||
560 | $classRenderer = $classPoll . 'Renderer'; |
||
561 | $renderer = new $classRenderer($pollObject); |
||
562 | $xoopsTpl->assign('lang_alreadyvoted2', _PL_ALREADYVOTED2); |
||
563 | $xoopsTpl->assign('has_ended', $pollObject->getVar('end_time') < time() ? 1 : 0); |
||
564 | // umfrage has polltype |
||
565 | $polltype = $pollObject->getVar('polltype'); |
||
566 | if (!empty($polltype)) { |
||
567 | $xoopsTpl->assign('polltype', $polltype); |
||
568 | switch ($polltype) { |
||
569 | case 1: |
||
570 | $xoopsTpl->assign('polltypecomment', ''); |
||
571 | break; |
||
572 | case 2: |
||
573 | $xoopsTpl->assign('polltypecomment', _PL_FULLBLIND); |
||
574 | break; |
||
575 | case 3: |
||
576 | $xoopsTpl->assign('polltypecomment', _PL_HALFBLIND); |
||
577 | break; |
||
578 | |||
579 | } |
||
580 | } |
||
581 | $classLog = $classPoll . 'Log'; |
||
582 | $hasvoted = 0; |
||
583 | if ($GLOBALS['xoopsUser']) { |
||
584 | if ($classLog::hasVoted($poll_id, Request::getString('REMOTE_ADDR', '', 'SERVER'), $uid)) { |
||
585 | $hasvoted = 1; |
||
586 | } |
||
587 | } else { |
||
588 | $hasvoted = 1; |
||
589 | } |
||
590 | $xoopsTpl->assign('hasVoted', $hasvoted); |
||
591 | $xoopsTpl->assign('lang_vote', _PL_VOTE); |
||
592 | $xoopsTpl->assign('lang_results', $pollObject->getVar('end_time') < time() ? _PL_RESULTS : _PL_STANDINGS); |
||
593 | // irmtfan - if the poll is expired show the result |
||
594 | if ($hasvoted || $pollObject->hasExpired()) { |
||
595 | $renderer->assignResults($xoopsTpl); |
||
596 | $xoopsTpl->assign('topic_pollresult', 1); |
||
597 | setcookie('newbb_polls[' . $poll_id . ']', 1); |
||
598 | } else { |
||
599 | $renderer->assignForm($xoopsTpl); |
||
600 | $xoopsTpl->assign('lang_vote', _PL_VOTE); |
||
601 | $xoopsTpl->assign('lang_results', _PL_RESULTS); |
||
602 | setcookie('newbb_polls[' . $poll_id . ']', 1); |
||
603 | } |
||
604 | } |
||
605 | } |
||
606 | // END can vote in poll |
||
607 | // START can add poll |
||
608 | if ($pollAdd) { |
||
609 | if (!$topicObject->getVar('topic_haspoll')) { |
||
610 | if (is_object($GLOBALS['xoopsUser']) |
||
611 | && $GLOBALS['xoopsUser']->getVar('uid') == $topicObject->getVar('topic_poster')) { |
||
612 | $t_poll = newbbDisplayImage('t_poll', _MD_NEWBB_ADDPOLL); |
||
613 | $xoopsTpl->assign('forum_addpoll', '<a href=\'' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/polls.php?op=add&topic_id=' . $topic_id . '\'>' . $t_poll . '</a>'); |
||
614 | } |
||
615 | } elseif ($isAdmin |
||
616 | || (is_object($pollObject) && is_object($GLOBALS['xoopsUser']) |
||
617 | && $GLOBALS['xoopsUser']->getVar('uid') == $pollObject->getVar('user_id'))) { |
||
618 | $poll_edit = ''; |
||
619 | $poll_delete = ''; |
||
620 | $poll_restart = ''; |
||
621 | $poll_log = ''; |
||
622 | |||
623 | $adminpoll_actions = []; |
||
624 | $adminpoll_actions['editpoll'] = [ |
||
625 | 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/polls.php?op=edit&poll_id=' . $topicObject->getVar('poll_id') . '&topic_id=' . $topic_id, |
||
626 | 'image' => $poll_edit, |
||
627 | 'name' => _MD_NEWBB_EDITPOLL |
||
628 | ]; |
||
629 | $adminpoll_actions['deletepoll'] = [ |
||
630 | 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/polls.php?op=delete&poll_id=' . $topicObject->getVar('poll_id') . '&topic_id=' . $topic_id, |
||
631 | 'image' => $poll_delete, |
||
632 | 'name' => _MD_NEWBB_DELETEPOLL |
||
633 | ]; |
||
634 | $adminpoll_actions['restartpoll'] = [ |
||
635 | 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/polls.php?op=restart&poll_id=' . $topicObject->getVar('poll_id') . '&topic_id=' . $topic_id . '&forum=' . $forum_id, |
||
636 | 'image' => $poll_restart, |
||
637 | 'name' => _MD_NEWBB_RESTARTPOLL |
||
638 | ]; |
||
639 | $adminpoll_actions['logpoll'] = [ |
||
640 | 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/polls.php?op=log&poll_id=' . $topicObject->getVar('poll_id') . '&topic_id=' . $topic_id . '&forum=' . $forum_id, |
||
641 | 'image' => $poll_log, |
||
642 | 'name' => _MD_NEWBB_POLL_VIEWLOG |
||
643 | ]; |
||
644 | |||
645 | $xoopsTpl->assign_by_ref('adminpoll_actions', $adminpoll_actions); |
||
646 | } |
||
647 | } |
||
648 | // END can add poll |
||
649 | } |
||
650 | if (isset($pollObject)) { |
||
651 | unset($pollObject); |
||
652 | } |
||
653 | // END irmtfan poll_module |
||
654 | |||
655 | $xoopsTpl->assign('p_up', newbbDisplayImage('up', _MD_NEWBB_TOP)); |
||
656 | $xoopsTpl->assign('rating_enable', $GLOBALS['xoopsModuleConfig']['rating_enabled']); |
||
657 | $xoopsTpl->assign('groupbar_enable', $GLOBALS['xoopsModuleConfig']['groupbar_enabled']); |
||
658 | $xoopsTpl->assign('anonymous_prefix', $GLOBALS['xoopsModuleConfig']['anonymous_prefix']); |
||
659 | // irmtfan add alt for prev next and down icons. |
||
660 | $xoopsTpl->assign('previous', newbbDisplayImage('previous', _MD_NEWBB_PREVTOPIC)); |
||
661 | $xoopsTpl->assign('next', newbbDisplayImage('next', _MD_NEWBB_NEXTTOPIC)); |
||
662 | $xoopsTpl->assign('down', newbbDisplayImage('down', _MD_NEWBB_BOTTOM)); |
||
663 | $xoopsTpl->assign('post_content', newbbDisplayImage('post')); |
||
664 | |||
665 | if (!empty($GLOBALS['xoopsModuleConfig']['rating_enabled'])) { |
||
666 | $xoopsTpl->assign('votes', $topicObject->getVar('votes')); |
||
667 | $rating = number_format($topicObject->getVar('rating') / 2, 0); |
||
668 | View Code Duplication | if ($rating < 1) { |
|
669 | $rating_img = newbbDisplayImage('blank'); |
||
670 | } else { |
||
671 | // irmtfan - add alt key for rating |
||
672 | $rating_img = newbbDisplayImage('rate' . $rating, constant('_MD_NEWBB_RATE' . $rating)); |
||
673 | } |
||
674 | $xoopsTpl->assign('rating_img', $rating_img); |
||
675 | $xoopsTpl->assign('rate1', newbbDisplayImage('rate1', _MD_NEWBB_RATE1)); |
||
676 | $xoopsTpl->assign('rate2', newbbDisplayImage('rate2', _MD_NEWBB_RATE2)); |
||
677 | $xoopsTpl->assign('rate3', newbbDisplayImage('rate3', _MD_NEWBB_RATE3)); |
||
678 | $xoopsTpl->assign('rate4', newbbDisplayImage('rate4', _MD_NEWBB_RATE4)); |
||
679 | $xoopsTpl->assign('rate5', newbbDisplayImage('rate5', _MD_NEWBB_RATE5)); |
||
680 | } |
||
681 | |||
682 | // create jump box |
||
683 | View Code Duplication | if (!empty($GLOBALS['xoopsModuleConfig']['show_jump'])) { |
|
684 | include_once __DIR__ . '/include/functions.forum.php'; |
||
685 | $xoopsTpl->assign('forum_jumpbox', newbbMakeJumpbox($forum_id)); |
||
686 | } |
||
687 | |||
688 | $xoopsTpl->assign([ |
||
689 | 'lang_forum_index' => sprintf(_MD_NEWBB_FORUMINDEX, htmlspecialchars($GLOBALS['xoopsConfig']['sitename'], ENT_QUOTES)), |
||
690 | 'lang_from' => _MD_NEWBB_FROM, |
||
691 | 'lang_joined' => _MD_NEWBB_JOINED, |
||
692 | 'lang_posts' => _MD_NEWBB_POSTS, |
||
693 | 'lang_poster' => _MD_NEWBB_POSTER, |
||
694 | 'lang_thread' => _MD_NEWBB_THREAD, |
||
695 | 'lang_edit' => _EDIT, |
||
696 | 'lang_delete' => _DELETE, |
||
697 | 'lang_reply' => _REPLY, |
||
698 | 'lang_postedon' => _MD_NEWBB_POSTEDON, |
||
699 | 'lang_groups' => _MD_NEWBB_GROUPS |
||
700 | ]); |
||
701 | |||
702 | $viewmode_options = []; |
||
703 | View Code Duplication | if ('DESC' === $order) { |
|
704 | $viewmode_options[] = [ |
||
705 | 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewtopic.php?order=ASC&status=$status&topic_id=' . $topic_id, |
||
706 | 'title' => _OLDESTFIRST |
||
707 | ]; |
||
708 | } else { |
||
709 | $viewmode_options[] = [ |
||
710 | 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewtopic.php?order=DESC&status=$status&topic_id=' . $topic_id, |
||
711 | 'title' => _NEWESTFIRST |
||
712 | ]; |
||
713 | } |
||
714 | |||
715 | switch ($status) { |
||
716 | case 'active': |
||
717 | $current_status = '[' . _MD_NEWBB_TYPE_ADMIN . ']'; |
||
718 | break; |
||
719 | case 'pending': |
||
720 | $current_status = '[' . _MD_NEWBB_TYPE_PENDING . ']'; |
||
721 | break; |
||
722 | case 'deleted': |
||
723 | $current_status = '[' . _MD_NEWBB_TYPE_DELETED . ']'; |
||
724 | break; |
||
725 | default: |
||
726 | $current_status = ''; |
||
727 | break; |
||
728 | } |
||
729 | $xoopsTpl->assign('topicstatus', $current_status); |
||
730 | |||
731 | $xoopsTpl->assign('mode', $mode); |
||
732 | $xoopsTpl->assign('status', $status); |
||
733 | //$xoopsTpl->assign('viewmode_compact', ($viewmode=="compact")?1:0); |
||
734 | $xoopsTpl->assign_by_ref('viewmode_options', $viewmode_options); |
||
735 | unset($viewmode_options); |
||
736 | $xoopsTpl->assign('menumode', $menumode); |
||
737 | $xoopsTpl->assign('menumode_other', $menumode_other); |
||
738 | |||
739 | // START irmtfan add verifyUser to quick reply |
||
740 | //check banning |
||
741 | //$moderateHandler = Newbb\Helper::getInstance()->getHandler('Moderate'); |
||
742 | if (!empty($GLOBALS['xoopsModuleConfig']['quickreply_enabled']) |
||
743 | && $topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'reply') |
||
744 | && $moderateHandler->verifyUser(-1, '', $forumObject->getVar('forum_id'))) { |
||
745 | // END irmtfan add verifyUser to quick reply |
||
746 | $forum_form = new \XoopsThemeForm(_MD_NEWBB_POSTREPLY, 'quick_reply', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/post.php', 'post', true); |
||
747 | if (!is_object($GLOBALS['xoopsUser'])) { |
||
748 | //$configHandler = xoops_getHandler('config'); |
||
749 | $user_tray = new \XoopsFormElementTray(_MD_NEWBB_ACCOUNT); |
||
750 | $user_tray->addElement(new \XoopsFormText(_MD_NEWBB_NAME, 'uname', 26, 255)); |
||
751 | $user_tray->addElement(new \XoopsFormPassword(_MD_NEWBB_PASSWORD, 'pass', 10, 32)); |
||
752 | $login_checkbox = new \XoopsFormCheckBox('', 'login', 1); |
||
753 | $login_checkbox->addOption(1, _MD_NEWBB_LOGIN); |
||
754 | $user_tray->addElement($login_checkbox); |
||
755 | $forum_form->addElement($user_tray); |
||
756 | $captcha = new \XoopsFormCaptcha('', "topic_{$topic_id}_{$start}"); |
||
757 | $captcha->setConfig('mode', 'text'); |
||
758 | $forum_form->addElement($captcha); |
||
759 | } |
||
760 | |||
761 | //$quickform = ( !empty($GLOBALS['xoopsModuleConfig']["editor_default"]) ) ? $GLOBALS['xoopsModuleConfig']["editor_default"] : "textarea"; |
||
762 | $quickform = !empty($GLOBALS['xoopsModuleConfig']['editor_quick_default']) ? $GLOBALS['xoopsModuleConfig']['editor_quick_default'] : 'textarea'; |
||
763 | $editor_configs = []; |
||
764 | $editor_configs ['name'] = 'message'; |
||
765 | //$editor_configs [ "value" ] = $message ; |
||
766 | $editor_configs ['rows'] = empty($GLOBALS['xoopsModuleConfig'] ['editor_rows']) ? 10 : $GLOBALS['xoopsModuleConfig'] ['editor_rows']; |
||
767 | $editor_configs ['cols'] = empty($GLOBALS['xoopsModuleConfig'] ['editor_cols']) ? 30 : $GLOBALS['xoopsModuleConfig'] ['editor_cols']; |
||
768 | $editor_configs ['width'] = empty($GLOBALS['xoopsModuleConfig'] ['editor_width']) ? '100%' : $GLOBALS['xoopsModuleConfig'] ['editor_width']; |
||
769 | $editor_configs ['height'] = empty($GLOBALS['xoopsModuleConfig'] ['editor_height']) ? '400px' : $GLOBALS['xoopsModuleConfig'] ['editor_height']; |
||
770 | $_editor = new \XoopsFormEditor(_MD_NEWBB_MESSAGEC, $quickform, $editor_configs, true); |
||
771 | $forum_form->addElement($_editor, true); |
||
772 | |||
773 | $forum_form->addElement(new \XoopsFormHidden('dohtml', 0)); |
||
774 | $forum_form->addElement(new \XoopsFormHidden('dosmiley', 1)); |
||
775 | $forum_form->addElement(new \XoopsFormHidden('doxcode', 1)); |
||
776 | $forum_form->addElement(new \XoopsFormHidden('dobr', 1)); |
||
777 | $forum_form->addElement(new \XoopsFormHidden('attachsig', 1)); |
||
778 | |||
779 | $forum_form->addElement(new \XoopsFormHidden('isreply', 1)); |
||
780 | |||
781 | $forum_form->addElement(new \XoopsFormHidden('subject', _MD_NEWBB_RE . ': ' . $topicObject->getVar('topic_title', 'e'))); |
||
782 | $forum_form->addElement(new \XoopsFormHidden('pid', empty($post_id) ? $topicHandler->getTopPostId($topic_id) : $post_id)); |
||
783 | $forum_form->addElement(new \XoopsFormHidden('topic_id', $topic_id)); |
||
784 | $forum_form->addElement(new \XoopsFormHidden('forum', $forum_id)); |
||
785 | //$forum_form->addElement(new \XoopsFormHidden('viewmode', $viewmode)); |
||
786 | $forum_form->addElement(new \XoopsFormHidden('order', $order)); |
||
787 | $forum_form->addElement(new \XoopsFormHidden('start', $start)); |
||
788 | |||
789 | $forum_form->addElement(new \XoopsFormHidden('notify', -1)); |
||
790 | $forum_form->addElement(new \XoopsFormHidden('contents_submit', 1)); |
||
791 | |||
792 | $submit_button = new \XoopsFormButton('', 'quick_submit', _SUBMIT, 'submit'); |
||
793 | $submit_button->setExtra('onclick="if (document.forms.quick_reply.message.value === \'RE\' || document.forms.quick_reply.message.value === \'\') { alert(\'' . _MD_NEWBB_QUICKREPLY_EMPTY . '\'); return false;} else { return true;}"'); |
||
794 | $forum_form->addElement($submit_button); |
||
795 | |||
796 | $toggles = newbbGetCookie('G', true); |
||
797 | // START irmtfan improve quickreply smarty variable - add alt key to quick reply button - change $display to $style for more comprehension - add toggle $quickreply['expand'] |
||
798 | $quickreply = []; |
||
799 | $qr_collapse = 't_qr'; |
||
800 | $qr_expand = 't_qr_expand'; // change this |
||
801 | $quickreply['icon'] = [ |
||
802 | 'expand' => $iconHandler->getImageSource($qr_expand), |
||
803 | 'collapse' => $iconHandler->getImageSource($qr_collapse) |
||
804 | ]; |
||
805 | $quickreply['show'] = 1; // = !empty($GLOBALS['xoopsModuleConfig']['quickreply_enabled'] |
||
806 | $quickreply['expand'] = (count($toggles) > 0) ? (in_array('qr', $toggles, true) ? false : true) : true; |
||
807 | if ($quickreply['expand']) { |
||
808 | $quickreply['style'] = 'block'; //irmtfan move semicolon |
||
809 | $quickreply_icon_display = $qr_expand; |
||
810 | $quickreply_alt = _MD_NEWBB_HIDE . ' ' . _MD_NEWBB_QUICKREPLY; |
||
811 | } else { |
||
812 | $quickreply['style'] = 'none'; //irmtfan move semicolon |
||
813 | $quickreply_icon_display = $qr_collapse; |
||
814 | $quickreply_alt = _MD_NEWBB_SEE . ' ' . _MD_NEWBB_QUICKREPLY; |
||
815 | } |
||
816 | $quickreply['displayImage'] = newbbDisplayImage($quickreply_icon_display, $quickreply_alt); |
||
817 | $quickreply['form'] = $forum_form->render(); |
||
818 | $xoopsTpl->assign('quickreply', $quickreply); |
||
819 | // END irmtfan improve quickreply smarty variable |
||
820 | unset($forum_form); |
||
821 | } else { |
||
822 | $xoopsTpl->assign('quickreply', ['show' => 0]); |
||
823 | } |
||
824 | |||
825 | if ($GLOBALS['xoopsModuleConfig']['do_tag'] |
||
826 | && @include_once $GLOBALS['xoops']->path('modules/tag/include/tagbar.php')) { |
||
827 | $xoopsTpl->assign('tagbar', tagBar($topicObject->getVar('topic_tags', 'n'))); |
||
828 | } |
||
829 | // irmtfan move to footer.php |
||
830 | include_once __DIR__ . '/footer.php'; |
||
831 | include $GLOBALS['xoops']->path('footer.php'); |
||
832 | $xoopsLogger->stopTime('newBB_viewtopic'); |
||
833 |
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.