Passed
Push — master ( 7b6eed...a3cd89 )
by Michael
02:46
created

index.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
/*
5
 * You may not change or alter any portion of this comment or credits
6
 * of supporting developers from this source code or any supporting source code
7
 * which is considered copyrighted (c) material of the original comment or credit authors.
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
 */
13
14
/**
15
 * @copyright    {@link https://xoops.org/ XOOPS Project}
16
 * @license      {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later}
17
 * @author      XOOPS Development Team
18
 */
19
20
use Xmf\Module\Admin;
21
use Xmf\Request;
22
use XoopsModules\Xoopsheadline\Helper;
23
use XoopsModules\Xoopsheadline\Utility;
24
/** @var Helper $helper */
25
26
require_once \dirname(__DIR__, 2) . '/mainfile.php';
27
28
$helper = Helper::getInstance();
29
30
$hlman = $helper->getHandler('Headline');
31
$hlid  = (!empty($_GET['id']) && (Request::getInt('id', 0, 'GET') > 0)) ? Request::getInt('id', 0, 'GET') : 0;
32
33
$GLOBALS['xoopsOption']['template_main'] = 'xoopsheadline_index.tpl';
34
require_once XOOPS_ROOT_PATH . '/header.php';
35
36
$criteria = new \CriteriaCompo();
37
$criteria->add(new \Criteria('headline_display', 1, '='));
38
$criteria->add(new \Criteria('headline_xml', '', '!='));
39
switch ((int)$helper->getConfig('sortby')) {
40
    case 1:
41
        $criteria->setSort('headline_name');
42
        $criteria->setOrder('DESC');
43
        break;
44
    case 2:
45
        $criteria->setSort('headline_name');
46
        $criteria->setOrder('ASC');
47
        break;
48
    case 3:
49
        $criteria->setSort('headline_weight');
50
        $criteria->setOrder('DESC');
51
        break;
52
    case 4:
53
    default:
54
        $criteria->setSort('headline_weight');
55
        $criteria->setOrder('ASC');
56
        break;
57
}
58
$headlines = $hlman->getObjects($criteria);
59
60
global $xoopsModule;
61
$pathIcon16    = Admin::iconUrl('', '16');
62
$moduleDirName = $xoopsModule->getVar('dirname');
63
64
$userIsAdmin = (is_object($xoopsUser) && $xoopsUser->isAdmin($xoopsModule->getVar('mid')));
65
$count       = count($headlines);
66
for ($i = 0; $i < $count; ++$i) {
67
    $thisId  = $headlines[$i]->getVar('headline_id');
68
    $editUrl = $userIsAdmin ? "&nbsp;<a href='" . XOOPS_URL . "/modules/{$moduleDirName}/admin/main.php?op=edit&amp;headline_id={$thisId}'><img src='" . $pathIcon16 . "/edit.png' alt='" . _EDIT . "' title='" . _EDIT . "'></a>" : '';
69
    $xoopsTpl->append('feed_sites', ['id' => $thisId, 'name' => $headlines[$i]->getVar('headline_name'), 'editurl' => $editUrl]);
70
}
71
$xoopsTpl->assign('lang_headlines', _MD_XOOPSHEADLINE_HEADLINES);
72
if (0 == $hlid) {
73
    $hlid = $headlines[0]->getVar('headline_id');
74
}
75
if ($hlid > 0) {
76
    $headline = $hlman->get($hlid);
77
    if (is_object($headline)) {
78
        $renderer = Utility::getRenderer($headline);
79
        if ($renderer->renderFeed()) {
80
            $xoopsTpl->assign('headline', $renderer->getFeed());
81
        } elseif (2 == $xoopsConfig['debug_mode']) {
82
                $xoopsTpl->assign('headline', '<p>' . sprintf(_MD_XOOPSHEADLINE_FAILGET, $headline->getVar('headline_name')) . '<br>' . $renderer->getErrors() . '</p>');
0 ignored issues
show
It seems like $headline->getVar('headline_name') can also be of type array and array; however, parameter $values of sprintf() does only seem to accept double|integer|string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

82
                $xoopsTpl->assign('headline', '<p>' . sprintf(_MD_XOOPSHEADLINE_FAILGET, /** @scrutinizer ignore-type */ $headline->getVar('headline_name')) . '<br>' . $renderer->getErrors() . '</p>');
Loading history...
83
        }
84
    }
85
}
86
require_once XOOPS_ROOT_PATH . '/footer.php';
87