Category.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace app\user\controller;
  3. use app\common\controller\Userend;
  4. use app\common\model\Category as CategoryModel;
  5. use fast\Tree;
  6. /**
  7. * 分类管理
  8. *
  9. * @icon fa fa-list
  10. * @remark 用于管理网站的所有分类,分类可进行无限级分类,分类类型请在常规管理->系统配置->字典配置中添加
  11. */
  12. class Category extends Userend
  13. {
  14. /**
  15. * @var \app\common\model\Category
  16. */
  17. protected $model = null;
  18. protected $categorylist = [];
  19. protected $noNeedRight = ['selectpage'];
  20. public function _initialize()
  21. {
  22. parent::_initialize();
  23. $this->model = model('app\common\model\Category');
  24. $tree = Tree::instance();
  25. $tree->init(collection($this->model->order('weigh desc,id desc')->select())->toArray(), 'pid');
  26. $this->categorylist = $tree->getTreeList($tree->getTreeArray(0), 'name');
  27. $categorydata = [0 => ['type' => 'all', 'name' => __('None')]];
  28. foreach ($this->categorylist as $k => $v) {
  29. $categorydata[$v['id']] = $v;
  30. }
  31. $typeList = CategoryModel::getTypeList();
  32. $this->view->assign("flagList", $this->model->getFlagList());
  33. $this->view->assign("typeList", $typeList);
  34. $this->view->assign("parentList", $categorydata);
  35. $this->assignconfig('typeList', $typeList);
  36. }
  37. /**
  38. * Selectpage搜索
  39. *
  40. * @internal
  41. */
  42. public function selectpage()
  43. {
  44. return parent::selectpage();
  45. }
  46. }