summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/php/controls/EventList.php56
-rw-r--r--app/php/controls/EventList.tpl6
-rw-r--r--app/php/pages/Calendar.page14
3 files changed, 76 insertions, 0 deletions
diff --git a/app/php/controls/EventList.php b/app/php/controls/EventList.php
new file mode 100644
index 0000000..325641b
--- /dev/null
+++ b/app/php/controls/EventList.php
@@ -0,0 +1,56 @@
+<?php
+
+class EventList extends UrlBasedCalendarControl {
+
+ private function _setDate($key, $date) {
+ $datetime = new DateTime($date, new DateTimeZone('UTC'));
+ if (!$datetime) {
+ throw new TInvalidDataValueException('Invalid date string: ' . $date);
+ }
+ $this->setViewState($key, $datetime);
+ }
+
+ public function setDateFrom($date) {
+ $this->_setDate('DateFrom', $date);
+ }
+
+ public function getDateFrom() {
+ return $this->getViewState('DateFrom');
+ }
+
+ public function setDateTo($date) {
+ $this->_setDate('DateTo', $date);
+ }
+
+ public function getDateTo() {
+ return $this->getViewState('DateTo');
+ }
+
+ public function setHeaderText($text) {
+ $this->setViewState('HeaderText', TPropertyValue::ensureString($text));
+ }
+
+ public function getHeaderText() {
+ return $this->getViewState('HeaderText');
+ }
+
+ public function setReverse($value) {
+ $this->setViewState('Reverse', TPropertyValue::ensureBoolean($value));
+ }
+
+ public function getReverse() {
+ return $this->getViewState('Reverse');
+ }
+
+ public function getEvents() {
+ return $this->getFacade()->getEventsForTimeframe(
+ $this->getCalendar(),
+ $this->getDateFrom() ?: new DateTime('0000-00-00'),
+ $this->getDateTo() ?: new DateTime('9999-99-99'),
+ $this->getReverse() ? 'DESC' : 'ASC'
+ );
+ }
+
+}
+
+?>
diff --git a/app/php/controls/EventList.tpl b/app/php/controls/EventList.tpl
new file mode 100644
index 0000000..5881ce7
--- /dev/null
+++ b/app/php/controls/EventList.tpl
@@ -0,0 +1,6 @@
+<com:THeader3>
+ <%= $this->getHeaderText() %>
+</com:THeader3>
+<com:EventRepeater CalendarLinkVisible="false">
+ <prop:Events><%= $this->getEvents() %></prop:Events>
+</com:EventRepeater>
diff --git a/app/php/pages/Calendar.page b/app/php/pages/Calendar.page
index c77c2c5..bc80d1a 100644
--- a/app/php/pages/Calendar.page
+++ b/app/php/pages/Calendar.page
@@ -11,4 +11,18 @@
calendar visible in current filter selection
</prop:Description>
</com:AddToFilter>
+ <com:EventList DateFrom="now" DateTo="+1 year">
+ <prop:Facade><%= CalendarFacade::getInstance() %></prop:Facade>
+ <prop:CalendarUrl><%= $this->Request->itemAt('calendar') %></prop:CalendarUrl>
+ <prop:HeaderText>
+ Upcoming events in the calendar:
+ </prop:HeaderText>
+ </com:EventList>
+ <com:EventList DateTo="now" Reverse="true">
+ <prop:Facade><%= CalendarFacade::getInstance() %></prop:Facade>
+ <prop:CalendarUrl><%= $this->Request->itemAt('calendar') %></prop:CalendarUrl>
+ <prop:HeaderText>
+ Past events in the calendar:
+ </prop:HeaderText>
+ </com:EventList>
</com:TContent>