From 3cfbd9cdc5b3afdb63a5d775a86b14ecfdc5b6db Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 6 May 2016 12:52:06 +0200 Subject: * event list refactored to universal repeater control --- app/php/controls/EventRepeater.php | 25 +++++++++++++++++++++++++ app/php/controls/EventRepeater.tpl | 12 ++++++++++++ app/php/controls/UpcomingEvents.php | 8 ++------ app/php/controls/UpcomingEvents.tpl | 11 +++-------- 4 files changed, 42 insertions(+), 14 deletions(-) create mode 100644 app/php/controls/EventRepeater.php create mode 100644 app/php/controls/EventRepeater.tpl (limited to 'app/php/controls') diff --git a/app/php/controls/EventRepeater.php b/app/php/controls/EventRepeater.php new file mode 100644 index 0000000..4fb2812 --- /dev/null +++ b/app/php/controls/EventRepeater.php @@ -0,0 +1,25 @@ +Events->DataSource = $events; + $this->Events->dataBind(); + } + + public function setCalendarLinkVisible($value) { + $this->setViewState( + 'CalendarLinkVisible', + TPropertyValue::ensureBoolean($value) + ); + } + + public function getCalendarLinkVisible() { + return $this->getViewState('CalendarLinkVisible', TRUE); + } + +} + +?> diff --git a/app/php/controls/EventRepeater.tpl b/app/php/controls/EventRepeater.tpl new file mode 100644 index 0000000..69aaabf --- /dev/null +++ b/app/php/controls/EventRepeater.tpl @@ -0,0 +1,12 @@ + + + <%# $this->Data->DateString %> + <%# $this->Data->Name %> + + <%# $this->SourceTemplateControl->CalendarLinkVisible %> + (<%# $this->Data->Calendar->Name %>) + <%# $this->Service->constructUrl('Calendar', ['calendar' => $this->Data->Calendar->Url]) %> + +
+
+
diff --git a/app/php/controls/UpcomingEvents.php b/app/php/controls/UpcomingEvents.php index 80f29a5..1ba5600 100644 --- a/app/php/controls/UpcomingEvents.php +++ b/app/php/controls/UpcomingEvents.php @@ -22,12 +22,8 @@ class UpcomingEvents extends TemplateControl { $this->setControlState('user', $user); } - public function onPreRender($param) { - parent::onPreRender($param); - $this->Events->setDataSource( - $this->_getEventsForUser($this->UserToDisplay) - ); - $this->Events->dataBind(); + public function getEvents() { + return $this->_getEventsForUser($this->UserToDisplay); } private function _getEventsForUser(DbUser $user) { diff --git a/app/php/controls/UpcomingEvents.tpl b/app/php/controls/UpcomingEvents.tpl index d660f54..1788c7e 100644 --- a/app/php/controls/UpcomingEvents.tpl +++ b/app/php/controls/UpcomingEvents.tpl @@ -1,10 +1,5 @@ Upcoming events:
- - - <%# $this->Data->DateString %> - <%# $this->Data->Name %> - (<%# $this->Data->Calendar->Name %>) -
-
-
+ + <%= $this->getEvents() %> + -- cgit v1.2.3