akanyan/templates/partials/file/view.php
2022-07-11 18:18:14 +08:00

39 lines
1.6 KiB
PHP

<?php $this->layout('template', ['title' => $title ?? null, 'nav' => $nav ?? null]) ?>
<?php $this->push('styles') ?>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.5.1/styles/default.min.css"/>
<?php $this->end() ?>
<?php $this->push('scripts') ?>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.5.1/highlight.min.js"></script>
<!--suppress JSUnresolvedVariable -->
<script>hljs.highlightAll()</script>
<?php $this->end() ?>
<div class="dropdown my-2">
<button class="btn btn-outline-secondary dropdown-toggle"
type="button"
id="file-selector"
data-bs-toggle="dropdown"
aria-expanded="false">
<?= $this->e($file ?? '') ?>
</button>
<ul class="dropdown-menu" aria-labelledby="file-selector">
<?php if (isset($list) && is_array($list)): ?>
<?php foreach ($list as $filename): ?>
<li>
<?php if (isset($file) && $file === $filename): ?>
<a class="dropdown-item active" href="view.php?file=<?= $this->e($filename) ?>">
<?= $this->e($filename) ?>
</a>
<?php else: ?>
<a class="dropdown-item" href="view.php?file=<?= $this->e($filename) ?>">
<?= $this->e($filename) ?>
</a>
<?php endif ?>
</li>
<?php endforeach ?>
<?php endif ?>
</ul>
</div>
<pre class="file-content"><code class="language-<?= $this->e($type ?? 'plaintext') ?>"><?= $this->e($content ?? '') ?></code></pre>