diff options
author | MaZderMind | 2016-12-10 18:22:34 +0100 |
---|---|---|
committer | MaZderMind | 2016-12-10 18:22:34 +0100 |
commit | f6c0270d40f6730fe1e1820f2866b08792df1db6 (patch) | |
tree | f0da1effc9f55f2f75dc57fe1ba17419d559b45b | |
parent | b227ac0ee80f6de300fed10a34e7393847227cfc (diff) |
rewrite data-model so that every configuration option is accessed through the conference
Diffstat (limited to '')
-rw-r--r-- | assets/js/lustiges-script.js | 2 | ||||
-rw-r--r-- | index.php | 23 | ||||
-rw-r--r-- | lib/helper.php | 10 | ||||
-rw-r--r-- | model/Conference.php | 84 | ||||
-rw-r--r-- | model/Conferences.php | 67 | ||||
-rw-r--r-- | model/Feedback.php | 22 | ||||
-rw-r--r-- | model/GenericConference.php | 5 | ||||
-rw-r--r-- | model/ModelBase.php | 20 | ||||
-rw-r--r-- | model/Overview.php | 15 | ||||
-rw-r--r-- | model/Relive.php | 17 | ||||
-rw-r--r-- | model/Room.php | 85 | ||||
-rw-r--r-- | model/RoomSelection.php | 10 | ||||
-rw-r--r-- | model/RoomTab.php | 8 | ||||
-rw-r--r-- | model/Schedule.php | 39 | ||||
-rw-r--r-- | model/Subtitles.php | 21 | ||||
-rw-r--r-- | template/allconferences.phtml | 6 | ||||
-rw-r--r-- | template/assemblies/feedback.phtml | 4 | ||||
-rw-r--r-- | template/assemblies/header.phtml | 4 | ||||
-rw-r--r-- | template/feedback-read.phtml | 2 | ||||
-rw-r--r-- | template/overview.phtml | 2 | ||||
-rw-r--r-- | template/page.phtml | 2 | ||||
-rw-r--r-- | view/feedback-read.php | 5 | ||||
-rw-r--r-- | view/feedback.php | 4 | ||||
-rw-r--r-- | view/overview.php | 2 | ||||
-rw-r--r-- | view/relive.php | 2 | ||||
-rw-r--r-- | view/room.php | 4 | ||||
-rw-r--r-- | view/schedule-json.php | 2 | ||||
-rw-r--r-- | view/schedule.php | 2 |
28 files changed, 290 insertions, 179 deletions
diff --git a/assets/js/lustiges-script.js b/assets/js/lustiges-script.js index d6b1f7e..7f22766 100644 --- a/assets/js/lustiges-script.js +++ b/assets/js/lustiges-script.js @@ -193,7 +193,7 @@ $(function() { function fetchProgram() { $.ajax({ - url: 'schedule.json', + url: $('div[data-schedule-url]').data('schedule-url'), dataType: 'json', success: function(data) { scheduleData = data; @@ -59,7 +59,8 @@ try { 'route' => $route, 'canonicalurl' => forceslash(baseurl()).forceslash($route), 'assemblies' => 'template/assemblies/', - 'assets' => 'assets/', + 'assets' => forceslash('assets'), + 'conference_assets' => '/', 'conference' => new GenericConference(), )); @@ -113,7 +114,7 @@ try { // redirect $clients = Conferences::getActiveConferences(); - header('Location: '.forceslash( baseurl() . $clients[0]['link'] )); + header('Location: '.joinpath([baseurl(), $clients[0]->getSlug()])); exit; } else @@ -132,8 +133,9 @@ try { require('view/404.php'); exit; } - - Conferences::load($mandator); + else { + // fallthrough through to the main mandator-based routes + } } catch(Exception $e) { @@ -144,20 +146,19 @@ catch(Exception $e) // PER-CONFERENCE CODE -$GLOBALS['MANDATOR'] = $mandator; -$conference = new Conference(); +$conference = Conferences::getConference($mandator); // update template information $tpl->set(array( 'baseurl' => forceslash(baseurl()), 'route' => $route, - 'canonicalurl' => forceslash(baseurl()).forceslash($route), - 'assets' => '../assets/', + 'canonicalurl' => joinpath([baseurl(), $mandator, $route]), + 'conference_assets' => forceslash($mandator), 'conference' => $conference, - 'feedback' => new Feedback(), - 'schedule' => new Schedule(), - 'subtitles' => new Subtitles(), + 'feedback' => $conference->getFeedback(), + 'schedule' => $conference->getSchedule(), + 'subtitles' => $conference->getSubtitles(), )); ob_start(); diff --git a/lib/helper.php b/lib/helper.php index 4fce91e..df7f329 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -18,14 +18,20 @@ function baseurl() if(startswith('//', $base)) $base = proto().':'.$base; - return forceslash(forceslash($base).@$GLOBALS['MANDATOR']); + return forceslash($base); } $base = ssl() ? 'https://' : 'http://'; $base .= $_SERVER['HTTP_HOST']; $base .= forceslash(dirname($_SERVER['SCRIPT_NAME'])); - return forceslash(forceslash($base).@$GLOBALS['MANDATOR']); + return forceslash($base); +} + +function joinpath($parts) +{ + $parts = array_map('forceslash', $parts); + return rtrim(implode('', $parts), '/'); } function forceslash($url) diff --git a/model/Conference.php b/model/Conference.php index c6afa98..07d72dd 100644 --- a/model/Conference.php +++ b/model/Conference.php @@ -2,6 +2,18 @@ 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'); } @@ -20,6 +32,14 @@ class Conference extends ModelBase return !$this->hasBegun() || $this->hasEnded(); } + public function startsAt() { + return $this->get('CONFERENCE.STARTS_AT'); + } + + public function endsAt() { + return $this->get('CONFERENCE.ENDS_AT'); + } + public function hasBegun() { // on the preview-domain all conferences are always open if($this->isPreviewEnabled()) @@ -101,10 +121,10 @@ 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() { @@ -112,12 +132,26 @@ class Conference extends ModelBase } public function getReliveUrl() { if($this->has('CONFERENCE.RELIVE_JSON')) - return 'relive/'.url_params(); + 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 +165,48 @@ 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); + } } diff --git a/model/Conferences.php b/model/Conferences.php index 461186f..4919345 100644 --- a/model/Conferences.php +++ b/model/Conferences.php @@ -4,27 +4,38 @@ class Conferences extends ModelBase { const MANDATOR_DIR = 'configs/conferences/'; + public static function listConferences() { + $directories = scandir(forceslash(Conferences::MANDATOR_DIR)); + $conferences = array_filter($directories, function($dirname) { + return $dirname[0] != '.'; + }); + + return $conferences; + } + public static function getConferences() { $conferences = []; - foreach(scandir(forceslash(Conferences::MANDATOR_DIR)) as $el) + foreach(Conferences::listConferences() as $conference) { - if($el[0] == '.') - continue; - - $conferences[$el] = Conferences::getConferenceInformation($el); + try { + $conferences[$conference] = Conferences::getConference($conference); + } + catch(Exception $e) { + // ignore unloadable conferences + } } return $conferences; } public static function getConferencesCount() { - return count(Conferences::getConferences()); + return count(Conferences::listConferences()); } public static function getActiveConferences() { return array_values(array_filter( Conferences::getConferences(), - function($info) { - return $info['active']; + function($conference) { + return !$conference->isClosed(); } )); } @@ -37,7 +48,7 @@ class Conferences extends ModelBase $sorted = Conferences::getConferences(); usort($sorted, function($a, $b) { - return @$b['CONFIG']['CONFERENCE']['STARTS_AT'] - @$a['CONFIG']['CONFERENCE']['STARTS_AT']; + return $b->startsAt() - $a->endsAt(); }); return $sorted; @@ -47,7 +58,7 @@ class Conferences extends ModelBase $sorted = Conferences::getConferencesSorted(); $finished = array_values(array_filter($sorted, function($c) { - return @$c['CONFIG']['CONFERENCE']['ENDS_AT'] < time(); + return $c->hasEnded(); })); return $finished; @@ -58,33 +69,16 @@ class Conferences extends ModelBase } public static function exists($mandator) { - return array_key_exists($mandator, Conferences::getConferences()); + return in_array($mandator, Conferences::listConferences()); } - public static function getConferenceInformation($mandator) { - if(isset($GLOBALS['CONFIG'])) - $saved_config = $GLOBALS['CONFIG']; - - Conferences::load($mandator); - $conf = new Conference(); - $info = [ - 'slug' => $mandator, - 'link' => forceslash($mandator).url_params(), - 'active' => !$conf->isClosed(), - 'title' => $conf->getTitle(), - 'description' => $conf->getDescription(), - - 'relive' => $conf->hasRelive() ? forceslash($mandator).$conf->getReliveUrl() : null, - 'releases' => $conf->hasReleases() ? $conf->getReleasesUrl() : null, - - 'CONFIG' => $GLOBALS['CONFIG'], - ]; - unset($GLOBALS['CONFIG']); - - if(isset($saved_config)) - $GLOBALS['CONFIG'] = $saved_config; + public static function loadConferenceConfig($mandator) { + $config = forceslash(Conferences::MANDATOR_DIR).forceslash($mandator).'config.php'; + return include($config); + } - return $info; + public static function getConference($mandator) { + return new Conference(Conferences::loadConferenceConfig($mandator), $mandator); } public static function hasCustomStyles($mandator) { @@ -96,9 +90,4 @@ class Conferences extends ModelBase public static function getCustomStylesDir($mandator) { return forceslash(Conferences::MANDATOR_DIR).forceslash($mandator); } - - public static function load($mandator) { - include(forceslash(Conferences::MANDATOR_DIR).forceslash($mandator).'config.php'); - return isset($GLOBALS['CONFIG']); - } } diff --git a/model/Feedback.php b/model/Feedback.php index 578650a..9475fe8 100644 --- a/model/Feedback.php +++ b/model/Feedback.php @@ -1,12 +1,16 @@ <?php -class Feedback extends ModelBase +class Feedback { - public function isEnabled() { - return $this->has('FEEDBACK'); + private $conference; + + public function __construct(Conference $conference) + { + $this->conference = $conference; } - public function getUrl() { - return 'feedback/'; + + public function getConference() { + return $this->conference; } public function validate($info) @@ -23,7 +27,7 @@ class Feedback extends ModelBase public function store($info) { - $db = new PDO($this->get('FEEDBACK.DSN')); + $db = new PDO($this->getConference()->get('FEEDBACK.DSN')); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $stm = $db->prepare(' @@ -50,8 +54,8 @@ class Feedback extends ModelBase { return isset($_SERVER['PHP_AUTH_USER']) && - $_SERVER['PHP_AUTH_USER'] == $this->get('FEEDBACK.USERNAME') && - $_SERVER['PHP_AUTH_PW'] == $this->get('FEEDBACK.PASSWORD'); + $_SERVER['PHP_AUTH_USER'] == $this->getConference()->get('FEEDBACK.USERNAME') && + $_SERVER['PHP_AUTH_PW'] == $this->getConference()->get('FEEDBACK.PASSWORD'); } public function requestLogin() @@ -64,7 +68,7 @@ class Feedback extends ModelBase public function read($from, $to) { - $db = new PDO($this->get('FEEDBACK.DSN')); + $db = new PDO($this->getConference()->get('FEEDBACK.DSN')); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $stm = $db->prepare(' diff --git a/model/GenericConference.php b/model/GenericConference.php index 5f134fc..63faf8f 100644 --- a/model/GenericConference.php +++ b/model/GenericConference.php @@ -2,6 +2,11 @@ class GenericConference extends Conference { + public function __construct() + { + $this->config = null; + } + public function hasBegun() { return true; } diff --git a/model/ModelBase.php b/model/ModelBase.php index 7b1370b..41f329b 100644 --- a/model/ModelBase.php +++ b/model/ModelBase.php @@ -2,14 +2,17 @@ class ModelBase { - protected function has($keychain) + protected $config; + public function __construct($config) { - return ModelBase::_has($GLOBALS['CONFIG'], $keychain); + $this->config = $config; } - protected static function staticHas($keychain) + + public function has($keychain) { - return ModelBase::_has($GLOBALS['CONFIG'], $keychain); + return ModelBase::_has($this->config, $keychain); } + private static function _has($array, $keychain) { if(!is_array($keychain)) @@ -25,14 +28,11 @@ class ModelBase return ModelBase::_has($array[$key], array_slice($keychain, 1)); } - protected function get($keychain, $default = null) + public function get($keychain, $default = null) { - return ModelBase::_get($GLOBALS['CONFIG'], $keychain, $default); - } - protected static function staticGet($keychain, $default = null) - { - return ModelBase::_get($GLOBALS['CONFIG'], $keychain, $default); + return ModelBase::_get($this->config, $keychain, $default); } + private static function _get($array, $keychain, $default) { if(!is_array($keychain)) diff --git a/model/Overview.php b/model/Overview.php index 03ef8b4..8a467bc 100644 --- a/model/Overview.php +++ b/model/Overview.php @@ -1,16 +1,25 @@ <?php -class Overview extends ModelBase +class Overview { + public function __construct(Conference $conference) + { + $this->conference = $conference; + } + + public function getConference() { + return $this->conference; + } + public function getGroups() { $groups = array(); - foreach($this->get('OVERVIEW.GROUPS') as $group => $rooms) + foreach($this->getConference()->get('OVERVIEW.GROUPS') as $group => $rooms) { foreach($rooms as $room) { try { - $groups[$group][] = new Room($room); + $groups[$group][] = $this->getConference()->getRoom($room); } catch(NotFoundException $e) { diff --git a/model/Relive.php b/model/Relive.php index d0e7522..ca32f19 100644 --- a/model/Relive.php +++ b/model/Relive.php @@ -1,16 +1,27 @@ <?php -class Relive extends ModelBase +class Relive { + private $conference; + + public function __construct($conference) + { + $this->conference = $conference; + } + + public function getConference() { + return $this->conference; + } + public function isEnabled() { // having CONFERENCE.RELIVE is not enough! - return $this->has('CONFERENCE.RELIVE_JSON'); + return $this->getConference()->has('CONFERENCE.RELIVE_JSON'); } public function getJsonUrl() { - return $this->get('CONFERENCE.RELIVE_JSON'); + return $this->getConference()->get('CONFERENCE.RELIVE_JSON'); } public function getTalks() diff --git a/model/Room.php b/model/Room.php index df3d92c..aa72630 100644 --- a/model/Room.php +++ b/model/Room.php @@ -1,107 +1,92 @@ <?php -class Room extends ModelBase +class Room { private $slug; + private $conference; - public function __construct($slug) + public function __construct(Conference $conference, $slug) { + $this->conference = $conference; + if(preg_match('/[^a-z0-9_\-]/i', $slug)) throw new Exception('Room Slug contains invalid Characters: "'.$slug.'"'); - if(! $this->has('ROOMS.'.$slug)) + if(!$this->getConference()->hasRoom($slug)) throw new NotFoundException('Room '.$slug); $this->slug = $slug; } - public static function exists($slug) - { - return ModelBase::staticHas('ROOMS.'.$slug); - } - - public static function createIfExists($room) - { - if(Room::exists($room)) - return new Room($room); - - return null; - } - - public static function rooms() - { - $rooms = array(); - foreach(ModelBase::staticGet('ROOMS') as $slug => $room) - $rooms[] = new Room($slug); - return $rooms; + public function getConference() { + return $this->conference; } - public function getSlug() { return $this->slug; } public function getThumb() { - return '../thumbs/'.$this->getStream().'.png'; + return joinpath(['/', 'thumbs', $this->getStream().'.png']); } public function getLink() { - return rawurlencode($this->getSlug()).'/'.url_params(); + return joinpath([$this->getConference()->getSlug(), $this->getSlug()]).url_params(); } public function getStream() { - return $this->get('ROOMS.'.$this->getSlug().'.STREAM', $this->getSlug()); + return $this->getConference()->get('ROOMS.'.$this->getSlug().'.STREAM', $this->getSlug()); } public function getScheduleName() { - return $this->get('ROOMS.'.$this->getSlug().'.SCHEDULE_NAME', $this->getSlug()); + return $this->getConference()->get('ROOMS.'.$this->getSlug().'.SCHEDULE_NAME', $this->getSlug()); } public function getDisplay() { - return $this->get('ROOMS.'.$this->getSlug().'.DISPLAY', $this->getSlug()); + return $this->getConference()->get('ROOMS.'.$this->getSlug().'.DISPLAY', $this->getSlug()); } public function hasStereo() { - return $this->get('ROOMS.'.$this->getSlug().'.STEREO'); + return $this->getConference()->get('ROOMS.'.$this->getSlug().'.STEREO'); } public function hasPreview() { - return $this->get('ROOMS.'.$this->getSlug().'.PREVIEW'); + return $this->getConference()->get('ROOMS.'.$this->getSlug().'.PREVIEW'); } public function requestsWide() { - return $this->get('ROOMS.'.$this->getSlug().'.WIDE'); + return $this->getConference()->get('ROOMS.'.$this->getSlug().'.WIDE'); } public function hasSchedule() { - return $this->get('ROOMS.'.$this->getSlug().'.SCHEDULE') && $this->has('SCHEDULE'); + return $this->getConference()->get('ROOMS.'.$this->getSlug().'.SCHEDULE') && $this->getConference()->has('SCHEDULE'); } public function hasSubtitles() { return - $this->get('ROOMS.'.$this->getSlug().'.SUBTITLES') && - $this->has('ROOMS.'.$this->getSlug().'.SUBTITLES_ROOM_ID') && - $this->has('SUBTITLES'); + $this->getConference()->get('ROOMS.'.$this->getSlug().'.SUBTITLES') && + $this->getConference()->has('ROOMS.'.$this->getSlug().'.SUBTITLES_ROOM_ID') && + $this->getConference()->has('SUBTITLES'); } public function getSubtitlesRoomId() { - return $this->get('ROOMS.'.$this->getSlug().'.SUBTITLES_ROOM_ID'); + return $this->getConference()->get('ROOMS.'.$this->getSlug().'.SUBTITLES_ROOM_ID'); } public function hasFeedback() { - return $this->get('ROOMS.'.$this->getSlug().'.FEEDBACK') && $this->has('FEEDBACK'); + return $this->getConference()->get('ROOMS.'.$this->getSlug().'.FEEDBACK') && $this->getConference()->has('FEEDBACK'); } public function hasTwitter() { - return $this->get('ROOMS.'.$this->getSlug().'.TWITTER') && $this->has('TWITTER'); + return $this->getConference()->get('ROOMS.'.$this->getSlug().'.TWITTER') && $this->getConference()->has('TWITTER'); } public function getTwitterDisplay() { return sprintf( - $this->get('ROOMS.'.$this->getSlug().'.TWITTER_CONFIG.DISPLAY', $this->get('TWITTER.DISPLAY')), + $this->getConference()->get('ROOMS.'.$this->getSlug().'.TWITTER_CONFIG.DISPLAY', $this->getConference()->get('TWITTER.DISPLAY')), $this->getSlug() ); } @@ -115,26 +100,26 @@ class Room extends ModelBase public function getTwitterText() { return sprintf( - $this->get('ROOMS.'.$this->getSlug().'.TWITTER_CONFIG.TEXT', $this->get('TWITTER.TEXT')), + $this->getConference()->get('ROOMS.'.$this->getSlug().'.TWITTER_CONFIG.TEXT', $this->getConference()->get('TWITTER.TEXT')), $this->getSlug() ); } public function hasIrc() { - return $this->get('ROOMS.'.$this->getSlug().'.IRC') && $this->has('IRC'); + return $this->getConference()->get('ROOMS.'.$this->getSlug().'.IRC') && $this->getConference()->has('IRC'); } public function getIrcDisplay() { return sprintf( - $this->get('ROOMS.'.$this->getSlug().'.IRC_CONFIG.DISPLAY', $this->get('IRC.DISPLAY')), + $this->getConference()->get('ROOMS.'.$this->getSlug().'.IRC_CONFIG.DISPLAY', $this->getConference()->get('IRC.DISPLAY')), $this->getSlug() ); } public function getIrcUrl() { return sprintf( - $this->get('ROOMS.'.$this->getSlug().'.IRC_CONFIG.URL', $this->get('IRC.URL')), + $this->getConference()->get('ROOMS.'.$this->getSlug().'.IRC_CONFIG.URL', $this->getConference()->get('IRC.URL')), rawurlencode($this->getSlug()) ); } @@ -146,16 +131,16 @@ class Room extends ModelBase public function hasEmbed() { - return $this->get('ROOMS.'.$this->getSlug().'.EMBED') && $this->get('EMBED'); + return $this->getConference()->get('ROOMS.'.$this->getSlug().'.EMBED') && $this->getConference()->get('EMBED'); } public function hasSdVideo() { - return $this->get('ROOMS.'.$this->getSlug().'.SD_VIDEO'); + return $this->getConference()->get('ROOMS.'.$this->getSlug().'.SD_VIDEO'); } public function hasHdVideo() { - return $this->get('ROOMS.'.$this->getSlug().'.HD_VIDEO'); + return $this->getConference()->get('ROOMS.'.$this->getSlug().'.HD_VIDEO'); } public function hasVideo() { @@ -163,19 +148,19 @@ class Room extends ModelBase } public function hasAudio() { - return $this->get('ROOMS.'.$this->getSlug().'.AUDIO'); + return $this->getConference()->get('ROOMS.'.$this->getSlug().'.AUDIO'); } public function hasSlides() { - return $this->get('ROOMS.'.$this->getSlug().'.SLIDES'); + return $this->getConference()->get('ROOMS.'.$this->getSlug().'.SLIDES'); } public function hasMusic() { - return $this->get('ROOMS.'.$this->getSlug().'.MUSIC'); + return $this->getConference()->get('ROOMS.'.$this->getSlug().'.MUSIC'); } public function hasTranslation() { - return $this->get('ROOMS.'.$this->getSlug().'.TRANSLATION'); + return $this->getConference()->get('ROOMS.'.$this->getSlug().'.TRANSLATION'); } public function getSelectionNames() diff --git a/model/RoomSelection.php b/model/RoomSelection.php index 9f0b16d..9211c31 100644 --- a/model/RoomSelection.php +++ b/model/RoomSelection.php @@ -20,16 +20,18 @@ class RoomSelection public function getLink() { + $path = [$this->getRoom()->getConference()->getSlug(), $this->getRoom()->getSlug()]; + $selection = $this->getRoom()->getSelectionNames(); - if($selection[0] == $this->getSelection()) - return rawurlencode($this->getRoom()->getSlug()).'/'; + if($selection[0] != $this->getSelection()) + $path[] = $this->getSelection(); - return rawurlencode($this->getRoom()->getSlug()).'/'.rawurlencode($this->getSelection()).'/'; + return joinpath($path).url_params(); } public function getTranslatedLink() { - return $this->getLink().'translated/'; + return joinpath([$this->getLink(), 'translated']); } public function getDisplay() diff --git a/model/RoomTab.php b/model/RoomTab.php index 16a8359..c7b564f 100644 --- a/model/RoomTab.php +++ b/model/RoomTab.php @@ -20,11 +20,13 @@ class RoomTab public function getLink() { + $path = [$this->getRoom()->getConference()->getSlug(), $this->getRoom()->getSlug()]; + $tabs = $this->getRoom()->getTabNames(); - if($tabs[0] == $this->getTab()) - return rawurlencode($this->getRoom()->getSlug()).'/'.url_params(); + if($tabs[0] != $this->getTab()) + $path[] = $this->getTab(); - return rawurlencode($this->getRoom()->getSlug()).'/'.rawurlencode($this->getTab()).'/'.url_params(); + return joinpath($path).url_params(); } public function getDisplay() diff --git a/model/Schedule.php b/model/Schedule.php index c0ff69b..0b789f2 100644 --- a/model/Schedule.php +++ b/model/Schedule.php @@ -1,26 +1,37 @@ <?php -class Schedule extends ModelBase +class Schedule { + private $conference; + + public function __construct($conference) + { + $this->conference = $conference; + } + + public function getConference() { + return $this->conference; + } + public function isEnabled() { - return $this->has('SCHEDULE'); + return $this->getConference()->has('SCHEDULE'); } private function isRoomFiltered($room) { - if(!$this->has('SCHEDULE.ROOMFILTER')) + if(!$this->getConference()->has('SCHEDULE.ROOMFILTER')) return false; - $rooms = $this->get('SCHEDULE.ROOMFILTER'); + $rooms = $this->getConference()->get('SCHEDULE.ROOMFILTER'); return !in_array($room, $rooms); } public function getSimulationOffset() { - return $this->get('SCHEDULE.SIMULATE_OFFSET', 0); + return $this->getConference()->get('SCHEDULE.SIMULATE_OFFSET', 0); } public function getScale() { - return floatval($this->get('SCHEDULE.SCALE', 7)); + return floatval($this->getConference()->get('SCHEDULE.SCALE', 7)); } private function fetchSchedule() @@ -35,7 +46,7 @@ class Schedule extends ModelBase $schedule = file_get_contents($this->getScheduleUrl(), false, $context); if(!$schedule) - throw new ScheduleException("Error Downloading Schedule from ".$this->getScheduleUrl()); + throw new ScheduleException("Error Downloading Schedule from ".$this->getConference()->getScheduleUrl()); return simplexml_load_string($schedule); } @@ -49,10 +60,10 @@ class Schedule extends ModelBase } catch(Exception $e) { - return array(); + return array('_error' => (string)$e); } - $mapping = $this->getScheduleToRoomSlugMapping(); + $mapping = $this->getConference()->getScheduleToRoomSlugMapping(); $program = array(); // re-calculate day-ends @@ -220,10 +231,10 @@ class Schedule extends ModelBase } - if($this->has('SCHEDULE.ROOMFILTER')) + if($this->getConference()->has('SCHEDULE.ROOMFILTER')) { // sort by roomfilter - $roomfilter = $this->get('SCHEDULE.ROOMFILTER'); + $roomfilter = $this->getConference()->get('SCHEDULE.ROOMFILTER'); // map roomfilter-rooms to room-slugs $roomfilter = array_map(function($e) use ($mapping) { @@ -246,7 +257,7 @@ class Schedule extends ModelBase public function getDurationSum() { $sum = 0; - $schedule = $this->getSchedule(); + $schedule = $this->getConference()->getSchedule(); foreach(reset($schedule) as $event) $sum += $event['duration']; @@ -263,13 +274,13 @@ class Schedule extends ModelBase private function getScheduleUrl() { - return $this->get('SCHEDULE.URL'); + return $this->getConference()->get('SCHEDULE.URL'); } public function getScheduleToRoomSlugMapping() { $mapping = array(); - foreach($this->get('ROOMS') as $slug => $room) + foreach($this->getConference()->get('ROOMS') as $slug => $room) { if(isset($room['SCHEDULE_NAME'])) $mapping[ $room['SCHEDULE_NAME'] ] = $slug; diff --git a/model/Subtitles.php b/model/Subtitles.php index e1878f2..1d401b8 100644 --- a/model/Subtitles.php +++ b/model/Subtitles.php @@ -1,14 +1,25 @@ <?php -class Subtitles extends ModelBase +class Subtitles { + private $conference; + + public function __construct(Conference $conference) + { + $this->conference = $conference; + } + + public function getConference() { + return $this->conference; + } + public function isEnabled() { - return $this->has('SUBTITLES'); + return $this->getConference()->has('SUBTITLES'); } public function getEnabledRooms($slug) { $rooms = []; - foreach(Room::rooms() as $room) + foreach($this->getConference()->getOverview()->getRooms() as $room) { if($room->hasSubtitles()) $rooms[] = $room; @@ -18,9 +29,9 @@ class Subtitles extends ModelBase } public function getPrimusURL() { - return $this->get('SUBTITLES.PRIMUS_URL'); + return $this->getConference()->get('SUBTITLES.PRIMUS_URL'); } public function getFrontendURL() { - return $this->get('SUBTITLES.FRONTEND_URL'); + return $this->getConference()->get('SUBTITLES.FRONTEND_URL'); } } diff --git a/template/allconferences.phtml b/template/allconferences.phtml index e1fb5e3..bee21d7 100644 --- a/template/allconferences.phtml +++ b/template/allconferences.phtml @@ -6,7 +6,7 @@ <div class="row clearfix"> <? $count = count($conferences) ?> - <? foreach($conferences as $idx => $info): ?> + <? foreach($conferences as $idx => $conference): ?> <? // when we have more then 3 conferences, all but the last 3 will be displayed with 1/3 width if($count - $idx <= ($count % 3)) @@ -24,8 +24,8 @@ "> <div class="panel panel-default"> <div class="panel-body"> - <a href="<?=h($info['link'])?>"><?=h($info['title'])?></a> - <p><?=h($info['description'])?></p> + <a href="<?=h($conference->getLink())?>"><?=h($conference->getTitle())?></a> + <p><?=h($conference->getDescription())?></p> </div> </div> </div> diff --git a/template/assemblies/feedback.phtml b/template/assemblies/feedback.phtml index a33cc31..6df80cc 100644 --- a/template/assemblies/feedback.phtml +++ b/template/assemblies/feedback.phtml @@ -1,4 +1,4 @@ -<form action="feedback/" target="feedback-target" method="post" role="form" class="feedback-form"> +<form action="<?=h($conference->getFeedbackURl())?>" target="feedback-target" method="post" role="form" class="feedback-form"> <div class="col-sm-4 col"> <div class="form-group"> <label for="net">Network Connection</label> @@ -52,7 +52,7 @@ <label for="stream">Stream</label> <select class="form-control" name="stream" id="stream"> <option></option> - <? foreach(Room::rooms() as $roomiter): ?> + <? foreach($conference->getRooms() as $roomiter): ?> <? if(!$roomiter->hasFeedback()) continue ?> <? foreach($roomiter->getSelections() as $selection): ?> <option diff --git a/template/assemblies/header.phtml b/template/assemblies/header.phtml index c4d92e7..6791bfe 100644 --- a/template/assemblies/header.phtml +++ b/template/assemblies/header.phtml @@ -15,8 +15,8 @@ </a> <? endif ?> - <? if(!$conference->hasEnded() && isset($feedback) && $feedback->isEnabled()): ?> - <a class="form-control btn btn-default feedback" title="Feedback" href="<?=h($feedback->getUrl())?>"> + <? if(!$conference->hasEnded() && $conference->hasFeedback()): ?> + <a class="form-control btn btn-default feedback" title="Feedback" href="<?=h($conference->getFeedbackUrl())?>"> <span class="fa fa-bullhorn"></span> </a> <? endif ?> diff --git a/template/feedback-read.phtml b/template/feedback-read.phtml index 0c42d37..8dc9cc7 100644 --- a/template/feedback-read.phtml +++ b/template/feedback-read.phtml @@ -1,6 +1,6 @@ <div class="container"> <h1><?=h($title)?></h1> - <form action="feedback/read/" method="POST"> + <form action="<?=h($conference->getFeedbackReadUrl())?>" method="POST"> <div class="row"> <div class="col-xs-12"> diff --git a/template/overview.phtml b/template/overview.phtml index c23320e..02f0b5f 100644 --- a/template/overview.phtml +++ b/template/overview.phtml @@ -1,6 +1,6 @@ <? include("$assemblies/banner.phtml") ?> -<div class="container"> +<div class="container" data-schedule-url="<?=h($conference->getScheduleJsonUrl())?>"> <div class="row headline"> <div class="col-xs-12"> <h1><?=h($title)?></h1> diff --git a/template/page.phtml b/template/page.phtml index b62f372..b3bad81 100644 --- a/template/page.phtml +++ b/template/page.phtml @@ -47,7 +47,7 @@ <link href="<?=h($assets)?>img/favicon.png" rel="icon" type="image/png" /> <link type="text/css" rel="stylesheet" href="<?=h($assets)?>mejs/mediaelementplayer.min.css" /> - <link type="text/css" rel="stylesheet" href="gen/main.css" /> + <link type="text/css" rel="stylesheet" href="<?=h($conference_assets)?>gen/main.css" /> <script type="text/javascript" src="<?=h($assets)?>js/lib/jquery.min.js"></script> <script type="text/javascript" src="<?=h($assets)?>js/lib/jquery.scrollTo.min.js"></script> diff --git a/view/feedback-read.php b/view/feedback-read.php index 4f04a02..3c29dbd 100644 --- a/view/feedback-read.php +++ b/view/feedback-read.php @@ -1,9 +1,6 @@ <?php -$feedback = new Feedback(); -if(!$feedback->isEnabled()) - throw new NotFoundException('Feedback is disabled'); - +$feedback = $conference->getFeedback(); if(!$feedback->isLoggedIn()) { $feedback->requestLogin(); diff --git a/view/feedback.php b/view/feedback.php index c4ba146..cff9c8e 100644 --- a/view/feedback.php +++ b/view/feedback.php @@ -1,11 +1,11 @@ <?php -$feedback = new Feedback(); -if(!$feedback->isEnabled()) +if(!$conference->hasFeedback()) throw new NotFoundException('Feedback is disabled'); $info = $_POST; +$feedback = $conference->getFeedback(); if($feedback->validate($info)) { $feedback->store($info); diff --git a/view/overview.php b/view/overview.php index 3b52e8f..93cf007 100644 --- a/view/overview.php +++ b/view/overview.php @@ -4,5 +4,5 @@ echo $tpl->render(array( 'page' => 'overview', 'title' => 'Live-Streams', - 'overview' => new Overview(), + 'overview' => $conference->getOverview(), )); diff --git a/view/relive.php b/view/relive.php index e59f80c..cc8d682 100644 --- a/view/relive.php +++ b/view/relive.php @@ -1,6 +1,6 @@ <?php -$relive = new Relive(); +$relive = $conference->getRelive(); if(!$relive->isEnabled()) throw new NotFoundException('Internal Relive is disabled'); diff --git a/view/room.php b/view/room.php index 505be95..d586248 100644 --- a/view/room.php +++ b/view/room.php @@ -1,6 +1,6 @@ <?php -$room = new Room($_GET['room']); +$room = $conference->getRoom($_GET['room']); $stream = $room->selectStream( $_GET['selection'], $_GET['language']); @@ -11,5 +11,5 @@ echo $tpl->render(array( 'room' => $room, 'stream' => $stream, - 'schedule' => new Schedule(), + 'schedule' => $conference->getSchedule(), )); diff --git a/view/schedule-json.php b/view/schedule-json.php index 9aea603..19346fd 100644 --- a/view/schedule-json.php +++ b/view/schedule-json.php @@ -1,6 +1,6 @@ <?php -$schedule = new Schedule(); +$schedule = $conference->getSchedule(); if(!$schedule->isEnabled()) throw new NotFoundException('Schedule is disabled'); diff --git a/view/schedule.php b/view/schedule.php index 4b2746d..3a3d6db 100644 --- a/view/schedule.php +++ b/view/schedule.php @@ -5,5 +5,5 @@ echo $tpl->render(array( 'title' => 'Schedule-Übersicht', 'refresh' => 15*60, - 'schedule' => new Schedule(), + 'schedule' => $conference->getSchedule(), )); |