-
Notifications
You must be signed in to change notification settings - Fork 589
/
themes.php
105 lines (91 loc) · 3.7 KB
/
themes.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
<div class="typecho-table-wrap">
<table class="typecho-list-table typecho-theme-list">
<colgroup>
<col width="35%"/>
<col/>
</colgroup>
<thead>
<th><?php _e('截图'); ?></th>
<th><?php _e('详情'); ?></th>
</thead>
<tbody>
<?php
use Typecho\Plugin;
use Typecho\Db;
use Widget\{Options, Notice};
$template = Options::alloc()->plugin('CommentNotifier')->template;
/* @var $request */
/* @var $response */
/* @var $options */
if ($request->change) {
$db = Db::get();
$select = $db->select('value')->from('table.options')->where('name = ?', 'plugin:CommentNotifier')->limit(1);
$aftersitting = $db->fetchRow($select);
$setting = unserialize($aftersitting['value']);
$setting['template'] = $request->change;
$setting = serialize($setting);
$update = $db->update('table.options')->rows(array('value' => $setting))->where('name = ?', 'plugin:CommentNotifier');
$updateRows = $db->query($update);
Notice::alloc()->set(_t("邮件模板启动成功"), 'success');
$template = $request->change;
$response->redirect($options->adminUrl . 'extending.php?panel=' . CommentNotifier_Plugin::$panel);
}
function getMailTheme(): array
{
return glob(__TYPECHO_ROOT_DIR__ . __TYPECHO_PLUGIN_DIR__ . '/CommentNotifier/template/*', GLOB_ONLYDIR);
}//获取模板
$themes = getMailTheme();
$html = '';
$ding = '';
$cite = '';
foreach ($themes as $key => $theme) {
$themeFile = $theme . '/owner.html';
if (file_exists($themeFile)) {//判断是否存在模板
$name = basename($theme);
$info = Plugin::parseInfo($themeFile);
$screen = array_filter(glob($theme . '/*'), function ($path) {
return preg_match("/screenshot\.(jpg|png|gif|bmp|jpeg|webp)$/i", $path);
});
if ($screen) {
$img = $options->pluginUrl . '/CommentNotifier/template/' . $name . '/' . basename(current($screen));
} else {
$img = Common::url('noscreen.png', $options->adminStaticUrl('img'));
}
if ($info['author']) {
$cite = '作者:' . $info['author'] . ' ';
}
if ($info['author'] && $info['homepage']) {
$cite = '作者:<a href="' . $info['homepage'] . '">' . $info['author'] . '</a> ';
}
if ($info['version']) {
$cite = $cite . '版本: ' . $info['version'];
}
if ($template == $name) {
$ding = '<tr>
<td valign="top"><img src="' . $img . '"></td>
<td valign="top">
<h3>' . $info['title'] . '</h3>
<cite>' . $cite . '</cite>
<p>' . nl2br($info['description']) . '</p>
</td>
</tr>';
} else {
$html = $html . '<tr>
<td valign="top"><img src="' . $img . '"></td>
<td valign="top">
<h3>' . $info['title'] . '</h3>
<cite>' . $cite . '</cite>
<p>' . nl2br($info['description']) . '</p>
<p>
<a class="activate" href="' . $options->adminUrl . 'extending.php?panel=' . CommentNotifier_Plugin::$panel . '&act=index' . '&change=' . $name . '">启用</a>
</p>
</td>
</tr>';
}
}
}
$html = $ding . $html;
echo $html;
?>
</tbody>
</table>