From b54206958d800ecedb4b4d962532db5ba822df4c Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Thu, 27 Jul 2017 20:37:31 +0200 Subject: [PATCH] Added calendar dashboard test --- Controller.php | 21 ++++++++++++++ Theme/Backend/calendar-dashboard.tpl.php | 2 +- Theme/Backend/dashboard-calendar.tpl.php | 36 ++++++++++++++++++++++-- 3 files changed, 55 insertions(+), 4 deletions(-) diff --git a/Controller.php b/Controller.php index 4db611f..bdf46d1 100644 --- a/Controller.php +++ b/Controller.php @@ -104,4 +104,25 @@ class Controller extends ModuleAbstract implements WebInterface return $view; } + /** + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return \Serializable + * + * @since 1.0.0 + */ + public function viewDashboard(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Calendar/Theme/Backend/dashboard-calendar'); + + $calendar = CalendarMapper::get(1); + $calendar->setDate(new SmartDateTime($request->getData('date') ?? 'now')); + $view->addData('calendar', $calendar); + + return $view; + } + } diff --git a/Theme/Backend/calendar-dashboard.tpl.php b/Theme/Backend/calendar-dashboard.tpl.php index 0c4ee91..bcd7a65 100644 --- a/Theme/Backend/calendar-dashboard.tpl.php +++ b/Theme/Backend/calendar-dashboard.tpl.php @@ -90,4 +90,4 @@ $calendar = $this->getData('calendar'); -getData('calendarEventPopup')->render('iCalendarEvent'), ENT_COMPAT, 'utf-8'); ?> \ No newline at end of file +getData('calendarEventPopup')->render('iCalendarEvent'); ?> \ No newline at end of file diff --git a/Theme/Backend/dashboard-calendar.tpl.php b/Theme/Backend/dashboard-calendar.tpl.php index 1b4bc6b..793b2e5 100644 --- a/Theme/Backend/dashboard-calendar.tpl.php +++ b/Theme/Backend/dashboard-calendar.tpl.php @@ -1,3 +1,33 @@ -
- Calendar -
\ No newline at end of file +getData('calendar'); +?> +
+getDate()->format('Y') . '-' . $calendar->getDate()->format('m') . '-' . '01'); +for($i = 0; $i < 6; $i++) : ?> +
+ +
+ getDate()->getFirstDayOfMonth() <= $i*7+$j+1 && $calendar->getDate()->getDaysOfMonth() >= $i*7+$j+1) { + echo ($i*7+$j+1) . ' ' . jddayofweek($j, 1); + } else { + echo $current->createModify(0, 0, -2)->format('d') . ' ' . jddayofweek($j, 1); + } ?> +
    + getEventByDate($current); + $current->smartModify(0, 0, 1); + foreach($events as $event) : ?> +
  • getName(), ENT_COMPAT, 'utf-8'); ?> + +
+
+ +
+ +
\ No newline at end of file