getTypes(); $type = json_encode($types, JSON_FORCE_OBJECT); $this->JsonResp(200, $type, "ok"); } public function docsAction() { if (isset($this->input->id)) { $docs = new Models\Doc(); $ret = $docs->docs($this->input->id); $this->JsonResp(200, $ret, "OK"); } else { $this->JsonResp(200, null, "error"); } } public function docAction() { if (isset($this->input->id)) { $docs = new Models\Doc(); $ret = $docs->doc($this->input->id); $this->JsonResp(200, $ret, "OK"); } else { $this->JsonResp(200, null, "error"); } } public function docTitleAction() { $docs = new Models\Doc(); $ret = $docs->AllTitle(); $this->JsonResp(200, $ret, "OK"); } public function countAction() { $docs = new Models\Doc(); $ret = $docs->Count(); $this->JsonResp(200, $ret, "OK"); } // 查找文件名字 function articleSearchAction() { if (isset($this->input->title)) { $docModel = new Models\Doc(); $titles = $docModel->titleLikeDoc($this->input->title); $this->JsonResp(0, $titles, "OK"); } else { $this->JsonResp(200, null, "OK"); } } function typedocAction() { $limit = 5; $type = 0; $offset = 0; if (sizeof($this->params) == 3) { $limit = $this->params[0]; $offset = $this->params[1]; $type = $this->params[2]; } $docModel = new Models\Doc(); $typedoc = $docModel->pageDoc($limit, $offset, $type); $ret = []; foreach ($typedoc as $key => $value) { $obj['title'] = $value['title']; $obj['id'] = $value['id']; $obj['content'] = $value['content']; $obj['type'] = $value['type']; //数据加工 $markdown = new Parsedown; $content = $markdown->text($value['content']); $obj['content'] = $content; array_push($ret,$obj); } $this->JsonResp(200, $ret, "OK"); } function typeCountAction() { $type = $this->params[0]; $docModel = new Models\Doc(); $count = $docModel->typeCounts($type); $this->JsonResp(200, $count, "OK"); } }