protected function AddAction() { $article = new ArticleModel(); $article->title = $_POST['title']; $article->content = $_POST['content']; $article->save(); $view = new View(); $view->display('add.php'); }
function invoke($request) { //save global $_SESSION, $config; session_start(); if(isset($request["password"]) and $request["password"]===$config["password"] ) { $_SESSION["password"] = $request["password"]; } if(isset($request["save"]) and $_SESSION["password"]===$config["password"]) { ArticleModel::save($request); } $view = new HtmlView($request); $view->put(); }
public function update() { if (!IS_POST) { $this->message2('非法操作!', __APP__ . '/Admin'); } $id = I('id', NULL); if (!empty($id)) { $article = new ArticleModel(); if ($data = $article->create()) { if (false !== $article->save()) { $this->message('编辑成功', __URL__ . '/index'); } else { $this->message('编辑失败:' . $article->getError(), __URL__ . '/index'); } } else { $this->message('编辑失败:' . $article->getError(), __URL__ . '/index'); } } else { $this->message('请选择编辑对象', __URL__ . '/index'); } }
public function SaveSubjectAction() { $request = Project::getRequest(); $article_model = new ArticleModel(); if (count($article_model->loadByParentId(0, array(ARTICLE_COMPETITION_STATUS::NEW_ARTICLE), Project::getUser()->getDbUser()->id)) < 5) { $article_model->title = $request->title; $article_model->articles_tree_id = $request->parent_id; $article_model->user_id = Project::getUser()->getDbUser()->id; $article_model->rate_status = ARTICLE_COMPETITION_STATUS::NEW_ARTICLE; $article_model->creation_date = date("Y-m-d H:i:s"); $article_model->save(); } Project::getResponse()->redirect($request->createUrl('Article', 'CompetitionCatalog')); }
/** * 文章编辑更新页面 */ function update() { $article = new ArticleModel(); if (!!($data = $article->create())) { if (!empty($data['id'])) { if (false !== $article->save()) { $this->assign('jumpUrl', __URL__ . '/index'); $this->success('更新成功'); } else { $this->error('更新失败:' . $article->getDbError()); } } else { $this->error('请选择编辑用户'); } } else { $this->error('更新失败:( ' . $article->getError() . ' )'); } }
public function SaveArticleAction() { $request = Project::getRequest(); $id = (int) $request->id; $article_model = new ArticleModel(); $article_page_model = new ArticlePageModel(); $article_model->load($id); $article_model->user_id = Project::getUser()->getDbUser()->id; $article_model->articles_tree_id = $request->article_cat; $article_model->title = $request->article_title; $article_model->allowcomments = (bool) $request->allow_comment; $article_model->rate_status = (bool) $request->allow_rate; $article_model->creation_date = date("Y-m-d H:i:s"); $id = $article_model->save(); for ($i = 0; $i < count($request->title_page); $i++) { $article_page_model = new ArticlePageModel(); $article_page_model->load($request->id_page[$i]); $article_page_model->article_id = $id; $article_page_model->title = $request->title_page[$i]; $article_page_model->p_text = $request->content_page[$i]; $article_page_model->save(); } $data = array(); $this->_makeArticleList($data); $this->_view->AjaxArticleList($data); $this->_view->ajax(); }