diff options
author | Florian Larysch | 2015-09-02 12:56:32 +0200 |
---|---|---|
committer | Florian Larysch | 2015-09-02 14:31:39 +0200 |
commit | 7a5c8ff018936ed7328042c88a2edae3c29d91be (patch) | |
tree | 23efc9fdb4e3c8fd1c44cc49a3f30be0a6ed1987 | |
parent | 502371650e4e1fe99ec382104e2eba945925a459 (diff) |
Automatically open/close conference based on time.
Toggle the 'closed' bit based on the current time, rather than manually
setting it in the config. This patch also adds a distinction between the
time before the conference and after: Different pages will be displayed
as to not confuse the user.
-rw-r--r-- | config.php | 23 | ||||
-rw-r--r-- | index.php | 7 | ||||
-rw-r--r-- | model/Conference.php | 35 | ||||
-rw-r--r-- | template/assemblies/header.phtml | 2 | ||||
-rw-r--r-- | template/assemblies/recordings.phtml | 41 | ||||
-rw-r--r-- | template/not_started.phtml | 3 | ||||
-rw-r--r-- | view/not_started.php | 5 |
7 files changed, 109 insertions, 7 deletions
@@ -14,11 +14,26 @@ if($_SERVER['HTTP_HOST'] != 'localhost') $GLOBALS['CONFIG']['CONFERENCE'] = array( /** - * Am Ende der Konferenz wird durch das Umlegen dieses Schalters auf True eine Danke-Und-Kommen-Sie- - * Gut-Nach-Hause-Seite sowie einem Ausblick auf die kommenden Events angezeigt. Während einer - * Konferenz kann dieser Schalter auskommentiert oder auf false gesetzt werden. + * Der Startzeitpunkt der Konferenz als Unix-Timestamp. Befinden wir uns davor, wird die Closed-Seite + * mit einem Text der Art "hat noch nicht angefangen" angezeigt. */ - 'CLOSED' => false, + 'STARTS_AT' => strtotime("2014-12-27 06:00"), + + /** + * Der Endzeitpunkt der Konferenz als Unix-Timestamp. Befinden wir uns danach, wird eine Danke-Und-Kommen-Sie- + * Gut-Nach-Hause-Seite sowie einem Ausblick auf die kommenden Events angezeigt. + */ + 'ENDS_AT' => strtotime("2014-12-30 21:00"), + + /** + * Hiermit kann die Funktionalitaet von STARTS_AT/ENDS_AT überschrieben werden. Der Wert 'before' + * simuliert, dass die Konferenz noch nicht begonnen hat. Der Wert 'after' simuliert, dass die Konferenz + * bereits beendet ist. 'running' simuliert eine laufende Konferenz. + * + * Der Boolean true ist aus Abwärtskompatibilitätsgründen äquivalent zu 'after'. False ist äquivalent + * zu 'running'. + */ + //'CLOSED' => false, /** * Titel der Konferenz (kann Leer- und Sonderzeichen enthalten) @@ -65,7 +65,12 @@ try { require('view/streams-json-v1.php'); } - else if($conference->isClosed()) + else if($conference->hasBegun()) + { + require('view/not_started.php'); + } + + else if($conference->hasEnded()) { require('view/closed.php'); } diff --git a/model/Conference.php b/model/Conference.php index e927a2b..d6ef913 100644 --- a/model/Conference.php +++ b/model/Conference.php @@ -7,7 +7,40 @@ class Conference extends ModelBase } public function isClosed() { - return $this->get('CONFERENCE.CLOSED'); + return !$this->hasBegun() || $this->hasEnded(); + } + + public function hasBegun() { + 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; + else if($closed == "running") + return true; + } + + return time() >= $this->get('CONFERENCE.STARTS_AT'); + } + + public function hasEnded() { + if($this->has('CONFERENCE.CLOSED')) { + $closed = $this->get('CONFERENCE.CLOSED'); + + if($closed == "after" || $closed === true) + return true; + else if($closed == "running" || $closed === false) + return false; + } + + return time() >= $this->get('CONFERENCE.ENDS_AT'); } public function hasAuthor() { diff --git a/template/assemblies/header.phtml b/template/assemblies/header.phtml index 68f4b6d..f57054c 100644 --- a/template/assemblies/header.phtml +++ b/template/assemblies/header.phtml @@ -15,7 +15,7 @@ </a> <? endif ?> - <? if(!$conference->isClosed() && $feedback->isEnabled()): ?> + <? if(!$conference->hasEnded() && $feedback->isEnabled()): ?> <a class="form-control btn btn-default" href="<?=h($feedback->getUrl())?>"> <span class="fa fa-bullhorn"></span> </a> diff --git a/template/assemblies/recordings.phtml b/template/assemblies/recordings.phtml new file mode 100644 index 0000000..71b7866 --- /dev/null +++ b/template/assemblies/recordings.phtml @@ -0,0 +1,41 @@ +<? if($conference->hasReleases() || $conference->hasRelive()): ?> + <? + $class = ($conference->hasReleases() && $conference->hasRelive()) ? + // both enabled + 'col-sm-6 col-xs-12' : + + // only one of both enabled + 'col-xs-12'; + ?> + <div class="row recordings"> + + <div class="col-xs-12"> + <h2>Recordings</h2> + </div> + + <? if($conference->hasReleases()): ?> + <div class="<?=h($class)?>"> + <div class="panel panel-primary"> + <div class="panel-body"> + <a href="<?=h($conference->getReleasesUrl())?>"> + <span class="fa fa-video-camera"></span> Releases + </a> + </div> + </div> + </div> + <? endif ?> + + <? if($conference->hasRelive()): ?> + <div class="<?=h($class)?>"> + <div class="panel panel-primary"> + <div class="panel-body"> + <a href="<?=h($conference->getReliveUrl())?>"> + <span class="fa fa-play-circle"></span> ReLive + </a> + </div> + </div> + </div> + <? endif ?> + + </div> +<? endif ?> diff --git a/template/not_started.phtml b/template/not_started.phtml new file mode 100644 index 0000000..a434f02 --- /dev/null +++ b/template/not_started.phtml @@ -0,0 +1,3 @@ +<div class="container about"> + <h1><?=h($conference->getTitle())?> has not started yet!</h1> +</div> diff --git a/view/not_started.php b/view/not_started.php new file mode 100644 index 0000000..ce4767c --- /dev/null +++ b/view/not_started.php @@ -0,0 +1,5 @@ +<?php +echo $tpl->render(array( + 'page' => 'not_started', + 'title' => 'See you soon!', +)); |