From 9babe5612bad919e0f3824ea4eb76b897d221334 Mon Sep 17 00:00:00 2001 From: weianguo Date: Thu, 31 Mar 2016 11:15:28 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=AF=BC=E8=88=AACURD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/ChannelController.class.php | 54 +++++++++++++++++-- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/wwwroot/Application/Admin/Controller/ChannelController.class.php b/wwwroot/Application/Admin/Controller/ChannelController.class.php index 9740e6c7..9cfab8bd 100644 --- a/wwwroot/Application/Admin/Controller/ChannelController.class.php +++ b/wwwroot/Application/Admin/Controller/ChannelController.class.php @@ -22,12 +22,22 @@ class ChannelController extends AdminController { */ public function index(){ $pid = I('get.pid', 0); + if($pid){ + $data = M('Channel')->where("id={$pid}")->field(true)->find(); + $this->assign('data',$data); + } /* 获取频道列表 */ $map = array('status' => array('gt', -1), 'pid'=>$pid); + $title = trim(I('get.title')); + if($title) + $map['title'] = array('like',"%{$title}%"); $list = M('Channel')->where($map)->order('sort asc,id asc')->select(); $this->assign('list', $list); $this->assign('pid', $pid); + // 记录当前列表页的cookie + Cookie('__forward__',$_SERVER['REQUEST_URI']); + $this->meta_title = '导航管理'; $this->display(); } @@ -43,7 +53,7 @@ public function add(){ if($data){ $id = $Channel->add(); if($id){ - $this->success('新增成功', U('index')); + $this->success('新增成功', Cookie('__forward__')); //记录行为 action_log('update_channel', 'channel', $id, UID); } else { @@ -79,7 +89,7 @@ public function edit($id = 0){ if($Channel->save()){ //记录行为 action_log('update_channel', 'channel', $data['id'], UID); - $this->success('编辑成功', U('index')); + $this->success('编辑成功',Cookie('__forward__')); } else { $this->error('编辑失败'); } @@ -130,7 +140,43 @@ public function del(){ $this->error('删除失败!'); } } - + + public function import(){ + if(IS_POST){ + $tree = I('post.tree'); + $lists = explode(PHP_EOL, $tree); + $channelModel = M('Channel'); + if($lists == array()){ + $this->error('请按格式填写批量导入的菜单,至少一个菜单'); + }else{ + $pid = I('post.pid'); + foreach ($lists as $key => $value) { + $record = explode('|', $value); + if(count($record) == 2){ + $channelModel->add(array( + 'title'=>$record[0], + 'url'=>$record[1], + 'pid'=>$pid, + 'sort'=>0, + 'create_time'=>time(), + 'update_time'=>time(), + 'status'=>0, + 'target'=>0, + )); + } + } + $this->success('导入成功',U('index?pid='.$pid)); + } + }else{ + $this->meta_title = '批量导入前台导航'; + $pid = (int)I('get.pid'); + $this->assign('pid', $pid); + $data = M('Channel')->where("id={$pid}")->field(true)->find(); + $this->assign('data', $data); + $this->display(); + } + } + /** * 导航排序 * @author huajie @@ -169,4 +215,4 @@ public function sort(){ $this->error('非法请求!'); } } -} \ No newline at end of file +} From 1e17507f2c584d65aac915aaae7756535058e7e6 Mon Sep 17 00:00:00 2001 From: weianguo Date: Thu, 31 Mar 2016 11:16:50 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AF=BC=E8=88=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/View/Channel/import.html | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 wwwroot/Application/Admin/View/Channel/import.html diff --git a/wwwroot/Application/Admin/View/Channel/import.html b/wwwroot/Application/Admin/View/Channel/import.html new file mode 100644 index 00000000..1d5e366e --- /dev/null +++ b/wwwroot/Application/Admin/View/Channel/import.html @@ -0,0 +1,50 @@ + + + +
+

+ 批量导入 [{$data.title|default='顶级导航'}] +

+
+ +
+
+ +
+ +
+
+ +
+ +
+ 导入格式:标题|url(回车键)
          标题|url
+
+
+
+ + 返 回 + + +
+
+
+
+
+ + + + From 858690038b7507594b787a477b67b06c61b05e02 Mon Sep 17 00:00:00 2001 From: weianguo Date: Thu, 31 Mar 2016 11:18:08 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AF=BC=E8=88=AA?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=92=8C=E6=90=9C=E7=B4=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Application/Admin/View/Channel/index.html | 39 ++++++++++++++++--- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/wwwroot/Application/Admin/View/Channel/index.html b/wwwroot/Application/Admin/View/Channel/index.html index a99e67b9..528153dd 100644 --- a/wwwroot/Application/Admin/View/Channel/index.html +++ b/wwwroot/Application/Admin/View/Channel/index.html @@ -2,13 +2,21 @@
-

导航管理

-
+

[ {$data.title} ] 子导航管理

+
新 增 - 删 除 + + 导 入 + +
+
+ + +
+
@@ -29,7 +37,7 @@

导航管理

- + {$channel.id} {$channel.title} {$channel.url} @@ -69,6 +77,27 @@

导航管理

window.location.href = url + '/ids/' + param; } }); + + //搜索功能 + $("#search").click(function() { + var url = $(this).attr('url'); + var query = $('.search-form').find('input').serialize(); + query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, ''); + query = query.replace(/^&/g, ''); + if (url.indexOf('?') > 0) { + url += '&' + query; + } else { + url += '?' + query; + } + window.location.href = url; + }); + //回车搜索 + $(".search-input").keyup(function(e) { + if (e.keyCode === 13) { + $("#search").click(); + return false; + } + }); }); - \ No newline at end of file +