完善栏目删除时的操作,自动整理左右值
This commit is contained in:
parent
c9b2e843b7
commit
b81b97f910
|
@ -1,127 +1,151 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Admin\Controller;
|
||||
|
||||
use Zend\Mvc\Controller\AbstractActionController;
|
||||
use Zend\View\Model\ViewModel;
|
||||
use Zend\View\Model\JsonModel;
|
||||
use Sookon\Helpers\View as view;
|
||||
|
||||
class CategoryController extends AbstractActionController
|
||||
{
|
||||
public $ViewModel;
|
||||
|
||||
function __construct($db = NULL)
|
||||
{
|
||||
$this->ViewModel = new ViewModel();
|
||||
}
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$ac = $this->params()->fromRoute('ac');
|
||||
|
||||
$record = new \Sookon\Article\Category;
|
||||
|
||||
$this->ViewModel->setVariable('categorys',$record->GetFullCategory());
|
||||
|
||||
$this->ViewModel->setTemplate('layout/admin/category/list');
|
||||
|
||||
return $this->ViewModel;
|
||||
|
||||
return $this->ViewModel;
|
||||
}
|
||||
|
||||
public function addAction()
|
||||
{
|
||||
$submit = $this->params()->fromPost('submit');
|
||||
|
||||
$category = new \Sookon\Article\Category;
|
||||
$this->ViewModel->setVariable('ptype',$category->ptype);
|
||||
$this->ViewModel->setVariable('categories',$category->GetFullCategory());
|
||||
|
||||
if(empty($submit) || !$this->getRequest()->isXmlHttpRequest())
|
||||
return $this->ViewModel;
|
||||
|
||||
$status = $category->add($category->getParam());
|
||||
|
||||
if($status !== true)
|
||||
{
|
||||
return new JsonModel(array('error'=>$status));
|
||||
}else{
|
||||
return new JsonModel(array('success'=>1));
|
||||
}
|
||||
}
|
||||
|
||||
public function editAction()
|
||||
{
|
||||
$submit = $this->params()->fromPost('submit');
|
||||
$id = $this->params()->fromRoute('id');
|
||||
$ac = $this->params()->fromRoute('ac');
|
||||
if(!is_numeric($id) || $id<1)
|
||||
{
|
||||
view::Post($this,"参数错误",-1);
|
||||
return $this->ViewModel;
|
||||
}
|
||||
|
||||
if($ac == 'content')
|
||||
{
|
||||
$this->ViewModel->setTemplate("admin/category/add");
|
||||
|
||||
$category = new \Sookon\Article\Category;
|
||||
$this->ViewModel->setVariable('categories',$category->GetFullCategory());
|
||||
$this->ViewModel->setVariable('data',$category->fetch($id));
|
||||
|
||||
if(empty($submit) || !$this->getRequest()->isXmlHttpRequest())
|
||||
return $this->ViewModel;
|
||||
|
||||
$status = $category->add($category->getParam(),$id);
|
||||
|
||||
if($status !== true)
|
||||
{
|
||||
return new JsonModel(array('error'=>$status));
|
||||
}else{
|
||||
return new JsonModel(array('success'=>1));
|
||||
}
|
||||
}
|
||||
|
||||
if($ac == "moveup")
|
||||
{
|
||||
$category = new \Sookon\Article\Category;
|
||||
$status = $category->move("up",$id);
|
||||
|
||||
if(is_array($status))
|
||||
{
|
||||
$this->ViewModel->setVariable('moved',$status);
|
||||
$this->ViewModel->setTemplate('layout/admin/category/moved');
|
||||
return $this->ViewModel;
|
||||
}else{
|
||||
view::Post($this,$status,-1);
|
||||
return $this->ViewModel;
|
||||
}
|
||||
}
|
||||
|
||||
if($ac == "movedown")
|
||||
{
|
||||
$category = new \Sookon\Article\Category;
|
||||
$status = $category->move("down",$id);
|
||||
|
||||
if(is_array($status))
|
||||
{
|
||||
$this->ViewModel->setVariable('moved',$status);
|
||||
$this->ViewModel->setTemplate('layout/admin/category/moved');
|
||||
return $this->ViewModel;
|
||||
}else{
|
||||
view::Post($this,$status,-1);
|
||||
return $this->ViewModel;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Admin\Controller;
|
||||
|
||||
use Zend\Mvc\Controller\AbstractActionController;
|
||||
use Zend\View\Model\ViewModel;
|
||||
use Zend\View\Model\JsonModel;
|
||||
use Sookon\Helpers\View as view;
|
||||
|
||||
class CategoryController extends AbstractActionController
|
||||
{
|
||||
public $ViewModel;
|
||||
|
||||
function __construct($db = NULL)
|
||||
{
|
||||
$this->ViewModel = new ViewModel();
|
||||
}
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$ac = $this->params()->fromRoute('ac');
|
||||
|
||||
$record = new \Sookon\Article\Category;
|
||||
|
||||
$this->ViewModel->setVariable('categorys',$record->GetFullCategory());
|
||||
|
||||
$this->ViewModel->setTemplate('layout/admin/category/list');
|
||||
|
||||
return $this->ViewModel;
|
||||
|
||||
return $this->ViewModel;
|
||||
}
|
||||
|
||||
public function addAction()
|
||||
{
|
||||
$submit = $this->params()->fromPost('submit');
|
||||
|
||||
$category = new \Sookon\Article\Category;
|
||||
$this->ViewModel->setVariable('ptype',$category->ptype);
|
||||
$this->ViewModel->setVariable('categories',$category->GetFullCategory());
|
||||
$this->ViewModel->setVariable('deepField',$category->DeepTitle);
|
||||
|
||||
if(empty($submit) || !$this->getRequest()->isXmlHttpRequest())
|
||||
return $this->ViewModel;
|
||||
|
||||
$status = $category->add($category->getParam());
|
||||
|
||||
if($status !== true)
|
||||
{
|
||||
return new JsonModel(array('error'=>$status));
|
||||
}else{
|
||||
return new JsonModel(array('success'=>1));
|
||||
}
|
||||
}
|
||||
|
||||
public function editAction()
|
||||
{
|
||||
$submit = $this->params()->fromPost('submit');
|
||||
$id = $this->params()->fromRoute('id');
|
||||
$ac = $this->params()->fromRoute('ac');
|
||||
if(!is_numeric($id) || $id<1)
|
||||
{
|
||||
view::Post($this,"参数错误",-1);
|
||||
return $this->ViewModel;
|
||||
}
|
||||
|
||||
if($ac == 'content')
|
||||
{
|
||||
$this->ViewModel->setTemplate("admin/category/add");
|
||||
|
||||
$category = new \Sookon\Article\Category;
|
||||
$this->ViewModel->setVariable('categories',$category->GetFullCategory());
|
||||
$this->ViewModel->setVariable('data',$category->fetch($id));
|
||||
|
||||
if(empty($submit) || !$this->getRequest()->isXmlHttpRequest())
|
||||
return $this->ViewModel;
|
||||
|
||||
$status = $category->add($category->getParam(),$id);
|
||||
|
||||
if($status !== true)
|
||||
{
|
||||
return new JsonModel(array('error'=>$status));
|
||||
}else{
|
||||
return new JsonModel(array('success'=>1));
|
||||
}
|
||||
}
|
||||
|
||||
if($ac == "moveup")
|
||||
{
|
||||
$category = new \Sookon\Article\Category;
|
||||
$status = $category->move("up",$id);
|
||||
|
||||
if(is_array($status))
|
||||
{
|
||||
$this->ViewModel->setVariable('moved',$status);
|
||||
$this->ViewModel->setTemplate('layout/admin/category/moved');
|
||||
return $this->ViewModel;
|
||||
}else{
|
||||
view::Post($this,$status,-1);
|
||||
return $this->ViewModel;
|
||||
}
|
||||
}
|
||||
|
||||
if($ac == "movedown")
|
||||
{
|
||||
$category = new \Sookon\Article\Category;
|
||||
$status = $category->move("down",$id);
|
||||
|
||||
if(is_array($status))
|
||||
{
|
||||
$this->ViewModel->setVariable('moved',$status);
|
||||
$this->ViewModel->setTemplate('layout/admin/category/moved');
|
||||
return $this->ViewModel;
|
||||
}else{
|
||||
view::Post($this,$status,-1);
|
||||
return $this->ViewModel;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function delAction()
|
||||
{
|
||||
$id = (int)$this->params()->fromRoute('id');
|
||||
|
||||
if(empty($id) || $id<=0)
|
||||
{
|
||||
return view::Post($this,"参数错误",-1);
|
||||
}
|
||||
|
||||
$category = new \Sookon\Article\Category;
|
||||
|
||||
$status = $category->del($id);
|
||||
|
||||
if($status === TRUE)
|
||||
{
|
||||
return view::Post($this,"删除成功!",-1);
|
||||
}else{
|
||||
if(is_string($status))
|
||||
return view::Post($this,$status,-1);
|
||||
return view::Post($this,"删除失败!",-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,9 @@
|
|||
<td><?= $v['ptype'] ?></td>
|
||||
<td><?= date("Y-m-d H:i",strtotime($v['ts_created'])) ?></td>
|
||||
<td>
|
||||
<a href="" onclick="return confirm('是否确定删除?')"><span class="glyphicon glyphicon-trash"></span></a>
|
||||
<a href="<?= $this->url('admin',array('controller'=>'category','action'=>'del','ac'=>'content','id'=>$v['id'])) ?>" onclick="return confirm('是否确定删除?')">
|
||||
<span class="glyphicon glyphicon-trash"></span>
|
||||
</a>
|
||||
<a href="<?= $this->url('admin',array('controller'=>'category','action'=>'edit','ac'=>'content','id'=>$v['id'])) ?>"><span class="glyphicon glyphicon-pencil"></span></a>
|
||||
<a href="<?= $this->url('admin',array('controller'=>'category','action'=>'edit','ac'=>'moveup','id'=>$v['id'])) ?>">
|
||||
<span class="glyphicon glyphicon-arrow-up"></span>
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue