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

minical.php ➔ bExtcalMinicalAddEventToArray()   C

Complexity

Conditions 7
Paths 15

Size

Total Lines 76
Code Lines 26

Duplication

Lines 23
Ratio 30.26 %

Importance

Changes 0
Metric Value
cc 7
eloc 26
nc 15
nop 6
dl 23
loc 76
rs 6.5808
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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 30 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
global $extcalConfig, $xoopsUser;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
21
require_once __DIR__ . '/../include/constantes.php';
22
require_once __DIR__ . '/../class/utility.php';
23
require_once __DIR__ . '/../class/tableForm.php';
24
//---------------------------------------------------------------------------
25
/**
26
 * @param $options
27
 *
28
 * @return array
29
 */
30
function bExtcalMinicalShow($options)
0 ignored issues
show
Coding Style introduced by
bExtcalMinicalShow uses the super-global variable $GLOBALS which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
31
{
32
    global $extcalConfig, $xoopsUser;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
33
34
    extcal_getDefautminicalOption($options);
35
36
    require_once __DIR__ . '/../class/config.php';
37
38
    require_once _EXTCAL_PEAR_CALENDAR_ROOT . '/Util/Textual.php';
39
    require_once _EXTCAL_PEAR_CALENDAR_ROOT . '/Month/Weeks.php';
40
    require_once _EXTCAL_PEAR_CALENDAR_ROOT . '/Day.php';
41
    //     require_once CALENDAR_ROOT . 'Month/Weeks.php';
42
    //     require_once CALENDAR_ROOT . 'Day.php';
43
44
    // Retriving Image for block if enabled
45
    if ($options[0] == 1) {
46
        $imageHandler = xoops_getHandler('image');
47
        $criteria     = new Criteria('imgcat_id', $options[1]);
48
        $criteria->setSort('RAND()');
49
        $criteria->setLimit($options[6]);
50
        $images         = $imageHandler->getObjects($criteria);
51
        $slideShowParam = array(
52
            'images'      => $images,
53
            'frameHeight' => $options[3],
54
            'frameWidth'  => $options[2],
55
            'transTime'   => $options[4],
56
            'pauseTime'   => $options[5],
57
        );
58
        if (count($images) > 0) {
59
            _makeXMLSlideshowConf($slideShowParam);
60
            $imageParam = array('displayImage' => true);
61
        } else {
62
            $imageParam = array('displayImage' => false);
63
        }
64
    } else {
65
        $imageParam = array('displayImage' => false);
66
    }
67
    $imageParam['frameHeight'] = $options[3];
68
    $imageParam['frameWidth']  = $options[2];
69
70
    // Retriving module config
71
    //     $extcalConfig = ExtcalConfig::getHandler();
0 ignored issues
show
Unused Code Comprehensibility introduced by
46% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
72
    //$xoopsModuleConfig = $extcalConfig->getModuleConfig();
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
73
    //----------------------------------------------------
74
    //recupe de xoopsmoduleConfig
75
    /** @var XoopsModuleHandler $moduleHandler */
76
    $moduleHandler = xoops_getHandler('module');
77
    $module        = $moduleHandler->getByDirname('extcal');
78
    $configHandler = xoops_getHandler('config');
79
    if ($module) {
80
        $extcalConfig = $configHandler->getConfigsByCat(0, $module->getVar('mid'));
81
    }
82
    //----------------------------------------------------
83
    // Getting eXtCal object's handler
84
    $catHandler = xoops_getModuleHandler(_EXTCAL_CLS_CAT, _EXTCAL_MODULE);
85
    $cats       = $catHandler->getAllCatById($xoopsUser);
86
    // $t = print_r($cats,true);
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
87
    // echo "zzz<pre>{$t}</pre>";
88
89
    $eventHandler      = xoops_getModuleHandler(_EXTCAL_CLS_EVENT, _EXTCAL_MODULE);
90
    $extcalTimeHandler = ExtcalTime::getHandler();
91
92
    // Retriving month and year value according to block options
93
    //modif JJD
94
    $offset      = $extcalConfig['offsetMinical'];
95
    $monthToShow = mktime(0, 0, 0, date('m') + $offset, date('d'), date('Y'));
96
    $month       = date('n', $monthToShow);
97
    $year        = date('Y', $monthToShow);
98
99
    //----------------------------------------------------
100
    $month += $options[7]; //ajout  ou retrait du nombre de mois de décalage
101
    if ($month < 1) {
102
        $month = 12;
103
        --$year;
104
    } elseif ($month > 12) {
105
        $month = 1;
106
        ++$year;
107
    }
108
    //----------------------------------------------------
109
110
    // Saving display link preference
111
    $displayLink = $options[8];
112
113
    // Delete options to keep only categorie data
114
    $tCatSelected = explode(',', $options[9]);
115
116
    /***************************************************************/
117
    // Retriving events and formatting them
118
    //$events = $eventHandler->objectToArray($eventHandler->getEventCalendarMonth($month, $year, $tCatSelected));
0 ignored issues
show
Unused Code Comprehensibility introduced by
69% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
119
    if (true) {
0 ignored issues
show
Bug introduced by
Avoid IF statements that are always true or false
Loading history...
120
        $criteres = array(
121
            'periode'      => _EXTCAL_EVENTS_MONTH,
122
            'month'        => $month,
123
            'year'         => $year,
124
            'cat'          => $tCatSelected,
125
            'externalKeys' => 'cat_id',
126
        );
127
        $events   = $eventHandler->getEventsOnPeriode($criteres);
128
    } else {
129
        $events = array();
130
    }
131
    //ext_echoArray($events, 'minical');
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
132
    /***************************************************************/
133
    //$eventHandler->formatEventDate($events, "l dS \of F Y h:i A");
0 ignored issues
show
Unused Code Comprehensibility introduced by
80% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
134
135
    // Calculating timestamp for the begin and the end of the month
136
    $startMonth = mktime(0, 0, 0, $month, 1, $year);
137
    $endMonth   = mktime(23, 59, 59, $month + 1, 0, $year);
138
139
    /*
140
     *  Adding all event occuring during this month to an array indexed by day number
141
     */
142
    $eventsArray = array();
143
    foreach ($events as $event) {
144
        //echo "id->{$event['event_id']}<br>";
145
        bExtcalMinicalAddEventToArray($event, $eventsArray, $extcalTimeHandler, $startMonth, $endMonth, $cats);
146
        //         if (!$event['event_isrecur']) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
147
        //             bExtcalMinicalAddEventToArray($event, $eventsArray, $extcalTimeHandler, $startMonth, $endMonth, $cats);
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
148
        //         } else {
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
149
        //
150
        //             $recurEvents = $eventHandler->getRecurEventToDisplay($event, $startMonth, $endMonth);
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
151
        //             foreach ($recurEvents as $recurEvent)
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
152
        //             {
153
        //                 bExtcalMinicalAddEventToArray($recurEvent, $eventsArray, $extcalTimeHandler, $startMonth, $endMonth, $cats);
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
154
        //             }
155
        //         }
156
    }
157
    //ext_echoArray($eventsArray);
158
159
    /*
160
     *  Making an array to create tabbed output on the template
161
     */
162
    // Flag current day
163
    $selectedDays = array(
164
        new Calendar_Day(date('Y', xoops_getUserTimestamp(time(), $extcalTimeHandler->_getUserTimeZone($GLOBALS['xoopsUser']))),
165
                         date('n', xoops_getUserTimestamp(time(), $extcalTimeHandler->_getUserTimeZone($GLOBALS['xoopsUser']))),
166
                         date('j', xoops_getUserTimestamp(time(), $extcalTimeHandler->_getUserTimeZone($GLOBALS['xoopsUser'])))),
167
    );
168
169
    // Build calendar object
170
    $monthCalObj = new Calendar_Month_Weeks($year, $month, $extcalConfig['week_start_day']);
171
    $monthCalObj->build();
172
173
    $tableRows = array();
174
    $rowId     = 0;
175
    $cellId    = 0;
176
    while ($weekCalObj = $monthCalObj->fetch()) {
177
        $weekCalObj->build($selectedDays);
178
        $tableRows[$rowId]['weekInfo'] = array(
179
            'week'  => $weekCalObj->thisWeek('n_in_year'),
180
            'day'   => $weekCalObj->thisDay(),
181
            'month' => $monthCalObj->thisMonth(),
182
            'year'  => $monthCalObj->thisYear(),
183
        );
184
        while ($dayCalObj = $weekCalObj->fetch()) {
185
            $tableRows[$rowId]['week'][$cellId] = array(
186
                'isEmpty'    => $dayCalObj->isEmpty(),
187
                'number'     => $dayCalObj->thisDay(),
188
                'isSelected' => $dayCalObj->isSelected(),
189
            );
190
            $day                                = $dayCalObj->thisDay();
191
            if (isset($eventsArray[$day]) && !$dayCalObj->isEmpty()) {
192
                $tableRows[$rowId]['week'][$cellId]['haveEvents'] = true;
193
                $tableRows[$rowId]['week'][$cellId]['color']      = $eventsArray[$day]['color'];
194
            } else {
195
                $tableRows[$rowId]['week'][$cellId]['haveEvents'] = false;
196
            }
197
            ++$cellId;
198
        }
199
        $cellId = 0;
200
        ++$rowId;
201
    }
202
203
    // Retriving weekdayNames
204
    //$loc_de = setlocale (LC_ALL, 'Fr');
0 ignored issues
show
Unused Code Comprehensibility introduced by
47% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
205
206
    $weekdayNames = Calendar_Util_Textual::weekdayNames('one');
207
    //$weekdayNames=array('D','L','M','M','J','V','S');
0 ignored issues
show
Unused Code Comprehensibility introduced by
95% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
208
209
    //     echo "<hr>L'identifiant de l'allemand sur ce système est '$loc_de'";
210
    //     echoArray($weekdayNames,true);
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
211
212 View Code Duplication
    for ($i = 0; $i < $extcalConfig['week_start_day']; ++$i) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
213
        $weekdayName    = array_shift($weekdayNames);
214
        $weekdayNames[] = $weekdayName;
215
    }
216
217
    // Making navig data
218
    $navig = array(
219
        'page' => $extcalConfig['start_page'],
220
        'uri'  => 'year=' . $monthCalObj->thisYear() . '&amp;month=' . $monthCalObj->thisMonth(),
221
        'name' => $extcalTimeHandler->getFormatedDate($extcalConfig['nav_date_month'], $monthCalObj->getTimestamp()),
222
    );
223
224
    $horloge             = array();
225
    $horloge['display']  = (trim($options[11]) != '');
226
    $horloge['fullName'] = XOOPS_URL . _EXTCAL_PATH_HORLOGES . $options[11];
227
    $horloge['width']    = $options[12] . 'px';
228
    $horloge['height']   = $options[13] . 'px';
229
230
    $ret = array(
231
        'imageParam'   => $imageParam,
232
        'displayLink'  => $displayLink,
233
        'submitText'   => _MB_EXTCAL_SUBMIT_LINK_TEXT,
234
        'tableRows'    => $tableRows,
235
        'weekdayNames' => $weekdayNames,
236
        'navig'        => $navig,
237
        'horloge'      => $horloge,
238
        'bgColor'      => $options[10],
239
    );
240
241
    // $t = print_r($horloge,true);
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
242
    // echo "<pre>{$t}</pre>";
243
    return $ret;
244
}
245
246
//---------------------------------------------------------------------------
247
/**
248
 * @param $options
249
 *
250
 * @return string
251
 */
252
function bExtcalMinicalEdit($options)
253
{
254
    require_once __DIR__ . '/../class/form/spin/formspin.php';
255
    global $xoopsUser;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
256
257
    //  $t = print_r(get_defined_vars(),true);
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
258
    // // $t = print_r($options,true);
259
    //  echo "<pre>{$t}</pre>";
260
261
    extcal_getDefautminicalOption($options);
262
263
    $xfValue = array();
264
265
    $form = new XoopsTableForm(_OPTIONS, '', '');
266
    //$form->setExtra('enctype="multipart/form-data"');
0 ignored issues
show
Unused Code Comprehensibility introduced by
86% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
267
268
    //============================================================
269
270
    $catHandler      = xoops_getModuleHandler(_EXTCAL_CLS_CAT, _EXTCAL_MODULE);
271
    $cats            = $catHandler->getAllCat($xoopsUser, 'extcal_cat_view');
272
    $imageCatHandler = xoops_getHandler('imagecategory');
273
274
    //=====================================================================
275
    $form->insertBreak('<div style="text-align: center;font-weight: bold;">' . _MB_EXTCAL_OPT_SLIDE_SHOW . '</div>', 'head');
276
277
    $k           = 0;
278
    $xfValue[$k] = new XoopsFormRadio(_MB_EXTCAL_DISPLAY_IMG, "options[{$k}]", $options[$k]);
279
    $xfValue[$k]->addOption(1, _YES);
280
    $xfValue[$k]->addOption(0, _NO);
281
282
    $form->addElement($xfValue[$k], false);
283
    //---------------------------------------------------------------------
284
    $imageCats = $imageCatHandler->getObjects();
285
    $t         = array();
286
    $t[0]      = _NONE;
287
    foreach ($imageCats as $cat) {
288
        $t[$cat->getVar('imgcat_id')] = $cat->getVar('imgcat_name');
289
    }
290
291
    $k           = 1;
292
    $xfValue[$k] = new XoopsFormSelect(_MB_EXTCAL_IMG_CAT, "options[{$k}]", $options[$k], 1, false);
293
    $xfValue[$k]->addOptionArray($t);
294
    $form->addElement($xfValue[$k], false);
295
    //---------------------------------------------------------------------
296
    $k           = 2;
297
    $xfValue[$k] = new ExtcalFormSpin(_MB_EXTCAL_SS_WIDTH, "options[{$k}]", $options[$k], 100, 250, 1, 0, 8, _MB_EXTCAL_PX, $imgFolder = '');
298
    $form->addElement($xfValue[$k], false);
299
    //---------------------------------------------------------------------
300
    $k           = 3;
301
    $xfValue[$k] = new ExtcalFormSpin(_MB_EXTCAL_SS_HEIGHT, "options[{$k}]", $options[$k], 100, 250, 1, 0, 8, _MB_EXTCAL_PX, $imgFolder = '');
302
    $form->addElement($xfValue[$k], false);
303
    //---------------------------------------------------------------------
304
    $k           = 4;
305
    $xfValue[$k] = new ExtcalFormSpin(_MB_EXTCAL_SS_TRANS_TIME, "options[{$k}]", $options[$k], 0, 12, 1, 0, 8, _MB_EXTCAL_PX, $imgFolder = '');
306
    $form->addElement($xfValue[$k], false);
307
    //---------------------------------------------------------------------
308
    $k           = 5;
309
    $xfValue[$k] = new ExtcalFormSpin(_MB_EXTCAL_SS_PAUSE_TIME, "options[{$k}]", $options[$k], 0, 12, 1, 0, 8, _MB_EXTCAL_PX, $imgFolder = '');
310
    $form->addElement($xfValue[$k], false);
311
    //---------------------------------------------------------------------
312
    $k           = 6;
313
    $xfValue[$k] = new ExtcalFormSpin(_MB_EXTCAL_SS_NB_PHOTOS, "options[{$k}]", $options[$k], 0, 50, 1, 0, 8, _MB_EXTCAL_PX, $imgFolder = '');
314
    $form->addElement($xfValue[$k], false);
315
    //=====================================================================
316
    $form->insertBreak('<div style="text-align: center;font-weight: bold;">' . _MB_EXTCAL_OPT_SHOW . '</div>', 'head');
317
318
    $t = array(
319
        -1 => _MB_EXTCAL_PREVIEW,
320
        0  => _MB_EXTCAL_CURRENT,
321
        1  => _MB_EXTCAL_NEXT,
322
    );
323
324
    $k           = 7;
325
    $xfValue[$k] = new XoopsFormSelect(_MB_EXTCAL_DISPLAY_MONTH, "options[{$k}]", $options[$k], 1, false);
326
    $xfValue[$k]->addOptionArray($t);
327
    $form->addElement($xfValue[$k], false);
328
    //---------------------------------------------------------------------
329
    $k           = 8;
330
    $xfValue[$k] = new XoopsFormRadio(_MB_EXTCAL_DISPLAY_SUBMIT_LINK, "options[{$k}]", $options[$k]);
331
    $xfValue[$k]->addOption(1, _YES);
332
    $xfValue[$k]->addOption(0, _NO);
333
334
    $form->addElement($xfValue[$k], false);
335
    //---------------------------------------------------------------------
336
    //for ($h=0;$h<8;++$h) array_shift($options);
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
337
    $t = array();
338
    foreach ($cats as $cat) {
339
        $t[$cat->getVar('cat_id')] = $cat->getVar('cat_name');
340
    }
341
342
    //function XoopsFormSelect($caption, $name, $value = null, $size = 1, $multiple = false)
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
343
344
    $k           = 9;
345
    $xfValue[$k] = new XoopsFormSelect(_MB_EXTCAL_CAT_TO_USE, "options[{$k}]", explode(',', $options[$k]), 8, true);
346
    $xfValue[$k]->setDescription(_MB_EXTCAL_CAT_TO_USE_DESC);
347
    $xfValue[$k]->addOptionArray($t);
348
    $form->addElement($xfValue[$k], false);
349
    //---------------------------------------------------------------------
350
    $k           = 10;
351
    $xfValue[$k] = new XoopsFormColorPicker(_MB_EXTCAL_BGCOLOR, "options[{$k}]", $options[$k]);
352
    $form->addElement($xfValue[$k], false);
353
354
    //=====================================================================
355
    $form->insertBreak('<div style="text-align: center;font-weight: bold;">' . _MB_EXTCAL_HORLOGE_OPT . '</div>', 'head');
356
    //---------------------------------------------------------------------
357
    $t = XoopsLists::getFileListAsArray(XOOPS_ROOT_PATH . _EXTCAL_PATH_HORLOGES);
358
    $t = array_merge(array(' ' => _NONE), $t);
359
360
    $k           = 11;
361
    $xfValue[$k] = new XoopsFormSelect(_MB_EXTCAL_HORLOGE, "options[{$k}]", $options[$k], 1, false);
362
    $xfValue[$k]->addOptionArray($t);
363
    $form->addElement($xfValue[$k], false);
364
365
    //---------------------------------------------------------------------
366
    $k           = 12;
367
    $xfValue[$k] = new ExtcalFormSpin(_MB_EXTCAL_WIDTH, "options[{$k}]", $options[$k], 50, 250, 1, 0, 8, _MB_EXTCAL_PX, $imgFolder = '');
368
    $form->addElement($xfValue[$k], false);
369
    //---------------------------------------------------------------------
370
    $k           = 13;
371
    $xfValue[$k] = new ExtcalFormSpin(_MB_EXTCAL_HEIGHT, "options[{$k}]", $options[$k], 50, 250, 1, 0, 8, _MB_EXTCAL_PX, $imgFolder = '');
372
    $form->addElement($xfValue[$k], false);
373
    //---------------------------------------------------------------------
374
    //=====================================================================
375
    return $form->render();
376
377
    //      $t = array();
0 ignored issues
show
Unused Code Comprehensibility introduced by
56% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
378
    //      while (list($key,$val) = each($xfValue)) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
379
    //       $t[] = $val->render();
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
380
    //      }
381
    //     return implode("\n", $t);
0 ignored issues
show
Unused Code Comprehensibility introduced by
64% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
382
383
    //    return extcal_buildHtmlArray($xfValue, _OPTIONS);
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
384
}
385
386
/**************************************************************************/
387
/**
388
 * @param $options
389
 */
390
function _makeXMLSlideshowConf($options)
391
{
392
393
    // create a new XML document
394
    $doc               = new DomDocument('1.0');
395
    $doc->formatOutput = true;
396
397
    // create root node
398
    $root = $doc->createElement('slideshow');
399
    $root = $doc->appendChild($root);
400
401
    // Create config node
402
    $config = $doc->createElement('config');
403
    $config = $root->appendChild($config);
404
405
    // Add config param
406
    $frameHeight = $doc->createElement('frameHeight');
407
    $frameHeight = $config->appendChild($frameHeight);
408
    $value       = $doc->createTextNode($options['frameHeight']);
409
    $frameHeight->appendChild($value);
410
411
    $frameWidth = $doc->createElement('frameWidth');
412
    $frameWidth = $config->appendChild($frameWidth);
413
    $value      = $doc->createTextNode($options['frameWidth']);
414
    $frameWidth->appendChild($value);
415
416
    $transTime = $doc->createElement('transTime');
417
    $transTime = $config->appendChild($transTime);
418
    $value     = $doc->createTextNode($options['transTime']);
419
    $transTime->appendChild($value);
420
421
    $pauseTime = $doc->createElement('pauseTime');
422
    $pauseTime = $config->appendChild($pauseTime);
423
    $value     = $doc->createTextNode($options['pauseTime']);
424
    $pauseTime->appendChild($value);
425
426
    // Add photos node
427
    $photos = $doc->createElement('photos');
428
    $photos = $root->appendChild($photos);
429
430
    $tempPhoto = $doc->createElement('photo');
431
    $tempSrc   = $doc->createElement('src');
432
    foreach ($options['images'] as $images) {
433
        // $photo = $doc->createElement('photo');
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
434
        $photo = clone $tempPhoto;
435
        $photo = $photos->appendChild($photo);
436
437
        // $src   = $doc->createElement('src');
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
438
        $src   = clone $tempSrc;
439
        $src   = $photo->appendChild($src);
440
        $value = $doc->createTextNode(XOOPS_URL . '/uploads/' . $images->getVar('image_name'));
441
        $src->appendChild($value);
442
    }
443
444
    // get completed xml document
445
    $xml_string = $doc->save(XOOPS_ROOT_PATH . '/cache/extcalSlideShowParam.xml');
0 ignored issues
show
Unused Code introduced by
$xml_string is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
446
}
447
448
/**************************************************************************/
449
/**
450
 * @param array      $event
451
 * @param array      $eventsArray
452
 * @param ExtcalTime $extcalTimeHandler
453
 * @param            $startMonth
454
 * @param            $endMonth
455
 * @param            $cats
456
 *
457
 * @return bool
0 ignored issues
show
Documentation introduced by
Should the return type not be false|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
458
 */
459
function bExtcalMinicalAddEventToArray($event, &$eventsArray, $extcalTimeHandler, $startMonth, $endMonth, $cats)
0 ignored issues
show
Unused Code introduced by
The parameter $cats is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Coding Style introduced by
bExtcalMinicalAddEventToArray uses the super-global variable $GLOBALS which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
460
{
461
    // ext_echoArray($event);
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
462
    // exit;
463
    // $d1 = date("j, m, Y", $startMonth);
0 ignored issues
show
Unused Code Comprehensibility introduced by
54% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
464
    // $d2 = date("j, m, Y", $endMonth);
0 ignored issues
show
Unused Code Comprehensibility introduced by
54% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
465
    // echo "bExtcalMinicalAddEventToArray : {$d1} - {$d2}<br>";
466
    // $d1 = date("j, m, Y", $event['event_start']);
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
467
    // $d2 = date("j, m, Y", $event['event_end']);
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
468
    // echo "bExtcalMinicalAddEventToArray : {$d1} - {$d2}<br>";
469
470
    //     $color  = $cats[$event['cat_id']]['cat_color'];
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
471
    //     $weight = $cats[$event['cat_id']]['cat_weight'];
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
472
    $color  = $event['cat']['cat_color'];
473
    $weight = $event['cat']['cat_weight'];
474
475
    // Calculating the start and the end of the event
476
    $startEvent = xoops_getUserTimestamp($event['event_start'], $extcalTimeHandler->_getUserTimeZone($GLOBALS['xoopsUser']));
477
    $endEvent   = xoops_getUserTimestamp($event['event_end'], $extcalTimeHandler->_getUserTimeZone($GLOBALS['xoopsUser']));
478
    // ext_echoTSU($event['event_start'],"event['event_start']");
0 ignored issues
show
Unused Code Comprehensibility introduced by
82% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
479
    // ext_echoTSU($event['event_end'],"event['event_end']");
0 ignored issues
show
Unused Code Comprehensibility introduced by
82% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
480
481
    //---------------------------------------------------------------
482 View Code Duplication
    if ($startEvent < $startMonth) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
483
        $firstDay = 1;
0 ignored issues
show
Unused Code introduced by
$firstDay is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
484
    } elseif ($startEvent > $endEvent) {
485
        return false;
486
    } else {
487
        $firstDay = date('j', $startEvent);
0 ignored issues
show
Unused Code introduced by
$firstDay is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
488
    }
489
490 View Code Duplication
    if ($endEvent < $startMonth) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
491
        return false;
492
    } elseif ($endEvent > $endMonth) {
493
        $lastDay = date('j', $endMonth);
0 ignored issues
show
Unused Code introduced by
$lastDay is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
494
    } else {
495
        $lastDay = date('j', $endEvent);
0 ignored issues
show
Unused Code introduced by
$lastDay is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
496
    }
497
498
    //echo "first dat - last day : {$firstDay} - {$lastDay}<br>";
499
    //echo $event['event_id'] . '-' . $weight .'<br>';
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
500
501
    $d = date('j', $event['event_start']);
502
    if (isset($eventsArray[$d])) {
503 View Code Duplication
        if ($weight > $eventsArray[$d]['weight']) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
504
            $eventsArray[$d]['weight'] = $weight;
505
            $eventsArray[$d]['color']  = $color;
506
        }
507 View Code Duplication
    } else {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
508
        $eventsArray[$d]['hasEvent'] = true;
509
        $eventsArray[$d]['weight']   = $weight;
510
        $eventsArray[$d]['color']    = $color;
511
    }
512
    /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
513
            for ($i = $firstDay; $i <= $lastDay; ++$i) {
514
                }
515
516
                $eventsArray[$i]['hasEvent'] = true;
517
                if (isset($eventsArray[$i]['weight'])) {
518
                  if ($weight > $eventsArray[$i]['weight']) {
519
                    $eventsArray[$i]['weight'] = $weight;
520
                    $eventsArray[$i]['color'] = $color;
521
                  }
522
                } else {
523
                  $eventsArray[$i]['weight'] = $weight;
524
                  $eventsArray[$i]['color'] = $color;
525
              }
526
            }
527
    */
528
529
    // $t = print_r($cats,true);
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
530
    // echo "<pre>{$t}</pre><hr>";
531
    //
532
    // $t = print_r($eventsArray,true);
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
533
    // echo "event id = {$event['event_id']} - weight = {$weight}<br>color = {$color}<br><pre>{$t}</pre><hr>";
534
}
535
536
/**
537
 * @param $options
538
 */
539
function extcal_getDefautminicalOption(&$options)
540
{
541
    // 0|0|150|225|1|3|10|0|1|1,2|| |120|120
0 ignored issues
show
Unused Code Comprehensibility introduced by
93% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
542
    for ($h = 0; $h <= 13; ++$h) {
543
        if (!isset($options[$h])) {
544
            switch ($h) {
545
                case  0:
0 ignored issues
show
Coding Style introduced by
As per coding-style, case should be followed by a single space.

As per the PSR-2 coding standard, there must be a space after the case keyword, instead of the test immediately following it.

switch (true) {
    case!isset($a):  //wrong
        doSomething();
        break;
    case !isset($b):  //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
546
                    $options[$h] = '0';
547
                    break;
548
                case  1:
0 ignored issues
show
Coding Style introduced by
As per coding-style, case should be followed by a single space.

As per the PSR-2 coding standard, there must be a space after the case keyword, instead of the test immediately following it.

switch (true) {
    case!isset($a):  //wrong
        doSomething();
        break;
    case !isset($b):  //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
549
                    $options[$h] = 0;
550
                    break;
551
                case  2:
0 ignored issues
show
Coding Style introduced by
As per coding-style, case should be followed by a single space.

As per the PSR-2 coding standard, there must be a space after the case keyword, instead of the test immediately following it.

switch (true) {
    case!isset($a):  //wrong
        doSomething();
        break;
    case !isset($b):  //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
552
                    $options[$h] = '150';
553
                    break;
554
                case  3:
0 ignored issues
show
Coding Style introduced by
As per coding-style, case should be followed by a single space.

As per the PSR-2 coding standard, there must be a space after the case keyword, instead of the test immediately following it.

switch (true) {
    case!isset($a):  //wrong
        doSomething();
        break;
    case !isset($b):  //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
555
                    $options[$h] = '255';
556
                    break;
557
                case  4:
0 ignored issues
show
Coding Style introduced by
As per coding-style, case should be followed by a single space.

As per the PSR-2 coding standard, there must be a space after the case keyword, instead of the test immediately following it.

switch (true) {
    case!isset($a):  //wrong
        doSomething();
        break;
    case !isset($b):  //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
558
                    $options[$h] = '1';
559
                    break;
560
                case  5:
0 ignored issues
show
Coding Style introduced by
As per coding-style, case should be followed by a single space.

As per the PSR-2 coding standard, there must be a space after the case keyword, instead of the test immediately following it.

switch (true) {
    case!isset($a):  //wrong
        doSomething();
        break;
    case !isset($b):  //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
561
                    $options[$h] = '3';
562
                    break;
563
                case  6:
0 ignored issues
show
Coding Style introduced by
As per coding-style, case should be followed by a single space.

As per the PSR-2 coding standard, there must be a space after the case keyword, instead of the test immediately following it.

switch (true) {
    case!isset($a):  //wrong
        doSomething();
        break;
    case !isset($b):  //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
564
                    $options[$h] = '10';
565
                    break;
566
                case  7:
0 ignored issues
show
Coding Style introduced by
As per coding-style, case should be followed by a single space.

As per the PSR-2 coding standard, there must be a space after the case keyword, instead of the test immediately following it.

switch (true) {
    case!isset($a):  //wrong
        doSomething();
        break;
    case !isset($b):  //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
567
                    $options[$h] = '0';
568
                    break;
569
                case  8:
0 ignored issues
show
Coding Style introduced by
As per coding-style, case should be followed by a single space.

As per the PSR-2 coding standard, there must be a space after the case keyword, instead of the test immediately following it.

switch (true) {
    case!isset($a):  //wrong
        doSomething();
        break;
    case !isset($b):  //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
570
                    $options[$h] = '1';
571
                    break;
572
                case  9:
0 ignored issues
show
Coding Style introduced by
As per coding-style, case should be followed by a single space.

As per the PSR-2 coding standard, there must be a space after the case keyword, instead of the test immediately following it.

switch (true) {
    case!isset($a):  //wrong
        doSomething();
        break;
    case !isset($b):  //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
573
                    $options[$h] = '1,2,3,4,5';
574
                    break;
575
                case 10:
576
                    $options[$h] = '';
577
                    break;
578
                case 11:
579
                    $options[$h] = '';
580
                    break;
581
                case 12:
582
                    $options[$h] = 120;
583
                    break;
584
                case 13:
585
                    $options[$h] = 120;
586
                    break;
587
            }
588
        }
589
    }
590
}
591