This repository has been archived by the owner on Oct 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
page-links.php
134 lines (118 loc) · 4.72 KB
/
page-links.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
<?php
/**
* 友链页
*
* @package custom
*/
/**
* Castle Links
* Last Update: 2020/04/18
*/
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
if (@$_SERVER['HTTP_X_PJAX'] == true) {
header('HTTP/1.1 200 OK');
echo '<title>'.Castle_Header::title($this, '', ' - ', true, false).'</title>';
echo '<div id="moe-pjax-content"'.Castle_Header::cardTransparent().'>';
}else{
$this->need('core/inc/header.php');
}
//懒得解决分页问题,直接 9999 (光速逃
Helper::options()->commentsPageSize = 9999;
$BloggerAvatar = (Helper::options()->siteAvatar) ? Helper::options()->siteAvatar : Castle_Libs::resources('static/img/avatar.jpg');
?>
<div id="links-view" data-view="<?php echo Castle_Contents::PostView($this); ?>"></div>
<main class="moe-links-box">
<div class="mdui-row-sm-2 mdui-row-md-4">
<div class="mdui-col">
<a class="moe-links-href" mdui-dialog="{target: '#links-dialog', history: false, modal: true}" no-go>
<div class="mdui-card moe-links-card mdui-hoverable">
<div class="mdui-card-media">
<main class="lazyload" data-src="<?php echo $BloggerAvatar; ?>" style="background-image: url('');"></main>
</div>
<div class="mdui-card-actions mdui-text-center">
<img src="<?php echo $BloggerAvatar; ?>" data-original="<?php echo $BloggerAvatar; ?>" class="moe-links-avatar"/><br>
<span class="moe-links-title">申请友链</span>
<span class="moe-links-description">点此进行申请</span>
</div>
</div>
</a>
</div>
<?php
if (Castle_Libs::hasPlugin('Links')) {
$Links = Links_Plugin::output('<div class="mdui-col">
<a class="moe-links-href" href="{url}" title="{title}" target="_blank">
<div class="mdui-card moe-links-card mdui-hoverable">
<div class="mdui-card-media">
<main class="lazyload" data-src="{image}" data-bgUrl="{user}" style="background-image: url(\'\');"></main>
</div>
<div class="mdui-card-actions mdui-text-center">
<img src="{image}" data-original="{image}" class="moe-links-avatar"/><br>
<span class="moe-links-title">{name}</span>
<span class="moe-links-description">{description}</span>
</div>
</div>
</a>
</div>');
if (Helper::options()->pageLinks && in_array('rand', Helper::options()->pageLinks)) {
shuffle($Links);
}
for ($i=0;$i<count($Links);$i++) {
preg_match_all('/data\-bgUrl="(.*?)"/i', $Links[$i], $bgUrl);
if (!empty($bgUrl[1][0])) {
$Links[$i] = preg_replace('/data\-src="(.*?)"/i', 'data-src="'.$bgUrl[1][0].'"', $Links[$i]);
}
$Links[$i] = preg_replace('/data\-bgUrl="(.*?)"/i', '', $Links[$i]);
echo $Links[$i];
}
}else{
echo '<div class="mdui-col">
<a class="moe-links-href" no-go>
<div class="mdui-card moe-links-card mdui-hoverable">
<div class="mdui-card-media">
<main class="lazyload" data-src="'.$BloggerAvatar.'" style="background-image: url(\'\');"></main>
</div>
<div class="mdui-card-actions mdui-text-center">
<img src="'.$BloggerAvatar.'" data-original="'.$BloggerAvatar.'" class="moe-links-avatar"/><br>
<span class="moe-links-title">友链插件未启用</span>
<span class="moe-links-description">请安装 Links 插件并启用</span>
</div>
</div>
</a>
</div>';
}
?>
</div>
</main>
<div class="mdui-dialog" id="links-dialog">
<div class="mdui-card moe-post-card">
<div class="mdui-card-media">
<div class="moe-card-cover-image lazyload" data-src="<?php
$cover = $this->fields->cover;
if (!empty($cover)) {
echo $cover;
}else{
Castle_Libs::randCover(true);
}
?>" style="background-image:url('');"></div>
<div class="mdui-card-media-covered">
<div class="mdui-card-primary">
<div class="mdui-card-primary-title mdui-text-truncate"><?php $this->title() ?></div>
<div class="mdui-card-primary-subtitle"><?php echo sprintf($GLOBALS['CastleLang']['page']['view'], Castle_Contents::PostView($this)); ?> | <?php echo sprintf($GLOBALS['CastleLang']['page']['comment'], $this->commentsNum); ?></div>
</div>
</div>
</div>
<div class="mdui-divider"></div>
<div class="moe-card-content">
<?php $this->content(); ?>
</div>
</div>
<?php $this->need('core/inc/comments.php'); ?>
<button class="mdui-btn mdui-btn-icon mdui-color-theme mdui-hoverable" id="links-close" mdui-dialog-close><i class="mdui-icon material-icons"></i></button>
</div>
<?php
if (@$_SERVER['HTTP_X_PJAX'] == true) {
echo '</div>';
}else{
$this->need('core/inc/footer.php');
}
?>