forked from xiaopanglian/icefox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost.php
404 lines (375 loc) · 23.2 KB
/
post.php
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
<?php
// 详情页
if (!defined('__TYPECHO_ROOT_DIR__'))
exit;
$isSingle = false;
$lineClamp = 'line-clamp-4';
if ($this->is('single')) {
$isSingle = true;
$lineClamp = '';
}
?>
<?php $this->need('/components/header.php'); ?>
<?php $this->need('/components/single-top.php'); ?>
<div class="bg-white dark:bg-[#323232] dark:text-[#cccccc] mx-auto main-container">
<?php $this->need('/components/option-header.php'); ?>
<div class="article-container">
<?php $this->widget('Widget_Archive@icefox' . $this->cid, 'pageSize=1&type=post', 'cid=' . $this->cid)->to($item); ?>
<?php $item = (object) $item; ?>
<article class="flex flex-row border-b borer-b-2 dark:border-gray-600 border-gray-200 pt-5 pl-5 pr-5">
<div class="mr-3">
<div class="w-9 h-9">
<img src="<?php echo $this->options->userAvatarUrl ?>" class="w-9 h-9 object-cover rounded-lg" />
</div>
</div>
<div
class="w-full border-t-0 border-l-0 border-r-0 border-b-1 dark:border-gray-600 border-gray-100 border-solid pb-1">
<section class="flex flex-row justify-between items-center mb-1">
<span class="text-color-link cursor-default text-[14px]">
<?php print_r(_getUserScreenNameByCid($item->cid)['screenName']); ?>
</span>
<?php
$advertiseData = getArticleFieldsByCid($item->cid, 'isAdvertise');
if (count($advertiseData) > 0) {
$isAdvertise = $advertiseData[0]['str_value'];
if ($isAdvertise == true) {
?>
<span class="text-[12px] dark:bg-[#262626] bg-[#f0f0f0] p-1 text-[#c6c6c6] rounded-sm">广告</span>
<?php }
} ?>
</section>
<section
class="mb-1 cursor-default text-[14px] article-content break-all <?php echo $lineClamp; ?> content-<?php echo $item->cid; ?>"
data-cid="<?php echo $item->cid; ?>">
<?php
$clearContent = preg_replace('/<img[^>]+>/i', '', $this::markdown($item->text));
$clearContent = preg_replace('/<br><br>/i', '', $clearContent);
echo $this::markdown($clearContent);
?>
</section>
<?php
if (!$isSingle) {
?>
<div class="text-[14px] text-color-link cursor-pointer qw qw-<?php echo $item->cid; ?> hidden mb-1"
data-cid="<?php echo $item->cid; ?>">全文</div>
<div class="text-[14px] text-color-link cursor-pointer ss ss-<?php echo $item->cid; ?> hidden mb-1"
data-cid="<?php echo $item->cid; ?>">收缩</div>
<?php
}
?>
<?php
$music = getArticleFieldsByCid($item->cid, 'music');
if (count($music) > 0 && !empty($music[0]['str_value'])) {
$music = $music[0]['str_value'];
$musicArr = explode('||', $music);
?>
<section class="w-full mb-1">
<figure class="flex overflow-hidden rounded-sm music-card m-0 bg-cover bg-center "
style="background-image: url('<?php echo $musicArr[3]; ?>')">
<div
class="w-full h-full bg-cover bg-center backdrop-blur-lg backdrop-filter bg-opacity-50 flex flex-row relative">
<img src="<?php echo $musicArr[3]; ?>"
class="h-full w-auto aspect-square object-cover rounded-full music-img"
id="music-img-<?php echo $item->cid; ?>" rotate="rotate-animation" />
<div class="flex flex-col text-white h-full justify-center pl-[5px]">
<span class="mt-1 truncate music-card-text">
<?php echo $musicArr[0]; ?>
</span>
<span class="mt-1 truncate music-card-text">
<?php echo $musicArr[1]; ?>
</span>
</div>
<div class="music-card-play-position">
<img width="36" height="36"
src="<?php $this->options->themeUrl('assets/svgs/music-play-light.svg'); ?>"
@click="playAudio(<?php echo $item->cid; ?>, '<?php echo $musicArr[2]; ?>')"
id="music-play-<?php echo $item->cid; ?>" class="music-play" />
<img width="36" height="36"
src="<?php $this->options->themeUrl('assets/svgs/music-pause-light.svg'); ?>"
class="music-pause hidden" @click="pauseAudio(<?php echo $item->cid; ?>)"
id="music-pause-<?php echo $item->cid; ?>" />
</div>
</div>
</figure>
</section>
<?php
}
?>
<?php
$friend_video = getArticleFieldsByCid($item->cid, 'friend_video');
if (count($friend_video) > 0 && !empty($friend_video[0]['str_value'])) {
$friendVideo = $friend_video[0]['str_value'];
if (!empty($friendVideo)) {
$autoplay = '';
if ($this->options->autoPlayVideo == 'yes') {
$autoplay = 'autoplay';
} else {
$autoplay = '';
}
$autoMuted = '';
if ($this->options->autoMutedPlayVideo == 'yes') {
$autoMuted = 'muted';
} else {
$autoMuted = '';
}
?>
<section class="grid grid-cols-3 gap-1 multi-pictures overflow-hidden mb-3"
id="preview-<?php echo $item->cid; ?>">
<div class="overflow-hidden rounded-lg cursor-zoom-in w-full col-span-2">
<video src="<?php echo $friendVideo ?>" <?php echo $autoplay; ?> <?php echo $autoMuted; ?> loop
preload="auto" controls="controls" class="w-full" data-cid="<?php echo $item->cid; ?>"
data-play="">您的浏览器不支持video标签</video>
</div>
</section>
<?php
}
} else {
$contentPictures = getAllImages($this::markdown($item->text));
$friendPicture = getArticleFieldsByCid($item->cid, 'friend_pictures');
if (count($friendPicture) > 0) {
foreach ($friendPicture as $tmpFriendPic) {
$onePic = $tmpFriendPic['str_value'];
$friendPictures = explode(',', $onePic);
foreach ($friendPictures as $friendPic) {
array_push($contentPictures, $friendPic);
}
}
}
$picture_list = array_filter(array_slice($contentPictures, 0, 9));
if (count($picture_list) == 1) {
$exten = pathinfo($picture_list[0], PATHINFO_EXTENSION);
if ($exten)
?>
<section class="grid grid-cols-3 gap-1 multi-pictures overflow-hidden mb-3"
id="preview-<?php echo $item->cid; ?>">
<div class="overflow-hidden cursor-zoom-in col-span-2">
<img src="<?php echo $picture_list[0] ?>" data-fancybox="<?php echo $item->cid; ?>"
class="cursor-zoom-in preview-image max-w-full max-h-64"
data-cid="<?php echo $item->cid; ?>" />
</div>
</section>
<?php
} else if (count($picture_list) == 4) {
?>
<section class="grid grid-cols-3 gap-1 multi-pictures overflow-hidden mb-3"
id="preview-<?php echo $item->cid; ?>">
<?php
$index = 0;
foreach ($picture_list as $picture) {
if ($index == 2) {
?>
<div class="overflow-hidden cursor-zoom-in w-full h-0 pt-[100%] relative">
</div>
<?php
}
$exten = pathinfo($picture, PATHINFO_EXTENSION);
if ($exten) {
?>
<div class="overflow-hidden cursor-zoom-in w-full h-0 pt-[100%] relative">
<img src="<?php echo $picture ?>" data-fancybox="<?php echo $item->cid; ?>"
class="w-full h-full object-cover absolute top-0 cursor-zoom-in preview-image"
data-cid="<?php echo $item->cid; ?>" />
</div>
<?php
}
$index++;
}
?>
</section>
<?php
} else if (count($picture_list) > 0) {
?>
<section class="grid grid-cols-3 gap-1 multi-pictures overflow-hidden mb-3"
id="preview-<?php echo $item->cid; ?>">
<?php
foreach ($picture_list as $picture) {
$exten = pathinfo($picture, PATHINFO_EXTENSION);
if ($exten)
?>
<div class="overflow-hidden cursor-zoom-in w-full h-0 pt-[100%] relative">
<img src="<?php echo $picture ?>" data-fancybox="<?php echo $item->cid; ?>"
class="w-full h-full object-cover absolute top-0 cursor-zoom-in preview-image"
data-cid="<?php echo $item->cid; ?>" />
</div>
<?php
}
?>
</section>
<?php
}
}
?>
<!--定位-->
<section class="mb-1">
<?php
$position = getArticleFieldsByCid($item->cid, 'position');
if (count($position) > 0) {
?>
<span class="text-color-link text-xs cursor-default">
<?php echo $position[0]['str_value'] ?>
</span>
<?php
}
?>
</section>
<!--时间-->
<section class="flex flex-row justify-between mb-1">
<div class="text-gray text-xs">
<?php echo getTimeFormatStr($item->created); ?>
</div>
<div class="w-[30px] h-[20px] relative">
<div class="hudong dark:bg-[#262626] rounded-sm"></div>
<div class="hudong-modal absolute right-10 top-[-10px] hidden">
<div
class="bg-[#4c4c4c] text-[#fff] hudong-container pt-2 pb-2 pl-5 pr-5 flex flex-row items-center justify-between">
<?php
$isAgree = isAgreeByCid($item->cid);
?>
<a href="javascript:;"
class="cursor-pointer text-[#fff] no-underline items-center text-[14px] like-to <?php echo $isAgree ? 'flex' : 'hidden'; ?> like-to-cancel-<?php echo $item->cid; ?>"
data-cid="<?php echo $item->cid; ?>" data-agree="0"><span
class="hudong-liked inline-block mr-2 cursor-pointer"
data-cid="<?php echo $item->cid; ?>" data-agree="0"></span>取消</a>
<a href="javascript:;"
class="cursor-pointer text-[#fff] no-underline items-center text-[14px] like-to <?php echo $isAgree ? 'hidden' : 'flex'; ?> like-to-show-<?php echo $item->cid; ?>"
data-cid="<?php echo $item->cid; ?>" data-agree="1"><span
class="hudong-like inline-block mr-2 cursor-pointer"
data-cid="<?php echo $item->cid; ?>" data-agree="1"></span>赞</a>
<span class="bg-[#454545] h-[22px] w-[1px]"></span>
<a href="javascript:;"
class="cursor-pointer text-[#fff] no-underline flex items-center text-[14px] comment-to"
data-cid="<?php echo $item->cid; ?>"><span
class="hudong-comment inline-block mr-2 cursor-pointer comment-to"
data-cid="<?php echo $item->cid; ?>"></span>评论</a>
</div>
</div>
</div>
</section>
<!--评论列表-->
<section class="break-all mb-1 overflow-hidden rounded-md">
<?php
$agreeNum = getAgreeNumByCid($item->cid);
$agree = $agreeNum['agree'];
$recording = $agreeNum['recording'];
if ($agree > 0):
?>
<div
class="bg-[#f7f7f7] dark:bg-[#262626] px-3 py-2 bottom-shadow items-center border-1 border-b-solid dark:border-gray-600 border-gray-100 <?php echo ($agree > 0 ? 'flex' : 'hidden'); ?> like-agree-<?php echo $item->cid; ?>">
<span class="like inline-block mr-2"></span>
<span class="text-[14px] ">
<!-- <span class="text-color-link no-underline text-[14px]">刘德华</span>,
<span class="text-color-link no-underline text-[14px]">张学友</span>, -->
<span class="text-color-link text-[14px]">
<span class="fk-cid-<?php echo $item->cid; ?>">
<?php echo $agree; ?>
</span> 位访客
</span>
</span>
</div>
<?php endif; ?>
<?php
$commentCount = 5;
if ($this->is('single')) {
$commentCount = 999;
}
?>
<?php
$count = getCommentCountByCid($item->cid);
$comments = getCommentByCid($item->cid, 0, $commentCount);
?>
<div class="index-comments bottom-shadow bg-[#f7f7f7] dark:bg-[#262626] ">
<ul class="list-none p-0 m-0 comment-ul-cid-<?php echo $item->cid; ?> comment-ul">
<?php
if ($comments) {
foreach ($comments as $comment): ?>
<li
class="pos-rlt comment-li-coid-<?php echo $comment['coid'] ?> pb-1 px-2 first-of-type:pt-2">
<div class="comment-body">
<span class="text-[14px] text-color-link">
<a href="<?php echo $comment['url'] ?>" target="_blank"
class="cursor-pointer text-color-link no-underline">
<?php echo $comment['author']; ?>
<?php
if ($comment['authorId'] == $item->authorId) {
?>
<span
class="text-xs text-red-700 border border-red-700 border-solid pl-[1px] pr-[1px] rounded">作者</span>
<?php
}
?>
</a>
</span>
<span data-separator=":"
class="before:content-[attr(data-separator)] text-[14px] cursor-help comment-to"
data-coid="<?php echo $comment['coid'] ?>"
data-cid="<?php echo $comment['cid'] ?>"
data-name="<?php echo $comment['author'] ?>">
<?php echo strip_tags(preg_replace("/<br>|<p>|<\/p>/", ' ', $comment['text'])) ?>
</span>
</div>
</li>
<?php
$childComments = getCommentByCid($item->cid, $comment['coid'], 999);
if ($childComments) {
foreach ($childComments as $childComment): ?>
<li class="pos-rlt comment-li-coid-<?php echo $childComment['coid'] ?> pb-1 px-2">
<div class="comment-body">
<span class="text-[14px] text-color-link">
<a href="<?php echo $childComment['url'] ?>" target="_blank"
class="cursor-pointer text-color-link no-underline">
<?php echo $childComment['author'] ?>
<?php
if ($childComment['authorId'] == $item->authorId) {
?>
<span
class="text-xs text-red-700 border border-red-700 border-solid pl-[1px] pr-[1px] rounded">作者</span>
<?php
}
?>
</a>
</span>
<span class="text-[14px]">回复</span>
<span class="text-[14px] text-color-link">
<?php echo $comment['author'] ?>
<?php
if ($comment['authorId'] == $item->authorId) {
?>
<span
class="text-xs text-red-700 border border-red-700 border-solid pl-[1px] pr-[1px] rounded">作者</span>
<?php
}
?>
</span>
<span data-separator=":"
class="before:content-[attr(data-separator)] text-[14px] cursor-help comment-to"
data-coid="<?php echo $childComment['coid'] ?>"
data-cid="<?php echo $childComment['cid'] ?>"
data-name="<?php echo $childComment['author'] ?>">
<?php echo strip_tags(preg_replace("/<br>|<p>|<\/p>/", ' ', $childComment['text'])) ?>
</span>
</div>
</li>
<?php endforeach;
}
?>
<?php ?>
<?php endforeach; ?>
<?php
if ($count > 5 & $commentCount == 5) {
?>
<li class="px-2 pb-1">
<a href="<?php echo $item->permalink; ?>"
class="cursor-pointer text-color-link no-underline text-[13px]">查看更多…</a>
</li>
<?php
}
}
?>
</ul>
</div>
</section>
</div>
</article>
</div>
</div><!-- end #main-->
<?php $this->need('/components/single-footer.php'); ?>