Reorganize PHP internals and static assets
Move shared PHP code into private/, move JavaScript files into js/, and block direct access to private/. Remove unused API key and cache artifacts from the working tree.
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
/*
|
||||
* header.php
|
||||
*
|
||||
* Shared page header renderer for logged-in application pages.
|
||||
*/
|
||||
|
||||
function app_header_h($s)
|
||||
{
|
||||
return htmlspecialchars((string)$s, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
|
||||
}
|
||||
|
||||
function render_app_header($options)
|
||||
{
|
||||
$title = (string)($options['title'] ?? '');
|
||||
$navItems = $options['nav_items'] ?? array();
|
||||
$user = $options['user'] ?? null;
|
||||
$userPrefix = (string)($options['user_prefix'] ?? '');
|
||||
$adminLabel = (string)($options['admin_label'] ?? 'admin');
|
||||
$languageLabel = (string)($options['language_label'] ?? 'Language');
|
||||
$language = (string)($options['language'] ?? 'en');
|
||||
$languages = $options['languages'] ?? array();
|
||||
$languageAction = (string)($options['language_action'] ?? '/');
|
||||
$languageHidden = $options['language_hidden'] ?? array();
|
||||
$logoutAction = (string)($options['logout_action'] ?? '');
|
||||
$logoutLabel = (string)($options['logout_label'] ?? '');
|
||||
$message = (string)($options['message'] ?? '');
|
||||
$error = (string)($options['error'] ?? '');
|
||||
?>
|
||||
<header class="page-header">
|
||||
<div class="page-titlebar">
|
||||
<h1><?= app_header_h($title) ?></h1>
|
||||
|
||||
<nav class="header-nav" aria-label="<?= app_header_h($title) ?> navigation">
|
||||
<?php foreach ($navItems as $item): ?>
|
||||
<?php if (!empty($item['separator_before'])): ?>
|
||||
<span class="nav-separator" aria-hidden="true">|</span>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($item['active'])): ?>
|
||||
<strong><?= app_header_h($item['label'] ?? '') ?></strong>
|
||||
<?php else: ?>
|
||||
<a href="<?= app_header_h($item['url'] ?? '#') ?>"><?= app_header_h($item['label'] ?? '') ?></a>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php if ($logoutAction !== '' && $logoutLabel !== ''): ?>
|
||||
<span class="nav-separator" aria-hidden="true">|</span>
|
||||
<form class="header-action-form" method="post" action="<?= app_header_h($logoutAction) ?>">
|
||||
<input type="hidden" name="action" value="logout">
|
||||
<button type="submit"><?= app_header_h($logoutLabel) ?></button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($user !== null): ?>
|
||||
<span class="nav-separator" aria-hidden="true">|</span>
|
||||
<span class="nav-user">
|
||||
<?php if ($userPrefix !== ''): ?>
|
||||
<?= app_header_h($userPrefix) ?>
|
||||
<?php endif; ?>
|
||||
<?= app_header_h($user->displayName()) ?>
|
||||
<?php if ($user->isAdmin()): ?>
|
||||
<span class="small">(<?= app_header_h($adminLabel) ?>)</span>
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
|
||||
<form class="header-language-form" method="get" action="<?= app_header_h($languageAction) ?>">
|
||||
<?php foreach ($languageHidden as $name => $value): ?>
|
||||
<input type="hidden" name="<?= app_header_h($name) ?>" value="<?= app_header_h($value) ?>">
|
||||
<?php endforeach; ?>
|
||||
<label>
|
||||
<?= app_header_h($languageLabel) ?>
|
||||
<select name="lang" onchange="this.form.submit()">
|
||||
<?php foreach ($languages as $lang => $label): ?>
|
||||
<option value="<?= app_header_h($lang) ?>" <?= $lang === $language ? 'selected' : '' ?>>
|
||||
<?= app_header_h($label) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</label>
|
||||
</form>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
<?php if ($message !== ''): ?>
|
||||
<div class="message"><?= app_header_h($message) ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($error !== ''): ?>
|
||||
<div class="error"><?= app_header_h($error) ?></div>
|
||||
<?php endif; ?>
|
||||
</header>
|
||||
<?php
|
||||
}
|
||||
Reference in New Issue
Block a user