summaryrefslogtreecommitdiff
path: root/app/php/controls
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2016-05-06 13:24:34 +0200
committeremkael <emkael@tlen.pl>2016-05-06 13:24:34 +0200
commit2e9216dcf303917764d4af622dcd212ec1491889 (patch)
treeddfaa9a95517b15c49554fd2cb25f83b9a0a5d09 /app/php/controls
parentfbc0d1f9860c7891b245acf6e31789b4cac82a58 (diff)
* event lists on calendar page
Diffstat (limited to 'app/php/controls')
-rw-r--r--app/php/controls/EventList.php56
-rw-r--r--app/php/controls/EventList.tpl6
2 files changed, 62 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>