|
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\Xoopsheadline\{ |
|
19
|
|
|
Helper, |
|
20
|
|
|
Utility |
|
21
|
|
|
}; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @param array $options |
|
25
|
|
|
* @return array|bool |
|
26
|
|
|
*/ |
|
27
|
|
|
function b_xoopsheadline_show(array $options) |
|
|
|
|
|
|
28
|
|
|
{ |
|
29
|
|
|
if (!class_exists(Helper::class)) { |
|
30
|
|
|
return false; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
$helper = Helper::getInstance(); |
|
34
|
|
|
|
|
35
|
|
|
$block = []; |
|
36
|
|
|
|
|
37
|
|
|
global $xoopsConfig; |
|
38
|
|
|
$hlDir = \basename(\dirname(__DIR__)); |
|
39
|
|
|
|
|
40
|
|
|
/** @var \XoopsModuleHandler $moduleHandler */ |
|
41
|
|
|
$moduleHandler = xoops_getHandler('module'); |
|
42
|
|
|
$module = $moduleHandler->getByDirname($hlDir); |
|
43
|
|
|
/** @var \XoopsConfigHandler $configHandler */ |
|
44
|
|
|
$configHandler = xoops_getHandler('config'); |
|
45
|
|
|
$moduleConfig = $configHandler->getConfigsByCat(0, $module->getVar('mid')); |
|
46
|
|
|
|
|
47
|
|
|
$headlineHandler = $helper->getHandler('Headline'); |
|
48
|
|
|
$criteria = new \CriteriaCompo(); |
|
49
|
|
|
$criteria->add(new \Criteria('headline_asblock', 1, '=')); |
|
50
|
|
|
switch ($moduleConfig['sortby']) { |
|
51
|
|
|
case 1: |
|
52
|
|
|
$criteria->setSort('headline_name'); |
|
53
|
|
|
$criteria->setOrder('DESC'); |
|
54
|
|
|
break; |
|
55
|
|
|
case 2: |
|
56
|
|
|
$criteria->setSort('headline_name'); |
|
57
|
|
|
$criteria->setOrder('ASC'); |
|
58
|
|
|
break; |
|
59
|
|
|
case 3: |
|
60
|
|
|
$criteria->setSort('headline_weight'); |
|
61
|
|
|
$criteria->setOrder('DESC'); |
|
62
|
|
|
break; |
|
63
|
|
|
case 4: |
|
64
|
|
|
default: |
|
65
|
|
|
$criteria->setSort('headline_weight'); |
|
66
|
|
|
$criteria->setOrder('ASC'); |
|
67
|
|
|
break; |
|
68
|
|
|
} |
|
69
|
|
|
if (null !== $headlineHandler) { |
|
70
|
|
|
$headlines = $headlineHandler->getObjects($criteria); |
|
71
|
|
|
foreach ($headlines as $i => $iValue) { |
|
72
|
|
|
$renderer = Utility::getRenderer($iValue); |
|
73
|
|
|
if (!$renderer->renderBlock()) { |
|
74
|
|
|
if (2 == $xoopsConfig['debug_mode']) { |
|
75
|
|
|
$block['feeds'][] = sprintf(_MD_XOOPSHEADLINE_FAILGET, $iValue->getVar('headline_name')) . '<br>' . $renderer->getErrors(); |
|
76
|
|
|
} |
|
77
|
|
|
continue; |
|
78
|
|
|
} |
|
79
|
|
|
$block['feeds'][] = &$renderer->getBlock(); |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
return $block; |
|
84
|
|
|
} |
|
85
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.