blob: ed58a4f1815c41718eab8ad271cd840a7846d91d (
plain)
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
<?php
require_once __DIR__ . '/rms.php';
require_once __DIR__ . '/mediaselector.php';
function next_renderFromRms(string $path) {
next_renderExperience(rms_fetch($path)->data);
}
function next_renderExperience(array $modules) {
foreach ($modules as $m) {
next_renderModule($m);
}
}
function next_renderModule(stdClass $module) {
$type = strtr($module->type, '_', '-');
$titleTag = $type == 'inline-header-module' ? 'h1' : 'h2';
echo "<$type id=\"$module->id\" module-style=\"$module->style\">";
echo "<$titleTag>"
. htmlspecialchars($module->title ?? '[no title]')
. "</$titleTag>";
if (isset($module->description)) {
echo '<module-description>'
. htmlspecialchars($module->description)
. '</module-description>';
}
echo '<module-items>';
if (!is_array($module->data)) {
next_renderItem($module->data);
} else {
foreach ($module->data as $item) {
next_renderItem($item);
}
}
echo "</module-items>";
if ($module->id == 'aod_play_area') {
$url = mediaselector_findHls($module->data[0]->id);
echo '<audio controls hidden id="hls-player" data-hls="' . $url . '" />';
echo '<script src="static/hls-player.js" defer></script>';
}
echo "</$type>";
}
function next_renderItem(stdClass $item) {
$type = strtr($item->type, '_', '-');
$primaryTag = $type == 'segment-item' ? 'primary-title' : 'h3';
echo "<$type id=\"$item->id\">";
echo '<item-titles><item-first-titles>';
echo "<$primaryTag>"
. htmlspecialchars($item->titles?->primary ?? '[no primary]')
. "</$primaryTag>";
if (isset($item->network)) {
echo '<item-network>'
. htmlspecialchars($item->network->short_title)
. '</item-network>';
}
echo '</item-first-titles>';
if (isset($item->titles->secondary)) {
echo '<secondary-title>'
. htmlspecialchars($item->titles->secondary)
. '</secondary-title>';
}
if (isset($item->titles->tertiary)) {
echo '<tertiary-title>'
. htmlspecialchars($item->titles->tertiary)
. '</tertiary-title>';
}
echo '</item-titles>';
if (isset($item->synopses?->short, $item->synopses?->medium)) {
echo '<synopsis><details><summary>'
. htmlspecialchars($item->synopses->short)
. '</summary>'
. htmlspecialchars($item->synopses->long ?? $item->synopses->medium)
. '</details></synopsis>';
} elseif (isset($item->synopses?->short)) {
echo '<synopsis>' . htmlspecialchars($item->synopses->short)
. '</synopsis>';
}
if (isset($item->item)) {
next_renderItem($item->item);
}
if (isset($item->offset)) {
echo '<offset-start>'
. gmdate('H:i:s', $item->offset->start)
. '</offset-start>';
echo '<offset-end>'
. gmdate('H:i:s', $item->offset->end)
. '</offset-end>';
}
if ($type == 'container-item') {
$href = '?path=' . RMS_SOUNDS_CONTAINER . '/' . $item->urn;
echo "<a href=\"$href\">View</a>";
} elseif ($type == 'playable-item') {
$pid = explode(':', $item->urn)[4];
$href = '?path=' . RMS_SOUNDS_PLAYABLE . '/' . $pid;
echo "<a href=\"$href\">Listen</a>";
}
foreach ($item->uris ?? [] as $uri) {
if ($uri->type != 'link') continue;
echo '<a href="' . htmlspecialchars($uri->uri) . '" target="_blank">'
. htmlspecialchars($uri->label) . '</a>';
}
if (isset($item->download) && $item->download->type == 'non_drm') {
$variant = $item->download->quality_variants->high;
echo '<a href="' . htmlspecialchars($variant->file_url) . '">'
. "Download ($variant->label)</a>";
}
echo "</$type>";
}
|