-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy patharchives.php
More file actions
executable file
·126 lines (114 loc) · 4.49 KB
/
Copy patharchives.php
File metadata and controls
executable file
·126 lines (114 loc) · 4.49 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
<?php
/**
* 归档页面
*
* @package custom
*/
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
$this->need('header.php'); ?>
<div class="main">
<?php $this->need('module/head2.php');?>
<!--背景图片+logo-->
<div class="page_thumb blur">
<!-- 背景图片容器 -->
<div class="post_bg lazy-load" data-src="<?php echo $this->fields->thumb ? $this->fields->thumb : Helper::options()->themeUrl . '/static/img/archives.jpg';?>"></div>
<div class="pc">
<!-- 新增的菜单按钮 -->
<i class="iconfont icon-nav menu-button"></i>
<div class="page-head">
<?php if ($this->options->logoStyle == 'text') : ?>
<h1>
<a href="<?php $this->options->siteUrl(); ?>"><?php $this->options->title(); ?></a>
<span class="soul">生活志</span>
</h1>
<?php else : ?>
<a class="logo" href="<?php $this->options->siteUrl(); ?>">
<img src="<?php echo $this->options->logoWhite ?: Helper::options()->themeUrl . '/static/img/logoWhite.svg'; ?>">
</a>
<?php endif; ?>
</div>
</div>
<div class="m">
<h1 class="page-head"><?php $this->archiveTitle(' » ', ''); ?><span>Blog's Archives</span></h1>
</div>
</div>
<div class="page-title animate__animated animate__fadeIn pc">
<h1><?php $this->title(); ?></h1>
</div>
<!-- 全部文章(不再排除任何分类) -->
<section class="archives padding animate__animated animate__fadeIn blur">
<?php
$db = Typecho_Db::get();
$archiveMeta = $db->fetchRow(
$db->select(array('COUNT(cid)' => 'total'), array('MAX(modified)' => 'latest_modified'), array('MAX(created)' => 'latest_created'))
->from('table.contents')
->where('type = ?', 'post')
->where('status = ?', 'publish')
);
$archiveSign = md5(json_encode(['archives_v1', $archiveMeta]));
$archiveHtml = function_exists('oneblogReadCache') ? oneblogReadCache('archives-posts', $archiveSign) : false;
if ($archiveHtml === false) {
ob_start();
$this->widget('Widget_Contents_Post_Recent', 'pageSize=10000')->to($archives);
$articlesByYear = [];
while ($archives->next()) {
$year = date('Y', $archives->created);
if (!isset($articlesByYear[$year])) {
$articlesByYear[$year] = [];
}
$articlesByYear[$year][] = [
'title' => $archives->hidden ? '密码保护:' . $archives->row['title'] : $archives->row['title'],
'permalink' => $archives->permalink,
'date' => date('m月d日', $archives->created)
];
}
foreach ($articlesByYear as $year => $articles) {
echo '<h3><span>#</span>' . $year . '年</h3>';
foreach ($articles as $article) {
echo '<li><a href="' . $article['permalink'] . '"><span>' . $article['date'] . '</span>' . $article['title'] . '</a></li>';
}
}
$archiveHtml = ob_get_clean();
if (function_exists('oneblogWriteCache')) {
oneblogWriteCache('archives-posts', $archiveSign, $archiveHtml);
}
}
echo $archiveHtml;
?>
</section>
<!-- 全部独立页面 -->
<section class="archives padding animate__animated animate__fadeIn blur">
<h3><span>#</span>页面</h3>
<?php
$this->widget('Widget_Contents_Page_List')->to($pages);
while ($pages->next()) {
echo '<li><a href="' . $pages->permalink . '">' . $pages->title . '</a></li>';
}
?>
</section>
<!-- 全部分类 -->
<section class="archives padding animate__animated animate__fadeIn blur">
<h3><span>#</span>分类</h3>
<?php
$this->widget('Widget_Metas_Category_List')->to($categories);
while ($categories->next()) {
echo '<li><a href="' . $categories->permalink . '">' . $categories->name . '</a></li>';
}
?>
</section>
<!-- 全部标签 -->
<section class="archives padding animate__animated animate__fadeIn blur">
<h3><span>#</span>标签</h3>
<div class="tags">
<?php
$this->widget('Widget_Metas_Tag_Cloud', 'ignoreZeroCount=1')->to($tags);
while ($tags->next()) {
echo '<a href="' . $tags->permalink . '">' . $tags->name . '</a>';
}
?>
</div>
</section>
<div class="load blur" >— END —</div>
<a id="gototop" class="hidden"><i class="iconfont icon-up"></i></a>
</div>
<?php $this->need('footer.php'); ?>