Files

61 lines
3.4 KiB
PHP
Raw Permalink Normal View History

<?php
/**
* 观影模块的「设置」下拉 —— 影院管理 / 高级搜索 / 统计 / 年度报告。
*
* 用户明确要求(2026-10-01):
* ① 设置按钮**去掉「设置」二字,只留图标**,图标是**三条横线**(☰);
* ② 设置按钮在**所有页面都排在最右侧**(统一位置);
* ③ 点开后的**每条条目,文字前都要加图标**;
* ④ 除设置外,其它按钮都要**有颜色**,跟设置(无色/描边)区分开。
*
* 实现要点:
* · 按钮本身用 .btn-icon(方形、只有图标、无文字)——与「记一场电影」等实心按钮同高;
* · 靠 CSS 的 `margin-left:auto` 把它推到动作区最右(见 app.css 的 .movie-set 一节)。
* 这样无论各页把片段 require 在 actions 的哪个位置,它都会贴右,不必逐页调顺序。
* · 条目图标用行内 SVG(不引外部字体/图片,避免多一次请求与 FOUC)。
*
* 用法(require 前 set 好):
* $setCurrent 当前页 key('list'|'cinemas'|'search'|'stats'|'report'|'show'|'form'),用来高亮当前项
* $setCanWrite 是否显示「影院管理」(只有能写的人才有管理入口)
*/
$setCurrent = (string)($setCurrent ?? '');
$setCanWrite = (bool)($setCanWrite ?? false);
$setOn = static function (string $key) use ($setCurrent): string {
return $setCurrent === $key ? ' class="on"' : '';
};
// 条目图标(行内 SVG,16×16,用 currentColor 跟随文字色)
$setIcon = static function (string $name): string {
$paths = [
// 影院管理:放映机/胶片
'cinemas' => '<rect x="2" y="4" width="12" height="8" rx="1.5"/><path d="M4.5 6.5h1.5M7.5 6.5h1.5M10.5 6.5h1.5M4.5 9.5h1.5M7.5 9.5h1.5M10.5 9.5h1.5"/>',
// 高级搜索:放大镜
'search' => '<circle cx="7" cy="7" r="4.5"/><path d="M10.5 10.5L14 14"/>',
// 统计:柱状图
'stats' => '<path d="M3 13V9M6.5 13V5M10 13V7.5M13.5 13V3"/>',
// 年度报告:文档
'report' => '<path d="M4 2h5l3 3v9H4z"/><path d="M9 2v3h3M6 8h4M6 10.5h4"/>',
];
$d = $paths[$name] ?? '';
if ($d === '') {
return '';
}
return '<svg class="mi" viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"'
. ' fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"'
. ' stroke-linejoin="round">' . $d . '</svg>';
};
?>
<details class="movie-set menu">
<summary class="btn btn-icon" title="观影设置" aria-label="观影设置"><svg viewBox="0 0 16 16" width="18" height="18" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round"><path d="M2.5 4.5h11M2.5 8h11M2.5 11.5h11"/></svg></summary>
<div class="menu-list">
<?php if ($setCanWrite): ?>
<a href="<?= e(url('movies/cinemas')) ?>"<?= $setOn('cinemas') ?>><?= $setIcon('cinemas') ?><span>影院管理</span></a>
<?php endif; ?>
<a href="<?= e(url('movies/search')) ?>"<?= $setOn('search') ?>><?= $setIcon('search') ?><span>高级搜索</span></a>
<a href="<?= e(url('movies/stats')) ?>"<?= $setOn('stats') ?>><?= $setIcon('stats') ?><span>统计</span></a>
<a href="<?= e(url('movies/report')) ?>"<?= $setOn('report') ?>><?= $setIcon('report') ?><span>年度报告</span></a>
</div>
</details>
<?php
// 用完即清,避免残留在后续 include 里(与 _datetime.php 同一纪律)
unset($setCurrent, $setCanWrite, $setOn, $setIcon);
?>