Esempio n. 1
0
 public function ajaxAddAction()
 {
     $data = array('user_id' => $this->loginUserInfo['id']);
     DocInterface::save($data);
     $this->setNotice(FrameworkVars::NOTICE_SUCCESS, '添加了新文章');
     $this->renderAjax(0);
 }
 public function ajaxSubmitAction()
 {
     // 获取参数
     $docId = (int) Request::getPOST('doc-id');
     $title = trim(Request::getPOST('title'));
     $content = Request::getPOST('content', '', true);
     if (strlen($content) > 65535) {
         $this->renderError('文章限制为64KB!');
     }
     // 校验
     if (empty($title) || mb_strlen($title, 'utf8') > 50) {
         $this->renderError('Title限制1-50个字!');
     }
     // 校验doc
     $docInfo = DocInterface::getById(array('id' => $docId));
     if (empty($docInfo)) {
         $this->renderError('文章不存在!');
     }
     // 更新
     $data = array('id' => $docId, 'title' => $title, 'content' => $content);
     DocInterface::save($data);
     $this->setNotice(FrameworkVars::NOTICE_SUCCESS, '编辑成功!');
     $this->renderAjax(0);
 }