Exemplo n.º 1
0
 public function dispatch($request, $response)
 {
     // start session
     session_start();
     $article_id = $request->getPathParam('articleid');
     if ($request->isPost() === true) {
         //  handle post
         $title = $_POST['title'];
         $body = $_POST['body'];
         $summary = $_POST['summary'];
         ArticleService::saveArticleInSession($article_id, $title, $body, $summary);
         $response->redirect('/admin.php/edit/preview/' . $article_id);
     } else {
         if ($request->isGet() === true) {
             if (ArticleService::isArticleInSession($article_id)) {
                 $model = ArticleService::getArticleFromSession($article_id);
             } else {
                 $model = ArticleService::getArticle($article_id);
             }
             $view_adapter = new EditArticleViewAdapter($model);
             $this->view = new EditArticleView($view_adapter);
             $this->view->render();
         }
     }
 }
Exemplo n.º 2
0
 public function dispatch($request, $response)
 {
     session_start();
     $article_id = $request->getPathParam('articleid');
     ArticleService::removeArticleFromSession($article_id);
     $response->redirect('/admin.php');
 }
Exemplo n.º 3
0
 public function dispatch($request, $response)
 {
     $nav_model = ArticleService::getAdminArticleLinks();
     $nav_view_adapter = new NavViewAdapter($nav_model['articles']);
     $this->view = new MobileMenuView($nav_view_adapter);
     $this->view->render($request, $response);
 }
 public function dispatch($request, $response)
 {
     $article_id = $request->getPathParam('articleid');
     $article_model = ArticleService::getArticle($article_id);
     $article_view_adapter = new ArticleViewAdapter($article_model);
     $nav_model = ArticleService::getAdminArticleLinks();
     $nav_view_adapter = new NavViewAdapter($nav_model['articles']);
     $this->view = new ArticleNavCompositeView($article_view_adapter, $nav_view_adapter);
     $this->view->render();
 }
 public function dispatch($request, $response)
 {
     session_start();
     $article_id = $request->getPathParam('articleid');
     if ($request->isPost() === true) {
         if (ArticleService::isArticleInSession($article_id)) {
             $model = ArticleService::getArticleFromSession($article_id);
             ArticleService::updateArticle($model);
             $response->redirect('/admin.php');
         }
     } else {
         if (ArticleService::isArticleInSession($article_id)) {
             $model = ArticleService::getArticleFromSession($article_id);
             $view_adapter = new EditPreviewArticleViewAdapter($model);
             $this->view = new EditPreviewArticleView($view_adapter);
             $this->view->render();
         } else {
             $response->redirect('/admin.php');
         }
     }
 }
 public function dispatch($request, $response)
 {
     session_start();
     if ($request->isPost() === true) {
         $title = $request->postParameter('title');
         $body = $request->postParameter('body');
         $summary = $request->postParameter('summary');
         ArticleService::saveArticleInSession('_new', $title, $body, $summary);
         $response->redirect('/admin.php/create/preview/_new');
     } else {
         if ($request->isGet() === true) {
             //  treat as GET
             $article_id = $request->getParameter('id');
             if (isset($article_id) && ArticleService::isArticleInSession($article_id)) {
                 $model = ArticleService::getArticleFromSession($article_id);
                 $view = new CreateArticleView(new CreateArticleViewAdapter($model));
             } else {
                 $view = new CreateArticleView(new CreateArticleViewAdapter(ArticleService::nullArticle()));
             }
             $view->render();
         }
     }
 }
Exemplo n.º 7
0
 private function getLatestArticleId()
 {
     return ArticleService::getIdOfMostRecentArticle();
 }
Exemplo n.º 8
0
 public function __construct()
 {
     $model = ArticleService::getAdminArticleLinks();
     $view_adapter = new ShowArticlesViewAdapter($model);
     $this->view = new ShowArticlesView($view_adapter);
 }