44 lines
1.9 KiB
PHP
44 lines
1.9 KiB
PHP
<?php
|
|||
|
|
/**
|
||
|
|
* 评论区(活动详情页 / 节点详情页共用)
|
||
|
|
* 依赖外部变量:$commentTree、$commentTargetType、$commentTargetId
|
||
|
|
*/
|
||
|
|
$tree = $commentTree ?? ['top' => [], 'replies' => [], 'total' => 0];
|
||
|
|
$ctType = (string)($commentTargetType ?? '');
|
||
|
|
$ctId = (int)($commentTargetId ?? 0);
|
||
|
|
?>
|
||
|
|
<section class="panel" id="comments">
|
||
|
|
<h2 class="section-title">💬 讨论 (<?= (int)($tree['total'] ?? 0) ?>)</h2>
|
||
|
|
|
||
|
|
<?php if (empty($tree['top'])): ?>
|
||
|
|
<p class="muted">还没有人发言,来说点什么吧</p>
|
||
|
|
<?php else: ?>
|
||
|
|
<div class="comment-list">
|
||
|
|
<?php foreach ($tree['top'] as $c): ?>
|
||
|
|
<?php $replies = $tree['replies'][(int)$c['id']] ?? []; ?>
|
||
|
|
<div class="comment-thread">
|
||
|
|
<?php require __DIR__ . '/_comment.php'; ?>
|
||
|
|
<?php if (!empty($replies)): ?>
|
||
|
|
<div class="comment-replies">
|
||
|
|
<?php foreach ($replies as $c): ?>
|
||
|
|
<?php require __DIR__ . '/_comment.php'; ?>
|
||
|
|
<?php endforeach; ?>
|
||
|
|
</div>
|
||
|
|
<?php endif; ?>
|
||
|
|
</div>
|
||
|
|
<?php endforeach; ?>
|
||
|
|
</div>
|
||
|
|
<?php endif; ?>
|
||
|
|
|
||
|
|
<form method="post" action="<?= url('comments/store') ?>" class="comment-form">
|
||
|
|
<input type="hidden" name="_csrf" value="<?= e(csrf_token()) ?>">
|
||
|
|
<input type="hidden" name="target_type" value="<?= e($ctType) ?>">
|
||
|
|
<input type="hidden" name="target_id" value="<?= (int)$ctId ?>">
|
||
|
|
<textarea name="content" rows="3" maxlength="2000" required
|
||
|
|
placeholder="写下你的想法、提醒或者吐槽…(最多 2000 字)"></textarea>
|
||
|
|
<div class="form-actions">
|
||
|
|
<button type="submit" class="btn-primary">发表评论</button>
|
||
|
|
</div>
|
||
|
|
</form>
|
||
|
|
</section>
|