- events 起止时间精确到秒(starts_at DATE→DATETIME + ends_at),_datetime.php 复用 - 影院独立成表(cinemas,地方/名称/地址/主题色 + 50 色板),movie_details 归一为 cinema_id - 评价模型 MovieLog 同款:movie_reviews 每账号每片一条(1-10 分+正文+感受 key), movie_review_comments 两级平铺评论(回复的回复规范化到顶层、跨评价回复拦截) - 感受目录迁到 MovieReview::CATALOG(12 种,Emoji 11.0 老码位) - 观影列表改瀑布流(CSS grid 海报墙),详情页五大块 + 灯箱 + 评价区 - 升级路径:v8 老数据自动归一(影院三段按 (family,place,name) 去重建行、 评价回填、中文感受反查英文 key),回填全部幂等;老库补 cinema_id 列+索引+外键 - 修三 bug:建表顺序(cinemas 必须在 movie_details 前,否则全新安装 1215)、 layout 导航用键名当路由(影院链接指向 r=cinemas)、 _datetime.php 分钟循环变量 $m 覆盖宿主模板的观影记录(编辑页简介/备注回填被清空)
141 lines
6.3 KiB
PHP
141 lines
6.3 KiB
PHP
<?php
|
|
/**
|
|
* 观影表单(新增 / 编辑,一张表单两用 —— 与 people/form 同一思路)。
|
|
*
|
|
* v9 变化:观影时间改为「开始 / 结束」两个秒级时刻(_datetime.php 控件,
|
|
* 服务端 read_dt_input 取值);评分与观后感**移出表单** —— 搬到详情页的
|
|
* 「评价与评论」区(MovieLog 同款:每账号一条评价,谁都能评);影院改为
|
|
* 下拉选择已有影院 + 可选「新建影院」行内三段。
|
|
*
|
|
* 海报与票根是 free 槽位(v8):不进裁剪器、整图等比缩进框内,普通文件控件即可。
|
|
* 现场照片只在**新增**时提供多选;编辑时在详情页里逐张补/删。
|
|
*/
|
|
$isEdit = !empty($m['id']);
|
|
|
|
// 时间回填:校验失败重画时优先用 old() 里的分字段重组(否则用户刚选的时刻会丢);
|
|
// 正常进编辑页时用库里的值。
|
|
$dtFromOld = static function (string $name, ?string $dbValue): ?string {
|
|
$date = trim((string)old($name . '_date', ''));
|
|
if ($date !== '') {
|
|
return sprintf('%s %02d:%02d:%02d', $date,
|
|
(int)old($name . '_hour', 0), (int)old($name . '_minute', 0), (int)old($name . '_second', 0));
|
|
}
|
|
return ($dbValue !== null && $dbValue !== '') ? $dbValue : null;
|
|
};
|
|
$dtStart = $dtFromOld('starts_at', $m['starts_at'] ?? null);
|
|
$dtEnd = $dtFromOld('ends_at', $m['ends_at'] ?? null);
|
|
$selCinema = (int)old('cinema_id', $m['cinema_id'] ?? 0);
|
|
$curAttendees = array_map('intval', array_column($m['attendees'] ?? [], 'id'));
|
|
$selAttendees = array_map('intval', (array)old('attendees', $curAttendees));
|
|
?>
|
|
<div class="page-head">
|
|
<h1><?= $isEdit ? '编辑观影记录' : '记一场电影' ?></h1>
|
|
<span class="sub"><?= $isEdit ? e($m['title']) : '片名必填,其他都可以以后再补' ?></span>
|
|
</div>
|
|
|
|
<form method="post" enctype="multipart/form-data"
|
|
action="<?= e(url($isEdit ? 'movies/update' : 'movies/create')) ?>">
|
|
<?= csrf_field() ?>
|
|
<?php if ($isEdit): ?>
|
|
<input type="hidden" name="id" value="<?= (int)$m['id'] ?>">
|
|
<?php endif; ?>
|
|
|
|
<div class="card card-pad">
|
|
<div class="form-grid">
|
|
<div class="field full">
|
|
<label for="title">片名 *</label>
|
|
<input class="input" id="title" name="title" value="<?= e(old('title', $m['title'] ?? '')) ?>" required>
|
|
<?php if (!empty($errors['title'])): ?><span class="err"><?= e($errors['title']) ?></span><?php endif; ?>
|
|
</div>
|
|
|
|
<div class="field full">
|
|
<label <?= $isEdit ? '' : 'for="starts_at_date"' ?>>开始时间(精确到秒)</label>
|
|
<?php $dtName = 'starts_at'; $dtValue = $dtStart; $dtId = 'starts_at_date';
|
|
require __DIR__ . '/../_datetime.php'; ?>
|
|
<?php if (!empty($errors['starts_at'])): ?><span class="err"><?= e($errors['starts_at']) ?></span><?php endif; ?>
|
|
</div>
|
|
|
|
<div class="field full">
|
|
<label>结束时间(散场,可不填)</label>
|
|
<?php $dtName = 'ends_at'; $dtValue = $dtEnd; $dtId = '';
|
|
require __DIR__ . '/../_datetime.php'; ?>
|
|
<?php if (!empty($errors['ends_at'])): ?><span class="err"><?= e($errors['ends_at']) ?></span><?php endif; ?>
|
|
</div>
|
|
|
|
<div class="field full">
|
|
<label for="cinema_id">影院</label>
|
|
<div class="cinema-select-row">
|
|
<select class="select" id="cinema_id" name="cinema_id">
|
|
<option value="0">不记录影院</option>
|
|
<?php foreach ($cinemas as $c): ?>
|
|
<option value="<?= (int)$c['id'] ?>" <?= $selCinema === (int)$c['id'] ? 'selected' : '' ?>>
|
|
<?= e(trim(((string)($c['place'] ?? '') !== '' ? $c['place'] . ' · ' : '') . $c['name'])) ?>
|
|
</option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
<a class="btn btn-ghost btn-sm" href="<?= e(url('movies/cinemas')) ?>">管理影院</a>
|
|
</div>
|
|
<span class="tip">想记一家还没录过的影院?先去「管理影院」里添加,回来这里就能选。</span>
|
|
</div>
|
|
|
|
<div class="field full">
|
|
<label>同行的人</label>
|
|
<?php if ($people): ?>
|
|
<div class="feel-grid">
|
|
<?php foreach ($people as $p): ?>
|
|
<label class="feel-item">
|
|
<input type="checkbox" name="attendees[]" value="<?= (int)$p['id'] ?>"
|
|
<?= in_array((int)$p['id'], $selAttendees, true) ? 'checked' : '' ?>>
|
|
<span><?= e($p['shown'] ?? $p['name']) ?></span>
|
|
</label>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php else: ?>
|
|
<span class="tip">名册里还没有人,先把家人加进名册再来记。</span>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<div class="field full">
|
|
<label for="info">简介</label>
|
|
<textarea class="input" id="info" name="info" rows="3"
|
|
placeholder="剧情简介(可选)"><?= e(old('info', $m['info'] ?? '')) ?></textarea>
|
|
</div>
|
|
|
|
<div class="field full">
|
|
<label for="note">备注</label>
|
|
<textarea class="input" id="note" name="note" rows="2"><?= e(old('note', $m['note'] ?? '')) ?></textarea>
|
|
</div>
|
|
|
|
<div class="field">
|
|
<label for="poster">海报</label>
|
|
<input class="input" id="poster" name="poster" type="file" accept="image/*">
|
|
<?php if ($isEdit && !empty($m['poster_key'])): ?>
|
|
<span class="tip">已有海报,不选新图就保留原图。</span>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<div class="field">
|
|
<label for="ticket">票根</label>
|
|
<input class="input" id="ticket" name="ticket" type="file" accept="image/*">
|
|
<?php if ($isEdit && !empty($m['ticket_key'])): ?>
|
|
<span class="tip">已有票根,不选新图就保留原图。</span>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<?php if (!$isEdit): ?>
|
|
<div class="field full">
|
|
<label for="photo">现场照片(可多选)</label>
|
|
<input class="input" id="photo" name="photo[]" type="file" accept="image/*" multiple>
|
|
<span class="tip">之后也可以在详情页里逐张补传。</span>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<div class="btn-row">
|
|
<button type="submit" class="btn"><?= $isEdit ? '保存' : '记下这场电影' ?></button>
|
|
<a class="btn btn-ghost"
|
|
href="<?= e($isEdit ? url('movies/show', ['id' => (int)$m['id']]) : url('movies')) ?>">取消</a>
|
|
</div>
|
|
</div>
|
|
</form>
|