1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
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(),
'streamId' => $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);
|