public function edit($id)
 {
     if ($id == NULL) {
         $view = $this->__common(new View(ArticleListView));
         $view->title = 'Craiglist | ' . 'My Posts';
         $view->isLoggedIn = Authentification::isLoggedIn();
         $model = new ArticleModel();
         $view->articles = $model->getArticlesForUserById($_SESSION['id']);
         $view->articles_number = count($view->articles);
         $view->control_method = '/article/edit/';
         print $view->display();
         return;
     }
     $view = $this->__common(new View(EditArticleView));
     $view->title = 'Craiglist | ' . 'Edit Post';
     $view->isLoggedIn = Authentification::isLoggedIn();
     $article_model = new ArticleModel();
     $view->article = $article_model->getArticleByID($id);
     $category_model = new CategoryModel();
     $view->categories = $category_model->getCategoryFullList();
     if (isset($_POST['submit'])) {
         if (isset($_POST['title'])) {
             $article_model->updateArticle($id, $_POST['title'], $_POST['content'], $_POST['category']);
             header('Location:' . SERVER_ROOT_URL . '/article/index/' . $id);
         }
     }
     print $view->display();
 }
 public function index()
 {
     $view = $this->__common(new View(MainView));
     $view->isLoggedIn = Authentification::isLoggedIn();
     $view->title = 'Craiglist | ' . 'Main Page';
     $model = new CategoryModel();
     $view->categories = $model->getCategoryFullList();
     $view->cat_number = count($view->categories);
     print $view->display();
 }
 public function subcategory($category_id)
 {
     $view = $this->__common(new View(SubCategoryView));
     $view->title = 'Craiglist | ' . 'SubCategories';
     $view->isLoggedIn = Authentification::isLoggedIn();
     $model = new CategoryModel();
     $view->category = $category_id;
     $view->subcategories = $model->getSubCategories($category_id);
     $view->subcat_number = count($view->subcategories);
     print $view->display();
 }