Completed
Branch master (77281f)
by Michael
03:56
created

ExtcalUtilities::getLighterColor()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
c 0
b 0
f 0
nc 1
nop 3
dl 0
loc 8
rs 9.4285
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 23 and the first side effect is on line 18.

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
 * classGenerator
4
 * walls_watermarks.
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
 * 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
 * L'utilisation de ce formulaire d'adminitration suppose
16
 * que la classe correspondante de la table a été générées avec classGenerator
17
 **/
18
include_once XOOPS_ROOT_PATH.'/class/uploader.php';
19
20
/**
21
 * Class ExtcalUtilities.
22
 */
23
class ExtcalUtilities
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
24
{
25
    /**
26
     * @param $eventId
27
     *
28
     * @return array
29
     */
30
    public static function extcal_getEvent($eventId)
31
    {
32
        $eventHandler = xoops_getModuleHandler(_EXTCAL_CLS_EVENT, _EXTCAL_MODULE);
33
        $event = $eventHandler->getEvent($eventId);
34
        $t = $event->getVars();
35
        $data = array();
36
        while (list($key, $val) = each($t)) {
37
            $data[$key] = $val['value'];
38
        }
39
40
        return $data;
41
    }
42
43
    /**
44
     * @param $REQUEST
45
     * @param $event_picture1
46
     * @param $event_picture2
47
     */
48
    public static function extcal_loadImg(&$REQUEST, &$event_picture1, &$event_picture2)
49
    {
50
        ///////////////////////////////////////////////////////////////////////////////
51
        $uploaddir_event = XOOPS_ROOT_PATH.'/uploads/extcal/';
52
        $uploadurl_event = XOOPS_URL.'/uploads/extcal/';
0 ignored issues
show
Unused Code introduced by
$uploadurl_event 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...
53
        //$picture = '';
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...
54
        for ($j = 1; $j < 3; ++$j) {
55
            $delimg = @$REQUEST['delimg_'.$j.''];
56
            $delimg = isset($delimg) ? (int) $delimg : 0;
57
            if (0 == $delimg && !empty($REQUEST['xoops_upload_file'][$j])) {
58
                $upload = new XoopsMediaUploader($uploaddir_event, array(
59
                    'image/gif',
60
                    'image/jpeg',
61
                    'image/pjpeg',
62
                    'image/x-png',
63
                    'image/png',
64
                    'image/jpg',
65
                ), 3145728, null, null);
66
                if ($upload->fetchMedia($REQUEST['xoops_upload_file'][$j])) {
67
                    $upload->setPrefix('event_');
68
                    $upload->fetchMedia($REQUEST['xoops_upload_file'][$j]);
69
                    if (!$upload->upload()) {
70
                        $errors = $upload->getErrors();
71
                        redirect_header('javascript:history.go(-1)', 3, $errors);
72
                    } else {
73
                        if ($j == 1) {
74
                            $event_picture1 = $upload->getSavedFileName();
75
                        } elseif ($j == 2) {
76
                            $event_picture2 = $upload->getSavedFileName();
77
                        }
78
                    }
79
                } elseif (!empty($REQUEST['file'.$j])) {
80
                    if ($j == 1) {
81
                        $event_picture1 = $REQUEST['file'.$j];
82
                    } elseif ($j == 2) {
83
                        $event_picture2 = $REQUEST['file'.$j];
84
                    }
85
                }
86
            } else {
87
                $url_event = XOOPS_ROOT_PATH.'/uploads/extcal/'.$REQUEST['file'.$j];
88
                if ($j == 1) {
89
                    $event_picture1 = '';
90
                } elseif ($j == 2) {
91
                    $event_picture2 = '';
92
                }
93
                if (is_file($url_event)) {
94
                    chmod($url_event, 0777);
95
                    unlink($url_event);
96
                }
97
            }
98
        }
99
        //exit;
100
        ///////////////////////////////////////////////////////////////////////////////
101
    }
102
103
    /*******************************************************************
104
     *
105
     ******************************************************************
106
     * @param        $cat
107
     * @param bool   $addNone
108
     * @param string $name
109
     * @return XoopsFormSelect
110
     */
111
    public static function getListCategories($cat, $addNone = true, $name = 'cat')
112
    {
113
        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...
114
        // Category selectbox
115
        $catHandler = xoops_getModuleHandler(_EXTCAL_CLS_CAT, _EXTCAL_MODULE);
116
117
        $catsList = $catHandler->getAllCat($xoopsUser);
118
        $catSelect = new XoopsFormSelect('', $name, $cat);
119
        if ($addNone) {
120
            $catSelect->addOption(0, ' ');
121
        }
122
123
        foreach ($catsList as $catList) {
124
            $catSelect->addOption($catList->getVar('cat_id'), $catList->getVar('cat_name'));
125
        }
126
127
        return $catSelect;
128
    }
129
130
    /*******************************************************************
131
     *
132
     ******************************************************************
133
     * @param string $name
134
     * @param        $cat
135
     * @return array
136
     */
137
    public static function getCheckeCategories($name = 'cat', $cat)
0 ignored issues
show
Unused Code introduced by
The parameter $name 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...
138
    {
139
        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...
140
        // Category selectbox
141
        //<option style="background-color:#00FFFF;">VARCHAR</option>
142
143
        $catHandler = xoops_getModuleHandler(_EXTCAL_CLS_CAT, _EXTCAL_MODULE);
144
        $catsList = $catHandler->getAllCat($xoopsUser);
145
146
        $t = array();
147
        foreach ($catsList as $catList) {
148
            $cat_id = $catList->getVar('cat_id');
149
            $name = $catList->getVar('cat_name');
150
            $cat_color = $catList->getVar('cat_color');
151
            $checked = in_array($cat_id, $cat) ? 'checked' : '';
152
            $cat = ''."<div style='float:left; margin-left:5px;'>"."<input type='checkbox' name='{$name}[{$cat_id}]' value='1' {$checked}>"
153
                         ."<div style='absolute:left;height:12px; width:6px; background-color:#{$cat_color}; border:1px solid black; float:left; margin-right:5px;' ></div>"." {$name}".'</div>';
154
155
            $t[] = $cat;
156
        }
157
158
        return $t;
159
    }
160
161
    /*******************************************************************
162
     *
163
     ******************************************************************
164
     * @param string $name
165
     * @param string $caption
166
     * @param        $defaut
167
     * @param bool   $addNone
168
     * @return XoopsFormSelect
169
     */
170
    public static function getListOrderBy($name = 'orderby', $caption = '', $defaut, $addNone = false)
171
    {
172
        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...
173
174
        $select = new XoopsFormSelect($caption, $name, $defaut);
175
        if ($addNone) {
176
            $select->addOption('', '');
177
        }
178
179
        $select->addOption('year ASC', _MD_EXTCAL_YEAR.' '._MD_EXTCAL_ORDER_BY_ASC);
180
        $select->addOption('year DESC', _MD_EXTCAL_YEAR.' '._MD_EXTCAL_ORDER_BY_DESC);
181
182
        $select->addOption('month ASC', _MD_EXTCAL_MONTH.' '._MD_EXTCAL_ORDER_BY_ASC);
183
        $select->addOption('month DESC', _MD_EXTCAL_MONTH.' '._MD_EXTCAL_ORDER_BY_DESC);
184
185
        $select->addOption('event_title ASC', _MD_EXTCAL_ALPHA.' '._MD_EXTCAL_ORDER_BY_ASC);
186
        $select->addOption('event_title DESC', _MD_EXTCAL_ALPHA.' '._MD_EXTCAL_ORDER_BY_DESC);
187
188
        $select->addOption('cat_name ASC', _MD_EXTCAL_CATEGORY.' '._MD_EXTCAL_ORDER_BY_ASC);
189
        $select->addOption('cat_name DESC', _MD_EXTCAL_CATEGORY.' '._MD_EXTCAL_ORDER_BY_DESC);
190
191
        return $select;
192
    }
193
194
    /*******************************************************************
195
     *
196
     ******************************************************************
197
     * @param string $name
198
     * @param string $caption
199
     * @param        $defaut
200
     * @return XoopsFormSelect
201
     */
202
    public static function getListAndOr($name = 'andor', $caption = '', $defaut)
203
    {
204
        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...
205
206
        $select = new XoopsFormSelect($caption, $name, $defaut);
207
208
        $select->addOption('AND', _MD_EXTCAL_AND);
209
        $select->addOption('OR', _MD_EXTCAL_OR);
210
211
        return $select;
212
    }
213
214
    /*******************************************************************
215
     *
216
     ******************************************************************
217
     * @param        $name
218
     * @param        $caption
219
     * @param        $defaut
220
     * @param        $options
221
     * @param string $sep
222
     * @return XoopsFormSelect
223
     */
224
    public static function getList($name, $caption, $defaut, $options, $sep = ';')
225
    {
226
        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...
227
228
        $select = new XoopsFormSelect($caption, $name, $defaut);
229
        if (!is_array($options)) {
230
            $options = explode($sep, $options);
231
        }
232
233
        for ($h = 0, $count = count($options); $h < $count; ++$h) {
234
            $select->addOption($h, $options[$h]);
235
        }
236
237
        return $select;
238
    }
239
240
    /*******************************************************************
241
     *
242
     ******************************************************************
243
     * @param        $ts
244
     * @param        $startMonth
245
     * @param        $endMonth
246
     * @param string $mode
247
     * @return DateTime
248
     */
249
    public static function getDateBetweenDates($ts, $startMonth, $endMonth, $mode = 'w')
0 ignored issues
show
Unused Code introduced by
The parameter $mode 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...
250
    {
251
        $d = new DateTime($periodStart);
0 ignored issues
show
Bug introduced by
The variable $periodStart does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
252
        $d->setTimestamp($ts);
253
254
        //echo "<br>affichage des periodes : <br>";
255
        $begin = new DateTime();
256
        $begin->setTimestamp($startMonth);
257
        //echo $begin->format("d/m/Y à H\hi:s").'<br>'; // 03/10/2007 à 19h39:53
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...
258
259
        $end = new DateTime();
260
        $end->setTimestamp($endMonth);
261
        //echo $end->format("d/m/Y à H\hi:s").'<br>'; // 03/10/2007 à 19h39:53
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...
262
        //echo "<hr>";
263
        $interval = DateInterval::createFromDateString('next sunday');
264
        $period = new DatePeriod($begin, $interval, $end);
0 ignored issues
show
Unused Code introduced by
$period 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...
265
        //echoDateArray($period);
266
267
        //echo "<hr>{$interval}";
268
        return $d;
269
270
        //echo mktime($heure, $minute, $seconde, $mois, $jour, $an);
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...
271
272
        //
273
        //   $jour = date('d', $ts);
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...
274
        //   $mois = date('m', $ts);
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...
275
        //   $an = date('Y', $ts);
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...
276
        //   $heure = date('H', $ts);
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...
277
        //   $minute = date('i', $ts);
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...
278
        //   $seconde = date('s', $ts);
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...
279
        //   $d->setDate($heure,$minute,$seconde,$mois,$jour,$an);
0 ignored issues
show
Unused Code Comprehensibility introduced by
89% 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...
280
281
        // <?php
282
        // $interval = DateInterval::createFromDateString('next sunday');
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...
283
        // $period = new DatePeriod($begin, $interval, $end);
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...
284
        // foreach ($period as $dt) {
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...
285
        //   echo $dt->format( "l Y-m-d H:i:s\n" );
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...
286
    }
287
288
    /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
57% 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...
289
    Sunday 2009-11-01 00:00:00
290
    Sunday 2009-11-08 00:00:00
291
    Sunday 2009-11-15 00:00:00
292
    Sunday 2009-11-22 00:00:00
293
    Sunday 2009-11-29 00:00:00
294
    Sunday 2009-12-06 00:00:00
295
    ...
296
    */
297
    /**
298
     * @param $period
299
     */
300
    public static function echoDateArray($period)
301
    {
302
        foreach ($period as $dt) {
303
            echo $dt->format("l Y-m-d H:i:s\n").'<br>';
304
        }
305
    }
306
307
    /*****************************************************************/
308
    /**
309
     * @param        $t
310
     * @param string $msg
311
     */
312
    public static function ext_echoArray($t, $msg = '')
313
    {
314
        if ($msg != '') {
315
            echo "<hr>{$msg}<hr>";
316
        }
317
318
        $txt = print_r($t, true);
319
        echo '<pre>Number of items: '.count($t)."<br>{$txt}</pre>";
320
    }
321
322
    /*****************************************************************/
323
    /**
324
     * @param        $line
325
     * @param string $msg
326
     */
327
    public static function ext_echo($line, $msg = '')
328
    {
329
        if ($msg != '') {
330
            echo "<hr>{$msg}<hr>";
331
        }
332
        echo $line.'<br>';
333
    }
334
335
    /*****************************************************************/
336
    /**
337
     * @param        $tsName
338
     * @param string $msg
339
     */
340
    public static function ext_echoTSN($tsName, $msg = '')
341
    {
342
        global $$tsName;
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...
343
        $ts = $$tsName;
344
        static::ext_echoTSU($ts, $tsName, $msg = '');
345
    }
346
347
    /*****************************************************************/
348
    /**
349
     * @param        $ts
350
     * @param        $tsName
351
     * @param string $msg
352
     */
353
    public static function ext_echoTSU($ts, $tsName, $msg = '')
354
    {
355
        if ($msg != '') {
356
            echo "<hr>{$msg}<hr>";
357
        }
358
359
        echo 'date --->'.$tsName.' = '.$ts.' - '.date('d-m-Y H:m:s', $ts).'<br>';
360
    }
361
362
    /*****************************************************************/
363
    /*****************************************************************/
364
    /**
365
     * @param        $date
366
     * @param string $sep
367
     *
368
     * @return int
0 ignored issues
show
Documentation introduced by
Should the return type not be integer|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...
369
     */
370
    public static function ext_convert_date($date, $sep = '-')
371
    {
372
        $lstSep = '/ .';
373
374
        for ($h = 0, $count = strlen($lstSep); $h < $count; ++$h) {
0 ignored issues
show
Unused Code introduced by
++$h; does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
375
            $sep2replace = substr($lstSep, $h, 1);
376
            if (strpos($date, $sep2replace)) {
377
                $date = str_replace($sep2replace, $sep, $date);
378
            }
379
380
            return strtotime($date);
381
        }
382
    }
383
384
    /**
385
     * @param     $givendate
386
     * @param int $day
387
     * @param int $mth
388
     * @param int $yr
389
     *
390
     * @return int
391
     */
392
    public static function ext_DateAdd($givendate, $day = 0, $mth = 0, $yr = 0)
393
    {
394
        //$cd = strtotime($givendate);
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...
395
        $cd = $givendate;
396
        $newdate = date('Y-m-d h:i:s', mktime(date('h', $cd), date('i', $cd), date('s', $cd), date('m', $cd) + $mth, date('d', $cd) + $day, date('Y', $cd) + $yr));
397
398
        return strtotime($newdate);
399
    }
400
401
    /**
402
     * @param $date
403
     * @param $number
404
     * @param $interval
405
     *
406
     * @return int
407
     */
408
    public static function ext_DateAdd2($date, $number, $interval = 'd')
409
    {
410
        $date_time_array = getdate($date);
411
        $hours = $date_time_array['hours'];
412
        $minutes = $date_time_array['minutes'];
413
        $seconds = $date_time_array['seconds'];
414
        $month = $date_time_array['mon'];
415
        $day = $date_time_array['mday'];
416
        $year = $date_time_array['year'];
417
418
        switch ($interval) {
419
420
            case 'yyyy':
421
                $year += $number;
422
                break;
423
            case 'q':
424
                $year += ($number * 3);
425
                break;
426
            case 'm':
427
                $month += $number;
428
                break;
429
            case 'y':
430
            case 'd':
431
            case 'w':
432
                $day += $number;
433
                break;
434
            case 'ww':
435
                $day += ($number * 7);
436
                break;
437
            case 'h':
438
                $hours += $number;
439
                break;
440
            case 'n':
441
                $minutes += $number;
442
                break;
443
            case 's':
444
                $seconds += $number;
445
                break;
446
        }
447
        $timestamp = mktime($hours, $minutes, $seconds, $month, $day, $year);
448
449
        return $timestamp;
450
    }
451
452
    // function date_diff($date1, $date2) {
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...
453
    //     $current = $date1;
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% 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...
454
    //     $datetime2 = date_create($date2);
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...
455
    //     $count = 0;
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% 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...
456
    //     while (date_create($current) < $datetime2) {
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...
457
    //         $current = gmdate("Y-m-d", strtotime("+1 day", strtotime($current)));
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...
458
    //         ++$count;
459
    //     }
460
    //     return $count;
461
    // }
462
463
    /**************************************************************************/
464
    /**
465
     * @param $color
466
     * @param $plancher
467
     * @param $plafond
468
     *
469
     * @return string
470
     */
471
    public static function getLighterColor($color, $plancher, $plafond)
472
    {
473
        include_once __DIR__.'/colorTools.php';
474
475
        //$ct = new ColorTools();
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...
476
        //return $ct->eclaircir($color,$plancher,$plafond);
0 ignored issues
show
Unused Code Comprehensibility introduced by
85% 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...
477
        return ColorTools::eclaircir($color, $plancher, $plafond);
478
    }
479
    /**************************************************************************/
480
}
481