Passed
Push — master ( 23721f...32f8a2 )
by Lio
03:12 queued 45s
created

index.php (10 issues)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 You may not change or alter any portion of this comment or credits
7
 of supporting developers from this source code or any supporting source code
8
 which is considered copyrighted (c) material of the original comment or credit authors.
9
10
 This program is distributed in the hope that it will be useful,
11
 but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
*/
14
15
/**
16
 * Module: Countdown
17
 *
18
 * @category        Module
19
 * @package         countdown
20
 * @author          XOOPS Development Team <https://xoops.org>
21
 * @copyright       {@link https://xoops.org/ XOOPS Project}
22
 * @license         GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
23
 * @link            https://xoops.org/
24
 * @since           1.0.0
25
 */
26
27
use Xmf\Request;
0 ignored issues
show
The type Xmf\Request was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
28
use XoopsModules\Countdown;
29
30
$GLOBALS['xoopsOption']['template_main'] = 'countdown_events_list.tpl';
31
require_once __DIR__ . '/header.php';
32
$start = Request::getInt('start', 0);
33
// Define Stylesheet
34
$xoTheme->addStylesheet($stylesheet);
35
36
$db = \XoopsDatabaseFactory::getDatabaseConnection();
0 ignored issues
show
The type XoopsDatabaseFactory was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
37
38
// Get Handler
39
/** @var \XoopsPersistableObjectHandler $eventsHandler */
40
$eventsHandler = new Countdown\EventsHandler($db);
41
42
$eventsPaginationLimit = $helper->getConfig('usereventperpage');
43
44
$criteria = new \CriteriaCompo();
0 ignored issues
show
The type CriteriaCompo was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
45
46
$criteria->setOrder('DESC');
47
$criteria->setSort('event_id');
48
$criteria->setLimit($eventsPaginationLimit);
49
$criteria->setStart($start);
50
$op    = Request::getCmd('op', '');
51
$today = date("Y-m-d H:i:s", time());
52
53
switch ($op) {
54
    case '':
55
    default: //Do nothing, we want to view all
56
		$xoopsTpl->assign('lang_events', _MD_COUNTDOWN_EVENT);
57
        break;
58
    case 'running':
59
        $criteria->add(new Criteria('event_date', $today, '>'));
0 ignored issues
show
The type Criteria was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
60
		$xoopsTpl->assign('lang_events', _MD_COUNTDOWN_EVENT_RUNNING);
61
        break;
62
    case 'expired':
63
        $criteria->add(new Criteria('event_date', $today, '<'));
64
		$xoopsTpl->assign('lang_events', _MD_COUNTDOWN_EVENT_EXPIRED);
65
}
66
67
$eventsCount = $eventsHandler->getCount($criteria);
68
$eventsArray = $eventsHandler->getAll($criteria);
69
70
$moduleDirNameUpper = strtoupper($moduleDirName);
71
72
$id = Request::getInt('event_id', 0, 'GET');
73
74
if ($eventsCount > 0) {
75
    foreach (array_keys($eventsArray) as $i) {
76
        $events['id']           = $eventsArray[$i]->getVar('event_id');
77
        $events['uid']          = $eventsArray[$i]->getVar('event_uid');
78
        $events['submitter']    = \XoopsUser::getUnameFromId($eventsArray[$i]->getVar('event_uid'));
0 ignored issues
show
The type XoopsUser was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
79
        $events['name']         = $eventsArray[$i]->getVar('event_name');
80
        $events['description']  = $eventsArray[$i]->getVar('event_description');
81
        $events['category']     = $eventsArray[$i]->getVar('event_categoryid');
82
        $categoryid             = $eventsArray[$i]->getVar('event_categoryid');
83
        $categoryHandler        = $helper->getHandler('category');
84
        $categoryObj            = $categoryHandler->get($categoryid);
85
        $events['categoryname'] = $categoryObj->getVar('category_title');
86
        $categoryname           = $categoryObj->getVar('category_title');
87
        $events['logo']         = $eventsArray[$i]->getVar('event_logo');
88
        $events['date']         = date(_DATESTRING, strtotime($eventsArray[$i]->getVar('event_date')));
0 ignored issues
show
The constant _DATESTRING was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
89
        $events['dateiso']      = $eventsArray[$i]->getVar('event_date');
90
        $events['date_created'] = formatTimestamp($eventsArray[$i]->getVar('date_created'));
0 ignored issues
show
The function formatTimestamp was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

90
        $events['date_created'] = /** @scrutinizer ignore-call */ formatTimestamp($eventsArray[$i]->getVar('date_created'));
Loading history...
91
        $date_created           = formatTimestamp($eventsArray[$i]->getVar('date_created'));
92
        $events['date_updated'] = formatTimestamp($eventsArray[$i]->getVar('date_updated'));
93
        $date_updated           = formatTimestamp($eventsArray[$i]->getVar('date_updated'));
94
95
        if ($date_created == $date_updated) {
96
            $events['info'] = sprintf(_MD_COUNTDOWN_POSTEDBY, \XoopsUser::getUnameFromId($eventsArray[$i]->getVar('event_uid')), formatTimestamp($eventsArray[$i]->getVar('date_created'), 'M d Y'), $categoryname);
97
        } else {
98
            $events['info'] = sprintf(_MD_COUNTDOWN_POSTEDBY, \XoopsUser::getUnameFromId($eventsArray[$i]->getVar('event_uid')), formatTimestamp($eventsArray[$i]->getVar('date_updated'), 'M d Y'), $categoryname);
99
        }
100
101
        $GLOBALS['xoopsTpl']->append('events', $events);
102
        $keywords[] = $eventsArray[$i]->getVar('event_id');
103
        unset($events);
104
    }
105
    // Display Navigation
106
    if ($eventsCount > $eventsPaginationLimit) {
107
        $GLOBALS['xoopsTpl']->assign('index_url', COUNTDOWN_URL . '/index.php');
108
        require_once XOOPS_ROOT_PATH . '/class/pagenav.php';
0 ignored issues
show
The constant XOOPS_ROOT_PATH was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
109
        $pagenav = new \XoopsPageNav($eventsCount, $eventsPaginationLimit, $start, 'start');
0 ignored issues
show
The type XoopsPageNav was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
110
        $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4));
111
    }
112
}
113
114
//keywords
115
if (isset($keywords)) {
116
    $utility::metaKeywords(xoops_getModuleOption('keywords', $moduleDirName) . ', ' . implode(', ', $keywords));
0 ignored issues
show
The function xoops_getModuleOption was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

116
    $utility::metaKeywords(/** @scrutinizer ignore-call */ xoops_getModuleOption('keywords', $moduleDirName) . ', ' . implode(', ', $keywords));
Loading history...
117
}
118
//description
119
$utility::metaDescription(_MD_COUNTDOWN_EVENTS_DESC);
120
//
121
$GLOBALS['xoopsTpl']->assign('eventperpage', $eventsPaginationLimit);
122
$GLOBALS['xoopsTpl']->assign('index_url', COUNTDOWN_URL . '/index.php');
123
$GLOBALS['xoopsTpl']->assign('countdown_url', COUNTDOWN_URL);
124
$GLOBALS['xoopsTpl']->assign('admin', COUNTDOWN_ADMIN);
125
$GLOBALS['xoopsTpl']->assign('copyright', $copyright);
126
127
require __DIR__ . '/footer.php';
128
require dirname(__DIR__, 2) . '/footer.php';
129