211 lines
12 KiB
PHP
211 lines
12 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
$payloadJson = json_encode($desktopPayload, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT);
|
|
$activeSkin = $desktopPayload['meta']['active_skin'];
|
|
$baseSkinProfile = $desktopPayload['meta']['base_skin_profile'];
|
|
$skinProfile = $desktopPayload['meta']['skin_profile'];
|
|
$wallpaper = $desktopPayload['desktop']['wallpaper'];
|
|
$debugShellApp = is_array($desktopPayload['shell']['debug_app'] ?? null) ? $desktopPayload['shell']['debug_app'] : null;
|
|
$debugShellLabel = trim((string) ($debugShellApp['label'] ?? 'Debug')) ?: 'Debug';
|
|
|
|
$assetVersion = static function (string $publicPath): string {
|
|
$filesystemPath = dirname(__DIR__, 2) . '/public' . $publicPath;
|
|
|
|
if (!is_file($filesystemPath)) {
|
|
return $publicPath;
|
|
}
|
|
|
|
$mtime = filemtime($filesystemPath);
|
|
|
|
return $mtime === false ? $publicPath : $publicPath . '?v=' . $mtime;
|
|
};
|
|
|
|
$nativeModuleStyles = [];
|
|
$nativeModuleScripts = [];
|
|
foreach ($desktopPayload['apps'] as $desktopApp) {
|
|
$assets = is_array($desktopApp['native_module']['assets'] ?? null) ? $desktopApp['native_module']['assets'] : [];
|
|
|
|
foreach ((array) ($assets['styles'] ?? []) as $style) {
|
|
if (!is_array($style) || trim((string) ($style['href'] ?? '')) === '') {
|
|
continue;
|
|
}
|
|
|
|
$href = (string) $style['href'];
|
|
$nativeModuleStyles[$href] = $style;
|
|
}
|
|
|
|
foreach ((array) ($assets['scripts'] ?? []) as $script) {
|
|
if (!is_array($script) || trim((string) ($script['src'] ?? '')) === '') {
|
|
continue;
|
|
}
|
|
|
|
$src = (string) $script['src'];
|
|
$nativeModuleScripts[$src] = $script;
|
|
}
|
|
}
|
|
|
|
$renderStartIcon = static function (array $profile): string {
|
|
$style = (string) ($profile['taskbar_icon_style'] ?? 'label');
|
|
|
|
return match ($style) {
|
|
'windows' => '<span class="start-glyph start-glyph-windows" aria-hidden="true"><span></span><span></span><span></span><span></span></span>',
|
|
'apple' => '<span class="start-glyph start-glyph-apple" aria-hidden="true"></span>',
|
|
'linux' => '<span class="start-glyph start-glyph-linux" aria-hidden="true"><span></span><span></span><span></span></span>',
|
|
default => '<span class="start-glyph start-glyph-label" aria-hidden="true">' . htmlspecialchars((string) ($profile['taskbar_icon'] ?? 'OS'), ENT_QUOTES) . '</span>',
|
|
};
|
|
};
|
|
?><!DOCTYPE html>
|
|
<html lang="de">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title><?= htmlspecialchars($desktopPayload['meta']['title'], ENT_QUOTES) ?></title>
|
|
<link rel="stylesheet" href="<?= htmlspecialchars($assetVersion('/assets/desktop/desktop.css'), ENT_QUOTES) ?>">
|
|
<?php if (!empty($baseSkinProfile['css_path'])): ?>
|
|
<link rel="stylesheet" href="<?= htmlspecialchars($assetVersion((string) $baseSkinProfile['css_path']), ENT_QUOTES) ?>">
|
|
<?php endif; ?>
|
|
<?php if (!empty($skinProfile['css_path']) && $skinProfile['css_path'] !== $baseSkinProfile['css_path']): ?>
|
|
<link rel="stylesheet" href="<?= htmlspecialchars($assetVersion((string) $skinProfile['css_path']), ENT_QUOTES) ?>">
|
|
<?php endif; ?>
|
|
</head>
|
|
<body
|
|
data-skin="<?= htmlspecialchars($activeSkin, ENT_QUOTES) ?>"
|
|
data-skin-family="<?= htmlspecialchars((string) ($skinProfile['family'] ?? $activeSkin), ENT_QUOTES) ?>"
|
|
data-taskbar-mode="<?= htmlspecialchars((string) ($skinProfile['taskbar_mode'] ?? 'taskbar'), ENT_QUOTES) ?>"
|
|
data-window-controls="<?= htmlspecialchars((string) ($skinProfile['window_controls'] ?? 'windows'), ENT_QUOTES) ?>"
|
|
style="--wallpaper: <?= htmlspecialchars($wallpaper, ENT_QUOTES) ?>;"
|
|
>
|
|
<div class="desktop-shell">
|
|
<?php if (($skinProfile['top_bar'] ?? false) === true): ?>
|
|
<header class="system-bar">
|
|
<div class="system-bar-left">
|
|
<span class="system-brand"><?= htmlspecialchars((string) ($skinProfile['label'] ?? ''), ENT_QUOTES) ?></span>
|
|
<span class="system-divider"></span>
|
|
<span>Finder</span>
|
|
<span>Ablage</span>
|
|
<span>Bearbeiten</span>
|
|
<span>Fenster</span>
|
|
</div>
|
|
<div class="system-bar-right">
|
|
<?php if (($desktopPayload['session']['is_admin'] ?? false) === true): ?>
|
|
<button class="tray-pill tray-pill-button tray-pill-debug" id="debug-toggle-top" type="button" aria-expanded="false"><?= htmlspecialchars($debugShellLabel, ENT_QUOTES) ?></button>
|
|
<?php endif; ?>
|
|
<time id="clock-top"></time>
|
|
</div>
|
|
</header>
|
|
<?php endif; ?>
|
|
<main class="desktop-stage">
|
|
<div class="desktop-icons" id="desktop-icons"></div>
|
|
|
|
<div class="widget-zone" id="widget-zone">
|
|
<?php foreach ($desktopPayload['widgets']['active'] as $widget): ?>
|
|
<article class="widget-card">
|
|
<div class="widget-card-header">
|
|
<div>
|
|
<h3><?= htmlspecialchars($widget['title'], ENT_QUOTES) ?></h3>
|
|
<p><?= htmlspecialchars($widget['summary'] ?? '', ENT_QUOTES) ?></p>
|
|
</div>
|
|
<span class="widget-badge"><?= htmlspecialchars($widget['icon'] ?? 'WG', ENT_QUOTES) ?></span>
|
|
</div>
|
|
<p><?= htmlspecialchars($widget['content'] ?? '', ENT_QUOTES) ?></p>
|
|
</article>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
|
|
<div class="window-layer" id="window-layer"></div>
|
|
|
|
<section class="start-menu" id="start-menu" hidden>
|
|
<div class="start-menu-sidebar" id="start-menu-user-settings">
|
|
<button class="start-menu-user-card" id="start-menu-user-card" type="button">
|
|
<span class="start-menu-user-avatar" id="start-menu-user-avatar">GU</span>
|
|
<span class="start-menu-user-copy">
|
|
<strong id="start-menu-user-name"><?= htmlspecialchars((string) ($desktopPayload['session']['display_name'] ?? 'Gast'), ENT_QUOTES) ?></strong>
|
|
<small>Benutzer</small>
|
|
</span>
|
|
</button>
|
|
<div class="start-menu-function-list" id="start-menu-functions">
|
|
<button class="start-menu-function is-active" type="button" data-function-id="programs">
|
|
<span class="start-menu-function-icon" aria-hidden="true">📁</span>
|
|
<span class="start-menu-function-copy">
|
|
<strong>Programme</strong>
|
|
<small>Installierte Apps</small>
|
|
</span>
|
|
</button>
|
|
</div>
|
|
<?php if (($desktopPayload['session']['authenticated'] ?? false) === true && !empty($desktopPayload['session']['logout_url'])): ?>
|
|
<a class="start-menu-session-action is-logout" id="start-menu-session-action" href="<?= htmlspecialchars((string) $desktopPayload['session']['logout_url'], ENT_QUOTES) ?>">
|
|
<span class="start-menu-session-icon" aria-hidden="true">⏻</span>
|
|
<span>Abmelden</span>
|
|
</a>
|
|
<?php else: ?>
|
|
<button class="start-menu-session-action" id="start-menu-session-action" type="button" data-session-action="login">
|
|
<span class="start-menu-session-icon" aria-hidden="true">→</span>
|
|
<span>Anmelden</span>
|
|
</button>
|
|
<?php endif; ?>
|
|
</div>
|
|
<div class="start-menu-selection-area start-menu-selection-area--programs">
|
|
<div class="start-menu-selection-header" id="start-menu-selection-header"></div>
|
|
<div class="start-menu-selection-list" id="start-menu-apps"></div>
|
|
</div>
|
|
</section>
|
|
|
|
<footer class="taskbar">
|
|
<button class="start-button" id="start-button" type="button">
|
|
<span class="start-button-icon"><?= $renderStartIcon($skinProfile) ?></span>
|
|
<span class="start-button-label"><?= htmlspecialchars((string) ($skinProfile['taskbar_label'] ?? 'Menu'), ENT_QUOTES) ?></span>
|
|
</button>
|
|
<div class="taskbar-apps" id="taskbar-apps"></div>
|
|
<div class="tray">
|
|
<?php foreach ($desktopPayload['tray'] as $trayItem): ?>
|
|
<button
|
|
class="tray-pill tray-pill-button"
|
|
type="button"
|
|
data-tray-id="<?= htmlspecialchars((string) $trayItem['id'], ENT_QUOTES) ?>"
|
|
<?php if (!empty($trayItem['app_id'])): ?>data-tray-app-id="<?= htmlspecialchars((string) $trayItem['app_id'], ENT_QUOTES) ?>" title="<?= htmlspecialchars((string) ($trayItem['title'] ?? $trayItem['label'] ?? ''), ENT_QUOTES) ?>"<?php endif; ?>
|
|
><?= htmlspecialchars($trayItem['label'], ENT_QUOTES) ?></button>
|
|
<?php endforeach; ?>
|
|
<?php if (($desktopPayload['session']['is_admin'] ?? false) === true): ?>
|
|
<button class="tray-pill tray-pill-button tray-pill-debug" id="debug-toggle" type="button" aria-expanded="false"><?= htmlspecialchars($debugShellLabel, ENT_QUOTES) ?></button>
|
|
<?php endif; ?>
|
|
<time id="clock"></time>
|
|
</div>
|
|
<div class="tray-menu" id="tray-account-menu" hidden>
|
|
<button class="tray-menu-entry" type="button" data-account-action="settings">Einstellungen</button>
|
|
<?php if (($desktopPayload['session']['authenticated'] ?? false) === true && !empty($desktopPayload['session']['logout_url'])): ?>
|
|
<a class="tray-menu-entry" data-account-action="logout" href="<?= htmlspecialchars((string) $desktopPayload['session']['logout_url'], ENT_QUOTES) ?>">Logout</a>
|
|
<?php else: ?>
|
|
<button class="tray-menu-entry" type="button" data-account-action="login">Login</button>
|
|
<?php endif; ?>
|
|
</div>
|
|
<div class="tray-menu" id="tray-fx-menu" hidden>
|
|
<p class="tray-menu-copy" id="tray-fx-status">Kursstatus wird geladen ...</p>
|
|
<button class="tray-menu-entry" type="button" data-fx-action="refresh">Refresh</button>
|
|
<button class="tray-menu-entry" type="button" data-fx-action="force-refresh">Force-Refresh</button>
|
|
</div>
|
|
</footer>
|
|
</main>
|
|
</div>
|
|
|
|
<script id="desktop-payload" type="application/json"><?= $payloadJson ?></script>
|
|
<script src="<?= htmlspecialchars($assetVersion('/assets/desktop/desktop.js'), ENT_QUOTES) ?>"></script>
|
|
<?php if (!empty($baseSkinProfile['js_path'])): ?>
|
|
<script src="<?= htmlspecialchars($assetVersion((string) $baseSkinProfile['js_path']), ENT_QUOTES) ?>"></script>
|
|
<?php endif; ?>
|
|
<?php if (!empty($skinProfile['js_path']) && $skinProfile['js_path'] !== $baseSkinProfile['js_path']): ?>
|
|
<script src="<?= htmlspecialchars($assetVersion((string) $skinProfile['js_path']), ENT_QUOTES) ?>"></script>
|
|
<?php endif; ?>
|
|
<?php foreach ($nativeModuleStyles as $style): ?>
|
|
<link rel="stylesheet" href="<?= htmlspecialchars((string) $style['href'], ENT_QUOTES) ?>">
|
|
<?php endforeach; ?>
|
|
<?php foreach ($nativeModuleScripts as $script): ?>
|
|
<script
|
|
<?php if (!empty($script['crossorigin'])): ?>crossorigin<?php endif; ?>
|
|
src="<?= htmlspecialchars((string) $script['src'], ENT_QUOTES) ?>"
|
|
></script>
|
|
<?php endforeach; ?>
|
|
</body>
|
|
</html>
|