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");
 }
 public function create($article_id = null)
 {
     $article = self::load_article($article_id);
     $page = new ArticlePage();
     $page->article = $article;
     $page->article_id = $article->id;
     if ($this->post) {
         $page->title = $this->PostData('title');
         $page->content = $this->PostData('fullbody');
         if ($page->save()) {
             Site::Flash("notice", "The page has been added");
             Redirect("admin/articles/{$article->id}");
         }
     }
     $this->assign("page", $page);
     $this->tinymce = true;
     $this->title = "Add Article Page";
     $this->render("article_page/create.tpl");
 }