diff --git a/application/modules/calendar/boxes/Calendar.php b/application/modules/calendar/boxes/Calendar.php index 7dbb99255..ca0b178a5 100644 --- a/application/modules/calendar/boxes/Calendar.php +++ b/application/modules/calendar/boxes/Calendar.php @@ -1,4 +1,5 @@ get('events') ?? [] as $url): ?> + get('events') ?? [] as $url) : ?> { url: 'getUrl($url->getUrl()) ?>' }, diff --git a/application/modules/calendar/config/config.php b/application/modules/calendar/config/config.php index 94264bc03..3ea324d53 100644 --- a/application/modules/calendar/config/config.php +++ b/application/modules/calendar/config/config.php @@ -1,4 +1,5 @@ addContent('calendar', $this->config['boxes']['calendar']); $boxMapper->install($boxModel); - removeDir(APPLICATION_PATH.'/modules/calendar/static/js/fullcalendar/'); + removeDir(APPLICATION_PATH . '/modules/calendar/static/js/fullcalendar/'); // no break case "1.7.0": - removeDir(APPLICATION_PATH.'/modules/calendar/static/js/fullcalendar_5_11_0/'); + removeDir(APPLICATION_PATH . '/modules/calendar/static/js/fullcalendar_5_11_0/'); // no break case "1.8.0": // Add the uid column. This property defines the persistent, globally unique identifier for the calendar component. @@ -254,10 +255,13 @@ public function getUpdate($installedVersion) // no break case "1.9.2": // Remove old version of fullcalendar as this version comes with version 6.1.10. - removeDir(APPLICATION_PATH.'/modules/calendar/static/js/fullcalendar_5_11_3/'); + removeDir(APPLICATION_PATH . '/modules/calendar/static/js/fullcalendar_5_11_3/'); // no break case "1.10.0": // no break + case "1.11.0": } + + return '"' . $this->config['key'] . '" Update-function executed.'; } } diff --git a/application/modules/calendar/controllers/Events.php b/application/modules/calendar/controllers/Events.php index f33fd2253..275a089b7 100644 --- a/application/modules/calendar/controllers/Events.php +++ b/application/modules/calendar/controllers/Events.php @@ -1,4 +1,5 @@ getView()->set('calendar', $calendarMapper->getEntries()) + $this->getView()->set('calendars', $calendarMapper->getEntries()) ->set('calendarMapper', $calendarMapper); } @@ -70,7 +71,7 @@ public function treatAction() $calendarMapper = new CalendarMapper(); $calendarModel = new CalendarModel(); $groupMapper = new GroupMapper(); - + if ($this->getRequest()->getParam('id')) { $this->getLayout()->getAdminHmenu() ->add($this->getTranslator()->trans('menuCalendar'), ['action' => 'index']) @@ -108,7 +109,7 @@ public function treatAction() } if ($this->getRequest()->getPost('end')) { - $validator['end']= 'required|date:d.m.Y H\:i'; + $validator['end'] = 'required|date:d.m.Y H\:i'; } $validation = Validation::create( @@ -147,7 +148,7 @@ public function treatAction() $this->redirect() ->withInput() ->withErrors($validation->getErrorBag()) - ->to(array_merge(['action' => 'treat'], ($calendarModel->getId()?['id' => $calendarModel->getId()]:[]))); + ->to(array_merge(['action' => 'treat'], ($calendarModel->getId() ? ['id' => $calendarModel->getId()] : []))); } if ($calendarModel->getId()) { diff --git a/application/modules/calendar/layouts/events.php b/application/modules/calendar/layouts/events.php index 1ec612ffa..50f4cdc88 100644 --- a/application/modules/calendar/layouts/events.php +++ b/application/modules/calendar/layouts/events.php @@ -1 +1,5 @@ -getContent() ?> +getContent(); diff --git a/application/modules/calendar/layouts/iCal.php b/application/modules/calendar/layouts/iCal.php index 1ec612ffa..50f4cdc88 100644 --- a/application/modules/calendar/layouts/iCal.php +++ b/application/modules/calendar/layouts/iCal.php @@ -1 +1,5 @@ -getContent() ?> +getContent(); diff --git a/application/modules/calendar/mappers/Calendar.php b/application/modules/calendar/mappers/Calendar.php index acc7f22fb..fa8f8ceb3 100644 --- a/application/modules/calendar/mappers/Calendar.php +++ b/application/modules/calendar/mappers/Calendar.php @@ -1,4 +1,5 @@ db()->select(); return $this->getEntriesBy( [ $select->orX( [ - $select->andX(['c.end <=' => $end->format('Y-m-d').' 23:59:59']), - $select->andX(['c.start >=' => $start->format('Y-m-d').' 00:00:00', 'c.end <=' => $end->format('Y-m-d').' 23:59:59']), + $select->andX(['c.end <=' => $end->format('Y-m-d') . ' 23:59:59']), + $select->andX(['c.start >=' => $start->format('Y-m-d') . ' 00:00:00', 'c.end <=' => $end->format('Y-m-d') . ' 23:59:59']), $select->andX( [ 'c.period_type !=' => '', - 'c.start <=' => $end->format('Y-m-d').' 00:00:00', - $select->orX(['c.end >=' => $start->format('Y-m-d').' 23:59:59', 'c.end =' => '1000-01-01 00:00:00']) + 'c.start <=' => $end->format('Y-m-d') . ' 00:00:00', + $select->orX(['c.end >=' => $start->format('Y-m-d') . ' 23:59:59', 'c.end =' => '1000-01-01 00:00:00']) ] ) ] @@ -192,11 +193,11 @@ public function saveReadAccess(int $calendarId, $readAccess, bool $addAdmin = tr } // Delete possible old entries to later insert the new ones. - $this->db()->delete($this->tablename.'_access') + $this->db()->delete($this->tablename . '_access') ->where(['calendar_id' => $calendarId]) ->execute(); - $sql = 'INSERT INTO [prefix]_'.$this->tablename.'_access (calendar_id, group_id) VALUES'; + $sql = 'INSERT INTO [prefix]_' . $this->tablename . '_access (calendar_id, group_id) VALUES'; $sqlWithValues = $sql; $rowCount = 0; $groupIds = []; @@ -253,13 +254,13 @@ public function delete($id): bool * @param int $factor * @return array */ - public function repeat(string $type, \Ilch\Date $startdate, \Ilch\Date $enddate, \Ilch\Date $untilDate, int $factor = 1): array + public function repeat(string $type, Date $startdate, Date $enddate, Date $untilDate, int $factor = 1): array { $recurrences = []; $startdateRecurrence = clone $startdate; $enddateRecurrence = clone $enddate; - while($startdateRecurrence <= $untilDate) { + while ($startdateRecurrence <= $untilDate) { $event = []; switch ($type) { case 'monthly': @@ -276,8 +277,8 @@ public function repeat(string $type, \Ilch\Date $startdate, \Ilch\Date $enddate, break; case 'quarterly': // work with a factor and 3 months as a quarter of a year is 3 months? - $startdateRecurrence->modify(($factor * 3). ' months'); - $enddateRecurrence->modify(($factor * 3). ' months'); + $startdateRecurrence->modify(($factor * 3) . ' months'); + $enddateRecurrence->modify(($factor * 3) . ' months'); break; case 'yearly': $startdateRecurrence->modify($factor . ' years'); diff --git a/application/modules/calendar/mappers/Events.php b/application/modules/calendar/mappers/Events.php index 4f80a7748..58f9cf4e3 100644 --- a/application/modules/calendar/mappers/Events.php +++ b/application/modules/calendar/mappers/Events.php @@ -1,4 +1,5 @@ $this->getTranslator()->trans('Monday'), '2' => $this->getTranslator()->trans('Tuesday'), @@ -19,7 +22,7 @@ ?>

getTrans('manage') ?>

-get('calendar') != ''): ?> +get('calendars') != '') : ?>
getTokenField() ?>
@@ -47,8 +50,10 @@ - get('calendar') as $calendar): ?> get('calendars') as $calendar) : ?> + getStart()); $endDate = $calendar->getEnd() != '1000-01-01 00:00:00' ? new \Ilch\Date($calendar->getEnd()) : 1; $endDate = is_numeric($endDate) ? null : $endDate; @@ -63,10 +68,10 @@ getPeriodType()) { echo $periodTypes[$calendar->getPeriodType()]; - if ($calendar->getPeriodType() != 'days'){ - echo ' (x '.$calendar->getPeriodDay().')'; + if ($calendar->getPeriodType() != 'days') { + echo ' (x ' . $calendar->getPeriodDay() . ')'; } else { - echo ' ('.$periodDays[$calendar->getPeriodDay()].')'; + echo ' (' . $periodDays[$calendar->getPeriodDay()] . ')'; } } ?> @@ -80,6 +85,6 @@
getListBar(['delete' => 'delete']) ?>
- + getTrans('noCalendar') ?> diff --git a/application/modules/calendar/views/admin/index/treat.php b/application/modules/calendar/views/admin/index/treat.php index c1faefeca..dd7cc91de 100644 --- a/application/modules/calendar/views/admin/index/treat.php +++ b/application/modules/calendar/views/admin/index/treat.php @@ -1,4 +1,7 @@ $this->getTranslator()->trans('Monday'), '2' => $this->getTranslator()->trans('Tuesday'), @@ -26,8 +29,9 @@ 'days' => $this->getTranslator()->trans('days'), ]; +/** @var \Modules\Calendar\Models\Calendar $entry */ $entry = $this->get('calendar'); - ?> +?> @@ -45,7 +49,7 @@ class="form-control" id="start" name="start" - value="escape($this->originalInput('start', ($entry->getId()?(new \Ilch\Date($entry->getStart()))->format('d.m.Y H:i'):''))) ?>" + value="escape($this->originalInput('start', ($entry->getId() ? (new \Ilch\Date($entry->getStart()))->format('d.m.Y H:i') : ''))) ?>" readonly> @@ -61,7 +65,7 @@ class="form-control" class="form-control" id="end" name="end" - value="escape($this->originalInput('end', ($entry->getId()?($entry->getEnd() != '1000-01-01 00:00:00' ? (new \Ilch\Date($entry->getEnd()))->format('d.m.Y H:i') : ''):''))) ?>"> + value="escape($this->originalInput('end', ($entry->getId() ? ($entry->getEnd() != '1000-01-01 00:00:00' ? (new \Ilch\Date($entry->getEnd()))->format('d.m.Y H:i') : '') : ''))) ?>"> @@ -76,7 +80,7 @@ class="form-control" class="form-control" id="title" name="title" - value="escape($this->originalInput('title', ($entry->getId()?$entry->getTitle():''))) ?>" /> + value="escape($this->originalInput('title', ($entry->getId() ? $entry->getTitle() : ''))) ?>" />
@@ -88,7 +92,7 @@ class="form-control" class="form-control" id="place" name="place" - value="escape($this->originalInput('place', ($entry->getId()?$entry->getPlace():''))) ?>" /> + value="escape($this->originalInput('place', ($entry->getId() ? $entry->getPlace() : ''))) ?>" />
@@ -97,9 +101,9 @@ class="form-control"
@@ -109,9 +113,9 @@ class="form-control"
@@ -126,7 +130,7 @@ class="form-control" class="form-control" id="periodDay" name="periodDay" - value="escape($this->originalInput('periodDay', ($this->originalInput('periodType', ($entry->getId()?$entry->getPeriodType():'')) == 'days'?'0':($entry->getId()?$entry->getPeriodDay():'1')))) ?>" /> + value="escape($this->originalInput('periodDay', ($this->originalInput('periodType', ($entry->getId() ? $entry->getPeriodType() : '')) == 'days' ? '0' : ($entry->getId() ? $entry->getPeriodDay() : '1')))) ?>" /> getPeriodType())) ? $this->getTrans($periodAppendix[$entry->getPeriodType()]) : '' ?>
@@ -142,7 +146,7 @@ class="form-control" class="form-control" id="repeatUntil" name="repeatUntil" - value="escape($this->originalInput('repeatUntil', ($entry->getId()?($entry->getRepeatUntil() != '1000-01-01 00:00:00' ? (new \Ilch\Date($entry->getRepeatUntil()))->format('d.m.Y H:i') : ''):''))) ?>" + value="escape($this->originalInput('repeatUntil', ($entry->getId() ? ($entry->getRepeatUntil() != '1000-01-01 00:00:00' ? (new \Ilch\Date($entry->getRepeatUntil()))->format('d.m.Y H:i') : '') : ''))) ?>" readonly> @@ -160,7 +164,7 @@ class="form-control" id="color" name="color" data-jscolor="" - value="escape($this->originalInput('color', ($entry->getId()?$entry->getColor():'#32333B'))) ?>"> + value="escape($this->originalInput('color', ($entry->getId() ? $entry->getColor() : '#32333B'))) ?>"> @@ -173,9 +177,11 @@ class="form-control"
@@ -190,7 +196,7 @@ class="form-control" id="ck_1" name="text" toolbar="ilch_html" - rows="5">escape($this->originalInput('text', ($entry->getId()?$entry->getText():''))) ?> + rows="5">escape($this->originalInput('text', ($entry->getId() ? $entry->getText() : ''))) ?>
getId()) ? $this->getSaveBar('updateButton') : $this->getSaveBar('addButton') ?> diff --git a/application/modules/calendar/views/events/iCal.php b/application/modules/calendar/views/events/iCal.php index 2f67c2a03..e01fa47b5 100644 --- a/application/modules/calendar/views/events/iCal.php +++ b/application/modules/calendar/views/events/iCal.php @@ -1,4 +1,7 @@ get('calendarList') ?? [] as $calendarList) { +/** @var \Modules\Calendar\Models\Calendar $calendar */ +foreach ($this->get('calendarList') ?? [] as $calendar) { $displayedEntries++; - $description = $calendarList->getText(); + $description = $calendar->getText(); $description = strip_tags($description, '


'); $description = str_replace('

', '', $description); $description = str_replace('

', "\\n\\n", $description); @@ -22,26 +26,26 @@ $description = str_replace(["\r", "\n"], '', $description); $description = rtrim(trim($description), "\\n\\n"); - $startDate = new \Ilch\Date($calendarList->getStart()); - $endDate = $calendarList->getEnd() != '1000-01-01 00:00:00' ? new \Ilch\Date($calendarList->getEnd()) : 1; - $repeatUntil = $calendarList->getEnd() != '1000-01-01 00:00:00' ? new \Ilch\Date($calendarList->getRepeatUntil()) : 1; + $startDate = new \Ilch\Date($calendar->getStart()); + $endDate = $calendar->getEnd() != '1000-01-01 00:00:00' ? new \Ilch\Date($calendar->getEnd()) : 1; + $repeatUntil = $calendar->getEnd() != '1000-01-01 00:00:00' ? new \Ilch\Date($calendar->getRepeatUntil()) : 1; $endDate = is_numeric($endDate) ? null : $endDate; $ical .= -'BEGIN:VEVENT -SUMMARY:' .$calendarList->getTitle(). ' -UID:' .$calendarList->getUid(). ' -DTSTART:' .date(DATE_ICAL, strtotime($calendarList->getStart())). ' -DTEND:' .date(DATE_ICAL, strtotime($calendarList->getEnd())). ' -LOCATION:' .$calendarList->getPlace(). ' -DESCRIPTION:' .$description; - - if ($calendarList->getPeriodType() != '') { - $freq = strtoupper($calendarList->getPeriodType()); + 'BEGIN:VEVENT +SUMMARY:' . $calendar->getTitle() . ' +UID:' . $calendar->getUid() . ' +DTSTART:' . date(DATE_ICAL, strtotime($calendar->getStart())) . ' +DTEND:' . date(DATE_ICAL, strtotime($calendar->getEnd())) . ' +LOCATION:' . $calendar->getPlace() . ' +DESCRIPTION:' . $description; + + if ($calendar->getPeriodType() != '') { + $freq = strtoupper($calendar->getPeriodType()); $quarterlyFactor = 1; - if ($calendarList->getPeriodType() === 'quarterly') { + if ($calendar->getPeriodType() === 'quarterly') { // 'quarterly' doesn't exist in iCal. Translate it to every 3 months. $freq = 'MONTHLY'; $quarterlyFactor = 3; @@ -49,11 +53,11 @@ // FREQ=WEEKLY;INTERVAL=3;UNTIL=00000000T000000Z // Supported for FREQ: "SECONDLY" / "MINUTELY" / "HOURLY" / "DAILY" / "WEEKLY" / "MONTHLY" / "YEARLY" $ical .= -"\n".'RRULE:FREQ='.strtoupper($calendarList->getPeriodType()).';INTERVAL='.($calendarList->getPeriodDay() * $quarterlyFactor).';UNTIL='.$repeatUntil->format(DATE_ICAL); + "\n" . 'RRULE:FREQ=' . strtoupper($calendar->getPeriodType()) . ';INTERVAL=' . ($calendar->getPeriodDay() * $quarterlyFactor) . ';UNTIL=' . $repeatUntil->format(DATE_ICAL); } $ical .= -"\nEND:VEVENT\n"; + "\nEND:VEVENT\n"; } $ical .= 'END:VCALENDAR'; diff --git a/application/modules/calendar/views/events/index.php b/application/modules/calendar/views/events/index.php index 190f6dba0..c334ca8a4 100644 --- a/application/modules/calendar/views/events/index.php +++ b/application/modules/calendar/views/events/index.php @@ -1,32 +1,36 @@ get('calendarList') ?? [] as $calendarList) { +/** @var \Modules\Calendar\Models\Calendar $calendar */ +foreach ($this->get('calendarList') ?? [] as $calendar) { $e = []; - $e['title'] = $calendarList->getTitle(); - $e['start'] = $calendarList->getStart(); - $e['end'] = $calendarList->getEnd(); - $e['color'] = $calendarList->getColor(); - $e['url'] = $this->getUrl('calendar/events/show/id/' . $calendarList->getId()); + $e['title'] = $calendar->getTitle(); + $e['start'] = $calendar->getStart(); + $e['end'] = $calendar->getEnd(); + $e['color'] = $calendar->getColor(); + $e['url'] = $this->getUrl('calendar/events/show/id/' . $calendar->getId()); - $startDate = new \Ilch\Date($calendarList->getStart()); - $endDate = $calendarList->getEnd() != '1000-01-01 00:00:00' ? new \Ilch\Date($calendarList->getEnd()) : 1; - $repeatUntil = $calendarList->getEnd() != '1000-01-01 00:00:00' ? new \Ilch\Date($calendarList->getRepeatUntil()) : 1; + $startDate = new \Ilch\Date($calendar->getStart()); + $endDate = $calendar->getEnd() != '1000-01-01 00:00:00' ? new \Ilch\Date($calendar->getEnd()) : 1; + $repeatUntil = $calendar->getEnd() != '1000-01-01 00:00:00' ? new \Ilch\Date($calendar->getRepeatUntil()) : 1; // Add only or initial (in case of recurring events) event. $events[] = $e; - if ($calendarList->getPeriodType() != '') { - $recurrentEvents = $this->get('calendarMapper')->repeat($calendarList->getPeriodType(), $startDate, $endDate, $repeatUntil, $calendarList->getPeriodDay()); + if ($calendar->getPeriodType() != '') { + $recurrentEvents = $this->get('calendarMapper')->repeat($calendar->getPeriodType(), $startDate, $endDate, $repeatUntil, $calendar->getPeriodDay()); $iteration = 0; - foreach($recurrentEvents as $event) { + foreach ($recurrentEvents as $event) { $e['start'] = $event['start']->format('Y-m-d H:i:s'); $e['end'] = $event['end']->format('Y-m-d H:i:s'); - $e['url'] = $this->getUrl('calendar/events/show/id/' . $calendarList->getId()) . '/iteration/' . $iteration; + $e['url'] = $this->getUrl('calendar/events/show/id/' . $calendar->getId()) . '/iteration/' . $iteration; $events[] = $e; $iteration++; } diff --git a/application/modules/calendar/views/events/show.php b/application/modules/calendar/views/events/show.php index 85e47c789..6f8a6461c 100644 --- a/application/modules/calendar/views/events/show.php +++ b/application/modules/calendar/views/events/show.php @@ -1,5 +1,13 @@ get('calendarMapper'); + +/** @var \Modules\Calendar\Models\Calendar $calendar */ $calendar = $this->get('calendar'); +/** @var int $iteration */ $iteration = $this->get('iteration'); $periodDays = [ '1' => $this->getTranslator()->trans('Monday'), @@ -23,8 +31,8 @@ $endDate = $calendar->getEnd() != '1000-01-01 00:00:00' ? new \Ilch\Date($calendar->getEnd()) : 1; $repeatUntil = $calendar->getEnd() != '1000-01-01 00:00:00' ? new \Ilch\Date($calendar->getRepeatUntil()) : 1; -if ($this->get('iteration') != '') { - $recurrence = $this->get('calendarMapper')->repeat($calendar->getPeriodType(), $startDate, $endDate, $repeatUntil, $calendar->getPeriodDay())[$iteration]; +if ($iteration != '') { + $recurrence = $calendarMapper->repeat($calendar->getPeriodType(), $startDate, $endDate, $repeatUntil, $calendar->getPeriodDay())[$iteration]; $startDate = $recurrence['start']; $endDate = $recurrence['end']; } @@ -33,7 +41,7 @@ ?>

escape($calendar->getTitle()) ?>

-getPlace()): ?> +getPlace()) : ?>
getTrans('place') ?>
escape($calendar->getPlace()) ?>
@@ -41,27 +49,27 @@
getTrans('start') ?>
-
getTrans($startDate->format('l')).$startDate->format(', d. ').$this->getTrans($startDate->format('F')).$startDate->format(' Y') ?> getTrans('at') ?> format('H:i') ?> getTrans('clock') ?>
+
getTrans($startDate->format('l')) . $startDate->format(', d. ') . $this->getTrans($startDate->format('F')) . $startDate->format(' Y') ?> getTrans('at') ?> format('H:i') ?> getTrans('clock') ?>
- +
getTrans('end') ?>
- getTrans($endDate->format('l')) . $endDate->format(', d. ') . $this->getTrans($endDate->format('F')) . $endDate->format(' Y') . ' ' . $this->getTrans('at').' '. $endDate->format('H:i').' '.$this->getTrans('clock') ?> + getTrans($endDate->format('l')) . $endDate->format(', d. ') . $this->getTrans($endDate->format('F')) . $endDate->format(' Y') . ' ' . $this->getTrans('at') . ' ' . $endDate->format('H:i') . ' ' . $this->getTrans('clock') ?>
-getPeriodType()): ?> +getPeriodType()) : ?>
getTrans('periodEntry') ?>
getPeriodType()) { echo $periodTypes[$calendar->getPeriodType()]; - if ($calendar->getPeriodType() != 'days'){ - echo ' (x '.$calendar->getPeriodDay().')'; + if ($calendar->getPeriodType() != 'days') { + echo ' (x ' . $calendar->getPeriodDay() . ')'; } else { - echo ' ('.$periodDays[$calendar->getPeriodDay()].')'; + echo ' (' . $periodDays[$calendar->getPeriodDay()] . ')'; } } ?> @@ -71,9 +79,9 @@
getTrans('description') ?>
- getText()): ?> + getText()) : ?> purify($calendar->getText()) ?> - + getTrans('noDescription') ?>
diff --git a/application/modules/calendar/views/index/index.php b/application/modules/calendar/views/index/index.php index 75d75549d..974140fc7 100644 --- a/application/modules/calendar/views/index/index.php +++ b/application/modules/calendar/views/index/index.php @@ -1,3 +1,7 @@ +
@@ -34,7 +38,7 @@ icalButton: { text: 'iCal', click: function() { - window.location = ''; + window.location = ''; } } }, @@ -59,7 +63,9 @@ weekNumbers: true, weekNumberCalculation: 'ISO', eventSources: [ - get('events') ?? [] as $url): ?> + get('events') ?? [] as $url) : ?> { url: 'getUrl($url->getUrl()) ?>' },