mirror of
https://github.com/voc/streaming-website
synced 2024-11-10 06:34:17 +00:00
Move get/set-Calls into ModelBase and abstract all access into a Model
Conflicts: model/Overview.php model/Room.php model/StreamList.php tests/ModelTestbase.php
This commit is contained in:
parent
97fe6bf0af
commit
ea4b6c7699
14 changed files with 221 additions and 82 deletions
42
config.php
42
config.php
|
@ -61,6 +61,27 @@ $GLOBALS['CONFIG']['CONFERENCE'] = array(
|
|||
* Wird diese Zeile auskommentiert, wird kein Banner ausgegeben.
|
||||
*/
|
||||
//'BANNER_HTML' => '31C3 – a new dawn',
|
||||
|
||||
/**
|
||||
* Link zu den Recordings
|
||||
* Wird diese Zeile auskommentiert, wird der Link nicht angezeigt
|
||||
*/
|
||||
'RELEASES' => 'http://media.ccc.de/browse/congress/2014/index.html',
|
||||
|
||||
/**
|
||||
* Link zu einer (externen) ReLive-Übersichts-Seite
|
||||
* Wird diese Zeile auskommentiert, wird der Link nicht angezeigt
|
||||
*/
|
||||
//'RELIVE' => 'http://vod.c3voc.de/',
|
||||
|
||||
/**
|
||||
* Alternativ kann ein ReLive-Json konfiguriert werden, um die interne
|
||||
* ReLive-Ansicht zu aktivieren.
|
||||
*
|
||||
* Wird beides aktiviert, hat der externe Link Vorrang!
|
||||
* Wird beides auskommentiert, wird der Link nicht angezeigt
|
||||
*/
|
||||
'RELIVE_JSON' => 'http://vod.c3voc.de/index.json',
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -90,27 +111,6 @@ $GLOBALS['CONFIG']['OVERVIEW'] = array(
|
|||
'sendezentrum',
|
||||
),
|
||||
),
|
||||
|
||||
/**
|
||||
* Link zu den Recordings
|
||||
* Wird diese Zeile auskommentiert, wird der Link nicht angezeigt
|
||||
*/
|
||||
'RELEASES' => 'http://media.ccc.de/browse/congress/2014/index.html',
|
||||
|
||||
/**
|
||||
* Link zu einer (externen) ReLive-Übersichts-Seite
|
||||
* Wird diese Zeile auskommentiert, wird der Link nicht angezeigt
|
||||
*/
|
||||
//'RELIVE' => 'http://vod.c3voc.de/',
|
||||
|
||||
/**
|
||||
* Alternativ kann ein ReLive-Json konfiguriert werden, um die interne
|
||||
* ReLive-Ansicht zu aktivieren.
|
||||
*
|
||||
* Wird beides aktiviert, hat der externe Link Vorrang!
|
||||
* Wird beides auskommentiert, wird der Link nicht angezeigt
|
||||
*/
|
||||
'RELIVE_JSON' => 'http://vod.c3voc.de/index.json',
|
||||
);
|
||||
|
||||
|
||||
|
|
|
@ -6,6 +6,10 @@ require_once('lib/PhpTemplate.php');
|
|||
require_once('lib/Exceptions.php');
|
||||
require_once('lib/helper.php');
|
||||
|
||||
require_once('model/ModelBase.php');
|
||||
require_once('model/Conference.php');
|
||||
require_once('model/Feedback.php');
|
||||
require_once('model/Schedule.php');
|
||||
require_once('model/Overview.php');
|
||||
require_once('model/Room.php');
|
||||
|
||||
|
@ -17,6 +21,10 @@ $tpl = new PhpTemplate('template/page.phtml');
|
|||
$tpl->set(array(
|
||||
'baseurl' => baseurl(),
|
||||
'assemblies' => './template/assemblies/',
|
||||
|
||||
'conference' => new Conference(),
|
||||
'feedback' => new Feedback(),
|
||||
'schedule' => new Schedule(),
|
||||
));
|
||||
|
||||
|
||||
|
|
70
model/Conference.php
Normal file
70
model/Conference.php
Normal file
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
|
||||
class Conference extends ModelBase
|
||||
{
|
||||
public function getTitle() {
|
||||
return $this->get('CONFERENCE.TITLE', 'C3Voc Streaming');
|
||||
}
|
||||
|
||||
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 hasRelive() {
|
||||
return $this->has('CONFERENCE.RELIVE') || $this->has('CONFERENCE.RELIVE_JSON');
|
||||
}
|
||||
public function getReliveUrl() {
|
||||
if($this->has('CONFERENCE.RELIVE'))
|
||||
return $this->get('CONFERENCE.RELIVE');
|
||||
|
||||
elseif($this->has('CONFERENCE.RELIVE_JSON'))
|
||||
return 'relive/';
|
||||
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
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 getAboutUrl() {
|
||||
return 'about/';
|
||||
}
|
||||
}
|
11
model/Feedback.php
Normal file
11
model/Feedback.php
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
class Feedback extends ModelBase
|
||||
{
|
||||
public function isEnabled() {
|
||||
return $this->has('FEEDBACK');
|
||||
}
|
||||
public function getUrl() {
|
||||
return 'feedback/';
|
||||
}
|
||||
}
|
42
model/ModelBase.php
Normal file
42
model/ModelBase.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
class Modelbase
|
||||
{
|
||||
protected function has($keychain)
|
||||
{
|
||||
return $this->_has($GLOBALS['CONFIG'], $keychain);
|
||||
}
|
||||
private function _has($array, $keychain)
|
||||
{
|
||||
if(!is_array($keychain))
|
||||
$keychain = explode('.', $keychain);
|
||||
|
||||
$key = $keychain[0];
|
||||
if(!isset($array[$key]))
|
||||
return false;
|
||||
|
||||
if(count($keychain) == 1)
|
||||
return true;
|
||||
|
||||
return $this->_has($array[$key], array_slice($keychain, 1));
|
||||
}
|
||||
|
||||
protected function get($keychain, $default = null)
|
||||
{
|
||||
return $this->_get($GLOBALS['CONFIG'], $keychain, $default);
|
||||
}
|
||||
private function _get($array, $keychain, $default)
|
||||
{
|
||||
if(!is_array($keychain))
|
||||
$keychain = explode('.', $keychain);
|
||||
|
||||
$key = $keychain[0];
|
||||
if(!isset($array[$key]))
|
||||
return $default;
|
||||
|
||||
if(count($keychain) == 1)
|
||||
return $array[$key];
|
||||
|
||||
return $this->_get($array[$key], array_slice($keychain, 1), $default);
|
||||
}
|
||||
}
|
|
@ -1,13 +1,11 @@
|
|||
<?php
|
||||
|
||||
require_once('model/Room.php');
|
||||
|
||||
class Overview
|
||||
class Overview extends ModelBase
|
||||
{
|
||||
public function getGroups() {
|
||||
$groups = array();
|
||||
|
||||
foreach(get('OVERVIEW.GROUPS') as $group => $rooms)
|
||||
foreach($this->get('OVERVIEW.GROUPS') as $group => $rooms)
|
||||
{
|
||||
foreach($rooms as $room)
|
||||
{
|
||||
|
@ -24,29 +22,4 @@ class Overview
|
|||
|
||||
return $groups;
|
||||
}
|
||||
|
||||
public function getReleasesUrl() {
|
||||
return get('OVERVIEW.RELEASES');
|
||||
}
|
||||
|
||||
public function getReliveUrl() {
|
||||
if(has('OVERVIEW.RELIVE'))
|
||||
return get('OVERVIEW.RELIVE');
|
||||
|
||||
elseif(has('OVERVIEW.RELIVE_JSON'))
|
||||
return 'relive/';
|
||||
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function hasRelive() {
|
||||
return has('OVERVIEW.RELIVE') || has('OVERVIEW.RELIVE_JSON');
|
||||
}
|
||||
|
||||
public function hasReleases() {
|
||||
return has('OVERVIEW.RELEASES');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
<?php
|
||||
|
||||
class Room
|
||||
class Room extends ModelBase
|
||||
{
|
||||
private $slug;
|
||||
|
||||
public function __construct($slug)
|
||||
{
|
||||
if(! has('ROOMS.'.$slug))
|
||||
if(! $this->has('ROOMS.'.$slug))
|
||||
throw new NotFoundException('Room '.$slug);
|
||||
|
||||
$this->slug = $slug;
|
||||
|
@ -26,11 +26,11 @@ class Room
|
|||
}
|
||||
|
||||
public function getStream() {
|
||||
return get('ROOMS.'.$this->getSlug().'.STREAM', $this->getSlug());
|
||||
return $this->get('ROOMS.'.$this->getSlug().'.STREAM', $this->getSlug());
|
||||
}
|
||||
|
||||
public function getDisplay() {
|
||||
return get('ROOMS.'.$this->getSlug().'.DISPLAY', $this->getSlug());
|
||||
return $this->get('ROOMS.'.$this->getSlug().'.DISPLAY', $this->getSlug());
|
||||
}
|
||||
|
||||
|
||||
|
@ -40,6 +40,6 @@ class Room
|
|||
}
|
||||
|
||||
public function hasSchedule() {
|
||||
return get('ROOMS.'.$this->getSlug().'.SCHEDULE') && has('SCHEDULE');
|
||||
return $this->get('ROOMS.'.$this->getSlug().'.SCHEDULE') && $this->has('SCHEDULE');
|
||||
}
|
||||
}
|
||||
|
|
8
model/Schedule.php
Normal file
8
model/Schedule.php
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
class Schedule extends ModelBase
|
||||
{
|
||||
public function getSimulationOffset() {
|
||||
return $this->get('SCHEDULE.SIMULATE_OFFSET', 0);
|
||||
}
|
||||
}
|
|
@ -1,9 +1,35 @@
|
|||
<?php
|
||||
|
||||
class StreamList implements AggregateIterator
|
||||
class StreamList extends ModelBase implements IteratorAggregate
|
||||
{
|
||||
private $streams = array();
|
||||
|
||||
public function __construct($slug)
|
||||
{
|
||||
if(! $this->has('ROOMS.'.$slug))
|
||||
throw new NotFoundException('Room '.$slug);
|
||||
|
||||
$this->slug = $slug;
|
||||
$this->streams = array();
|
||||
|
||||
$streams = $this->get("ROOMS.$slug.STREAMS");
|
||||
foreach((array)$streams as $stream) {
|
||||
$this->streams[$stream] = explode('-', $stream);
|
||||
}
|
||||
}
|
||||
|
||||
public function getRoomSlug() {
|
||||
return $this->slug;
|
||||
}
|
||||
|
||||
public function getRoom() {
|
||||
return new Room($this->getRoomSlug());
|
||||
}
|
||||
|
||||
public function getStreams() {
|
||||
return array_keys($this->streams);
|
||||
}
|
||||
|
||||
public function getIterator() {
|
||||
return new ArrayIterator($this->streams);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<? if(has('CONFERENCE.BANNER_HTML')) ?>
|
||||
<div class="banner">
|
||||
<?=get('CONFERENCE.BANNER_HTML')?>
|
||||
</div>
|
||||
<? if($conference->hasBannerHtml()): ?>
|
||||
<div class="banner">
|
||||
<?=$conference->getBannerHtml()?>
|
||||
</div>
|
||||
<? endif ?>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<footer>
|
||||
<? if(has('CONFERENCE.FOOTER_HTML')): ?>
|
||||
<?= get('CONFERENCE.FOOTER_HTML') ?>
|
||||
<? if($conference->hasFooterHtml()): ?>
|
||||
<?= $conference->getFooterHtml() ?>
|
||||
<? else: ?>
|
||||
by <a href="https://c3voc.de">c3voc</a>
|
||||
<? endif ?>
|
||||
|
|
|
@ -3,22 +3,22 @@
|
|||
<div class="navbar-header">
|
||||
<a class="navbar-brand" href="">
|
||||
<i class="icon"></i>
|
||||
<?=h(get('CONFERENCE.TITLE', 'C3Voc Streaming'))?>
|
||||
<?=h($conference->getTitle())?>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="nav navbar-form navbar-right button-wrapper">
|
||||
<? if(has('FEEDBACK')): ?>
|
||||
<a class="form-control btn btn-default" href="feedback/">
|
||||
<? if($feedback->isEnabled()): ?>
|
||||
<a class="form-control btn btn-default" href="<?=h($feedback->getUrl())?>">
|
||||
<span class="fa fa-bullhorn"></span>
|
||||
</a>
|
||||
<? endif ?>
|
||||
<? if(has('OVERVIEW.RELEASES')): ?>
|
||||
<a class="form-control btn btn-default" href="<?=h(get('OVERVIEW.RELEASES'))?>">
|
||||
<? if($conference->hasReleases()): ?>
|
||||
<a class="form-control btn btn-default" href="<?=h($conference->getReleasesUrl())?>">
|
||||
<span class="fa fa-video-camera"></span>
|
||||
</a>
|
||||
<? endif ?>
|
||||
<a class="form-control btn btn-default" href="about/">
|
||||
<a class="form-control btn btn-default" href="<?=h($conference->getAboutUrl())?>">
|
||||
<span class="fa fa-info"></span>
|
||||
</a>
|
||||
</div>
|
||||
|
|
|
@ -89,9 +89,9 @@
|
|||
</div>
|
||||
<? endforeach ?>
|
||||
|
||||
<? if($overview->hasReleases() || $overview->hasRelive()): ?>
|
||||
<? if($conference->hasReleases() || $conference->hasRelive()): ?>
|
||||
<?
|
||||
$class = ($overview->hasReleases() && $overview->hasRelive()) ?
|
||||
$class = ($conference->hasReleases() && $conference->hasRelive()) ?
|
||||
// both enabled
|
||||
'col-sm-6 col-xs-12' :
|
||||
|
||||
|
@ -104,11 +104,11 @@
|
|||
<h2>Recordings</h2>
|
||||
</div>
|
||||
|
||||
<? if($overview->hasReleases()): ?>
|
||||
<? if($conference->hasReleases()): ?>
|
||||
<div class="<?=h($class)?>">
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-body">
|
||||
<a href="<?=h($overview->getReleasesUrl())?>">
|
||||
<a href="<?=h($conference->getReleasesUrl())?>">
|
||||
<span class="fa fa-video-camera"></span> Releases
|
||||
</a>
|
||||
</div>
|
||||
|
@ -116,11 +116,11 @@
|
|||
</div>
|
||||
<? endif ?>
|
||||
|
||||
<? if($overview->hasRelive()): ?>
|
||||
<? if($conference->hasRelive()): ?>
|
||||
<div class="<?=h($class)?>">
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-body">
|
||||
<a href="<?=h($overview->getReliveUrl())?>">
|
||||
<a href="<?=h($conference->getReliveUrl())?>">
|
||||
<span class="fa fa-play-circle"></span> ReLive
|
||||
</a>
|
||||
</div>
|
||||
|
|
|
@ -8,20 +8,20 @@
|
|||
|
||||
<? include("$assemblies/motd.phtml") ?>
|
||||
|
||||
<title><?=h($title)?> – <?=h(get('CONFERENCE.TITLE', 'C3Voc'))?> Streaming</title>
|
||||
<title><?=h($title)?> – <?=h($conference->getTitle())?> Streaming</title>
|
||||
|
||||
<meta name="robots" content="index,follow" />
|
||||
|
||||
<? if(has('CONFERENCE.AUTHOR')): ?>
|
||||
<meta name="author" content="<?=h(get('CONFERENCE.AUTHOR'))?>" />
|
||||
<? if($conference->hasAuthor()): ?>
|
||||
<meta name="author" content="<?=h($conference->getAuthor())?>" />
|
||||
<? endif ?>
|
||||
|
||||
<? if(has('CONFERENCE.DESCRIPTION')): ?>
|
||||
<meta name="description" content="<?=h(get('CONFERENCE.DESCRIPTION'))?>" />
|
||||
<? if($conference->hasDescription()): ?>
|
||||
<meta name="description" content="<?=h($conference->getDescription())?>" />
|
||||
<? endif ?>
|
||||
|
||||
<? if(has('CONFERENCE.KEYWORDS')): ?>
|
||||
<meta name="keywords" content="<?=h(get('CONFERENCE.KEYWORDS'))?>" />
|
||||
<? if($conference->hasKeywords()): ?>
|
||||
<meta name="keywords" content="<?=h($conference->getKeywords())?>" />
|
||||
<? endif ?>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
|
@ -57,7 +57,7 @@
|
|||
<? include("$assemblies/footer.phtml") ?>
|
||||
|
||||
<span class="js-settings"
|
||||
data-scheduleoffset="<?=h(get('SCHEDULE.SIMULATE_OFFSET', 0))?>"
|
||||
data-scheduleoffset="<?=h($schedule->getSimulationOffset())?>"
|
||||
></span>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in a new issue