diff options
-rw-r--r-- | app/php/controls/EventRepeater.php | 25 | ||||
-rw-r--r-- | app/php/controls/EventRepeater.tpl | 12 | ||||
-rw-r--r-- | app/php/controls/UpcomingEvents.php | 8 | ||||
-rw-r--r-- | app/php/controls/UpcomingEvents.tpl | 11 |
4 files changed, 42 insertions, 14 deletions
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 @@ +<?php + +Prado::using('Application.web.TemplateControl'); + +class EventRepeater extends TemplateControl { + + public function setEvents($events) { + $this->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 @@ +<com:TRepeater ID="Events"> + <prop:ItemTemplate> + <%# $this->Data->DateString %> + <%# $this->Data->Name %> + <com:THyperLink> + <prop:Visible><%# $this->SourceTemplateControl->CalendarLinkVisible %></prop:Visible> + <prop:Text>(<%# $this->Data->Calendar->Name %>)</prop:Text> + <prop:NavigateUrl><%# $this->Service->constructUrl('Calendar', ['calendar' => $this->Data->Calendar->Url]) %></prop:NavigateUrl> + </com:THyperLink> + <br /> + </prop:ItemTemplate> +</com:TRepeater> 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: <br /> -<com:TRepeater ID="Events"> - <prop:ItemTemplate> - <%# $this->Data->DateString %> - <%# $this->Data->Name %> - (<%# $this->Data->Calendar->Name %>) - <br /> - </prop:ItemTemplate> -</com:TRepeater> +<com:EventRepeater ID="Events"> + <prop:Events><%= $this->getEvents() %></prop:Events> +</com:EventRepeater> |