public function create() { $article = new Article(); if ($this->post) { $article->title = $this->PostData('title'); $article->permalink = $this->PostData('permalink'); $article->summary = $this->PostData('summary'); $article->published = $this->PostData('published'); if ($this->PostData('publish_now') == 1) { $article->publish_at = time(); } else { $article->set_publish_at($this->PostData('publish_at')); } $article->user_id = Site::CurrentUser()->id; if ($article->save()) { $page = new ArticlePage(); $page->article_id = $article->id; $page->title = $article->title; $page->content = $this->PostData('fullbody'); $page->save(); Site::Flash("notice", "The article has been added"); Redirect("admin/articles/{$article->id}"); } $this->assign("body", $this->PostData('fullbody')); } $this->assign("article", $article); $this->tinymce = true; $this->title = "Add Article"; $this->render("article/create.tpl"); }