1
|
|
|
<?php namespace XoopsModules\Extcal; |
|
|
|
|
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* classGenerator |
5
|
|
|
* walls_watermarks. |
6
|
|
|
* |
7
|
|
|
* You may not change or alter any portion of this comment or credits |
8
|
|
|
* of supporting developers from this source code or any supporting source code |
9
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
10
|
|
|
* This program is distributed in the hope that it will be useful, |
11
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
13
|
|
|
* |
14
|
|
|
* |
15
|
|
|
* |
16
|
|
|
* L'utilisation de ce formulaire d'adminitration suppose |
17
|
|
|
* que la classe correspondante de la table a été générées avec classGenerator |
18
|
|
|
**/ |
19
|
|
|
require_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
|
|
|
20
|
|
|
|
21
|
|
|
use XoopsModules\Extcal; |
22
|
|
|
use XoopsModules\Extcal\Common; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Class Utility |
26
|
|
|
*/ |
27
|
|
|
class Utility |
28
|
|
|
{ |
29
|
|
|
use Common\VersionChecks; //checkVerXoops, checkVerPhp Traits |
30
|
|
|
|
31
|
|
|
use Common\ServerStats; // getServerStats Trait |
32
|
|
|
|
33
|
|
|
use Common\FilesManagement; // Files Management Trait |
34
|
|
|
|
35
|
|
|
//--------------- Custom module methods ----------------------------- |
36
|
|
|
/** |
37
|
|
|
* @param $eventId |
38
|
|
|
* |
39
|
|
|
* @return array |
40
|
|
|
*/ |
41
|
|
|
public static function getEvent($eventId) |
42
|
|
|
{ |
43
|
|
|
$eventHandler = Extcal\Helper::getInstance()->getHandler(_EXTCAL_CLN_EVENT); |
44
|
|
|
$event = $eventHandler->getEvent($eventId); |
45
|
|
|
$t = $event->getVars(); |
46
|
|
|
$data = []; |
47
|
|
|
// while (list($key, $val) = each($t)) { |
|
|
|
|
48
|
|
|
foreach ($t as $key => $val) { |
49
|
|
|
$data[$key] = $val['value']; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
return $data; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @param $REQUEST |
57
|
|
|
* @param $event_picture1 |
58
|
|
|
* @param $event_picture2 |
59
|
|
|
*/ |
60
|
|
|
public static function loadImg(&$REQUEST, &$event_picture1, &$event_picture2) |
61
|
|
|
{ |
62
|
|
|
/////////////////////////////////////////////////////////////////////////////// |
63
|
|
|
$uploaddir_event = XOOPS_ROOT_PATH . '/uploads/extcal/'; |
|
|
|
|
64
|
|
|
$uploadurl_event = XOOPS_URL . '/uploads/extcal/'; |
|
|
|
|
65
|
|
|
//$picture = ''; |
|
|
|
|
66
|
|
|
for ($j = 1; $j < 3; ++$j) { |
67
|
|
|
$delimg = @$REQUEST['delimg_' . $j . '']; |
68
|
|
|
$delimg = isset($delimg) ? (int)$delimg : 0; |
69
|
|
|
if (0 == $delimg && !empty($REQUEST['xoops_upload_file'][$j])) { |
70
|
|
|
$upload = new \XoopsMediaUploader($uploaddir_event, [ |
|
|
|
|
71
|
|
|
'image/gif', |
72
|
|
|
'image/jpeg', |
73
|
|
|
'image/pjpeg', |
74
|
|
|
'image/x-png', |
75
|
|
|
'image/png', |
76
|
|
|
'image/jpg', |
77
|
|
|
], 3145728, null, null); |
78
|
|
|
if ($upload->fetchMedia($REQUEST['xoops_upload_file'][$j])) { |
79
|
|
|
$upload->setPrefix('event_'); |
80
|
|
|
$upload->fetchMedia($REQUEST['xoops_upload_file'][$j]); |
81
|
|
|
if (!$upload->upload()) { |
82
|
|
|
$errors = $upload->getErrors(); |
83
|
|
|
redirect_header('javascript:history.go(-1)', 3, $errors); |
|
|
|
|
84
|
|
|
} else { |
85
|
|
|
if (1 == $j) { |
86
|
|
|
$event_picture1 = $upload->getSavedFileName(); |
87
|
|
|
} elseif (2 == $j) { |
88
|
|
|
$event_picture2 = $upload->getSavedFileName(); |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
} elseif (!empty($REQUEST['file' . $j])) { |
92
|
|
|
if (1 == $j) { |
93
|
|
|
$event_picture1 = $REQUEST['file' . $j]; |
94
|
|
|
} elseif (2 == $j) { |
95
|
|
|
$event_picture2 = $REQUEST['file' . $j]; |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
} else { |
99
|
|
|
$url_event = XOOPS_ROOT_PATH . '/uploads/extcal/' . $REQUEST['file' . $j]; |
100
|
|
|
if (1 == $j) { |
101
|
|
|
$event_picture1 = ''; |
102
|
|
|
} elseif (2 == $j) { |
103
|
|
|
$event_picture2 = ''; |
104
|
|
|
} |
105
|
|
|
if (is_file($url_event)) { |
106
|
|
|
chmod($url_event, 0777); |
107
|
|
|
unlink($url_event); |
108
|
|
|
} |
109
|
|
|
} |
110
|
|
|
} |
111
|
|
|
//exit; |
112
|
|
|
/////////////////////////////////////////////////////////////////////////////// |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/******************************************************************* |
116
|
|
|
* |
117
|
|
|
****************************************************************** |
118
|
|
|
* @param $cat |
119
|
|
|
* @param bool $addNone |
120
|
|
|
* @param string $name |
121
|
|
|
* @return \XoopsFormSelect |
122
|
|
|
*/ |
123
|
|
|
public static function getListCategories($cat, $addNone = true, $name = 'cat') |
124
|
|
|
{ |
125
|
|
|
global $xoopsUser; |
|
|
|
|
126
|
|
|
// Category selectbox |
127
|
|
|
$catHandler = Extcal\Helper::getInstance()->getHandler(_EXTCAL_CLN_CAT); |
128
|
|
|
|
129
|
|
|
$catsList = $catHandler->getAllCat($xoopsUser); |
130
|
|
|
$catSelect = new \XoopsFormSelect('', $name, $cat); |
|
|
|
|
131
|
|
|
if ($addNone) { |
132
|
|
|
$catSelect->addOption(0, ' '); |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
foreach ($catsList as $catList) { |
136
|
|
|
$catSelect->addOption($catList->getVar('cat_id'), $catList->getVar('cat_name')); |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
return $catSelect; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/******************************************************************* |
143
|
|
|
* |
144
|
|
|
****************************************************************** |
145
|
|
|
* @param string $name |
146
|
|
|
* @param $cat |
147
|
|
|
* @return array |
148
|
|
|
*/ |
149
|
|
|
public static function getCheckeCategories($name = 'cat', $cat) |
|
|
|
|
150
|
|
|
{ |
151
|
|
|
global $xoopsUser; |
|
|
|
|
152
|
|
|
// Category selectbox |
153
|
|
|
//<option style="background-color:#00FFFF;">VARCHAR</option> |
154
|
|
|
|
155
|
|
|
$catHandler = Extcal\Helper::getInstance()->getHandler(_EXTCAL_CLN_CAT); |
156
|
|
|
$catsList = $catHandler->getAllCat($xoopsUser); |
157
|
|
|
|
158
|
|
|
$t = []; |
159
|
|
|
foreach ($catsList as $catList) { |
160
|
|
|
$cat_id = $catList->getVar('cat_id'); |
161
|
|
|
$name = $catList->getVar('cat_name'); |
162
|
|
|
$cat_color = $catList->getVar('cat_color'); |
163
|
|
|
$checked = in_array($cat_id, $cat) ? 'checked' : ''; |
164
|
|
|
$cat = '' |
165
|
|
|
. "<div style='float:left; margin-left:5px;'>" |
166
|
|
|
. "<input type='checkbox' name='{$name}[{$cat_id}]' value='1' {$checked}>" |
167
|
|
|
. "<div style='absolute:left;height:12px; width:6px; background-color:#{$cat_color}; border:1px solid black; float:left; margin-right:5px;' ></div>" |
168
|
|
|
. " {$name}" |
169
|
|
|
. '</div>'; |
170
|
|
|
|
171
|
|
|
$t[] = $cat; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
return $t; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/******************************************************************* |
178
|
|
|
* |
179
|
|
|
****************************************************************** |
180
|
|
|
* @param string $name |
181
|
|
|
* @param string $caption |
182
|
|
|
* @param $defaut |
183
|
|
|
* @param bool $addNone |
184
|
|
|
* @return \XoopsFormSelect |
185
|
|
|
*/ |
186
|
|
|
public static function getListOrderBy($name = 'orderby', $caption = '', $defaut, $addNone = false) |
187
|
|
|
{ |
188
|
|
|
global $xoopsUser; |
|
|
|
|
189
|
|
|
|
190
|
|
|
$select = new \XoopsFormSelect($caption, $name, $defaut); |
191
|
|
|
if ($addNone) { |
192
|
|
|
$select->addOption('', ''); |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
$select->addOption('year ASC', _MD_EXTCAL_YEAR . ' ' . _MD_EXTCAL_ORDER_BY_ASC); |
196
|
|
|
$select->addOption('year DESC', _MD_EXTCAL_YEAR . ' ' . _MD_EXTCAL_ORDER_BY_DESC); |
197
|
|
|
|
198
|
|
|
$select->addOption('month ASC', _MD_EXTCAL_MONTH . ' ' . _MD_EXTCAL_ORDER_BY_ASC); |
199
|
|
|
$select->addOption('month DESC', _MD_EXTCAL_MONTH . ' ' . _MD_EXTCAL_ORDER_BY_DESC); |
200
|
|
|
|
201
|
|
|
$select->addOption('event_title ASC', _MD_EXTCAL_ALPHA . ' ' . _MD_EXTCAL_ORDER_BY_ASC); |
202
|
|
|
$select->addOption('event_title DESC', _MD_EXTCAL_ALPHA . ' ' . _MD_EXTCAL_ORDER_BY_DESC); |
203
|
|
|
|
204
|
|
|
$select->addOption('cat_name ASC', _MD_EXTCAL_CATEGORY . ' ' . _MD_EXTCAL_ORDER_BY_ASC); |
205
|
|
|
$select->addOption('cat_name DESC', _MD_EXTCAL_CATEGORY . ' ' . _MD_EXTCAL_ORDER_BY_DESC); |
206
|
|
|
|
207
|
|
|
return $select; |
208
|
|
|
} |
209
|
|
|
|
210
|
|
|
/******************************************************************* |
211
|
|
|
* |
212
|
|
|
****************************************************************** |
213
|
|
|
* @param string $name |
214
|
|
|
* @param string $caption |
215
|
|
|
* @param $defaut |
216
|
|
|
* @return \XoopsFormSelect |
217
|
|
|
*/ |
218
|
|
|
public static function getListAndOr($name = 'andor', $caption = '', $defaut) |
219
|
|
|
{ |
220
|
|
|
global $xoopsUser; |
|
|
|
|
221
|
|
|
|
222
|
|
|
$select = new \XoopsFormSelect($caption, $name, $defaut); |
223
|
|
|
|
224
|
|
|
$select->addOption('AND', _MD_EXTCAL_AND); |
225
|
|
|
$select->addOption('OR', _MD_EXTCAL_OR); |
226
|
|
|
|
227
|
|
|
return $select; |
228
|
|
|
} |
229
|
|
|
|
230
|
|
|
/******************************************************************* |
231
|
|
|
* |
232
|
|
|
****************************************************************** |
233
|
|
|
* @param $name |
234
|
|
|
* @param $caption |
235
|
|
|
* @param $defaut |
236
|
|
|
* @param $options |
237
|
|
|
* @param string $sep |
238
|
|
|
* @return \XoopsFormSelect |
239
|
|
|
*/ |
240
|
|
|
public static function getList($name, $caption, $defaut, $options, $sep = ';') |
241
|
|
|
{ |
242
|
|
|
global $xoopsUser; |
|
|
|
|
243
|
|
|
|
244
|
|
|
$select = new \XoopsFormSelect($caption, $name, $defaut); |
245
|
|
|
if (!is_array($options)) { |
246
|
|
|
$options = explode($sep, $options); |
247
|
|
|
} |
248
|
|
|
|
249
|
|
|
foreach ($options as $h => $hValue) { |
250
|
|
|
$select->addOption($h, $options[$h]); |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
return $select; |
254
|
|
|
} |
255
|
|
|
|
256
|
|
|
/******************************************************************* |
257
|
|
|
* |
258
|
|
|
****************************************************************** |
259
|
|
|
* @param $ts |
260
|
|
|
* @param $startMonth |
261
|
|
|
* @param $endMonth |
262
|
|
|
* @param string $mode |
263
|
|
|
* @return \DateTime |
264
|
|
|
*/ |
265
|
|
|
public static function getDateBetweenDates($ts, $startMonth, $endMonth, $mode = 'w') |
|
|
|
|
266
|
|
|
{ |
267
|
|
|
$d = new \DateTime($periodStart); |
|
|
|
|
268
|
|
|
$d->setTimestamp($ts); |
269
|
|
|
|
270
|
|
|
//echo "<br>affichage des periodes : <br>"; |
271
|
|
|
$begin = new \DateTime(); |
272
|
|
|
$begin->setTimestamp($startMonth); |
273
|
|
|
//echo $begin->format("d/m/Y à H\hi:s").'<br>'; // 03/10/2007 à 19h39:53 |
|
|
|
|
274
|
|
|
|
275
|
|
|
$end = new \DateTime(); |
276
|
|
|
$end->setTimestamp($endMonth); |
277
|
|
|
//echo $end->format("d/m/Y à H\hi:s").'<br>'; // 03/10/2007 à 19h39:53 |
|
|
|
|
278
|
|
|
//echo "<hr>"; |
279
|
|
|
$interval = \DateInterval::createFromDateString('next sunday'); |
280
|
|
|
$period = new \DatePeriod($begin, $interval, $end); |
|
|
|
|
281
|
|
|
//echoDateArray($period); |
282
|
|
|
|
283
|
|
|
//echo "<hr>{$interval}"; |
284
|
|
|
return $d; |
285
|
|
|
|
286
|
|
|
//echo mktime($heure, $minute, $seconde, $mois, $jour, $an); |
|
|
|
|
287
|
|
|
|
288
|
|
|
// |
289
|
|
|
// $jour = date('d', $ts); |
|
|
|
|
290
|
|
|
// $mois = date('m', $ts); |
|
|
|
|
291
|
|
|
// $an = date('Y', $ts); |
|
|
|
|
292
|
|
|
// $heure = date('H', $ts); |
|
|
|
|
293
|
|
|
// $minute = date('i', $ts); |
|
|
|
|
294
|
|
|
// $seconde = date('s', $ts); |
|
|
|
|
295
|
|
|
// $d->setDate($heure,$minute,$seconde,$mois,$jour,$an); |
|
|
|
|
296
|
|
|
|
297
|
|
|
// <?php |
298
|
|
|
// $interval = DateInterval::createFromDateString('next sunday'); |
|
|
|
|
299
|
|
|
// $period = new \DatePeriod($begin, $interval, $end); |
|
|
|
|
300
|
|
|
// foreach ($period as $dt) { |
|
|
|
|
301
|
|
|
// echo $dt->format( "l Y-m-d H:i:s\n" ); |
|
|
|
|
302
|
|
|
} |
303
|
|
|
|
304
|
|
|
/* |
|
|
|
|
305
|
|
|
Sunday 2009-11-01 00:00:00 |
306
|
|
|
Sunday 2009-11-08 00:00:00 |
307
|
|
|
Sunday 2009-11-15 00:00:00 |
308
|
|
|
Sunday 2009-11-22 00:00:00 |
309
|
|
|
Sunday 2009-11-29 00:00:00 |
310
|
|
|
Sunday 2009-12-06 00:00:00 |
311
|
|
|
... |
312
|
|
|
*/ |
313
|
|
|
/** |
314
|
|
|
* @param $period |
315
|
|
|
*/ |
316
|
|
|
public static function echoDateArray($period) |
317
|
|
|
{ |
318
|
|
|
foreach ($period as $dt) { |
319
|
|
|
echo $dt->format("l Y-m-d H:i:s\n") . '<br>'; |
320
|
|
|
} |
321
|
|
|
} |
322
|
|
|
|
323
|
|
|
/*****************************************************************/ |
324
|
|
|
/** |
325
|
|
|
* @param $t |
326
|
|
|
* @param string $msg |
327
|
|
|
*/ |
328
|
|
|
public static function echoArray($t, $msg = '') |
329
|
|
|
{ |
330
|
|
|
if ('' != $msg) { |
331
|
|
|
echo "<hr>{$msg}<hr>"; |
332
|
|
|
} |
333
|
|
|
|
334
|
|
|
$txt = print_r($t, true); |
335
|
|
|
echo '<pre>Number of items: ' . count($t) . "<br>{$txt}</pre>"; |
336
|
|
|
} |
337
|
|
|
|
338
|
|
|
/*****************************************************************/ |
339
|
|
|
/** |
340
|
|
|
* @param $line |
341
|
|
|
* @param string $msg |
342
|
|
|
*/ |
343
|
|
|
public static function extEcho($line, $msg = '') |
344
|
|
|
{ |
345
|
|
|
if ('' != $msg) { |
346
|
|
|
echo "<hr>{$msg}<hr>"; |
347
|
|
|
} |
348
|
|
|
echo $line . '<br>'; |
349
|
|
|
} |
350
|
|
|
|
351
|
|
|
/*****************************************************************/ |
352
|
|
|
/** |
353
|
|
|
* @param $tsName |
354
|
|
|
* @param string $msg |
355
|
|
|
*/ |
356
|
|
|
public static function echoTsn($tsName, $msg = '') |
357
|
|
|
{ |
358
|
|
|
global $$tsName; |
|
|
|
|
359
|
|
|
$ts = $$tsName; |
360
|
|
|
static::echoTsu($ts, $tsName, $msg = ''); |
361
|
|
|
} |
362
|
|
|
|
363
|
|
|
/*****************************************************************/ |
364
|
|
|
/** |
365
|
|
|
* @param $ts |
366
|
|
|
* @param $tsName |
367
|
|
|
* @param string $msg |
368
|
|
|
*/ |
369
|
|
|
public static function echoTsu($ts, $tsName, $msg = '') |
370
|
|
|
{ |
371
|
|
|
if ('' != $msg) { |
372
|
|
|
echo "<hr>{$msg}<hr>"; |
373
|
|
|
} |
374
|
|
|
|
375
|
|
|
echo 'date --->' . $tsName . ' = ' . $ts . ' - ' . date('d-m-Y H:m:s', $ts) . '<br>'; |
376
|
|
|
} |
377
|
|
|
|
378
|
|
|
/*****************************************************************/ |
379
|
|
|
/*****************************************************************/ |
380
|
|
|
/** |
381
|
|
|
* @param $date |
382
|
|
|
* @param string $sep |
383
|
|
|
* |
384
|
|
|
* @return int |
385
|
|
|
*/ |
386
|
|
|
public static function convertDate($date, $sep = '-') |
387
|
|
|
{ |
388
|
|
|
$lstSep = '/ .'; |
389
|
|
|
|
390
|
|
|
for ($h = 0, $count = strlen($lstSep); $h < $count; ++$h) { |
|
|
|
|
391
|
|
|
$sep2replace = substr($lstSep, $h, 1); |
392
|
|
|
if (strpos($date, $sep2replace)) { |
393
|
|
|
$date = str_replace($sep2replace, $sep, $date); |
394
|
|
|
} |
395
|
|
|
|
396
|
|
|
return strtotime($date); |
397
|
|
|
} |
398
|
|
|
} |
399
|
|
|
|
400
|
|
|
/** |
401
|
|
|
* @param $givendate |
402
|
|
|
* @param int $day |
403
|
|
|
* @param int $mth |
404
|
|
|
* @param int $yr |
405
|
|
|
* |
406
|
|
|
* @return int |
407
|
|
|
*/ |
408
|
|
|
public static function addDate($givendate, $day = 0, $mth = 0, $yr = 0) |
409
|
|
|
{ |
410
|
|
|
//$cd = strtotime($givendate); |
|
|
|
|
411
|
|
|
$cd = $givendate; |
412
|
|
|
$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)); |
|
|
|
|
413
|
|
|
|
414
|
|
|
return strtotime($newdate); |
415
|
|
|
} |
416
|
|
|
|
417
|
|
|
/** |
418
|
|
|
* @param $date |
419
|
|
|
* @param $number |
420
|
|
|
* @param $interval |
421
|
|
|
* |
422
|
|
|
* @return int |
423
|
|
|
*/ |
424
|
|
|
public static function addDate2($date, $number, $interval = 'd') |
425
|
|
|
{ |
426
|
|
|
$date_time_array = getdate($date); |
427
|
|
|
$hours = $date_time_array['hours']; |
428
|
|
|
$minutes = $date_time_array['minutes']; |
429
|
|
|
$seconds = $date_time_array['seconds']; |
430
|
|
|
$month = $date_time_array['mon']; |
431
|
|
|
$day = $date_time_array['mday']; |
432
|
|
|
$year = $date_time_array['year']; |
433
|
|
|
|
434
|
|
|
switch ($interval) { |
435
|
|
|
|
436
|
|
|
case 'yyyy': |
437
|
|
|
$year += $number; |
438
|
|
|
break; |
439
|
|
|
case 'q': |
440
|
|
|
$year += ($number * 3); |
441
|
|
|
break; |
442
|
|
|
case 'm': |
443
|
|
|
$month += $number; |
444
|
|
|
break; |
445
|
|
|
case 'y': |
446
|
|
|
case 'd': |
447
|
|
|
case 'w': |
448
|
|
|
$day += $number; |
449
|
|
|
break; |
450
|
|
|
case 'ww': |
451
|
|
|
$day += ($number * 7); |
452
|
|
|
break; |
453
|
|
|
case 'h': |
454
|
|
|
$hours += $number; |
455
|
|
|
break; |
456
|
|
|
case 'n': |
457
|
|
|
$minutes += $number; |
458
|
|
|
break; |
459
|
|
|
case 's': |
460
|
|
|
$seconds += $number; |
461
|
|
|
break; |
462
|
|
|
} |
463
|
|
|
$timestamp = mktime($hours, $minutes, $seconds, $month, $day, $year); |
464
|
|
|
|
465
|
|
|
return $timestamp; |
466
|
|
|
} |
467
|
|
|
|
468
|
|
|
// function date_diff($date1, $date2) { |
|
|
|
|
469
|
|
|
// $current = $date1; |
|
|
|
|
470
|
|
|
// $datetime2 = date_create($date2); |
|
|
|
|
471
|
|
|
// $count = 0; |
|
|
|
|
472
|
|
|
// while (date_create($current) < $datetime2) { |
|
|
|
|
473
|
|
|
// $current = gmdate("Y-m-d", strtotime("+1 day", strtotime($current))); |
|
|
|
|
474
|
|
|
// ++$count; |
475
|
|
|
// } |
476
|
|
|
// return $count; |
477
|
|
|
// } |
478
|
|
|
|
479
|
|
|
/**************************************************************************/ |
480
|
|
|
/** |
481
|
|
|
* @param $color |
482
|
|
|
* @param $plancher |
483
|
|
|
* @param $plafond |
484
|
|
|
* |
485
|
|
|
* @return string |
486
|
|
|
*/ |
487
|
|
|
public static function getLighterColor($color, $plancher, $plafond) |
488
|
|
|
{ |
489
|
|
|
require_once __DIR__ . '/ColorTools.php'; |
490
|
|
|
|
491
|
|
|
//$ct = new \ColorTools(); |
|
|
|
|
492
|
|
|
//return $ct->eclaircir($color,$plancher,$plafond); |
|
|
|
|
493
|
|
|
return ColorTools::eclaircir($color, $plancher, $plafond); |
494
|
|
|
} |
495
|
|
|
/**************************************************************************/ |
496
|
|
|
|
497
|
|
|
} |
498
|
|
|
|
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.