From 92d27365cadbd98e6d709673cd0729de8793c494 Mon Sep 17 00:00:00 2001
From: jade (winter)
Date: Fri, 5 Dec 2025 00:34:03 +0000
Subject: initial commit
---
lib/bbcnext.php | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 109 insertions(+)
create mode 100644 lib/bbcnext.php
(limited to 'lib/bbcnext.php')
diff --git a/lib/bbcnext.php b/lib/bbcnext.php
new file mode 100644
index 0000000..988d248
--- /dev/null
+++ b/lib/bbcnext.php
@@ -0,0 +1,109 @@
+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 ''
+ . htmlspecialchars($module->description)
+ . '';
+ }
+ echo '';
+ if (!is_array($module->data)) {
+ next_renderItem($module->data);
+ } else {
+ foreach ($module->data as $item) {
+ next_renderItem($item);
+ }
+ }
+ echo "$type>";
+}
+
+function next_renderItem(stdClass $item) {
+ $type = strtr($item->type, '_', '-');
+ $primaryTag = $type == 'segment-item' ? 'primary-title' : 'h3';
+ echo "<$type id=\"$item->id\">";
+ echo '';
+ echo "<$primaryTag>"
+ . htmlspecialchars($item->titles?->primary ?? '[no primary]')
+ . "$primaryTag>";
+ if (isset($item->network)) {
+ echo ''
+ . htmlspecialchars($item->network->short_title)
+ . '';
+ }
+ echo '';
+ if (isset($item->titles->secondary)) {
+ echo ''
+ . htmlspecialchars($item->titles->secondary)
+ . '';
+ }
+ if (isset($item->titles->tertiary)) {
+ echo ''
+ . htmlspecialchars($item->titles->tertiary)
+ . '';
+ }
+ echo '';
+ if (isset($item->synopses?->short, $item->synopses?->medium)) {
+ echo ''
+ . htmlspecialchars($item->synopses->short)
+ . '
'
+ . htmlspecialchars($item->synopses->long ?? $item->synopses->medium)
+ . ' ';
+ } elseif (isset($item->synopses?->short)) {
+ echo '' . htmlspecialchars($item->synopses->short)
+ . '';
+ }
+
+ if (isset($item->item)) {
+ next_renderItem($item->item);
+ }
+
+ if (isset($item->offset)) {
+ echo ''
+ . gmdate('H:i:s', $item->offset->start)
+ . '';
+ echo ''
+ . gmdate('H:i:s', $item->offset->end)
+ . '';
+ }
+
+ if ($type == 'container-item') {
+ $href = '?path=' . RMS_SOUNDS_CONTAINER . '/' . $item->urn;
+ echo "View";
+ } elseif ($type == 'playable-item') {
+ $pid = explode(':', $item->urn)[4];
+ $href = '?path=' . RMS_SOUNDS_PLAYABLE . '/' . $pid;
+ echo "Listen";
+ }
+
+ foreach ($item->uris ?? [] as $uri) {
+ if ($uri->type != 'link') continue;
+ echo ''
+ . htmlspecialchars($uri->label) . '';
+ }
+
+ if (isset($item->download) && $item->download->type == 'non_drm') {
+ $variant = $item->download->quality_variants->high;
+ echo ''
+ . "Download ($variant->label)";
+ }
+
+ echo "$type>";
+}
--
cgit v1.3