status-partial.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. declare(strict_types=1);
  3. // Small status block for an existing settings page in the host application.
  4. //
  5. // Include it wherever a short "update available / last backup" summary belongs:
  6. //
  7. // <?php include __DIR__ . "/../manage-client/ui/status-partial.php"; ?>
  8. //
  9. // Renders nothing but a fragment: no <html>, no styles of its own beyond the
  10. // inline minimum, and it never throws. Set $manageStatusPanelUrl before the
  11. // include to link to the full panel.
  12. require_once dirname(__DIR__) . "/lib/client.php";
  13. /** @var string $manageStatusPanelUrl */
  14. $manageStatusPanelUrl = $manageStatusPanelUrl ?? "manage.php";
  15. $manageStatus = null;
  16. $manageStatusError = null;
  17. try {
  18. $manageStatus = manageClientStatus();
  19. } catch (Throwable $exception) {
  20. $manageStatusError = $exception->getMessage();
  21. }
  22. $manageStatusEscape = static function ($value): string {
  23. return htmlspecialchars((string) $value, ENT_QUOTES | ENT_SUBSTITUTE, "UTF-8");
  24. };
  25. ?>
  26. <div class="manage-status" style="border:1px solid #d9dde3;border-radius:8px;padding:.9rem 1rem;background:#fff;">
  27. <?php if ($manageStatusError !== null): ?>
  28. <p>Status nicht verfügbar: <?php echo $manageStatusEscape($manageStatusError); ?></p>
  29. <?php elseif ($manageStatus === null): ?>
  30. <p>Status nicht verfügbar.</p>
  31. <?php else: ?>
  32. <p>
  33. <strong>Version:</strong>
  34. <?php echo $manageStatusEscape($manageStatus["version"] !== "" ? $manageStatus["version"] : "unbekannt"); ?>
  35. <?php if ($manageStatus["update"] !== null && $manageStatus["update"]["available"]): ?>
  36. &mdash; <strong>Update <?php echo $manageStatusEscape($manageStatus["update"]["latest"]); ?> verfügbar</strong>
  37. <?php elseif ($manageStatus["update"] !== null): ?>
  38. &mdash; aktuell
  39. <?php elseif ($manageStatus["update_error"] !== null): ?>
  40. &mdash; <span title="<?php echo $manageStatusEscape($manageStatus["update_error"]); ?>">Update-Prüfung fehlgeschlagen</span>
  41. <?php endif; ?>
  42. </p>
  43. <p>
  44. <strong>Letztes Backup:</strong>
  45. <?php echo $manageStatusEscape($manageStatus["last_backup_at"] ?? "nie"); ?>
  46. (<?php echo count($manageStatus["backups"]); ?> lokal)
  47. </p>
  48. <?php if ($manageStatus["pending_migrations"] !== []): ?>
  49. <p><strong><?php echo count($manageStatus["pending_migrations"]); ?> offene Migration(en).</strong></p>
  50. <?php endif; ?>
  51. <p><a href="<?php echo $manageStatusEscape($manageStatusPanelUrl); ?>">Update &amp; Backup verwalten</a></p>
  52. <?php endif; ?>
  53. </div>