aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--index.php12
-rw-r--r--view/config-json.php94
2 files changed, 106 insertions, 0 deletions
diff --git a/index.php b/index.php
index b109937..1c0df61 100644
--- a/index.php
+++ b/index.php
@@ -112,6 +112,12 @@ try {
exit;
}
+ else if($route == 'config.json')
+ {
+ require('view/config-json.php');
+ exit;
+ }
+
else if($route == 'about')
{
// global about-page
@@ -182,6 +188,12 @@ ob_start();
try {
$conference = Conferences::getConference($mandator);
+ if($route == 'config.json')
+ {
+ require('view/config-json.php');
+ exit();
+ }
+
// update template information
$tpl->set(array(
'baseurl' => forceslash(baseurl()),
diff --git a/view/config-json.php b/view/config-json.php
new file mode 100644
index 0000000..e6d26e4
--- /dev/null
+++ b/view/config-json.php
@@ -0,0 +1,94 @@
+<?php
+
+header('Content-Type: application/json');
+
+function formatConference($conference) {
+ return array(
+ 'conference' => array(
+ 'title' => $conference->getTitle(),
+ 'acronym' => $conference->getSlug(),
+ 'organizer' => $conference->getAuthor(),
+ 'description' => $conference->getDescription(),
+ 'keywords' => $conference->hasKeywords() ? preg_split('/,\s*/', $conference->getKeywords()) : null,
+ 'start' => $conference->startsAt() ? $conference->startsAt()->format('c') : null,
+ 'end' => $conference->endsAt() ? $conference->endsAt()->format('c') : null,
+ 'streamingConfig' => array(
+ //'closed' => null,
+ //'unlisted' => $conference->isUnlisted(),
+ 'features' => array(
+ 'embed' => $conference->get('EMBED', false),
+ 'relive' => $conference->hasRelive(),
+ 'feedback' => $conference->hasFeedback(),
+ 'irc' => lowerCaseKeys($conference->get('IRC', false)),
+ 'twitter' => lowerCaseKeys($conference->get('TWITTER', false)),
+ ),
+ 'schedule' => lowerCaseKeys($conference->get('SCHEDULE')),
+ 'overviewPage' => array(
+ 'sections' => formatSections($conference->get('OVERVIEW.GROUPS')),
+ ),
+ 'html' => array(
+ 'banner' => $conference->getBannerHtml(),
+ 'footer' => $conference->getFooterHtml(),
+ 'not_started' => $conference->getNotStartedHtml(),
+ ),
+ 'extraFiles' => $conference->get('EXTRA_FILES'),
+ ),
+ 'rooms' => formatRooms($conference),
+ ),
+ );
+}
+
+function formatRooms($conference) {
+ $struct = [];
+
+ foreach($conference->getRooms() as $room) {
+ $config = $conference->get('ROOMS.'.$room->getSlug());
+ $struct[] = array(
+ 'name' => $room->getDisplay(),
+ 'slug' => $room->getSlug(),
+ 'livestreamId' => $room->getStream(),
+ 'streamingConfig' => lowerCaseKeys($config),
+ );
+ }
+ return $struct;
+}
+
+function formatSections($pageConfig) {
+ $struct = [];
+
+ foreach($pageConfig as $sectionTitle => $rooms)
+ {
+ $section = array(
+ 'title' => $sectionTitle,
+ 'rooms' => [],
+ );
+
+ foreach($rooms as $room)
+ {
+ $section['rooms'][] = array(
+ 'slug' => $room,
+ );
+ }
+ $struct[] = $section;
+ }
+ return $struct;
+}
+
+function lowerCaseKeys($config)
+{
+ return array_map(function($item) {
+ return is_array($item) ? lowerCaseKeys($item) : $item;
+ }, array_change_key_case($config));
+}
+
+if (!empty($conference)) {
+ $struct = formatConference($conference);
+}
+else {
+ $struct = [];
+ foreach (Conferences::getActiveConferences() as $conference)
+ {
+ $struct[] = formatConference($conference);
+ }
+}
+echo json_encode($struct, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);