+---------------------------------------------------------------------- | TickyPHP [ This is a freeware ] +---------------------------------------------------------------------- | Copyright (c) 2015 All rights reserved.
+----------------------------------------------------------------------
| Author: 罗敏贵 e-mail:minguiluo@163.com
friendlink |
<?php
/**
* +----------------------------------------------------------------------
* | TickyPHP [ This is a freeware ]
* +----------------------------------------------------------------------
* | Copyright (c) 2015 All rights reserved.
* +----------------------------------------------------------------------
* | Author: 罗敏贵 <e-mail:minguiluo@163.com> <QQ:271391233>
* +----------------------------------------------------------------------
* | SVN: $Id: Friendlink.php 02603 2018-10-10 16:47:33 luomingui $
* +----------------------------------------------------------------------
* | 文件功能:对应的表名:tky_friendlink
* +----------------------------------------------------------------------
*/
namespace application\admin\controller;
use ticky\request;
use ticky\response;
class friendlink extends auth {
//首页
public function index() {
$search = $this->search_frm();
$ret = $this->db->page('friendlink', $search['sql'], 'displayorder', $this->p);
$this->assign('page', $ret['page']);
$this->assign('items', $ret['items']);
$this->assign('search', $search['arr']);
$this->display('friendlink/index');
}
// 批量删除
public function batchremove() {
$optype = request::post('optype', '');
$ids = request::post('ids', []);
if ($optype == "del") {
for ($i = 0; $i < count($ids); $i++) {
$id = $ids[$i];
db('friendlink')->where(['id' => $id])->delete();
}
if (request::isAjax()) {
response::ajax(['code' => 200, 'msg' => '修改成功']);
} else {
showmsg('删除成功', '/admin/friendlink');
}
} else {
if (is_array($_GET['name'])) {
foreach ($_GET['name'] as $id => $val) {
$type_str = intval($_GET['portal'][$id]) . intval($_GET['forum'][$id]) . intval($_GET['group'][$id]) . intval($_GET['home'][$id]);
$type_str = intval($type_str, '2');
$arr = array();
$arr['displayorder'] = $_GET['displayorder'][$id];
$arr['name'] = $_GET['name'][$id];
$arr['url'] = $_GET['url'][$id];
$arr['description'] = $_GET['description'][$id];
$arr['logo'] = $_GET['logo'][$id];
$arr['type'] = $type_str;
db('friendlink')->where(['id' => $id])->update($arr);
}
}
if (is_array($_GET['newname'])) {
foreach ($_GET['newname'] as $key => $value) {
if ($value) {
$type_str = intval($_GET['newportal'][$key]) . intval($_GET['newforum'][$key]) . intval($_GET['newgroup'][$key]) . intval($_GET['newhome'][$key]);
$type_str = intval($type_str, '2');
$arr = array();
$arr['displayorder'] = $_GET['newdisplayorder'][$key];
$arr['name'] = $value;
$arr['url'] = $_GET['newurl'][$key];
$arr['description'] = $_GET['newdescription'][$key];
$arr['logo'] = $_GET['newlogo'][$key];
$arr['type'] = $type_str;
db('friendlink')->add($arr);
}
}
}
showmsg('更新成功', '/admin/friendlink');
}
}
//查询条件
private function search_frm() {
$search = request::get('search', []);
$where = '1=1 ';
if ($id = trim($search['id'])) {
$where .= "and id = '{$id}' ";
}
if ($displayorder = trim($search['displayorder'])) {
$where .= "and displayorder = '{$displayorder}' ";
}
if ($name = trim($search['name'])) {
$where .= "and name = '{$name}' ";
}
if ($url = trim($search['url'])) {
$where .= "and url = '{$url}' ";
}
if ($description = trim($search['description'])) {
$where .= "and description = '{$description}' ";
}
if ($logo = trim($search['logo'])) {
$where .= "and logo = '{$logo}' ";
}
if ($type = trim($search['type'])) {
$where .= "and type = '{$type}' ";
}
return [
'arr' => $search,
'sql' => $where
];
}
}