diff options
author | emkael <emkael@tlen.pl> | 2016-06-07 15:17:49 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2016-06-10 11:46:41 +0200 |
commit | 823d71ced9b4947b1a5a5ade7245d521ed490061 (patch) | |
tree | a9a6c7cb0de74ff705e8320c284de423a698f5b5 /app/php/dto/EventDTO.php | |
parent | df401552aac363655ab8f056a6c910a7611954d6 (diff) |
* renaming php directory
Diffstat (limited to 'app/php/dto/EventDTO.php')
-rw-r--r-- | app/php/dto/EventDTO.php | 85 |
1 files changed, 0 insertions, 85 deletions
diff --git a/app/php/dto/EventDTO.php b/app/php/dto/EventDTO.php deleted file mode 100644 index 8f5cdf5..0000000 --- a/app/php/dto/EventDTO.php +++ /dev/null @@ -1,85 +0,0 @@ -<?php - -Prado::using('Application.model.Entry'); -Prado::using('Application.dto.CalendarDTO'); -Prado::using('Application.facades.UserFacade'); - -class EventDTO { - - public $DateString; - public $Name; - public $Location; - public $Calendar; - - private $_utc; - private $_targetTZ; - - public function __construct(TimezoneDTO $tz = NULL) { - $this->_utc = new DateTimeZone('UTC'); - $this->_targetTZ = new DateTimeZone( - $tz - ? $tz->Name - : UserFacade::getInstance()->getTimezonePreference( - Prado::getApplication()->getUser() - )->Name - ); - } - - private $_beginDate; - protected function getBeginDate(Entry $event) { - if (!$this->_beginDate) { - $this->_beginDate = new DateTime($event->BeginDate, $this->_utc); - } - return $this->_beginDate; - } - - private $_endDate; - protected function getEndDate(Entry $event) { - if (!$this->_endDate) { - $this->_endDate = new DateTime($event->EndDate, $this->_utc); - if ($event->AllDay) { - $this->_endDate = $this->_endDate->modify('-1 day'); - } - } - return $this->_endDate; - } - - public function loadRecord(Entry $event, array $calendars) { - $this->Name = $event->Name; - $this->Location = $event->Location; - - if ($event->AllDay) { - $this->DateString = $this->getBeginDate($event)->format('Y-m-d'); - if ($this->getBeginDate($event) != $this->getEndDate($event)) { - $this->DateString .= sprintf( - ' - %s', - $this->getEndDate($event)->format('Y-m-d') - ); - } - } else { - $beginDate = $this->getBeginDate($event)->setTimezone($this->_targetTZ); - $this->DateString = $beginDate->format('Y-m-d H:i'); - } - - $calendars = array_filter( - $calendars, - function ($calendar) use($event) { - return $calendar->UID == $event->CalendarID; - } - ); - $this->Calendar = new CalendarDTO(); - $this->Calendar->loadRecord( - $calendars ? array_values($calendars)[0] : $event->Calendar - ); - } - - public static function __compare(EventDTO $ev1, EventDTO $ev2) { - if ($ev1->DateString === $ev2->DateString) { - return strcmp($ev1->Calendar->Name, $ev2->Calendar->Name); - } - return strcmp($ev1->DateString, $ev2->DateString); - } - -} - -?> |