streaming-website/model/Conference.php

236 lines
5 KiB
PHP
Raw Normal View History

<?php
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'])
return true;
if($this->has('PREVIEW_DOMAIN') && ($this->get('PREVIEW_DOMAIN') == $_SERVER['SERVER_NAME']))
return true;
return false;
}
public function isClosed() {
return !$this->hasBegun() || $this->hasEnded();
}
public function isOpen() {
return !$this->isClosed();
}
public function startsAt() {
2016-12-11 19:27:35 +00:00
if(!$this->has('CONFERENCE.STARTS_AT'))
return null;
return DateTime::createFromFormat('U', $this->get('CONFERENCE.STARTS_AT'));
}
public function endsAt() {
2016-12-11 19:27:35 +00:00
if(!$this->has('CONFERENCE.ENDS_AT'))
return null;
return DateTime::createFromFormat('U', $this->get('CONFERENCE.ENDS_AT'));
}
public function hasBegun() {
2015-12-23 10:58:44 +00:00
// on the preview-domain all conferences are always open
if($this->isPreviewEnabled())
2015-12-23 10:58:44 +00:00
return true;
if($this->has('CONFERENCE.CLOSED')) {
$closed = $this->get('CONFERENCE.CLOSED');
/* when CLOSED is a boolean, we're reading an old config where
* conferences didn't have a pre-beginning phase, thus we always
* return true.
*/
if(gettype($closed) == "boolean")
return true;
if($closed == "before")
return false;
2015-09-02 14:54:42 +00:00
else if($closed == "running" || $closed == "after")
return true;
}
if($this->has('CONFERENCE.STARTS_AT')) {
2016-12-11 19:27:35 +00:00
$now = new DateTime('now');
return $now >= $this->startsAt();
} else {
return true;
}
}
public function hasEnded() {
2015-12-23 10:58:44 +00:00
// on the preview-domain no conference ever ends
if($this->isPreviewEnabled())
2015-12-23 10:58:44 +00:00
return false;
if($this->has('CONFERENCE.CLOSED')) {
$closed = $this->get('CONFERENCE.CLOSED');
if($closed == "after" || $closed === true)
return true;
2015-09-02 14:54:42 +00:00
else if($closed == "running" || $closed == "before" ||
$closed === false)
return false;
}
if($this->has('CONFERENCE.ENDS_AT')) {
2016-12-11 19:27:35 +00:00
$now = new DateTime('now');
return $now >= $this->endsAt();
} else {
return false;
}
}
public function hasAuthor() {
return $this->has('CONFERENCE.AUTHOR');
}
public function getAuthor() {
return $this->get('CONFERENCE.AUTHOR', '');
}
public function hasDescription() {
return $this->has('CONFERENCE.DESCRIPTION');
}
public function getDescription() {
return $this->get('CONFERENCE.DESCRIPTION', '');
}
public function hasKeywords() {
return $this->has('CONFERENCE.KEYWORDS');
}
public function getKeywords() {
return $this->get('CONFERENCE.KEYWORDS', '');
}
public function hasReleases() {
return $this->has('CONFERENCE.RELEASES');
}
public function getReleasesUrl() {
return $this->get('CONFERENCE.RELEASES');
}
public function getLink() {
return forceslash($this->getSlug()).url_params();
}
public function getAboutLink() {
return joinpath([$this->getSlug(), 'about']).url_params();
}
public function hasRelive() {
return $this->getRelive()->isEnabled();
}
public function getReliveUrl() {
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');
}
public function getBannerHtml() {
return $this->get('CONFERENCE.BANNER_HTML');
}
public function hasFooterHtml() {
return $this->has('CONFERENCE.FOOTER_HTML');
}
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', []);
}
public function hasAdditionalHtml() {
return $this->has('CONFERENCE.ADDITIONAL_HTML');
}
public function getAdditionalHtml() {
return $this->get('CONFERENCE.ADDITIONAL_HTML');
}
}