12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace app\admin\controller;
- use app\common\controller\Backend;
- use app\common\model\Category as CategoryModel;
- use fast\Tree;
- class Category extends Backend
- {
- protected $model = null;
- protected $categorylist = [];
- public function _initialize()
- {
- parent::_initialize();
- $this->model = model('Category');
- $tree = Tree::instance();
- $tree->init($this->model->order('weigh desc,id desc')->select(), 'pid');
- $this->categorylist = $tree->getTreeList($tree->getTreeArray(0), 'name');
- $categorydata = [0 => __('None')];
- foreach ($this->categorylist as $k => $v)
- {
- $categorydata[$v['id']] = $v['name'];
- }
- $this->view->assign("flagList", $this->model->getFlagList());
- $this->view->assign("typeList", CategoryModel::getTypeList());
- $this->view->assign("parentList", $categorydata);
- }
-
- public function index()
- {
- if ($this->request->isAjax())
- {
-
- $list = $this->categorylist;
- $total = count($list);
- $result = array("total" => 1, "rows" => $list);
- return json($result);
- }
- return $this->view->fetch();
- }
- }
|