foxygit / foxygit Log in
A tiny read-only git web frontend — browse bare repos with just PHP and git, no database, no framework.
commits tags

/views/partials/theme-switcher.php · 911 B

raw
<?php
/** @var string $theme @var string[] $themes
 *  Theme dropdown, shown when there's more than one theme to pick from.
 *  Reads $_GET directly (rather than taking it as a param) since its whole
 *  job is to reflect the current request back into a self-submitting form —
 *  preserves r/a/ref/... so switching theme doesn't lose your place. */
if (count($themes) <= 1) return;
?>
<form class="theme-switch" method="get">
  <?php foreach ($_GET as $k => $v): ?>
    <?php if ($k === 'theme' || !is_string($v)) continue; ?>
    <input type="hidden" name="<?= h($k) ?>" value="<?= h($v) ?>">
  <?php endforeach; ?>
  <select name="theme" onchange="this.form.submit()">
    <?php foreach ($themes as $t): ?>
      <option value="<?= h($t) ?>"<?= $t === $theme ? ' selected' : '' ?>><?= h($t) ?></option>
    <?php endforeach; ?>
  </select>
  <noscript><button type="submit">byt</button></noscript>
</form>