1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
You may not change or alter any portion of this comment or credits |
5
|
|
|
of supporting developers from this source code or any supporting source code |
6
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
7
|
|
|
|
8
|
|
|
This program is distributed in the hope that it will be useful, |
9
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
10
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* wgEvents module for xoops |
15
|
|
|
* |
16
|
|
|
* @copyright 2021 XOOPS Project (https://xoops.org) |
17
|
|
|
* @license GPL 2.0 or later |
18
|
|
|
* @package wgevents |
19
|
|
|
* @since 1.0.0 |
20
|
|
|
* @min_xoops 2.5.11 Beta1 |
21
|
|
|
* @author Goffy - Wedega - Email:[email protected] - Website:https://xoops.wedega.com |
22
|
|
|
*/ |
23
|
|
|
|
24
|
|
|
use XoopsModules\Wgevents; |
25
|
|
|
use XoopsModules\Wgevents\Helper; |
26
|
|
|
use XoopsModules\Wgevents\Constants; |
27
|
|
|
|
28
|
|
|
require_once \XOOPS_ROOT_PATH . '/modules/wgevents/include/common.php'; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Function show block |
32
|
|
|
* @param $options |
33
|
|
|
* @return array |
34
|
|
|
*/ |
35
|
|
|
function b_wgevents_event_spotlight_show($options) |
36
|
|
|
{ |
37
|
|
|
$block = []; |
38
|
|
|
$typeBlock = $options[0]; |
|
|
|
|
39
|
|
|
$limit = $options[1]; |
40
|
|
|
$lengthTitle = $options[2]; |
|
|
|
|
41
|
|
|
$helper = Helper::getInstance(); |
42
|
|
|
$eventHandler = $helper->getHandler('Event'); |
43
|
|
|
$crEvent = new \CriteriaCompo(); |
44
|
|
|
\array_shift($options); |
45
|
|
|
\array_shift($options); |
46
|
|
|
\array_shift($options); |
47
|
|
|
|
48
|
|
|
$eventRegprocessbar = (string)$helper->getConfig('event_regprocessbar'); |
49
|
|
|
$GLOBALS['xoopsTpl']->assign('event_regprocessbar', $eventRegprocessbar); |
50
|
|
|
|
51
|
|
|
// Criteria for status field |
52
|
|
|
$crEvent->add(new \Criteria('status', Constants::STATUS_SUBMITTED, '>')); |
53
|
|
|
|
54
|
|
|
if (\count($options) > 0 && (int)$options[0] > 0) { |
55
|
|
|
$crEvent->add(new \Criteria('id', '(' . \implode(',', $options) . ')', 'IN')); |
56
|
|
|
$limit = 0; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
$crEvent->setSort('id'); |
60
|
|
|
$crEvent->setOrder('DESC'); |
61
|
|
|
$crEvent->setLimit($limit); |
62
|
|
|
$eventsAll = $eventHandler->getAll($crEvent); |
63
|
|
|
unset($crEvent); |
64
|
|
|
if (\count($eventsAll) > 0) { |
65
|
|
|
foreach (\array_keys($eventsAll) as $i) { |
66
|
|
|
/** |
67
|
|
|
* If you want to use the parameter for limits you have to adapt the line where it should be applied |
68
|
|
|
* e.g. change |
69
|
|
|
* $block[$i]['title'] = $eventsAll[$i]->getVar('art_title'); |
70
|
|
|
* into |
71
|
|
|
* $myTitle = $eventsAll[$i]->getVar('art_title'); |
72
|
|
|
* if ($limit > 0) { |
73
|
|
|
* $myTitle = \substr($myTitle, 0, (int)$limit); |
74
|
|
|
* } |
75
|
|
|
* $block[$i]['title'] = $myTitle; |
76
|
|
|
*/ |
77
|
|
|
$block[$i] = $eventsAll[$i]->getValuesEvents(); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
$GLOBALS['xoopsTpl']->assign('wgevents_upload_catlogos_url', \WGEVENTS_UPLOAD_CATLOGOS_URL); |
82
|
|
|
$GLOBALS['xoopsTpl']->assign('wgevents_upload_eventlogos_url', \WGEVENTS_UPLOAD_EVENTLOGOS_URL); |
83
|
|
|
$GLOBALS['xoopsTpl']->assign('wgevents_url', \WGEVENTS_URL . '/'); |
84
|
|
|
|
85
|
|
|
return $block; |
86
|
|
|
|
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Function edit block |
91
|
|
|
* @param $options |
92
|
|
|
* @return string |
93
|
|
|
*/ |
94
|
|
|
function b_wgevents_event_spotlight_edit($options) |
95
|
|
|
{ |
96
|
|
|
$helper = Helper::getInstance(); |
97
|
|
|
$eventHandler = $helper->getHandler('Event'); |
98
|
|
|
$GLOBALS['xoopsTpl']->assign('wgevents_upload_url', \WGEVENTS_UPLOAD_URL); |
99
|
|
|
$form = \_MB_WGEVENTS_DISPLAY_SPOTLIGHT . ' : '; |
100
|
|
|
$form .= "<input type='hidden' name='options[0]' value='".$options[0]."' >"; |
101
|
|
|
$form .= "<input type='text' name='options[1]' size='5' maxlength='255' value='" . $options[1] . "' > <br>"; |
102
|
|
|
$form .= \_MB_WGEVENTS_TITLE_LENGTH . " : <input type='text' name='options[2]' size='5' maxlength='255' value='" . $options[2] . "' ><br><br>"; |
103
|
|
|
\array_shift($options); |
104
|
|
|
\array_shift($options); |
105
|
|
|
\array_shift($options); |
106
|
|
|
|
107
|
|
|
$crEvent = new \CriteriaCompo(); |
108
|
|
|
$crEvent->add(new \Criteria('id', 0, '!=')); |
109
|
|
|
$crEvent->setSort('id'); |
110
|
|
|
$crEvent->setOrder('ASC'); |
111
|
|
|
$eventsAll = $eventHandler->getAll($crEvent); |
112
|
|
|
unset($crEvent); |
113
|
|
|
$form .= \_MB_WGEVENTS_EVENTS_TO_DISPLAY . "<br><select name='options[]' multiple='multiple' size='5'>"; |
114
|
|
|
$form .= "<option value='0' " . (!\in_array(0, $options) && !\in_array('0', $options) ? '' : "selected='selected'") . '>' . \_MB_WGEVENTS_ALL_EVENTS . '</option>'; |
115
|
|
|
foreach (\array_keys($eventsAll) as $i) { |
116
|
|
|
$id = $eventsAll[$i]->getVar('id'); |
117
|
|
|
$form .= "<option value='" . $id . "' " . (!\in_array($id, $options) ? '' : "selected='selected'") . '>' . $eventsAll[$i]->getVar('name') . '</option>'; |
118
|
|
|
} |
119
|
|
|
$form .= '</select>'; |
120
|
|
|
|
121
|
|
|
return $form; |
122
|
|
|
|
123
|
|
|
} |
124
|
|
|
|