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
|
|
|
use XoopsModules\News\{ |
19
|
|
|
Helper, |
20
|
|
|
NewsTopic, |
21
|
|
|
ObjectTree, |
22
|
|
|
Utility |
23
|
|
|
}; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @return mixed |
27
|
|
|
*/ |
28
|
|
|
function b_news_topics_show() |
29
|
|
|
{ |
30
|
|
|
global $storytopic; // Don't know why this is used and where it's coming from .... |
31
|
|
|
// require_once XOOPS_ROOT_PATH . '/modules/news/class/class.newstopic.php'; |
32
|
|
|
// require_once XOOPS_ROOT_PATH . '/modules/news/class/tree.php'; |
33
|
|
|
|
34
|
|
|
$moduleDirName = \basename(\dirname(__DIR__)); |
|
|
|
|
35
|
|
|
|
36
|
|
|
/** @var Helper $helper */ |
37
|
|
|
if (!class_exists(Helper::class)) { |
38
|
|
|
return false; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
$helper = Helper::getInstance(); |
|
|
|
|
42
|
|
|
|
43
|
|
|
$jump = XOOPS_URL . '/modules/news/index.php?storytopic='; |
44
|
|
|
$storytopic = !empty($storytopic) ? $storytopic : 0; |
45
|
|
|
$restricted = Utility::getModuleOption('restrictindex'); |
46
|
|
|
|
47
|
|
|
$xt = new NewsTopic(); |
48
|
|
|
$allTopics = $xt->getAllTopics($restricted); |
49
|
|
|
$topic_tree = new ObjectTree($allTopics, 'topic_id', 'topic_pid'); |
50
|
|
|
$additional = " onchange='location=\"" . $jump . "\"+this.options[this.selectedIndex].value'"; |
51
|
|
|
|
52
|
|
|
if (Utility::checkVerXoops($GLOBALS['xoopsModule'], '2.5.9')) { |
53
|
|
|
// $block['selectbox'] = $topic_tree->makeSelBox('storytopic', 'topic_title', '-- ', '', true, 0, $additional); |
54
|
|
|
$topicSelect = $topic_tree->makeSelectElement('storytopic', 'topic_title', '--', '', true, 0, $additional); |
55
|
|
|
$block['selectbox'] = $topicSelect->render(); |
|
|
|
|
56
|
|
|
} else { |
57
|
|
|
$block['selectbox'] = $topic_tree->makeSelBox('storytopic', 'topic_title', '-- ', '', true, 0, $additional); |
|
|
|
|
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
return $block; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @param $options |
65
|
|
|
*/ |
66
|
|
|
function b_news_topics_onthefly($options): void |
67
|
|
|
{ |
68
|
|
|
$options = explode('|', $options); |
69
|
|
|
$block = b_news_topics_show($options); |
|
|
|
|
70
|
|
|
|
71
|
|
|
$tpl = new \XoopsTpl(); |
72
|
|
|
$tpl->assign('block', $block); |
73
|
|
|
$tpl->display('db:news_block_topics.tpl'); |
74
|
|
|
} |
75
|
|
|
|