Skip to content

Commit a45e19f

Browse files
author
xiaogouxo
committed
update
1 parent 32fe0e4 commit a45e19f

File tree

8 files changed

+30
-26
lines changed

8 files changed

+30
-26
lines changed

Diff for: Likes/Action.php renamed to Like/Action.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22
/**
3-
* Likes Plugin
3+
* Like Plugin
44
*
55
* @copyright Copyright (c) 2014 skylzl (http://www.woyoudian.com)
66
* @license GNU General Public License 2.0
77
*
88
*/
99

10-
class Likes_Action extends Typecho_Widget implements Widget_Interface_Do
10+
class Like_Action extends Typecho_Widget implements Widget_Interface_Do
1111
{
1212
private $db;
1313

@@ -20,7 +20,7 @@ public function __construct($request, $response, $params = NULL)
2020
/**
2121
* 点赞Like
2222
*/
23-
public function like(){
23+
public function up(){
2424
$cid=$this->request->filter('int')->cid;
2525
if($cid){
2626
try {
@@ -37,7 +37,7 @@ public function like(){
3737
}
3838

3939
public function action(){
40-
$this->on($this->request->is('like'))->like();
40+
$this->on($this->request->is('up'))->up();
4141
$this->response->goBack();
4242
}
4343
}

Diff for: Likes/Plugin.php renamed to Like/Plugin.php

+19-18
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
/**
44
* Typecho 点赞插件
55
*
6-
* @package Likes
6+
* @package Like
77
* @author skylzl
88
* @version 1.0.0
99
* @link http://www.phoneshuo.com
1010
*/
1111

12-
class Likes_Plugin implements Typecho_Plugin_Interface
12+
class Like_Plugin implements Typecho_Plugin_Interface
1313
{
1414
/**
1515
* 激活插件方法,如果激活失败,直接抛出异常
@@ -20,9 +20,9 @@ class Likes_Plugin implements Typecho_Plugin_Interface
2020
*/
2121
public static function activate()
2222
{
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');
2626
$db = Typecho_Db::get();
2727
$prefix = $db->getPrefix();
2828
// contents 如果没有likes字段,则添加
@@ -71,22 +71,22 @@ public static function personalConfig(Typecho_Widget_Helper_Form $form){
7171
/**
7272
* 输出点赞链接或者点赞次数
7373
*
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>'
7676
*
77-
* 语法: Likes_Plugin::theLikes(false);
77+
* 语法: Like_Plugin::theLike(false);
7878
* 输出: 0
7979
*
8080
* @access public
8181
* @param bool $link 是否输入链接 (false为显示纯数字)
8282
* @return string
8383
*/
84-
public static function theLikes($link = true){
84+
public static function theLike($link = true){
8585
$db = Typecho_Db::get();
8686
$cid = Typecho_Widget::widget('Widget_Archive')->cid;
8787
$row = $db->fetchRow($db->select('likes')->from('table.contents')->where('cid = ?', $cid));
8888
if($link){
89-
$settings = Helper::options()->plugin('Likes');
89+
$settings = Helper::options()->plugin('Like');
9090
echo '<a href="javascript:;" class="'.$settings->likeClass.'" data-pid="'.$cid.'"><i class="fa-thumbs-up"></i>赞 (<span>'.$row['likes'].'</span>)</a>';
9191
}else{
9292
return $row['likes'];
@@ -96,16 +96,16 @@ public static function theLikes($link = true){
9696
/**
9797
* 输出点赞最多的文章
9898
*
99-
* 语法: Likes_Plugin::theMostLiked();
99+
* 语法: Like_Plugin::theMostLiked();
100100
*
101101
* @access public
102102
* @param int $limit 文章数目
103-
* @param string $shownum 是否显示点赞数量
103+
* @param string $showlink 是否显示点赞链接
104104
* @param string $before 前字串
105105
* @param string $after 后字串
106106
* @return string
107107
*/
108-
public static function theMostLiked($limit = 10, $shownum = true, $before = '<br/> - ( 点赞: ', $after = ' 次 ) ')
108+
public static function theMostLiked($limit = 10, $showlink = true, $before = '<br/> - ( 点赞: ', $after = ' 次 ) ')
109109
{
110110
$db = Typecho_Db::get();
111111
$limit = is_numeric($limit) ? $limit : 10;
@@ -121,10 +121,11 @@ public static function theMostLiked($limit = 10, $shownum = true, $before = '<br
121121
$post_likes = number_format($result['likes']);
122122
$post_title = htmlspecialchars($result['title']);
123123
$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";
126127
}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";
128129
}
129130
}
130131

@@ -136,14 +137,14 @@ public static function theMostLiked($limit = 10, $shownum = true, $before = '<br
136137
* 点赞相关css加载在头部
137138
*/
138139
public static function header() {
139-
$cssUrl = Helper::options()->pluginUrl . '/Likes/css/style.css';
140+
$cssUrl = Helper::options()->pluginUrl . '/Like/css/style.css';
140141
echo '<link rel="stylesheet" type="text/css" href="' . $cssUrl . '" />';
141142
}
142143

143144
/**
144145
* 点赞相关js加载在尾部
145146
*/
146147
public static function footer() {
147-
include 'likes-js.php';
148+
include 'like-js.php';
148149
}
149150
}

Diff for: Like/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 插件说明 ##
2+
####typecho点赞like插件,调用<?php Like_Plugin::theLike(); ?>即可
3+
####详细介绍:http://www.phoneshuo.com/PHP/typecho-like-plugin.html

Diff for: Likes/css/style.css renamed to Like/css/style.css

File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: Likes/js/jquery.js renamed to Like/js/jquery.js

File renamed without changes.

Diff for: Likes/likes-js.php renamed to Like/like-js.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit;
2-
$jqueryScriptUrl = Helper::options()->pluginUrl . '/Likes/js/jquery.js';
3-
$macaroonScriptUrl = Helper::options()->pluginUrl . '/Likes/js/jquery.fs.macaroon.js';
4-
$settings = Helper::options()->plugin('Likes');
2+
$jqueryScriptUrl = Helper::options()->pluginUrl . '/Like/js/jquery.js';
3+
$macaroonScriptUrl = Helper::options()->pluginUrl . '/Like/js/jquery.fs.macaroon.js';
4+
$settings = Helper::options()->plugin('Like');
55
?>
66

77
<script type="text/javascript" src="<?php echo $jqueryScriptUrl; ?>"></script>
@@ -16,7 +16,7 @@
1616
cookies ? cookies.length >= 160 ? (cookies = cookies.substring(0, cookies.length - 1), cookies = cookies.substr
1717
(1).split(","), cookies.splice(0, 1), cookies.push(id), cookies = cookies.join(","), $.macaroon("_syan_like", "," + cookies +
1818
",")) : $.macaroon("_syan_like", cookies + id + ",") : $.macaroon("_syan_like", "," + id + ",");
19-
$.post('<?php Helper::options()->index('/action/likes?like'); ?>',{
19+
$.post('<?php Helper::options()->index('/action/like?up'); ?>',{
2020
cid:id
2121
},function(data){
2222
th.addClass('actived');

0 commit comments

Comments
 (0)