| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- // +----------------------------------------------------------------------
- // |
- // +----------------------------------------------------------------------
- // |
- // +----------------------------------------------------------------------
- // |
- // +----------------------------------------------------------------------
- // |
- // +----------------------------------------------------------------------
- // +----------------------------------------------------------------------
- // | 模型管理
- // +----------------------------------------------------------------------
- namespace app\admin\controller\cms;
- use app\admin\model\cms\Models as ModelsModel;
- use app\common\controller\Backend;
- class Models extends Backend
- {
- protected $modelClass = null;
- protected $modelValidate = true;
- protected $filepath = '';
- protected $noNeedRight = ['get_tpl_list'];
- protected function initialize()
- {
- parent::initialize();
- $this->modelClass = new ModelsModel;
- //取得当前内容模型模板存放目录
- $this->filepath = TEMPLATE_PATH . (empty(config('site.theme')) ? "default" : config('site.theme')) . DS . "cms" . DS;
- }
- //模型列表
- public function index()
- {
- if ($this->request->isAjax()) {
- $data = $this->modelClass->where('module', 'cms')->select();
- return json(["code" => 0, "data" => $data]);
- }
- return $this->fetch();
- }
- /**
- * 获取模板列表
- */
- public function get_tpl_list()
- {
- $type = $this->request->param('type', 'category');
- $keyValue = $this->request->param('keyValue');
- $path = $this->filepath . $type;
- $list = str_replace($this->filepath, '', glob($path . '*.html'));
- $arr = [];
- foreach ($list as $key => $value) {
- if (!empty($keyValue) && $value != $keyValue) {
- continue;
- }
- $arr[]['name'] = $value;
- }
- return json(['count' => count($arr), 'data' => $arr]);
- }
- }
|