Completed
Push — master ( a9decc...a21b67 )
by Michael
02:51
created

blocks/day_events.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 27 and the first side effect is on line 20.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
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 http://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later}
15
 * @package      extcal
16
 * @since
17
 * @author       XOOPS Development Team,
18
 */
19
20
require_once __DIR__ . '/../include/constantes.php';
21
22
/**
23
 * @param $options
24
 *
25
 * @return mixed
26
 */
27 View Code Duplication
function bExtcalDayShow($options)
28
{
29
    require_once __DIR__ . '/../class/config.php';
30
31
    // Retriving module config
32
    $extcalConfig      = ExtcalConfig::getHandler();
33
    $xoopsModuleConfig = $extcalConfig->getModuleConfig();
34
35
    $eventHandler = xoops_getModuleHandler(_EXTCAL_CLS_EVENT, _EXTCAL_MODULE);
36
37
    $nbEvent     = $options[0];
38
    $titleLenght = $options[1];
39
    array_shift($options);
40
    array_shift($options);
41
42
    // Checking if no cat is selected
43
    if (0 == $options[0] && 1 == count($options)) {
44
        $options = 0;
45
    }
46
47
    $events = $eventHandler->objectToArray($eventHandler->getThisDayEvent($nbEvent, $options));
48
    $eventHandler->serverTimeToUserTimes($events);
49
    $eventHandler->formatEventsDate($events, $xoopsModuleConfig['event_date_month']);
50
51
    return $events;
52
}
53
54
/**
55
 * @param $options
56
 *
57
 * @return string
58
 */
59 View Code Duplication
function bExtcalDayEdit($options)
60
{
61
    global $xoopsUser;
62
63
    $catHandler = xoops_getModuleHandler(_EXTCAL_CLS_CAT, _EXTCAL_MODULE);
64
65
    $cats = $catHandler->getAllCat($xoopsUser, 'extcal_cat_view');
66
67
    $form = _MB_EXTCAL_DISPLAY . "&nbsp;\n";
68
    $form .= '<input name="options[0]" size="5" maxlength="255" value="' . $options[0] . '" type="text">&nbsp;' . _MB_EXTCAL_EVENT . '<br>';
69
    $form .= _MB_EXTCAL_TITLE_LENGTH . ' : <input name="options[1]" size="5" maxlength="255" value="' . $options[1] . '" type="text"><br>';
70
    array_shift($options);
71
    array_shift($options);
72
    $form .= _MB_EXTCAL_CAT_TO_USE . '<br><select name="options[]" multiple="multiple" size="5">';
73
    if (array_search(0, $options) === false) {
74
        $form .= '<option value="0">' . _MB_EXTCAL_ALL_CAT . '</option>';
75
    } else {
76
        $form .= '<option value="0" selected="selected">' . _MB_EXTCAL_ALL_CAT . '</option>';
77
    }
78
    foreach ($cats as $cat) {
79
        if (array_search($cat->getVar('cat_id'), $options) === false) {
80
            $form .= '<option value="' . $cat->getVar('cat_id') . '">' . $cat->getVar('cat_name') . '</option>';
81
        } else {
82
            $form .= '<option value="' . $cat->getVar('cat_id') . '" selected="selected">' . $cat->getVar('cat_name') . '</option>';
83
        }
84
    }
85
    $form .= '</select>';
86
87
    return $form;
88
}
89