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 https://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
|
|
|
use XoopsModules\Extcal\{Helper, |
21
|
|
|
Category, |
22
|
|
|
CategoryHandler, |
23
|
|
|
EventHandler |
24
|
|
|
}; |
25
|
|
|
|
26
|
|
|
require_once dirname(__DIR__) . '/include/constantes.php'; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @param $options |
30
|
|
|
* |
31
|
|
|
* @return array|bool |
32
|
|
|
*/ |
33
|
|
|
function bExtcalDayShow($options) |
34
|
|
|
{ |
35
|
|
|
// // require_once dirname(__DIR__) . '/class/Config.php'; |
36
|
|
|
|
37
|
|
|
/** @var Helper $helper */ |
38
|
|
|
if (!class_exists(Helper::class)) { |
39
|
|
|
return false; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
$helper = Helper::getInstance(); |
43
|
|
|
$helper->loadLanguage('main'); |
44
|
|
|
|
45
|
|
|
/** @var EventHandler $eventHandler */ |
46
|
|
|
$eventHandler = $helper->getHandler(_EXTCAL_CLN_EVENT); |
47
|
|
|
|
48
|
|
|
$nbEvent = $options[0]; |
49
|
|
|
$titleLenght = $options[1]; |
|
|
|
|
50
|
|
|
array_shift($options); |
51
|
|
|
array_shift($options); |
52
|
|
|
|
53
|
|
|
// Checking if no cat is selected |
54
|
|
|
if (isset($options[0]) && 0 == $options[0] && 1 == count($options)) { |
55
|
|
|
$options = 0; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
$events = $eventHandler->objectToArray($eventHandler->getThisDayEvent($nbEvent, $options)); |
59
|
|
|
$eventHandler->serverTimeToUserTimes($events); |
60
|
|
|
$eventHandler->formatEventsDate($events, $helper->getConfig('event_date_month')); |
61
|
|
|
|
62
|
|
|
return $events; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @param $options |
67
|
|
|
* |
68
|
|
|
* @return string |
69
|
|
|
*/ |
70
|
|
|
function bExtcalDayEdit($options) |
71
|
|
|
{ |
72
|
|
|
global $xoopsUser; |
73
|
|
|
|
74
|
|
|
// $categoryHandler = xoops_getModuleHandler(_EXTCAL_CLS_CAT, _EXTCAL_MODULE); |
75
|
|
|
/** @var CategoryHandler $categoryHandler */ |
76
|
|
|
$categoryHandler = Helper::getInstance()->getHandler(_EXTCAL_CLN_CAT); |
77
|
|
|
|
78
|
|
|
$cats = $categoryHandler->getAllCat($xoopsUser, 'extcal_cat_view'); |
79
|
|
|
|
80
|
|
|
$form = _MB_EXTCAL_DISPLAY . " \n"; |
81
|
|
|
$form .= '<input name="options[0]" size="5" maxlength="255" value="' . $options[0] . '" type="text"> ' . _MB_EXTCAL_EVENT . '<br>'; |
82
|
|
|
$form .= _MB_EXTCAL_TITLE_LENGTH . ' : <input name="options[1]" size="5" maxlength="255" value="' . $options[1] . '" type="text"><br>'; |
83
|
|
|
array_shift($options); |
84
|
|
|
array_shift($options); |
85
|
|
|
$form .= _MB_EXTCAL_CAT_TO_USE . '<br><select name="options[]" multiple="multiple" size="5">'; |
86
|
|
|
if (false === array_search(0, $options, true)) { |
87
|
|
|
$form .= '<option value="0">' . _MB_EXTCAL_ALL_CAT . '</option>'; |
88
|
|
|
} else { |
89
|
|
|
$form .= '<option value="0" selected="selected">' . _MB_EXTCAL_ALL_CAT . '</option>'; |
90
|
|
|
} |
91
|
|
|
/** @var Category $cat */ |
92
|
|
|
foreach ($cats as $cat) { |
93
|
|
|
if (false === array_search($cat->getVar('cat_id'), $options, true)) { |
94
|
|
|
$form .= '<option value="' . $cat->getVar('cat_id') . '">' . $cat->getVar('cat_name') . '</option>'; |
95
|
|
|
} else { |
96
|
|
|
$form .= '<option value="' . $cat->getVar('cat_id') . '" selected="selected">' . $cat->getVar('cat_name') . '</option>'; |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
$form .= '</select>'; |
100
|
|
|
|
101
|
|
|
return $form; |
102
|
|
|
} |
103
|
|
|
|