diff options
Diffstat (limited to 'model/Conference.php')
-rw-r--r-- | model/Conference.php | 110 |
1 files changed, 102 insertions, 8 deletions
diff --git a/model/Conference.php b/model/Conference.php index c6afa98..8d387a0 100644 --- a/model/Conference.php +++ b/model/Conference.php @@ -2,12 +2,24 @@ class Conference extends ModelBase { + private $slug; + + public function __construct($config, $slug) + { + parent::__construct($config); + $this->slug = $slug; + } + + public function getSlug() { + return $this->slug; + } + public function getTitle() { return $this->get('CONFERENCE.TITLE', 'C3VOC'); } public function isPreviewEnabled() { - if($GLOBALS['forceopen']) + if(@$GLOBALS['forceopen']) return true; if($this->has('PREVIEW_DOMAIN') && ($this->get('PREVIEW_DOMAIN') == $_SERVER['SERVER_NAME'])) @@ -20,6 +32,24 @@ class Conference extends ModelBase return !$this->hasBegun() || $this->hasEnded(); } + public function isOpen() { + return !$this->isClosed(); + } + + public function startsAt() { + if(!$this->has('CONFERENCE.STARTS_AT')) + return null; + + return DateTime::createFromFormat('U', $this->get('CONFERENCE.STARTS_AT')); + } + + public function endsAt() { + if(!$this->has('CONFERENCE.ENDS_AT')) + return null; + + return DateTime::createFromFormat('U', $this->get('CONFERENCE.ENDS_AT')); + } + public function hasBegun() { // on the preview-domain all conferences are always open if($this->isPreviewEnabled()) @@ -42,7 +72,8 @@ class Conference extends ModelBase } if($this->has('CONFERENCE.STARTS_AT')) { - return time() >= $this->get('CONFERENCE.STARTS_AT'); + $now = new DateTime('now'); + return $now >= $this->startsAt(); } else { return true; } @@ -64,7 +95,8 @@ class Conference extends ModelBase } if($this->has('CONFERENCE.ENDS_AT')) { - return time() >= $this->get('CONFERENCE.ENDS_AT'); + $now = new DateTime('now'); + return $now >= $this->endsAt(); } else { return false; } @@ -101,23 +133,37 @@ class Conference extends ModelBase } public function getLink() { - return url_params(); + return forceslash($this->getSlug()).url_params(); } public function getAboutLink() { - return 'about/'.url_params(); + return joinpath([$this->getSlug(), 'about']).url_params(); } public function hasRelive() { - return $this->has('CONFERENCE.RELIVE_JSON'); + return $this->getRelive()->isEnabled(); } public function getReliveUrl() { - if($this->has('CONFERENCE.RELIVE_JSON')) - return 'relive/'.url_params(); + if($this->getRelive()->isEnabled()) + return joinpath([$this->getSlug(), 'relive']).url_params(); else return null; } + public function hasFeedback() { + return $this->has('FEEDBACK'); + } + public function getFeedbackUrl() { + return joinpath([$this->getSlug(), 'feedback']).url_params(); + } + public function getFeedbackReadUrl() { + return joinpath([$this->getSlug(), 'feedback', 'read']).url_params(); + } + + public function getScheduleJsonUrl() { + return joinpath([$this->getSlug(), 'schedule.json']).url_params(); + } + public function hasBannerHtml() { return $this->has('CONFERENCE.BANNER_HTML'); } @@ -131,4 +177,52 @@ class Conference extends ModelBase public function getFooterHtml() { return $this->get('CONFERENCE.FOOTER_HTML'); } + + + public function getRooms() + { + $rooms = array(); + foreach($this->get('ROOMS') as $slug => $room) + $rooms[] = $this->getRoom($slug); + + return $rooms; + } + + public function getRoomIfExists($room) + { + if($this->hasRoom($room)) + return $this->getRoom($room); + + return null; + } + + public function hasRoom($slug) + { + return $this->has('ROOMS.'.$slug); + } + + public function getRoom($room) { + return new Room($this, $room); + } + + + public function getFeedback() { + return new Feedback($this); + } + public function getSchedule() { + return new Schedule($this); + } + public function getSubtitles() { + return new Subtitles($this); + } + public function getOverview() { + return new Overview($this); + } + public function getRelive() { + return new Relive($this); + } + + public function getExtraFiles() { + return $this->get('EXTRA_FILES', []); + } } |