Skip to content

Commit

Permalink
PSR-Fix (#1037)
Browse files Browse the repository at this point in the history
  • Loading branch information
hhunderter authored Aug 15, 2024
1 parent 923ff23 commit 8b6f437
Show file tree
Hide file tree
Showing 20 changed files with 151 additions and 96 deletions.
1 change: 1 addition & 0 deletions application/modules/calendar/boxes/Calendar.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Ilch 2
* @package ilch
Expand Down
2 changes: 1 addition & 1 deletion application/modules/calendar/boxes/views/calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
nowIndicator: true,
height: 450,
eventSources: [
<?php foreach ($this->get('events') ?? [] as $url): ?>
<?php foreach ($this->get('events') ?? [] as $url) : ?>
{
url: '<?=$this->getUrl($url->getUrl()) ?>'
},
Expand Down
12 changes: 8 additions & 4 deletions application/modules/calendar/config/config.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Ilch 2
* @package ilch
Expand Down Expand Up @@ -115,7 +116,7 @@ public function getInstallSql(): string
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;';
}

public function getUpdate($installedVersion)
public function getUpdate(string $installedVersion): string
{
switch ($installedVersion) {
case "1.0":
Expand Down Expand Up @@ -234,10 +235,10 @@ public function getUpdate($installedVersion)
$boxModel->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.
Expand All @@ -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.';
}
}
1 change: 1 addition & 0 deletions application/modules/calendar/controllers/Events.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Ilch 2
* @package ilch
Expand Down
1 change: 1 addition & 0 deletions application/modules/calendar/controllers/Index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Ilch 2
* @package ilch
Expand Down
9 changes: 5 additions & 4 deletions application/modules/calendar/controllers/admin/Index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Ilch 2
* @package ilch
Expand Down Expand Up @@ -61,7 +62,7 @@ public function indexAction()
}
}

$this->getView()->set('calendar', $calendarMapper->getEntries())
$this->getView()->set('calendars', $calendarMapper->getEntries())
->set('calendarMapper', $calendarMapper);
}

Expand All @@ -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'])
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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()) {
Expand Down
6 changes: 5 additions & 1 deletion application/modules/calendar/layouts/events.php
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
<?=$this->getContent() ?>
<?php

/** @var \Ilch\Layout\Base $this */

echo $this->getContent();
6 changes: 5 additions & 1 deletion application/modules/calendar/layouts/iCal.php
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
<?=$this->getContent() ?>
<?php

/** @var \Ilch\Layout\Base $this */

echo $this->getContent();
33 changes: 17 additions & 16 deletions application/modules/calendar/mappers/Calendar.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Ilch 2
* @package ilch
Expand Down Expand Up @@ -107,8 +108,8 @@ public function getCalendarById($id): ?EntriesModel
/**
* Gets the Calendar entries by start and end.
*
* @param \Ilch\Date|string $start
* @param \Ilch\Date|string $end
* @param Date|string $start
* @param Date|string $end
* @param string|array $groupIds A string like '1,2,3' or an array like [1,2,3]
* @return array|null
*/
Expand All @@ -119,24 +120,24 @@ public function getEntriesForJson($start, $end, $groupIds = '3'): ?array
}

if ($start && $end) {
if (!is_a($start, \Ilch\Date::class)) {
$start = new \Ilch\Date($start);
if (!is_a($start, Date::class)) {
$start = new Date($start);
}
if (!is_a($end, \Ilch\Date::class)) {
$end = new \Ilch\Date($end);
if (!is_a($end, Date::class)) {
$end = new Date($end);
}
$select = $this->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'])
]
)
]
Expand Down Expand Up @@ -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 = [];
Expand Down Expand Up @@ -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':
Expand All @@ -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');
Expand Down
1 change: 1 addition & 0 deletions application/modules/calendar/mappers/Events.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Ilch 2
* @package ilch
Expand Down
1 change: 1 addition & 0 deletions application/modules/calendar/models/Calendar.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Ilch 2
* @package ilch
Expand Down
1 change: 1 addition & 0 deletions application/modules/calendar/models/Events.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Ilch 2
* @package ilch
Expand Down
1 change: 1 addition & 0 deletions application/modules/calendar/translations/de.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Ilch 2
* @package ilch
Expand Down
1 change: 1 addition & 0 deletions application/modules/calendar/translations/en.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Ilch 2
* @package ilch
Expand Down
17 changes: 11 additions & 6 deletions application/modules/calendar/views/admin/index/index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

/** @var \Ilch\View $this */

$periodDays = [
'1' => $this->getTranslator()->trans('Monday'),
'2' => $this->getTranslator()->trans('Tuesday'),
Expand All @@ -19,7 +22,7 @@
?>

<h1><?=$this->getTrans('manage') ?></h1>
<?php if ($this->get('calendar') != ''): ?>
<?php if ($this->get('calendars') != '') : ?>
<form method="POST" action="">
<?=$this->getTokenField() ?>
<div class="table-responsive">
Expand Down Expand Up @@ -47,8 +50,10 @@
</tr>
</thead>
<tbody>
<?php foreach ($this->get('calendar') as $calendar): ?>
<?php
/** @var \Modules\Calendar\Models\Calendar $calendar */
foreach ($this->get('calendars') as $calendar) : ?>
<?php
$startDate = new \Ilch\Date($calendar->getStart());
$endDate = $calendar->getEnd() != '1000-01-01 00:00:00' ? new \Ilch\Date($calendar->getEnd()) : 1;
$endDate = is_numeric($endDate) ? null : $endDate;
Expand All @@ -63,10 +68,10 @@
<?php
if ($calendar->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()] . ')';
}
}
?>
Expand All @@ -80,6 +85,6 @@
</div>
<?=$this->getListBar(['delete' => 'delete']) ?>
</form>
<?php else: ?>
<?php else : ?>
<?=$this->getTrans('noCalendar') ?>
<?php endif; ?>
Loading

0 comments on commit 8b6f437

Please sign in to comment.