-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathpost.php
More file actions
255 lines (250 loc) · 18.4 KB
/
post.php
File metadata and controls
255 lines (250 loc) · 18.4 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
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
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit;
$GLOBALS['page'] = 'post';
// 点赞
if (isset($_POST['agree'])) {
if ($_POST['agree'] == $this->cid) {
exit((string)agree($this->cid));
}
exit('error');
}
// 获取文章底部交互区域的按钮设置
$engagementSection = str_replace(' ', '', $this->options->engagementSection);
if ($engagementSection != '') $engagementSection = explode(',', $engagementSection);
// 语言初始化
languageInit($this->options->language);
$this->need('components/header.php');
?>
<div id="main">
<div class="container post-page main-content mb-0">
<?php if ($this->options->breadcrumb == 'on'): ?>
<nav aria-label="<?php echo $GLOBALS['t']['breadcrumb']; ?>" class="breadcrumb-nav">
<ol class="breadcrumb m-0 p-0">
<li class="breadcrumb-item">
<a href="<?php $this->options->siteUrl(); ?>"><?php echo $GLOBALS['t']['header']['home']; ?></a>
</li>
<li class="breadcrumb-item">
<?php $this->category(' '); ?>
</li>
<li tabindex="0" class="breadcrumb-item active" aria-current="page"><?php $this->title(); ?></li>
</ol>
</nav>
<?php endif; ?>
<div class="row">
<div class="col-md-12 col-lg-8 col-sm-12 article-page content-area">
<main class="mwordstar-block">
<header class="entry-header">
<h1 class="entry-title p-name" itemprop="name headline">
<a itemprop="url" href="<?php $this->permalink(); ?>" rel="bookmark">
<?php
if ($this->hidden) {
echo $GLOBALS['t']['post']['thisPostIsPasswordProtected'];
}else {
$this->title();
}
?>
</a>
</h1>
</header>
<?php $headerImg = headerImageDisplay($this, $this->options->headerImage, $this->options->headerImageUrl); ?>
<?php if ($headerImg): ?>
<div class="header-img border-top">
<a tabindex="-1" aria-hidden="true" href="<?php $this->permalink() ?>" aria-label="<?php echo $GLOBALS['t']['post']['featuredImage']; ?>" style="background-image: url(<?php echo $headerImg; ?>);background-color: <?php echo headerImageBgColor($this->options->headerImageBg); ?>;" class="fixed"></a>
</div>
<?php endif; ?>
<div class="article-info clearfix border-bottom border-top" role="group" aria-label="<?php echo $GLOBALS['t']['post']['postInfo']; ?>">
<!--时间-->
<div class="info">
<i class="icon-calendar icon" aria-hidden="true"></i>
<span data-toggle="tooltip" data-placement="top" title="<?php echo $GLOBALS['t']['post']['publicationDate']; ?>">
<time datetime="<?php echo date('c', $this->created); ?>"><?php echo postDateFormat($this->created); ?></time>
</span>
</div>
<!--作者-->
<div class="info">
<i class="icon-user icon" aria-hidden="true"></i>
<a data-toggle="tooltip" data-placement="top" href="<?php $this->author->permalink(); ?>" title="<?php echo $GLOBALS['t']['post']['author']; ?>"><?php $this->author(); ?></a>
</div>
<!--阅读量-->
<div class="info">
<i class="icon-eye icon" aria-hidden="true"></i>
<?php $views = postViews($this); ?>
<span data-toggle="tooltip" data-placement="top" title="<?php echo $GLOBALS['t']['post']['views']; ?>"><?php echo $views; ?></span>
</div>
<!--评论-->
<div class="info">
<i class="icon-bubbles2 icon" aria-hidden="true"></i>
<a data-toggle="tooltip" data-placement="top" title="<?php echo $GLOBALS['t']['post']['comments']; ?>" href="<?php $this->permalink() ?>#comments"><?php $this->commentsNum('%d ' . $GLOBALS['t']['post']['comments']); ?></a>
</div>
<!--分类-->
<div class="info category">
<i class="icon-folder-open icon" aria-hidden="true"></i>
<?php $this->category(''); ?>
</div>
<!--标签-->
<div class="info tags">
<i class="icon-price-tags icon" aria-hidden="true"></i>
<?php $this->tags(' ', true, '暂无标签'); ?>
</div>
<?php if ($this->user->hasLogin()): ?>
<div class="info d-sm-none d-none d-md-inline d-lg-inline d-xl-inline">
<i class="icon icon-pencil"></i>
<a href="<?php echo $this->options->adminUrl . 'write-post.php?cid=' . $this->cid; ?>"><?php echo $GLOBALS['t']['post']['edit']; ?></a>
</div>
<?php endif; ?>
</div>
<!--文章内容-->
<article>
<?php if (is_numeric($this->fields->expired) && (int)$this->fields->expired > 0 && $this->created + (int)$this->fields->expired * 86400 < time()): ?>
<div class="alert warning-info" role="alert">
<?php printf($GLOBALS['t']['post']['warningMessage'], getDays($this->created, time())); ?>
</div>
<?php endif; ?>
<div data-target="<?php $this->options->postLinkOpen(); ?>" class="post-content">
<?php
// 使用分隔符对文章进行分页
$GLOBALS['postPage'] = splitArticleContent($this->content);
// 如果使用 url query 传入了页码就获取页码,否则就设置为第一页
$postPageNum = isset($_GET['post-page']) ? $_GET['post-page'] : 1;
// 如果传入的页码找不到对应的文章页面就把页码设置为第一页
if (!isset($GLOBALS['postPage'][$postPageNum - 1])) $postPageNum = 1;
// 生成章节目录
$GLOBALS['post'] = articleDirectory($GLOBALS['postPage'][$postPageNum - 1]);
// 设置表格样式
$GLOBALS['post']['content'] = addBootstrapTableClasses($GLOBALS['post']['content']);
// 如果启用了图片懒加载就把 img 的 src 替换为 data-src
if ($this->options->imagelazyloading == 'on') {
$GLOBALS['post']['content'] = replaceImgSrc($GLOBALS['post']['content']);
}
echo $GLOBALS['post']['content'];
?>
</div>
<?php if (count($GLOBALS['postPage']) > 1): ?>
<nav aria-label="<?php echo $GLOBALS['t']['pagination']['postContentPagination']; ?>" class="py-3 post-pagination">
<ol class="pagination justify-content-center">
<?php if ($postPageNum > 1): ?>
<li class="page-item">
<a href="<?php echo $this->permalink . '?post-page=' . ($postPageNum - 1); ?>" class="page-link previous-page" aria-label="<?php echo $GLOBALS['t']['pagination']['previousPage']; ?>" title="<?php echo $GLOBALS['t']['pagination']['previousPage']; ?>" data-toggle="tooltip" data-placement="top">
<i class="icon-chevron-left"></i>
</a>
</li>
<?php endif; ?>
<?php for ($i = 0; $i < count($GLOBALS['postPage']); $i++): ?>
<li class="page-item <?php if ($i == $postPageNum - 1) echo 'active'; ?>">
<a href="<?php echo $this->permalink . '?post-page=' . ($i + 1); ?>" class="page-link" <?php if ($i == $postPageNum - 1) echo 'aria-current="page"'; ?>><?php echo $i + 1; ?></a>
</li>
<?php endfor; ?>
<?php if ($postPageNum < count($GLOBALS['postPage'])): ?>
<li class="page-item">
<a href="<?php echo $this->permalink . '?post-page=' . ($postPageNum + 1); ?>" class="page-link next-page" aria-label="<?php echo $GLOBALS['t']['pagination']['nextPage']; ?>" title="<?php echo $GLOBALS['t']['pagination']['nextPage']; ?>" data-toggle="tooltip" data-placement="top">
<i class="icon-chevron-right"></i>
</a>
</li>
<?php endif; ?>
</ol>
</nav>
<?php endif; ?>
<div class="clearfix" id="copyright-info">
<?php if ($this->options->modified == 'show'): ?>
<span class="float-xl-left float-lg-left float-md-left d-block">
<time datetime="<?php echo date('c', $this->modified); ?>">
<?php printf($GLOBALS['t']['post']['updated'], postDateFormat($this->modified)); ?>
</time>
</span>
<?php endif; ?>
<?php if ($this->fields->articleCopyright != 'hide'): ?>
<span tabindex="0" data-toggle="tooltip" data-placement="top" title="<?php printf($GLOBALS['t']['post']['copyrightNotice'][1], $this->options->title); ?>" class="mt-1 mt-sm-1 mt-md-0 mt-lg-0 mt-lg-0 mt-xl-0 float-xl-right float-lg-right float-md-right d-block"><?php echo $GLOBALS['t']['post']['copyrightNotice'][0]; ?></span>
<?php endif; ?>
</div>
</article>
<?php if ($engagementSection != ''): ?>
<div class="mb-3 agree-and-share">
<div class="text-center">
<?php foreach ($engagementSection as $val): ?>
<?php if ($val == '点赞'): ?>
<?php $agree = $this->hidden ? array('agree' => 0, 'recording' => true) : agreeNum($this->cid); ?>
<button <?php echo $agree['recording'] ? 'disabled' : ''; ?> data-cid="<?php echo $this->cid; ?>" data-url="<?php $this->permalink(); ?>" id="agree-btn" type="button" class="btn mr-2">
<i class="icon-thumbs-up"></i>
<span><?php echo $GLOBALS['t']['post']['like']; ?></span>
<span class="agree-num"><?php echo $agree['agree']; ?></span>
</button>
<?php endif; ?>
<?php if ($val == '分享'): ?>
<button id="share-btn" data-url="<?php $this->permalink(); ?>" type="button" class="btn mr-2" data-toggle="collapse" data-target="#qr-link" aria-expanded="false" aria-controls="collapseExample">
<i class="icon-share2"></i>
<span><?php echo $GLOBALS['t']['post']['share']; ?></span>
</button>
<?php endif; ?>
<?php if ($val == '打赏'): ?>
<button type="button" class="btn mr-2" data-toggle="collapse" data-target="#reward-qr" aria-expanded="false">
<i class="icon-coffee"></i>
<span><?php echo $GLOBALS['t']['post']['donate']; ?></span>
</button>
<?php endif; ?>
<?php endforeach; ?>
</div>
<?php if (in_array('打赏', $engagementSection)): ?>
<!--打赏二维码-->
<div class="collapse" id="reward-qr">
<div class="mt-4 text-center qr">
<img src="<?php $this->options->rewardQr(); ?>" alt="<?php echo $GLOBALS['t']['post']['QRCode']; ?>">
</div>
</div>
<?php endif; ?>
<?php if (in_array('分享', $engagementSection)): ?>
<!--分享区域-->
<div class="collapse" id="qr-link">
<div class="mt-4 qr-link">
<p class="text-center mb-2"><?php echo $GLOBALS['t']['post']['scanTheQRCodeBelowToViewAndShareThisPageOnYourPhone']; ?></p>
<div class="text-center">
<div id="qr" class="mb-1"></div>
<div class="link-box">
<a class="text-danger" href="https://service.weibo.com/share/share.php?url=<?php $this->permalink(); ?>&title=<?php $this->title(); ?>" target="_blank" rel="external nofollow" aria-label="<?php echo $GLOBALS['t']['post']['shareOnWeibo']; ?>" title="<?php echo $GLOBALS['t']['post']['shareOnWeibo']; ?>" data-toggle="tooltip" data-placement="top">
<i class="icon-sina-weibo mr-1"></i>
</a>
<a class="text-info" href="https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=<?php $this->permalink(); ?>&title=<?php $this->title(); ?>&site=<?php $this->options->siteUrl(); ?>&summary=<?php $this->fields->summaryContent ? $this->fields->summaryContent() : $this->excerpt($this->options->summary, '...'); ?>" target="_blank" rel="external nofollow" aria-label="<?php echo $GLOBALS['t']['post']['shareOnQzone']; ?>" title="<?php echo $GLOBALS['t']['post']['shareOnQzone']; ?>" data-toggle="tooltip" data-placement="top">
<i class="icon-qzone-logo mr-1"></i>
</a>
<a class="text-info" href="https://twitter.com/intent/tweet?url=<?php $this->permalink(); ?>&text=<?php $this->title(); ?>" target="_blank" rel="external nofollow" aria-label="<?php echo $GLOBALS['t']['post']['shareOnTwitter']; ?>" title="<?php echo $GLOBALS['t']['post']['shareOnTwitter']; ?>" data-toggle="tooltip" data-placement="top">
<i class="icon-twitter mr-1"></i>
</a>
</div>
</div>
</div>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
<!--上一篇和下一篇文章的导航-->
<nav class="post-navigation border-top">
<div class="row">
<div class="col-12 col-sm-12 col-md-6 col-lg-6 col-xl-6 previous">
<div id="previous-post-text"><?php echo $GLOBALS['t']['post']['previousPost']; ?></div>
<?php $this->thePrev('%s', $GLOBALS['t']['post']['none']); ?>
</div>
<div class="col-12 col-sm-12 col-md-6 col-lg-6 col-xl-6 next">
<div id="next-post-text" class="text-lg-right text-xl-right text-md-right"><?php echo $GLOBALS['t']['post']['nextPost']; ?></div class="text-lg-right text-xl-right text-md-right">
<div class="text-lg-right text-xl-right text-md-right next-box"><?php $this->theNext('%s', $GLOBALS['t']['post']['none']); ?></div>
</div>
</div>
</nav>
<?php $this->need('components/comments.php'); ?>
</main>
</div>
<?php $this->need('components/sidebar.php'); ?>
</div>
</div>
<?php if ($this->options->directoryMobile == 'enable'): ?>
<div id="directory-mobile" class="border rounded" style="display: none;">
<div class="title-bar border-bottom">
<h5 class="m-0"><?php echo $GLOBALS['t']['sidebar']['tableOfContents']; ?></h5>
<button type="button" class="btn btn-sm close-btn" aria-label="<?php echo $GLOBALS['t']['sidebar']['closeTableOfContents']; ?>" title="<?php echo $GLOBALS['t']['sidebar']['closeTableOfContents']; ?>">
<i class="icon-cancel-circle"></i>
</button>
</div>
<div class="p-3 directory-list">
<?php echo $GLOBALS['post']['directory']; ?>
</div>
</div>
<?php endif; ?>
</div>
<?php $this->need('components/footer.php'); ?>