|
1
|
|
|
<?php |
|
|
|
|
|
|
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; |
|
|
|
|
|
|
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) |
|
|
|
|
|
|
31
|
|
|
{ |
|
32
|
|
|
global $extcalConfig, $xoopsUser; |
|
|
|
|
|
|
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(); |
|
|
|
|
|
|
72
|
|
|
//$xoopsModuleConfig = $extcalConfig->getModuleConfig(); |
|
|
|
|
|
|
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); |
|
|
|
|
|
|
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)); |
|
|
|
|
|
|
119
|
|
|
if (true) { |
|
|
|
|
|
|
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'); |
|
|
|
|
|
|
132
|
|
|
/***************************************************************/ |
|
133
|
|
|
//$eventHandler->formatEventDate($events, "l dS \of F Y h:i A"); |
|
|
|
|
|
|
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']) { |
|
|
|
|
|
|
147
|
|
|
// bExtcalMinicalAddEventToArray($event, $eventsArray, $extcalTimeHandler, $startMonth, $endMonth, $cats); |
|
|
|
|
|
|
148
|
|
|
// } else { |
|
|
|
|
|
|
149
|
|
|
// |
|
150
|
|
|
// $recurEvents = $eventHandler->getRecurEventToDisplay($event, $startMonth, $endMonth); |
|
|
|
|
|
|
151
|
|
|
// foreach ($recurEvents as $recurEvent) |
|
|
|
|
|
|
152
|
|
|
// { |
|
153
|
|
|
// bExtcalMinicalAddEventToArray($recurEvent, $eventsArray, $extcalTimeHandler, $startMonth, $endMonth, $cats); |
|
|
|
|
|
|
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'); |
|
|
|
|
|
|
205
|
|
|
|
|
206
|
|
|
$weekdayNames = Calendar_Util_Textual::weekdayNames('one'); |
|
207
|
|
|
//$weekdayNames=array('D','L','M','M','J','V','S'); |
|
|
|
|
|
|
208
|
|
|
|
|
209
|
|
|
// echo "<hr>L'identifiant de l'allemand sur ce système est '$loc_de'"; |
|
210
|
|
|
// echoArray($weekdayNames,true); |
|
|
|
|
|
|
211
|
|
|
|
|
212
|
|
View Code Duplication |
for ($i = 0; $i < $extcalConfig['week_start_day']; ++$i) { |
|
|
|
|
|
|
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() . '&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); |
|
|
|
|
|
|
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; |
|
|
|
|
|
|
256
|
|
|
|
|
257
|
|
|
// $t = print_r(get_defined_vars(),true); |
|
|
|
|
|
|
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"'); |
|
|
|
|
|
|
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); |
|
|
|
|
|
|
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) |
|
|
|
|
|
|
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(); |
|
|
|
|
|
|
378
|
|
|
// while (list($key,$val) = each($xfValue)) { |
|
|
|
|
|
|
379
|
|
|
// $t[] = $val->render(); |
|
|
|
|
|
|
380
|
|
|
// } |
|
381
|
|
|
// return implode("\n", $t); |
|
|
|
|
|
|
382
|
|
|
|
|
383
|
|
|
// return extcal_buildHtmlArray($xfValue, _OPTIONS); |
|
|
|
|
|
|
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'); |
|
|
|
|
|
|
434
|
|
|
$photo = clone $tempPhoto; |
|
435
|
|
|
$photo = $photos->appendChild($photo); |
|
436
|
|
|
|
|
437
|
|
|
// $src = $doc->createElement('src'); |
|
|
|
|
|
|
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'); |
|
|
|
|
|
|
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 |
|
|
|
|
|
|
458
|
|
|
*/ |
|
459
|
|
|
function bExtcalMinicalAddEventToArray($event, &$eventsArray, $extcalTimeHandler, $startMonth, $endMonth, $cats) |
|
|
|
|
|
|
460
|
|
|
{ |
|
461
|
|
|
// ext_echoArray($event); |
|
|
|
|
|
|
462
|
|
|
// exit; |
|
463
|
|
|
// $d1 = date("j, m, Y", $startMonth); |
|
|
|
|
|
|
464
|
|
|
// $d2 = date("j, m, Y", $endMonth); |
|
|
|
|
|
|
465
|
|
|
// echo "bExtcalMinicalAddEventToArray : {$d1} - {$d2}<br>"; |
|
466
|
|
|
// $d1 = date("j, m, Y", $event['event_start']); |
|
|
|
|
|
|
467
|
|
|
// $d2 = date("j, m, Y", $event['event_end']); |
|
|
|
|
|
|
468
|
|
|
// echo "bExtcalMinicalAddEventToArray : {$d1} - {$d2}<br>"; |
|
469
|
|
|
|
|
470
|
|
|
// $color = $cats[$event['cat_id']]['cat_color']; |
|
|
|
|
|
|
471
|
|
|
// $weight = $cats[$event['cat_id']]['cat_weight']; |
|
|
|
|
|
|
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']"); |
|
|
|
|
|
|
479
|
|
|
// ext_echoTSU($event['event_end'],"event['event_end']"); |
|
|
|
|
|
|
480
|
|
|
|
|
481
|
|
|
//--------------------------------------------------------------- |
|
482
|
|
View Code Duplication |
if ($startEvent < $startMonth) { |
|
|
|
|
|
|
483
|
|
|
$firstDay = 1; |
|
|
|
|
|
|
484
|
|
|
} elseif ($startEvent > $endEvent) { |
|
485
|
|
|
return false; |
|
486
|
|
|
} else { |
|
487
|
|
|
$firstDay = date('j', $startEvent); |
|
|
|
|
|
|
488
|
|
|
} |
|
489
|
|
|
|
|
490
|
|
View Code Duplication |
if ($endEvent < $startMonth) { |
|
|
|
|
|
|
491
|
|
|
return false; |
|
492
|
|
|
} elseif ($endEvent > $endMonth) { |
|
493
|
|
|
$lastDay = date('j', $endMonth); |
|
|
|
|
|
|
494
|
|
|
} else { |
|
495
|
|
|
$lastDay = date('j', $endEvent); |
|
|
|
|
|
|
496
|
|
|
} |
|
497
|
|
|
|
|
498
|
|
|
//echo "first dat - last day : {$firstDay} - {$lastDay}<br>"; |
|
499
|
|
|
//echo $event['event_id'] . '-' . $weight .'<br>'; |
|
|
|
|
|
|
500
|
|
|
|
|
501
|
|
|
$d = date('j', $event['event_start']); |
|
502
|
|
|
if (isset($eventsArray[$d])) { |
|
503
|
|
View Code Duplication |
if ($weight > $eventsArray[$d]['weight']) { |
|
|
|
|
|
|
504
|
|
|
$eventsArray[$d]['weight'] = $weight; |
|
505
|
|
|
$eventsArray[$d]['color'] = $color; |
|
506
|
|
|
} |
|
507
|
|
View Code Duplication |
} else { |
|
|
|
|
|
|
508
|
|
|
$eventsArray[$d]['hasEvent'] = true; |
|
509
|
|
|
$eventsArray[$d]['weight'] = $weight; |
|
510
|
|
|
$eventsArray[$d]['color'] = $color; |
|
511
|
|
|
} |
|
512
|
|
|
/* |
|
|
|
|
|
|
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); |
|
|
|
|
|
|
530
|
|
|
// echo "<pre>{$t}</pre><hr>"; |
|
531
|
|
|
// |
|
532
|
|
|
// $t = print_r($eventsArray,true); |
|
|
|
|
|
|
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 |
|
|
|
|
|
|
542
|
|
|
for ($h = 0; $h <= 13; ++$h) { |
|
543
|
|
|
if (!isset($options[$h])) { |
|
544
|
|
|
switch ($h) { |
|
545
|
|
|
case 0: |
|
|
|
|
|
|
546
|
|
|
$options[$h] = '0'; |
|
547
|
|
|
break; |
|
548
|
|
|
case 1: |
|
|
|
|
|
|
549
|
|
|
$options[$h] = 0; |
|
550
|
|
|
break; |
|
551
|
|
|
case 2: |
|
|
|
|
|
|
552
|
|
|
$options[$h] = '150'; |
|
553
|
|
|
break; |
|
554
|
|
|
case 3: |
|
|
|
|
|
|
555
|
|
|
$options[$h] = '255'; |
|
556
|
|
|
break; |
|
557
|
|
|
case 4: |
|
|
|
|
|
|
558
|
|
|
$options[$h] = '1'; |
|
559
|
|
|
break; |
|
560
|
|
|
case 5: |
|
|
|
|
|
|
561
|
|
|
$options[$h] = '3'; |
|
562
|
|
|
break; |
|
563
|
|
|
case 6: |
|
|
|
|
|
|
564
|
|
|
$options[$h] = '10'; |
|
565
|
|
|
break; |
|
566
|
|
|
case 7: |
|
|
|
|
|
|
567
|
|
|
$options[$h] = '0'; |
|
568
|
|
|
break; |
|
569
|
|
|
case 8: |
|
|
|
|
|
|
570
|
|
|
$options[$h] = '1'; |
|
571
|
|
|
break; |
|
572
|
|
|
case 9: |
|
|
|
|
|
|
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
|
|
|
|
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.