-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
824 changed files
with
27,484 additions
and
46,349 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?php | ||
/** | ||
* 收藏夹管理 | ||
* @作者 qinggan <[email protected]> | ||
* @版权 深圳市锟铻科技有限公司 | ||
* @主页 http://www.phpok.com | ||
* @版本 4.x | ||
* @许可 http://www.phpok.com/lgpl.html PHPOK开源授权协议:GNU Lesser General Public License | ||
* @时间 2018年06月04日 | ||
**/ | ||
namespace phpok\app\control\fav; | ||
|
||
/** | ||
* 安全限制,防止直接访问 | ||
**/ | ||
if(!defined("PHPOK_SET")){ | ||
exit("<h1>Access Denied</h1>"); | ||
} | ||
|
||
class admin_control extends \phpok_control | ||
{ | ||
private $popedom; | ||
public function __construct() | ||
{ | ||
parent::control(); | ||
$this->popedom = appfile_popedom('fav'); | ||
$this->assign("popedom",$this->popedom); | ||
} | ||
|
||
public function index_f() | ||
{ | ||
if(!$this->popedom['list']){ | ||
$this->error(P_Lang('您没有查看权限')); | ||
} | ||
$keywords = $this->get('keywords'); | ||
$keytype = $this->get('keytype'); | ||
$condition = '1=1'; | ||
$pageurl = $this->url('fav'); | ||
if($keywords && $keytype){ | ||
$stype = $this->get('stype','int'); | ||
if($keytype == 'title' || $keytype == 'note' || $keytype == 'thumb'){ | ||
if($stype){ | ||
$condition .= " AND f.".$keytype."='".$keywords."'"; | ||
}else{ | ||
$keywords = str_replace(' ','%',$keywords); | ||
$condition .= " AND f.".$keytype." LIKE '%".$keywords."%'"; | ||
} | ||
}elseif($keytype == 'user' || $keytype == 'email' || $keytype == 'mobile'){ | ||
if($stype){ | ||
$condition .= " AND u.".$keytype."='".$keywords."'"; | ||
}else{ | ||
$keywords = str_replace(' ','%',$keywords); | ||
$condition .= " AND u.".$keytype." LIKE '%".$keywords."%'"; | ||
} | ||
} | ||
$pageurl .= "&keytype=".$keytype."&keywords=".rawurlencode($keywords); | ||
if($stype){ | ||
$pageurl .= "&stype=".$stype; | ||
} | ||
$this->assign('keytype',$keytype); | ||
$this->assign('keywords',$keywords); | ||
$this->assign('stype',$stype); | ||
} | ||
$total = $this->model('fav')->get_count($condition); | ||
if($total){ | ||
$this->assign('total',$total); | ||
$pageid = $this->get($this->config['pageid'],'int'); | ||
if(!$pageid){ | ||
$pageid = 1; | ||
} | ||
$psize = $this->config['psize'] ? $this->config['psize'] : 30; | ||
$offset = ($pageid-1) * $psize; | ||
$rslist = $this->model('fav')->get_all($condition,$offset,$psize); | ||
$this->assign('rslist',$rslist); | ||
$string = 'home='.P_Lang('首页').'&prev='.P_Lang('上一页').'&next='.P_Lang('下一页').'&last='.P_Lang('尾页').'&half=5'; | ||
$string.= '&add='.P_Lang('数量:').'(total)/(psize)'.P_Lang(',').P_Lang('页码:').'(num)/(total_page)&always=1'; | ||
$pagelist = phpok_page($pageurl,$total,$pageid,$psize,$string); | ||
$this->assign("pagelist",$pagelist); | ||
} | ||
$this->display('admin_index'); | ||
} | ||
|
||
public function delete_f() | ||
{ | ||
if(!$this->popedom['delete']){ | ||
$this->error(P_Lang('您没有删除权限')); | ||
} | ||
$id = $this->get('id','int'); | ||
if(!$id){ | ||
$this->error(P_Lang('未指定要删除的ID')); | ||
} | ||
$this->model('fav')->del($id); | ||
$this->success(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* 后台管理收藏夹的JS | ||
* @作者 qinggan <[email protected]> | ||
* @版权 深圳市锟铻科技有限公司 | ||
* @主页 http://www.phpok.com | ||
* @版本 5.x | ||
* @授权 http://www.phpok.com/lgpl.html 开源授权协议:GNU Lesser General Public License | ||
* @时间 2018年06月04日 | ||
**/ | ||
;(function($){ | ||
$.admin_fav = { | ||
del:function(id) | ||
{ | ||
$.dialog.confirm(p_lang('确认要删除该收藏主题(ID:{id})吗?',id),function(){ | ||
$.phpok.json(get_url('fav','delete','id='+id),function(data){ | ||
if(data.status){ | ||
$("tr[data-id="+id+"]").remove(); | ||
return true; | ||
} | ||
$.dialog.alert(data.info); | ||
return false; | ||
}); | ||
}); | ||
} | ||
} | ||
})(jQuery); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,191 @@ | ||
<?php | ||
/** | ||
* 收藏夹相关功能接口 | ||
* @作者 qinggan <[email protected]> | ||
* @版权 深圳市锟铻科技有限公司 | ||
* @主页 http://www.phpok.com | ||
* @版本 5.x | ||
* @授权 http://www.phpok.com/lgpl.html 开源授权协议:GNU Lesser General Public License | ||
* @时间 2018年06月04日 | ||
**/ | ||
namespace phpok\app\control\fav; | ||
|
||
/** | ||
* 安全限制,防止直接访问 | ||
**/ | ||
if(!defined("PHPOK_SET")){ | ||
exit("<h1>Access Denied</h1>"); | ||
} | ||
|
||
class api_control extends \phpok_control | ||
{ | ||
public function __construct() | ||
{ | ||
parent::control(); | ||
} | ||
|
||
/** | ||
* 加入收藏 | ||
* @参数 id 主题ID | ||
**/ | ||
public function add_f() | ||
{ | ||
if(!$this->session->val('user_id')){ | ||
$this->error(P_Lang('您还未登录,不能执行此操作')); | ||
} | ||
$id = $this->get('id','int'); | ||
if(!$id){ | ||
$this->error(P_Lang('未指定要收藏的主题ID')); | ||
} | ||
$chk = $this->model('fav')->chk($id,$this->session->val('user_id')); | ||
if($chk){ | ||
$this->error(P_Lang('主题已经收藏过,不能重复收藏')); | ||
} | ||
$rs = $this->call->phpok('_arc','title_id='.$id); | ||
if(!$rs){ | ||
$this->error(P_Lang('内容不存在')); | ||
} | ||
$data = array('user_id'=>$this->session->val('user_id')); | ||
$type = ($this->config['fav'] && $this->config['fav']['thumb_id']) ? $this->config['fav']['thumb_id'] : 'thumb'; | ||
if($rs[$type]){ | ||
if(is_array($rs[$type])){ | ||
$data['thumb'] = $rs[$type]['filename']; | ||
}else{ | ||
$data['thumb'] = $rs[$type]; | ||
} | ||
} | ||
$data['title'] = $rs['title']; | ||
$type = ($this->config['fav'] && $this->config['fav']['note_id']) ? $this->config['fav']['note_id'] : 'content'; | ||
if($rs[$type]){ | ||
$data['note'] = $this->lib('string')->cut($rs[$type],80,'…',false); | ||
} | ||
$data['addtime'] = $this->time; | ||
$data['lid'] = $id; | ||
$this->model('fav')->save($data); | ||
$this->success(); | ||
} | ||
|
||
/** | ||
* 删除收藏的主题 | ||
* @参数 id 收藏表中 qinggan_fav 里的主键ID,注意噢,不是主题ID | ||
* @参数 lid 主题ID | ||
**/ | ||
public function delete_f() | ||
{ | ||
if(!$this->session->val('user_id')){ | ||
$this->error(P_Lang('您还未登录,不能执行此操作')); | ||
} | ||
$id = $this->get('id','int'); | ||
if(!$id){ | ||
$lid = $this->get('lid','int'); | ||
if(!$lid){ | ||
$this->error(P_Lang('未指定ID')); | ||
} | ||
$chk = $this->model('fav')->chk($lid,$this->session->val('user_id')); | ||
if(!$chk){ | ||
$this->error(P_Lang('没有找到要删除的记录')); | ||
} | ||
$id = $chk['id']; | ||
} | ||
$rs = $this->model('fav')->get_one($id); | ||
if(!$rs){ | ||
$this->error(P_Lang('数据不存在')); | ||
} | ||
if($rs['user_id'] != $this->session->val('user_id')){ | ||
$this->error(P_Lang('您没有权限删除')); | ||
} | ||
$this->model('fav')->delete($id); | ||
$this->success(); | ||
} | ||
|
||
/** | ||
* 检测主题是否已存在 | ||
* @参数 $id 主题ID | ||
**/ | ||
public function check_f() | ||
{ | ||
if(!$this->session->val('user_id')){ | ||
$this->error(P_Lang('您还未登录,不能执行此操作')); | ||
} | ||
$id = $this->get('id','int'); | ||
if(!$id){ | ||
$this->error(P_Lang('未指定主题ID')); | ||
} | ||
$rs = $this->model('fav')->chk($id,$_SESSION['user_id']); | ||
if($rs){ | ||
$this->success($rs['id']); | ||
} | ||
$this->success(0); | ||
} | ||
|
||
/** | ||
* 读取收藏列表 | ||
* @参数 $pageid 页码ID | ||
* @参数 $psize 每页数量 | ||
**/ | ||
public function index_f() | ||
{ | ||
if(!$this->session->val('user_id')){ | ||
$this->error(P_Lang('您还未登录,不能执行此操作')); | ||
} | ||
$condition = "f.user_id='".$this->session->val('user_id')."'"; | ||
$total = $this->model('fav')->get_count($condition); | ||
if(!$total){ | ||
$this->error(P_Lang('您的收藏夹还是空的噢')); | ||
} | ||
$pageid = $this->get($this->config['pageid'],'int'); | ||
if(!$pageid){ | ||
$pageid = 1; | ||
} | ||
$psize = $this->get('psize','int'); | ||
if(!$psize){ | ||
$psize = $this->config['psize'] ? $this->config['psize'] : 30; | ||
} | ||
$offset = ($pageid-1) * $psize; | ||
$rslist = $this->model('fav')->get_all($condition,$offset,$psize); | ||
$data = array('total'=>$total,'pageid'=>$pageid,'psize'=>$psize,'rslist'=>$rslist); | ||
$this->success($data); | ||
} | ||
|
||
/** | ||
* 执行动作,未添加收藏时进行添加操作,已添加执行取消操作 | ||
* @参数 $id 主题ID | ||
**/ | ||
public function act_f() | ||
{ | ||
if(!$this->session->val('user_id')){ | ||
$this->error(P_Lang('您还未登录,不能执行此操作')); | ||
} | ||
$id = $this->get('id','int'); | ||
if(!$id){ | ||
$this->error(P_Lang('未指定主题ID')); | ||
} | ||
$chk = $this->model('fav')->chk($id,$this->session->val('user_id')); | ||
if($chk){ | ||
$this->model('fav')->delete($chk['id']); | ||
$this->success('delete'); | ||
} | ||
$rs = $this->call->phpok('_arc','title_id='.$id); | ||
if(!$rs){ | ||
$this->error(P_Lang('内容不存在')); | ||
} | ||
$data = array('user_id'=>$this->session->val('user_id')); | ||
$type = ($this->config['fav'] && $this->config['fav']['thumb_id']) ? $this->config['fav']['thumb_id'] : 'thumb'; | ||
if($rs[$type]){ | ||
if(is_array($rs[$type])){ | ||
$data['thumb'] = $rs[$type]['filename']; | ||
}else{ | ||
$data['thumb'] = $rs[$type]; | ||
} | ||
} | ||
$data['title'] = $rs['title']; | ||
$type = ($this->config['fav'] && $this->config['fav']['note_id']) ? $this->config['fav']['note_id'] : 'content'; | ||
if($rs[$type]){ | ||
$data['note'] = $this->lib('string')->cut($rs[$type],80,'…',false); | ||
} | ||
$data['addtime'] = $this->time; | ||
$data['lid'] = $id; | ||
$this->model('fav')->save($data); | ||
$this->success('add'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<root> | ||
<title><![CDATA[收藏夹]]></title> | ||
<status> | ||
<admin>1</admin> | ||
<api>1</api> | ||
<www>1</www> | ||
</status> | ||
<install><![CDATA[install.php]]></install> | ||
<uninstall><![CDATA[uninstall.php]]></uninstall> | ||
</root> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
/** | ||
* 公共函数 | ||
* @作者 qinggan <[email protected]> | ||
* @版权 深圳市锟铻科技有限公司 | ||
* @主页 http://www.phpok.com | ||
* @版本 5.x | ||
* @授权 http://www.phpok.com/lgpl.html 开源授权协议:GNU Lesser General Public License | ||
* @时间 2018年06月04日 | ||
**/ | ||
|
||
|
||
/** | ||
* 返回主题被收藏的次数 | ||
* @参数 $title_id 主题ID | ||
* @内容页模板代码 {func fav_count $rs.id} | ||
**/ | ||
function fav_count($title_id=0) | ||
{ | ||
return $GLOBALS['app']->model('fav')->title_fav_count($title_id); | ||
} | ||
|
||
/** | ||
* 检测主题是否已被收藏 | ||
* @参数 $title_id 主题ID | ||
* @参数 $user_id 会员ID,留空直接通过 session 获取 | ||
* @内容示例 {if fav_check($rs.id,$session.user_id)} | ||
**/ | ||
function fav_check($title_id=0,$user_id=0) | ||
{ | ||
if(!$user_id){ | ||
$user_id = $GLOBALS['app']->session->val('user_id'); | ||
} | ||
return $GLOBALS['app']->model('fav')->chk($title_id,$user_id); | ||
} |
Oops, something went wrong.