3
3
/**
4
4
* Typecho 点赞插件
5
5
*
6
- * @package Likes
6
+ * @package Like
7
7
* @author skylzl
8
8
* @version 1.0.0
9
9
* @link http://www.phoneshuo.com
10
10
*/
11
11
12
- class Likes_Plugin implements Typecho_Plugin_Interface
12
+ class Like_Plugin implements Typecho_Plugin_Interface
13
13
{
14
14
/**
15
15
* 激活插件方法,如果激活失败,直接抛出异常
@@ -20,9 +20,9 @@ class Likes_Plugin implements Typecho_Plugin_Interface
20
20
*/
21
21
public static function activate ()
22
22
{
23
- Typecho_Plugin::factory ('Widget_Archive ' )->footer = array ('Likes_Plugin ' , 'header ' );
24
- Typecho_Plugin::factory ('Widget_Archive ' )->footer = array ('Likes_Plugin ' , 'footer ' );
25
- Helper::addAction ('likes ' , 'Likes_Action ' );
23
+ Typecho_Plugin::factory ('Widget_Archive ' )->footer = array ('Like_Plugin ' , 'header ' );
24
+ Typecho_Plugin::factory ('Widget_Archive ' )->footer = array ('Like_Plugin ' , 'footer ' );
25
+ Helper::addAction ('like ' , 'Like_Action ' );
26
26
$ db = Typecho_Db::get ();
27
27
$ prefix = $ db ->getPrefix ();
28
28
// contents 如果没有likes字段,则添加
@@ -71,22 +71,22 @@ public static function personalConfig(Typecho_Widget_Helper_Form $form){
71
71
/**
72
72
* 输出点赞链接或者点赞次数
73
73
*
74
- * 语法: Likes_Plugin::theLikes ();
75
- * 输出: '<a href="javascript:;" class="post-like" data-pid="'.$cid.'">赞 (<span>'.$row['likes '].'</span>)</a>'
74
+ * 语法: Like_Plugin::theLike ();
75
+ * 输出: '<a href="javascript:;" class="post-like" data-pid="'.$cid.'">赞 (<span>'.$row['like '].'</span>)</a>'
76
76
*
77
- * 语法: Likes_Plugin::theLikes (false);
77
+ * 语法: Like_Plugin::theLike (false);
78
78
* 输出: 0
79
79
*
80
80
* @access public
81
81
* @param bool $link 是否输入链接 (false为显示纯数字)
82
82
* @return string
83
83
*/
84
- public static function theLikes ($ link = true ){
84
+ public static function theLike ($ link = true ){
85
85
$ db = Typecho_Db::get ();
86
86
$ cid = Typecho_Widget::widget ('Widget_Archive ' )->cid ;
87
87
$ row = $ db ->fetchRow ($ db ->select ('likes ' )->from ('table.contents ' )->where ('cid = ? ' , $ cid ));
88
88
if ($ link ){
89
- $ settings = Helper::options ()->plugin ('Likes ' );
89
+ $ settings = Helper::options ()->plugin ('Like ' );
90
90
echo '<a href="javascript:;" class=" ' .$ settings ->likeClass .'" data-pid=" ' .$ cid .'"><i class="fa-thumbs-up"></i>赞 (<span> ' .$ row ['likes ' ].'</span>)</a> ' ;
91
91
}else {
92
92
return $ row ['likes ' ];
@@ -96,16 +96,16 @@ public static function theLikes($link = true){
96
96
/**
97
97
* 输出点赞最多的文章
98
98
*
99
- * 语法: Likes_Plugin ::theMostLiked();
99
+ * 语法: Like_Plugin ::theMostLiked();
100
100
*
101
101
* @access public
102
102
* @param int $limit 文章数目
103
- * @param string $shownum 是否显示点赞数量
103
+ * @param string $showlink 是否显示点赞链接
104
104
* @param string $before 前字串
105
105
* @param string $after 后字串
106
106
* @return string
107
107
*/
108
- public static function theMostLiked ($ limit = 10 , $ shownum = true , $ before = '<br/> - ( 点赞: ' , $ after = ' 次 ) ' )
108
+ public static function theMostLiked ($ limit = 10 , $ showlink = true , $ before = '<br/> - ( 点赞: ' , $ after = ' 次 ) ' )
109
109
{
110
110
$ db = Typecho_Db::get ();
111
111
$ limit = is_numeric ($ limit ) ? $ limit : 10 ;
@@ -121,10 +121,11 @@ public static function theMostLiked($limit = 10, $shownum = true, $before = '<br
121
121
$ post_likes = number_format ($ result ['likes ' ]);
122
122
$ post_title = htmlspecialchars ($ result ['title ' ]);
123
123
$ permalink = $ result ['permalink ' ];
124
- if ($ shownum == true ){
125
- echo "<li><a href=' $ permalink' title=' $ post_title'> $ post_title</a><span style='font-size:70%'> $ before $ post_likes $ after</span></li> \n" ;
124
+ $ settings = Helper::options ()->plugin ('Like ' );
125
+ if ($ showlink == true ){
126
+ echo "<li><a href=' $ permalink' title=' $ post_title'> $ post_title</a><span style='font-size:70%'><br/><a href='javascript:;' class=' $ settings ->likeClass ' data-pid=' $ cid'><i class='fa-thumbs-up'></i>赞 (<span>' $ post_likes</span>)</a></span></li> \n" ;
126
127
}else {
127
- echo "<li><a href=' $ permalink' title=' $ post_title'> $ post_title</a></li> \n" ;
128
+ echo "<li><a href=' $ permalink' title=' $ post_title'> $ post_title</a><span style='font-size:70%'> $ before $ post_likes $ after </span>< /li> \n" ;
128
129
}
129
130
}
130
131
@@ -136,14 +137,14 @@ public static function theMostLiked($limit = 10, $shownum = true, $before = '<br
136
137
* 点赞相关css加载在头部
137
138
*/
138
139
public static function header () {
139
- $ cssUrl = Helper::options ()->pluginUrl . '/Likes /css/style.css ' ;
140
+ $ cssUrl = Helper::options ()->pluginUrl . '/Like /css/style.css ' ;
140
141
echo '<link rel="stylesheet" type="text/css" href=" ' . $ cssUrl . '" /> ' ;
141
142
}
142
143
143
144
/**
144
145
* 点赞相关js加载在尾部
145
146
*/
146
147
public static function footer () {
147
- include 'likes -js.php ' ;
148
+ include 'like -js.php ' ;
148
149
}
149
150
}
0 commit comments