Esempio n. 1
0
 public function display_article()
 {
     $t = $this->_template;
     $t->article = \Plugins\Articles\Article::mapper()->get_article($this->_args['article_id'], 'Agent');
     $t->content = $t->render('news_article.php');
     $t->title = $article->title;
     echo $t->render('main.php');
 }
Esempio n. 2
0
 public function display_article() {
     $this->_init();
     $t = $this->_template;
     try {
         $t->article = \Plugins\Articles\Article::mapper()
             ->get_article($this->_args['article_id']);
         $t->article_id = $this->_args['article_id'];
         $t->content = $t->render('news_article.php');
         $t->title = $t->article->title;
         $t->canonical = $t->article->id . '/' . $t->article->seo_title . ".html";
         echo $t->render('main.php');            
     } catch (\Plugins\Articles\ArticleNotFoundError $e) {
         throw new \Core\HTTPError(404, "Article #{$this->_args[article_id]}");
     }
 }
Esempio n. 3
0
    protected function _edit_article($tok, $author, $id=False) {
        $t = \Plugins\Articles\Plugin::get_template('admin/edit.php');
        $t->admin_url = "/admin";
        $t->tok = $tok;
        try {
            if($id) {
                $t->title = "Edit Article";
                $article = \Plugins\Articles\Article::container()
                    ->get_by_id($id);
            } else {
                $t->title = "Create Article";
                $t->new = True;
                $article = \Plugins\Articles\Article::create($_POST, True);
            }

            if($_POST['_do'] == '1' && $this->_confirmed_request) {
                $article->overwrite($_POST);
                $article->form_values();
                $validator = \Core\Validator::validator('\Plugins\Articles\Article');
                $validator->validate($_POST, \Plugins\Articles\Article::validation());
                
                if($t->new) {
                    $article->author = $author;
                }

                \Core\Storage::container()
                    ->get_storage('Article')
                    ->save($article);
            }

            $t->article = $article;
                
        } catch(\Core\ValidationError $e) {
            return $this->_return_message("Fail",
                "Validation error(s):",
                $e->get_errors(), $t);
        }

        return $t->render();
    }