Passed
Push — master ( d055a2...691b2e )
by Goffy
14:00
created

EventHandler   F

Complexity

Total Complexity 61

Size/Duplication

Total Lines 515
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 237
dl 0
loc 515
rs 3.52
c 2
b 0
f 0
wmc 61

14 Methods

Rating   Name   Duplication   Size   Complexity  
A getInsertId() 0 3 1
A create() 0 3 1
A get() 0 3 1
A getCountEvents() 0 5 1
A getAllEvents() 0 5 1
A __construct() 0 3 1
A getFormEventSelect() 0 21 2
A getEventsCriteria() 0 7 1
A getFormPageNavCounter() 0 29 2
F getEvents() 0 125 19
A getRecipientsNotify() 0 16 5
B getFormFilterExport() 0 56 5
B getDateFromToText() 0 49 11
B getEventsCompare() 0 63 10

How to fix   Complexity   

Complex Class

Complex classes like EventHandler often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use EventHandler, and based on these observations, apply Extract Interface, too.

1
<?php declare(strict_types=1);
2
3
4
namespace XoopsModules\Wgevents;
5
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
11
 This program is distributed in the hope that it will be useful,
12
 but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
*/
15
16
/**
17
 * wgEvents module for xoops
18
 *
19
 * @copyright    2021 XOOPS Project (https://xoops.org)
20
 * @license      GPL 2.0 or later
21
 * @package      wgevents
22
 * @since        1.0.0
23
 * @min_xoops    2.5.11 Beta1
24
 * @author       Goffy - Wedega - Email:[email protected] - Website:https://xoops.wedega.com
25
 */
26
27
use XoopsModules\Wgevents;
28
use XoopsModules\Wgevents\MailHandler;
29
30
31
/**
32
 * Class Object Handler Event
33
 */
34
class EventHandler extends \XoopsPersistableObjectHandler
35
{
36
    /**
37
     * Constructor
38
     *
39
     * @param \XoopsDatabase $db
40
     */
41
    public function __construct(\XoopsDatabase $db)
42
    {
43
        parent::__construct($db, 'wgevents_event', Event::class, 'id', 'name');
44
    }
45
46
    /**
47
     * @param bool $isNew
48
     *
49
     * @return object
50
     */
51
    public function create($isNew = true)
52
    {
53
        return parent::create($isNew);
54
    }
55
56
    /**
57
     * retrieve a field
58
     *
59
     * @param int $id field id
60
     * @param null fields
0 ignored issues
show
Bug introduced by
The type XoopsModules\Wgevents\fields was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
61
     * @return \XoopsObject|null reference to the {@link Get} object
62
     */
63
    public function get($id = null, $fields = null)
64
    {
65
        return parent::get($id, $fields);
66
    }
67
68
    /**
69
     * get inserted id
70
     *
71
     * @param null
72
     * @return int reference to the {@link Get} object
73
     */
74
    public function getInsertId()
75
    {
76
        return $this->db->getInsertId();
77
    }
78
79
    /**
80
     * Get Count Event in the database
81
     * @param int    $start
82
     * @param int    $limit
83
     * @param string $sort
84
     * @param string $order
85
     * @return int
86
     */
87
    public function getCountEvents($start = 0, $limit = 0, $sort = 'id', $order = 'DESC')
88
    {
89
        $crCountEvents = new \CriteriaCompo();
90
        $crCountEvents = $this->getEventsCriteria($crCountEvents, $start, $limit, $sort, $order);
91
        return $this->getCount($crCountEvents);
0 ignored issues
show
Bug introduced by
$crCountEvents of type integer is incompatible with the type CriteriaElement|null expected by parameter $criteria of XoopsPersistableObjectHandler::getCount(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

91
        return $this->getCount(/** @scrutinizer ignore-type */ $crCountEvents);
Loading history...
92
    }
93
94
    /**
95
     * Get All Event in the database
96
     * @param int    $start
97
     * @param int    $limit
98
     * @param string $sort
99
     * @param string $order
100
     * @return array
101
     */
102
    public function getAllEvents($start = 0, $limit = 0, $sort = 'id', $order = 'DESC')
103
    {
104
        $crAllEvents = new \CriteriaCompo();
105
        $crAllEvents = $this->getEventsCriteria($crAllEvents, $start, $limit, $sort, $order);
106
        return $this->getAll($crAllEvents);
0 ignored issues
show
Bug introduced by
$crAllEvents of type integer is incompatible with the type CriteriaElement|null expected by parameter $criteria of XoopsPersistableObjectHandler::getAll(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

106
        return $this->getAll(/** @scrutinizer ignore-type */ $crAllEvents);
Loading history...
107
    }
108
109
    /**
110
     * Get Criteria Event
111
     * @param        $crEvent
112
     * @param int $start
113
     * @param int $limit
114
     * @param string $sort
115
     * @param string $order
116
     * @return int
117
     */
118
    private function getEventsCriteria($crEvent, int $start, int $limit, string $sort, string $order)
119
    {
120
        $crEvent->setStart($start);
121
        $crEvent->setLimit($limit);
122
        $crEvent->setSort($sort);
123
        $crEvent->setOrder($order);
124
        return $crEvent;
125
    }
126
127
    /**
128
     * @public function getForm
129
     * @param bool $action
130
     * @return \XoopsThemeForm
131
     */
132
    public function getFormEventSelect($action = false)
133
    {
134
        $helper = Helper::getInstance();
135
        if (!$action) {
136
            $action = $_SERVER['REQUEST_URI'];
137
        }
138
        // Get Theme Form
139
        \xoops_load('XoopsFormLoader');
140
        $form = new \XoopsThemeForm(\_MA_WGEVENTS_EVENT_SELECT, 'form', $action, 'post', true);
141
        $form->setExtra('enctype="multipart/form-data"');
142
        // Form Table categories
143
        $eventHandler = $helper->getHandler('Event');
144
        $evidSelect = new \XoopsFormSelect(\_MA_WGEVENTS_EVENT_ID, 'evid', 0);
145
        $evidSelect->addOption('');
146
        $evidSelect->addOptionArray($eventHandler->getList());
147
        $evidSelect->setExtra("onchange='submit()'");
148
        $form->addElement($evidSelect);
149
        // To list
150
        $form->addElement(new \XoopsFormHidden('op', 'list'));
151
152
        return $form;
153
    }
154
155
    /**
156
     * TODO: not in use currently
157
     * @public function getForm
158
     * @param array  $params
159
     * @param string $action
160
     * @return Forms\FormInline
161
     */
162
    public function getFormPageNavCounter($params = [], $action = '')
163
    {
164
        if (!$action) {
165
            $action = $_SERVER['REQUEST_URI'];
166
        }
167
        // Get Theme Form
168
        \xoops_load('XoopsFormLoader');
169
        $form = new Forms\FormInline('', 'formPageNavCounter', $action, 'post', true);
170
        $form->setExtra('enctype="multipart/form-data"');
171
        // Form Table categories
172
        $pageNavTray = new Forms\FormElementTray('', '');
173
        $evidSelect = new \XoopsFormSelect(\_MA_WGEVENTS_EVENT_ID, 'limit', $params['limit']);
174
        $evidSelect->addOption(10);
175
        $evidSelect->addOption(20);
176
        $evidSelect->addOption(30);
177
        $evidSelect->addOption(40);
178
        $evidSelect->addOption(50);
179
        $evidSelect->addOption(100);
180
        $evidSelect->addOption(0, _ALL);
181
        $evidSelect->setExtra("onchange='submit()'");
182
        $pageNavTray->addElement($evidSelect);
183
        $form->addElement($pageNavTray);
184
        // To list
185
        $form->addElement(new \XoopsFormHidden('op',         $params['op']));
186
        $form->addElement(new \XoopsFormHidden('start', 0));
187
        $form->addElement(new \XoopsFormHidden('cat_id',     $params['cat_id']));
188
        $form->addElement(new \XoopsFormHidden('filterCats', $params['filterCats']));
189
190
        return $form;
191
    }
192
193
    /**
194
     * @public function to get events for given params
195
     *
196
     * @param int    $start
197
     * @param int    $limit
198
     * @param int    $dateFrom      // filter date created from (timestamp)
199
     * @param int    $dateTo        // filter date created to (timestamp)
200
     * @param string $sortBy
201
     * @param string $orderBy
202
     * @param string $op
203
     * @param int    $evId
204
     * @param string $filter
205
     * @param array  $filterCats
206
     * @param int    $dateCreated
207
     * @return array
208
     */
209
    public function getEvents($start = 0, $limit = 0, $dateFrom = 0, $dateTo = 0, $sortBy = 'datefrom', $orderBy = 'ASC', $op = 'list', $evId = 0, $filter = '', $filterCats = [], $dateCreated = 0)
210
    {
211
        $helper = Helper::getInstance();
212
213
        /*
214
        echo '<br>start:'.$start;
215
        echo '<br>limit:'.$limit;
216
        echo '<br>datefrom:'.\formatTimestamp($dateFrom, 'm').'('.$dateFrom.')';
217
        echo '<br>dateto:'.\formatTimestamp($dateTo, 'm').'('.$dateTo.')';
218
        echo '<br>sortBy:'.$sortBy;
219
        echo '<br>orderBy:'.$orderBy;
220
        echo '<br>op:'.$op;
221
        echo '<br>evId:'.$evId;
222
        echo '<br>filter:'.$filter;
223
        foreach ($filterCats as $filterCat) {
224
            echo '<br>filterCat:'.$filterCat;
225
        }
226
        */
227
228
        $showItem = ($evId > 0);
229
        $uidCurrent  = 0;
230
        $userIsAdmin = false;
231
        if (\is_object($GLOBALS['xoopsUser'])) {
232
            $uidCurrent  = $GLOBALS['xoopsUser']->uid();
233
            $userIsAdmin = $GLOBALS['xoopsUser']->isAdmin();
234
        }
235
        $useGroups = (bool)$helper->getConfig('use_groups');
236
237
        //apply criteria for events
238
        $crEvent = new \CriteriaCompo();
239
        if ($showItem) {
240
            $crEvent->add(new \Criteria('id', $evId));
241
        } else {
242
            if ('me' == $filter && $uidCurrent > 0) {
243
                $crEvent->add(new \Criteria('submitter', $uidCurrent));
244
            }
245
        }
246
        //get only events which are online or from me
247
        $crEventOnline = new \CriteriaCompo();
248
        $crEventOnline->add(new \Criteria('status', Constants::STATUS_OFFLINE, '>'));
249
        $crEventOnline->add(new \Criteria('submitter', $uidCurrent), 'OR');
250
        $crEvent->add($crEventOnline);
251
252
        if ($dateCreated > 0) {
253
            $crEvent->add(new \Criteria('datecreated', $dateCreated, '>='));
254
        }
255
        if ($useGroups) {
256
            // current user
257
            // - must have perm to see event or
258
            // - must be event owner
259
            // - is admin
260
            if (!$userIsAdmin) {
261
                $crEventGroup = new \CriteriaCompo();
262
                $crEventGroup->add(new \Criteria('groups', '%00000%', 'LIKE')); //all users
263
                if ($uidCurrent > 0) {
264
                    // Get groups
265
                    $memberHandler = \xoops_getHandler('member');
266
                    $xoopsGroups = $memberHandler->getGroupsByUser($uidCurrent);
0 ignored issues
show
Bug introduced by
The method getGroupsByUser() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsMembershipHandler or XoopsPersistableObjectHandler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

266
                    /** @scrutinizer ignore-call */ 
267
                    $xoopsGroups = $memberHandler->getGroupsByUser($uidCurrent);
Loading history...
267
                    foreach ($xoopsGroups as $group) {
268
                        $crEventGroup->add(new \Criteria('groups', '%' . substr('00000' . $group, -5) . '%', 'LIKE'), 'OR');
269
                    }
270
                }
271
                $crEventGroup->add(new \Criteria('submitter', $uidCurrent), 'OR');
272
                $crEvent->add($crEventGroup);
273
                unset($crEventGroup);
274
            }
275
        }
276
        if (!$showItem) {
277
            if ('past' == $op) {
278
                // list events before now
279
                $crEvent->add(new \Criteria('datefrom', $dateFrom, '<'));
280
                $sortBy  = 'datefrom';
281
                $orderBy = 'DESC';
282
            } else {
283
                // calendar view:
284
                // - event start is between dateFrom and dateTo
285
                // - event end is between dateFrom and dateTo
286
                // ==> dateFrom and dateTo needed
287
288
                // index/event/block view:
289
                // - event start or event end is greater than dateFrom
290
                // ==> dateFrom needed, dateTo must be 0
291
                $crEventFromTo = new \CriteriaCompo();
292
                $crEventStart = new \CriteriaCompo();
293
                $crEventStart->add(new \Criteria('datefrom', $dateFrom, '>='));
294
                if ($dateTo > 0) {
295
                    $crEventStart->add(new \Criteria('datefrom', $dateTo, '<='));
296
                }
297
                $crEventFromTo->add($crEventStart);
298
                $crEventEnd = new \CriteriaCompo();
299
                $crEventEnd->add(new \Criteria('dateto', $dateFrom, '>='));
300
                if ($dateTo > 0) {
301
                    $crEventEnd->add(new \Criteria('dateto', $dateTo, '<='));
302
                }
303
                $crEventFromTo->add($crEventEnd, 'OR');
304
                $crEvent->add($crEventFromTo);
305
306
                unset($crEventStart, $crEventEnd, $crEventFromTo);
307
                $sortBy  = 'datefrom';
308
                $orderBy = 'ASC';
309
            }
310
            if (\count($filterCats) > 0) {
311
                $crEventCats = new \CriteriaCompo();
312
                $crEventCats->add(new \Criteria('catid', '(' . \implode(',', $filterCats) . ')', 'IN'));
313
                foreach ($filterCats as $filterCat) {
314
                    $crEventCats->add(new \Criteria('subcats', '%"' . $filterCat . '"%', 'LIKE'), 'OR');
315
                }
316
                $crEvent->add($crEventCats);
317
            }
318
        }
319
        $crEvent->setSort($sortBy);
320
        $crEvent->setOrder($orderBy);
321
        $eventsCount = $this->getCount($crEvent);
322
        if ($eventsCount > 0) {
323
            if ($limit > 0 && !$showItem) {
324
                $crEvent->setStart($start);
325
                $crEvent->setLimit($limit);
326
            }
327
            // Get All Event
328
            $eventsAll = $this->getAll($crEvent);
329
330
            return ['count' => $eventsCount, 'eventsAll' => $eventsAll];
331
        }
332
333
        return ['count' => 0, 'eventsAll' => []];
334
    }
335
336
    /**
337
     * compare two versions of events
338
     * @param  $versionOld
339
     * @param  $versionNew
340
     * @return string
341
     */
342
    public function getEventsCompare($versionOld, $versionNew)
343
    {
344
        $changedValues = [];
345
        // find changes in important fields of table events
346
        $fields = [];
347
        $fields[] = ['name' => 'name', 'caption' => \_MA_WGEVENTS_EVENT_NAME, 'type' => 'text'];
348
        $fields[] = ['name' => 'desc', 'caption' => \_MA_WGEVENTS_EVENT_DESC, 'type' => 'text'];
349
        $fields[] = ['name' => 'datefrom', 'caption' => \_MA_WGEVENTS_EVENT_DATEFROM, 'type' => 'datetime'];
350
        $fields[] = ['name' => 'dateto', 'caption' => \_MA_WGEVENTS_EVENT_DATETO, 'type' => 'datetime'];
351
        $fields[] = ['name' => 'location', 'caption' => \_MA_WGEVENTS_EVENT_LOCATION, 'type' => 'text'];
352
        $fields[] = ['name' => 'fee', 'caption' => \_MA_WGEVENTS_EVENT_FEE, 'type' => 'fee'];
353
354
        foreach ($fields as $field) {
355
            $valueOld = $versionOld->getVar($field['name']);
356
            $valueNew = $versionNew->getVar($field['name']);
357
            if ($valueOld != $valueNew) {
358
                if ('' == $valueNew) {
359
                    $valueNew = _MA_WGEVENTS_MAIL_REG_MODIFICATION_DELETED;
360
                }
361
                switch ($field['type']) {
362
                    case 'datetime':
363
                        $changedValues[] = [
364
                            'caption' => $field['caption'],
365
                            'valueOld' => \formatTimestamp($valueOld, 'm'),
366
                            'valueNew' => \formatTimestamp($valueNew, 'm')
367
                        ];
368
                        break;
369
                    case 'fee':
370
                        $evFee = \json_decode($valueOld, true);
371
                        $evFeeText = '';
372
                        foreach($evFee as $fee) {
373
                            $evFeeText .= Utility::FloatToString((float)$fee[0]) . ' ' . $fee[1] . '<br>';
374
                        }
375
                        $valueOld = $evFeeText;
376
                        $evFee = \json_decode($valueNew, true);
377
                        $evFeeText = '';
378
                        foreach($evFee as $fee) {
379
                            $evFeeText .= Utility::FloatToString((float)$fee[0]) . ' ' . $fee[1] . '<br>';
380
                        }
381
                        $valueNew = $evFeeText;
382
                        $changedValues[] = [
383
                            'caption' => $field['caption'],
384
                            'valueOld' => $valueOld,
385
                            'valueNew' => $valueNew
386
                        ];
387
                        break;
388
                    case'default':
389
                    default:
390
                       $changedValues[] = [
391
                            'caption' => $field['caption'],
392
                            'valueOld' => $valueOld,
393
                            'valueNew' => $valueNew
394
                        ];
395
                        break;
396
                }
397
            }
398
        }
399
        if (\count($changedValues) > 0) {
400
            $mailHandler = new MailHandler();
401
            return $mailHandler->array2table ($changedValues);
402
        }
403
404
        return '';
405
    }
406
    /**
407
     * get email recipients for noticiations
408
     * @param  $registerNotify
409
     * @return array|false|string[]
410
     */
411
    public function getRecipientsNotify($registerNotify)
412
    {
413
        $notifyEmails   = preg_split("/\r\n|\n|\r/", $registerNotify);
414
        // no notification to myself
415
        if (\is_object($GLOBALS['xoopsUser'])) {
416
            $email = $GLOBALS['xoopsUser']->email();
417
            if ('' != $email) {
418
                foreach ($notifyEmails as $key => $value) {
419
                    if ($value == $email) {
420
                        unset($notifyEmails[$key]);
421
                    }
422
                }
423
            }
424
       }
425
426
        return $notifyEmails;
427
    }
428
    /**
429
     * get clean date from/to for displaying
430
     * @param  int $datefrom
431
     * @param  int $dateto
432
     * @param  bool $allday
433
     * @return string
434
     */
435
    public function getDateFromToText($datefrom, $dateto, $allday)
436
    {
437
        $text       = '';
438
        $today      = date('d.m.Y', time()) === date('d.m.Y', $datefrom);
439
        $multiday   = (int)date('j', $dateto) !== (int)date('j', $datefrom);
440
        /*
441
        $days       = 1;
442
        if ($multiday) {
443
            $days = (1 + date_create(date('d.m.Y', $dateto))->diff(date_create(date('d.m.Y', $datefrom)))->format("%a"));
444
        }
445
        */
446
        $lng_until  = ' ' . \_MA_WGEVENTS_EVENT_DATEUNTIL . ' ';
447
        $lng_today  = \_MA_WGEVENTS_EVENT_TODAY;
448
        $lng_allday = \_MA_WGEVENTS_EVENT_ALLDAY;
449
450
        if ($today) {
451
            // get all types of today
452
            if ($allday && !$multiday) {
453
                // today, allday, no multiday
454
                $text = $lng_today . ' ' . $lng_allday;
455
            } else if ($today && !$allday && !$multiday) {
456
                // today, no allday, no multiday
457
                $text = $lng_today . ' ' . date('H:i', $datefrom) . $lng_until . date('H:i', $dateto);
458
            } else {
459
                // today, no allday, multiday
460
                $text = $lng_today . ' ' . date('H:i', $datefrom) . $lng_until . \formatTimestamp($dateto, 'm');
461
            }
462
        } else {
463
            // not today
464
            if ($allday && $multiday) {
465
                // allday, multiday
466
                $text =  \formatTimestamp($datefrom, 's') . $lng_allday . $lng_until . \formatTimestamp($dateto, 'm') . $lng_allday;
467
            } else if (!$allday && !$multiday) {
468
                // no allday, no multiday
469
                $text = \formatTimestamp($datefrom, 's') . ' ' . date('H:i', $datefrom) . $lng_until . date('H:i', $dateto);
470
            } else {
471
                // no allday, multiday
472
                $text = \formatTimestamp($datefrom, 'm') . $lng_until . \formatTimestamp($dateto, 'm');
473
                //TODO: same time for each day / different times for different days
474
            }
475
        }
476
        /*
477
        echo '<br>today:'.$today;
478
        echo '<br>datefrom:'.\formatTimestamp($datefrom, 'm');
479
        echo '<br>dateto:'.\formatTimestamp($dateto, 'm');
480
        echo '<br>multiday:'.$multiday;
481
        echo '<br>return:'.$text;
482
        */
483
        return $text;
484
    }
485
486
487
    /**
488
     * @public function getFormFilterExport: form for selecting cats and number of lines for export of events
489
     * @param bool  $eventDisplayCats
490
     * @param array $filterCats
491
     * @return \XoopsThemeForm
492
     */
493
    public function getFormFilterExport($limit, $dateFrom, $dateTo, $eventDisplayCats = false, $filterCats = [])
494
    {
495
        $helper = Helper::getInstance();
496
497
        $categoryHandler = $helper->getHandler('Category');
498
        // Get Theme Form
499
        \xoops_load('XoopsFormLoader');
500
        $form = new \XoopsThemeForm('', 'formFilterExport', $_SERVER['REQUEST_URI'], 'post', true);
501
        $form->setExtra('enctype="multipart/form-data"');
502
503
        if ($eventDisplayCats) {
504
            $cbAll = 1;
505
            // Form Select categories
506
            $catsOnline = $categoryHandler->getAllCatsOnline();
507
            if (0 == \count($filterCats)) {
508
                foreach (\array_keys($catsOnline) as $i) {
509
                    $filterCats[] = $i;
510
                }
511
            } elseif (\count($filterCats) < \count($catsOnline)) {
512
                $cbAll = 0;
513
            }
514
            $catTray = new \XoopsFormElementTray(\_MA_WGEVENTS_CATEGORY_FILTER);
515
            // checkbox for(de)select all
516
            $catAllSelect = new Forms\FormCheckboxInline('', 'all_cats', $cbAll);
517
            $catAllSelect->addOption(1, _ALL);
518
            $catAllSelect->setExtra(" onclick='toggleAllCats()' ");
519
            // checkboxes for all existing categories
520
            $catTray->addElement($catAllSelect);
521
            $catSelect = new Forms\FormCheckboxInline('', 'filter_cats', $filterCats);
522
            $catSelect->addOptionArray($catsOnline);
523
            $catTray->addElement($catSelect);
524
            $form->addElement($catTray);
525
        }
526
        // Form Text Date Select evDateto
527
        $form->addElement(new \XoopsFormDateTime(\_MA_WGEVENTS_EVENT_DATEFROM, 'datefrom', 15, $dateFrom), true);
528
        // Form Text Date Select evDateto
529
        $form->addElement(new \XoopsFormDateTime(\_MA_WGEVENTS_EVENT_DATETO, 'dateto', 15, $dateTo));
530
        // Form Select for setting limit of events
531
        $eventCountSelect = new \XoopsFormSelect(\_MA_WGEVENTS_EVENTS_FILTER_NB, 'limit', $limit);
532
        $eventCountSelect->addOption(10, 10);
533
        $eventCountSelect->addOption(20, 20);
534
        $eventCountSelect->addOption(30, 30);
535
        $eventCountSelect->addOption(40, 40);
536
        $eventCountSelect->addOption(50, 50);
537
        $eventCountSelect->addOption(0, _ALL);
538
        $form->addElement($eventCountSelect);
539
        $btnFilter = new \XoopsFormButton('', 'submit', \_MA_WGEVENTS_APPLY_FILTER, 'submit');
540
        $btnFilter->setClass('btn btn-success');
541
        $form->addElement($btnFilter);
542
543
        // To Save
544
        $form->addElement(new \XoopsFormHidden('op', 'list'));
545
        $form->addElement(new \XoopsFormHidden('start', '0'));
546
        $form->addElement(new \XoopsFormHidden('new', '1'));
547
        //$form->addElement(new \XoopsFormHidden('filter', $filter));
548
        return $form;
549
    }
550
}
551