From f7ca10017b71c0b01db79031579fa41c69872ffc Mon Sep 17 00:00:00 2001
From: colly_wyx <wangyixiong_007@163.com>
Date: Fri, 11 Aug 2017 14:15:42 +0800
Subject: [PATCH] 修改后台tab
---
application/modules/Article/controllers/Manager.php | 103 +++++++++++++++++++++++----------------------------
1 files changed, 46 insertions(+), 57 deletions(-)
diff --git a/application/modules/Article/controllers/Manager.php b/application/modules/Article/controllers/Manager.php
index d3854bc..2347825 100644
--- a/application/modules/Article/controllers/Manager.php
+++ b/application/modules/Article/controllers/Manager.php
@@ -4,17 +4,19 @@
public function init(){
parent::init();
- $this->module_service = new Service_Module();
+ $this->article_service = new Service_Article();
//echo $this->layout;
}
public function ListAction(){
if($this->getRequest()->isXmlHttpRequest()){
- $total = $this->module_service->getModuleTotal();
+ $total = $this->article_service->getArticleTotal();
$data['draw'] = !empty($_REQUEST['draw'])?$_REQUEST['draw']:1;
+ $data['start'] = !empty($_REQUEST['start'])?$_REQUEST['start']:0;
+ $data['length'] = !empty($_REQUEST['length'])?$_REQUEST['length']:10;
$data['recordsTotal'] = $total;
$data['recordsFiltered'] = $total;
- $data['data'] = $this->module_service->getModuleList();
+ $data['data'] = $this->article_service->getArticleList(array(), array(), array(), $data['length'], $data['start']);
//print_r($this->module_service->getModuleList());
exit($this->sendToDataTable($data));
}
@@ -25,81 +27,68 @@
*/
public function AddAction(){
if($this->getRequest()->isXmlHttpRequest()){
- $data['module'] = $this->getRequest()->getPost('module');
- $data['controller'] = $this->getRequest()->getPost('controller');
- $data['action'] = $this->getRequest()->getPost('action');
- $data['parent'] = $this->getRequest()->getPost('parent');
$data['name'] = $this->getRequest()->getPost('name');
- if($data['parent'] != 0){
- $parent_module = $this->module_service->getModuleInfo(array('_id' => $data['parent']));
- if($parent_module){
- $data['is_module'] = false;
- if($parent_module['level'] <= 2 ){
- $data['level'] = $parent_module['level'] + 1;
- }
- else{
- exit($this->showError('���������������������������', 400, true));
- }
- }
- else{
- exit($this->showError('���������������������������������������', 400, true));
- }
- }
- else{
- $data['level'] = 1;
- $data['is_module'] = true;
- }
- if($this->module_service->add($data)){
+ $data['category'] = $this->getRequest()->getPost('category');
+ $data['is_publish'] = $this->getRequest()->getPost('is_publish');
+ $data['content'] = $this->getRequest()->getPost('content');
+ $data['create_time'] = date('Y-m-d H:i:s');
+
+ if($this->article_service->add($data)){
Util::updateModules();
- exit($this->showSuccess('������������������', true));
+ exit($this->showSuccess('������������������', true));
}
else{
- exit($this->showError($this->module_service->error, 400, true));
+ exit($this->showError($this->article_service->error, 400, true));
}
}
}
+ /**
+ * ������������
+ * @param [type] $id [description]
+ */
public function EditAction($id){
- $module = $this->module_service->getModuleInfo(array('_id' => $id));
- if($module){
+ $article = $this->article_service->getArticleInfo(array('_id' => $id));
+ if($article){
if($this->getRequest()->isXmlHttpRequest()){
- $data['module'] = $this->getRequest()->getPost('module');
- $data['controller'] = $this->getRequest()->getPost('controller');
- $data['action'] = $this->getRequest()->getPost('action');
- $data['parent'] = $this->getRequest()->getPost('parent');
$data['name'] = $this->getRequest()->getPost('name');
- if($data['parent']){
- $parent_module = $this->module_service->getModuleInfo(array('_id' => $data['parent']));
- if($parent_module){
- if($parent_module['level'] <= 2 ){
- $data['level'] = $parent_module['level'] + 1;
- }
- else{
- exit($this->showError('���������������������������', 400, true));
- }
- }
- else{
- exit($this->showError('���������������������������������������', 400, true));
- }
- }
- else{
- $data['level'] = 1;
- $data['is_module'] = true;
- }
- if($this->module_service->update($data, array('_id' => $module['_id']))){
- Util::updateModules();
- exit($this->showSuccess('������������������', true));
+ $data['category'] = $this->getRequest()->getPost('category');
+ $data['is_publish'] = $this->getRequest()->getPost('is_publish');
+ $data['content'] = $this->getRequest()->getPost('content');
+
+ if($this->article_service->update($data, array('_id' => $article['_id']))){
+ exit($this->showSuccess('������������������', true));
}
else{
exit($this->showError($this->module_service->error, 400, true));
}
}
- $this->getView()->assign('module', $module);
+ $this->getView()->assign('article', $article);
}
else{
$this->redirect('/error/show/type/no_data');
}
}
+ /**
+ * ������
+ */
+ public function DelAction(){
+ $id = $this->post('id');
+ $article = $this->article_service->getArticleInfo(array('_id' => $id));
+ if($article){
+ if($this->article_service->delete(array('_id' => $id))){
+ exit($this->showSuccess('������������������', true));
+ }
+ else{
+ exit($this->showError($this->module_service->error, 400, true));
+ }
+ }
+ else{
+ exit($this->showError('������������,���������������', 400, true));
+ }
+ }
+
+
}
\ No newline at end of file
--
Gitblit v1.8.0