forked from xiaopanglian/icefox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost.php
More file actions
164 lines (153 loc) · 10.3 KB
/
post.php
File metadata and controls
164 lines (153 loc) · 10.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<?php
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
/**
* 文章详情页
*
* @package icefox
* @author 小胖脸
* @version 3.0.0
* @link https://xiaopanglian.com
*/
// 包含头部文件
$this->need('header.php');
?>
<main>
<?php $this->need('components/head.php'); ?>
<section class="content-container">
<div class="post-detail" x-data="commentReplyManager()">
<!-- 文章主体 -->
<article class="post-item post-detail-item">
<div class="post-item-left">
<a href="<?php $this->author->permalink() ?>">
<img alt="<?php $this->author() ?>"
src="<?php echo getGravatarUrl($this->author->mail, 64, 'identicon', 'g'); ?>">
</a>
</div>
<div class="post-item-right">
<!-- 作者信息 -->
<h2 class="post-title">
<a href="<?php $this->author->permalink() ?>"><?php $this->author() ?></a>
<?php
// 显示置顶标识
if (getPostIsTop($this->cid)):
?>
<span class="top-badge">置顶</span>
<?php endif; ?>
<?php
// 显示广告标识
$isAdvertise = getArticleFieldsByCid($this->cid, 'isAdvertise');
if (!empty($isAdvertise) && ($isAdvertise[0]['int_value'] == 1 || $isAdvertise[0]['str_value'] == '1')):
?>
<span class="ad-badge">广告</span>
<?php endif; ?>
</h2>
<!-- 文章内容(完整显示) -->
<div class="post-content">
<?php echo themeContent($this); ?>
</div>
<!-- 详情页不需要单独显示视频和图片,因为已经在 content 中显示了 -->
<!-- 文章位置 -->
<?php $this->need('components/post/post-position.php'); ?>
<div class="post-time">
<time
datetime="<?php $this->date('yyyy年mm月dd日'); ?>"><?php $this->date('Y年m月d日'); ?></time>
<div class="post-time-comment" x-data="{ptcmShow: false}"
:id="'ptcm-' + <?php echo $this->cid; ?>">
<div class="ptc-more" @click="togglePostTimeComment($event, <?php echo $this->cid; ?>)">
<svg t="1709204592505" class="icon" viewBox="0 0 1024 1024" version="1.1"
xmlns="http://www.w3.org/2000/svg"
p-id="16237" width="16" height="16">
<path d="M229.2 512m-140 0a140 140 0 1 0 280 0 140 140 0 1 0-280 0Z"
p-id="16238" fill="#8a8a8a"></path>
<path d="M794.8 512m-140 0a140 140 0 1 0 280 0 140 140 0 1 0-280 0Z" p-id="16239"
fill="#8a8a8a"></path>
</svg>
</div>
<div class="post-time-comment-modal" x-show="ptcmShow"
x-transition.in.duration.300ms.origin.top.right>
<div class="ptcm-good like-menu-btn" data-cid="<?php echo $this->cid; ?>"
@click="toggleLike($event, <?php echo $this->cid; ?>)">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" height="16"
width="16"
stroke-width="1.5" stroke="currentColor" class="size-6 like-menu-icon">
<path stroke-linecap="round" stroke-linejoin="round"
d="M21 8.25c0-2.485-2.099-4.5-4.688-4.5-1.935 0-3.597 1.126-4.312 2.733-.715-1.607-2.377-2.733-4.313-2.733C5.1 3.75 3 5.765 3 8.25c0 7.22 9 12 9 12s9-4.78 9-12Z"/>
</svg>
<span class="like-menu-text">点赞</span>
</div>
<div class="ptcm-comment" @click="showPostReplyForm($event, <?php echo $this->cid; ?>)">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" height="16"
width="16"
stroke-width="1.5" stroke="currentColor" class="size-6">
<path stroke-linecap="round" stroke-linejoin="round"
d="M2.25 12.76c0 1.6 1.123 2.994 2.707 3.227 1.087.16 2.185.283 3.293.369V21l4.076-4.076a1.526 1.526 0 0 1 1.037-.443 48.282 48.282 0 0 0 5.68-.494c1.584-.233 2.707-1.626 2.707-3.228V6.741c0-1.602-1.123-2.995-2.707-3.228A48.394 48.394 0 0 0 12 3c-2.392 0-4.744.175-7.043.513C3.373 3.746 2.25 5.14 2.25 6.741v6.018Z"/>
</svg>
评论
</div>
</div>
</div>
</div>
<!-- 点赞和评论区 -->
<div class="post-comment-container" data-cid="<?php echo $this->cid; ?>">
<!-- 点赞列表 -->
<div class="pcc-like-list" data-cid="<?php echo $this->cid; ?>">
<div class="pcc-like-summary">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" height="16"
width="16"
stroke-width="1.5" stroke="currentColor" class="like-icon">
<path stroke-linecap="round" stroke-linejoin="round"
d="M21 8.25c0-2.485-2.099-4.5-4.688-4.5-1.935 0-3.597 1.126-4.312 2.733-.715-1.607-2.377-2.733-4.313-2.733C5.1 3.75 3 5.765 3 8.25c0 7.22 9 12 9 12s9-4.78 9-12Z"/>
</svg>
<span class="like-users-text"></span>
</div>
</div>
<!-- 评论列表 -->
<div class="pcc-comment-list">
<?php
// 使用与首页相同的评论显示方式
$comments = getPostLatestCommentsWithReplies($this->cid, 20);
foreach ($comments as $comment) {
?>
<div class="pcc-comment-item"
data-comment-id="<?php echo $comment['coid'] ?? $comment['id'] ?? 0; ?>">
<a href="<?php echo htmlspecialchars($comment['url'] ?? '', ENT_QUOTES, 'UTF-8'); ?>"><?php echo htmlspecialchars($comment['author'], ENT_QUOTES, 'UTF-8'); ?></a>
<?php if (isset($comment['userGroup']) && $comment['userGroup'] == 'administrator'): ?>
<span class="author-badge">作者</span>
<?php endif; ?>
<span>:</span>
<span class="cursor-help pcc-comment-content"
@click="showReplyForm($event, '<?php echo $this->cid; ?>', '<?php echo $comment['coid'] ?? $comment['id'] ?? 0; ?>', <?php echo htmlspecialchars(json_encode($comment['author'], JSON_UNESCAPED_UNICODE), ENT_QUOTES, 'UTF-8'); ?>)"><?php echo htmlspecialchars($comment['text'], ENT_QUOTES, 'UTF-8'); ?></span>
</div>
<?php
foreach ($comment['replies'] as $reply) {
?>
<div class="pcc-comment-item"
data-comment-id="<?php echo $reply['coid'] ?? $reply['id'] ?? 0; ?>">
<a href="<?php echo htmlspecialchars($reply['url'] ?? '', ENT_QUOTES, 'UTF-8'); ?>"><?php echo htmlspecialchars($reply['author'], ENT_QUOTES, 'UTF-8'); ?></a>
<?php if (isset($reply['userGroup']) && $reply['userGroup'] == 'administrator'): ?>
<span class="author-badge">作者</span>
<?php endif; ?>
<span>回复</span>
<a href="<?php echo htmlspecialchars($reply['parentUrl'] ?? '', ENT_QUOTES, 'UTF-8'); ?>"><?php echo htmlspecialchars($reply['parentAuthor'], ENT_QUOTES, 'UTF-8'); ?></a>
<?php if (isset($reply['parentUserGroup']) && $reply['parentUserGroup'] == 'administrator'): ?>
<span class="author-badge">作者</span>
<?php endif; ?>
<span>:</span>
<span class="cursor-help pcc-comment-content"
@click="showReplyForm($event, '<?php echo $this->cid; ?>', '<?php echo $reply['coid'] ?? $reply['id'] ?? 0; ?>', <?php echo htmlspecialchars(json_encode($reply['author'], JSON_UNESCAPED_UNICODE), ENT_QUOTES, 'UTF-8'); ?>)"><?php echo htmlspecialchars($reply['text'], ENT_QUOTES, 'UTF-8'); ?></span>
</div>
<?php
}
}
?>
</div>
</div>
</div>
</article>
</div>
</section>
<?php $this->need('components/modals/setting.php'); ?>
<?php $this->need('components/modals/login.php'); ?>
<?php $this->need('components/modals/links.php'); ?>
</main>
<?php $this->need('footer.php'); ?>