1、获取数组形式参数的方法
2、更新内核路由类
This commit is contained in:
@@ -103,7 +103,7 @@ class Action extends Admin {
|
||||
* @author colin <colin@tensent.cn>
|
||||
*/
|
||||
public function del(){
|
||||
$id = array_unique((array)$this->param['id']);
|
||||
$id = $this->getArrayParam('id');
|
||||
if(empty($id)){
|
||||
return $this->error("非法操作!",'');
|
||||
}
|
||||
@@ -122,7 +122,7 @@ class Action extends Admin {
|
||||
* @author colin <colin@tensent.cn>
|
||||
*/
|
||||
public function setstatus(){
|
||||
$id = array_unique((array)$this->param['id']);
|
||||
$id = $this->getArrayParam('id');
|
||||
if(empty($id)){
|
||||
return $this->error("非法操作!",'');
|
||||
}
|
||||
@@ -189,7 +189,7 @@ class Action extends Admin {
|
||||
* @author huajie <banhuajie@163.com>
|
||||
*/
|
||||
public function dellog() {
|
||||
$id = array_unique((array)$this->param['id']);
|
||||
$id = $this->getArrayParam('id');
|
||||
if(empty($id)){
|
||||
return $this->error("非法操作!",'');
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ class Ad extends Admin {
|
||||
}
|
||||
|
||||
public function del(){
|
||||
$id = array_unique((array)$this->param['id']);
|
||||
$id = $this->getArrayParam('id');
|
||||
|
||||
if (empty($id)) {
|
||||
return $this->error("非法操作!");
|
||||
@@ -175,7 +175,7 @@ class Ad extends Admin {
|
||||
}
|
||||
|
||||
public function delad(){
|
||||
$id = array_unique((array)$this->param['id']);
|
||||
$id = $this->getArrayParam('id');
|
||||
|
||||
if (empty($id)) {
|
||||
return $this->error("非法操作!");
|
||||
|
||||
@@ -127,7 +127,7 @@ class Channel extends Admin{
|
||||
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
|
||||
*/
|
||||
public function del() {
|
||||
$id = array_unique((array)$this->param['id']);
|
||||
$id = $this->getArrayParam('id');
|
||||
|
||||
if (empty($id)) {
|
||||
return $this->error('请选择要操作的数据!');
|
||||
|
||||
@@ -145,7 +145,7 @@ class Content extends Admin{
|
||||
* @author molong <ycgpp@126.com>
|
||||
*/
|
||||
public function del(){
|
||||
$id = array_unique((array)$this->param['id']);
|
||||
$id = $this->getArrayParam('id');
|
||||
if (empty($id)) {
|
||||
return $this->error("非法操作!");
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ class Group extends Admin {
|
||||
|
||||
//会员分组删除控制器
|
||||
public function del(){
|
||||
$id = array_unique((array)$this->param['id']);
|
||||
$id = $this->getArrayParam('id');
|
||||
if (empty($id)) {
|
||||
return $this->error("非法操作!");
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ class Link extends Admin{
|
||||
|
||||
//删除
|
||||
public function delete(){
|
||||
$id = array_unique((array)$this->param['id']);
|
||||
$id = $this->getArrayParam('id');
|
||||
if (empty($id)) {
|
||||
return $this->error('非法操作!');
|
||||
}
|
||||
|
||||
@@ -49,19 +49,15 @@ class Menu extends Admin{
|
||||
if(IS_POST){
|
||||
$Menu = model('Menu');
|
||||
$data = input('post.');
|
||||
if($data){
|
||||
$id = $Menu->save($data);
|
||||
if($id){
|
||||
session('admin_menu_list',null);
|
||||
//记录行为
|
||||
action_log('update_menu', 'Menu', $id, session('user_auth.uid'));
|
||||
return $this->success('新增成功', Cookie('__forward__'));
|
||||
} else {
|
||||
return $this->error('新增失败');
|
||||
}
|
||||
} else {
|
||||
return $this->error($Menu->getError());
|
||||
}
|
||||
$id = $Menu->save($data);
|
||||
if($id){
|
||||
session('admin_menu_list',null);
|
||||
//记录行为
|
||||
action_log('update_menu', 'Menu', $id, session('user_auth.uid'));
|
||||
return $this->success('新增成功', Cookie('__forward__'));
|
||||
} else {
|
||||
return $this->error('新增失败');
|
||||
}
|
||||
} else {
|
||||
$this->assign('info',array('pid'=>input('pid')));
|
||||
$menus = db('Menu')->select();
|
||||
@@ -87,18 +83,14 @@ class Menu extends Admin{
|
||||
if(IS_POST){
|
||||
$Menu = model('Menu');
|
||||
$data = input('post.');
|
||||
if($data){
|
||||
if($Menu->save($data,array('id'=>$data['id']))!== false){
|
||||
session('admin_menu_list',null);
|
||||
//记录行为
|
||||
action_log('update_menu', 'Menu', $data['id'], session('user_auth.uid'));
|
||||
return $this->success('更新成功', Cookie('__forward__'));
|
||||
} else {
|
||||
return $this->error('更新失败');
|
||||
}
|
||||
} else {
|
||||
return $this->error($Menu->getError());
|
||||
}
|
||||
if($Menu->save($data,array('id'=>$data['id']))!== false){
|
||||
session('admin_menu_list',null);
|
||||
//记录行为
|
||||
action_log('update_menu', 'Menu', $data['id'], session('user_auth.uid'));
|
||||
return $this->success('更新成功', Cookie('__forward__'));
|
||||
} else {
|
||||
return $this->error('更新失败');
|
||||
}
|
||||
} else {
|
||||
$info = array();
|
||||
/* 获取数据 */
|
||||
@@ -123,9 +115,9 @@ class Menu extends Admin{
|
||||
* @author yangweijie <yangweijiester@gmail.com>
|
||||
*/
|
||||
public function del(){
|
||||
$id = array_unique((array)$this->param['id']);
|
||||
$id = $this->getArrayParam('id');
|
||||
|
||||
if ( empty($id) ) {
|
||||
if (empty($id) ) {
|
||||
return $this->error('请选择要操作的数据!');
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ class Seo extends Admin{
|
||||
}
|
||||
|
||||
public function del(){
|
||||
$id = array_unique((array)$this->param['id']);
|
||||
$id = $this->getArrayParam('id');
|
||||
if (empty($id)) {
|
||||
return $this->error("非法操作!");
|
||||
}
|
||||
|
||||
@@ -148,4 +148,15 @@ class Base extends \think\Controller{
|
||||
$this->assign('request',$this->request);
|
||||
$this->assign('param',$this->param);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单个参数的数组形式
|
||||
*/
|
||||
protected function getArrayParam($param){
|
||||
if (isset($this->param['id'])) {
|
||||
return array_unique((array)$this->param[$param]);
|
||||
}else{
|
||||
return array();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -754,7 +754,7 @@ class Route
|
||||
}
|
||||
if (isset($miss)) {
|
||||
// 未匹配所有路由的路由规则处理
|
||||
return self::parseRule('', $miss, $url);
|
||||
return self::parseRule('', $miss['route'], $url, $miss['option']);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -1162,7 +1162,7 @@ class Route
|
||||
$paths = explode('/', $pathinfo);
|
||||
}
|
||||
// 获取路由地址规则
|
||||
$url = is_array($route) ? $route[0] : $route;
|
||||
$url = $route;
|
||||
// 替换路由地址中的变量
|
||||
if (is_string($url) && !empty($matches)) {
|
||||
foreach ($matches as $key => $val) {
|
||||
@@ -1177,7 +1177,7 @@ class Route
|
||||
$result = ['type' => 'function', 'function' => $url, 'params' => $matches];
|
||||
} elseif (0 === strpos($url, '/') || 0 === strpos($url, 'http')) {
|
||||
// 路由到重定向地址
|
||||
$result = ['type' => 'redirect', 'url' => $url, 'status' => (is_array($route) && isset($route[1])) ? $route[1] : 301];
|
||||
$result = ['type' => 'redirect', 'url' => $url, 'status' => isset($option['status']) ? $option['status'] : 301];
|
||||
} elseif (0 === strpos($url, '\\')) {
|
||||
// 路由到方法
|
||||
$method = strpos($url, '@') ? explode('@', $url) : $url;
|
||||
|
||||
Reference in New Issue
Block a user