summaryrefslogtreecommitdiff
path: root/app/frontend/controls/EventList.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/frontend/controls/EventList.php')
-rw-r--r--app/frontend/controls/EventList.php59
1 files changed, 59 insertions, 0 deletions
diff --git a/app/frontend/controls/EventList.php b/app/frontend/controls/EventList.php
new file mode 100644
index 0000000..d40e000
--- /dev/null
+++ b/app/frontend/controls/EventList.php
@@ -0,0 +1,59 @@
+<?php
+
+class EventList extends UrlBasedCalendarControl {
+
+ private function _setDate($key, $date) {
+ $datetime = new DateTime($date, new DateTimeZone('UTC'));
+ if (!$datetime) {
+ throw new TInvalidDataValueException(
+ Prado::localize('Invalid date string: {date}',
+ ['date' => $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'
+ );
+ }
+
+}
+
+?>