public function index()
 {
     $blog_post = new BlogPostModel();
     $blog_post->setAuthor('Hiran');
     $blog_post->setBody('Adooo');
     $blog_post->getSummary('this is the summary');
     // var_dump($blog_post);
     //        $post = new Models\PostModel();
     $post = new PostModel();
     $view = new ViewController();
     if (isset($_GET['method'])) {
         if ($_GET['method'] == 'add') {
             return $view->theme('post', array('posts' => $post->savePost($_POST)));
         } else {
             if ($_GET['method'] == 'delete') {
                 return $view->theme('post', array('posts' => $post->deletePost($_GET['post'])));
             } else {
                 $posts = $post->get_post($_GET['post']);
                 if (!empty($posts)) {
                     foreach ($posts as $post) {
                         return $view->theme('post', array('posts' => $post));
                     }
                 } else {
                     header('Location: ?action=admin');
                 }
             }
         }
     } else {
         return $view->theme('post', array('posts' => $post->defaultPost()));
     }
 }
 public function index()
 {
     $blog_post = new BlogPostModel();
     $blog_post->setAuthor('Hiran');
     $blog_post->setBody('Adooo');
     $blog_post->getSummary('this is the summary');
     // var_dump($blog_post);
     //        $post = new Models\PostModel();
     $post = new PostModel();
     $view = new ViewController();
     if (isset($_POST['searchtext'])) {
         return $view->theme('search', array('posts' => $post->searchPost($_POST['searchtext'])));
     } else {
         return $view->theme('search', array('posts' => ''));
     }
 }
 public function index()
 {
     if (isset($_SESSION['admin'])) {
         session_destroy();
     }
     $blog_post = new BlogPostModel();
     $blog_post->setAuthor('Hiran');
     $blog_post->setBody('Adooo');
     $blog_post->getSummary('this is the summary');
     // var_dump($blog_post);
     //        $post = new Models\PostModel();
     $post = new PostModel();
     $view = new ViewController();
     if (isset($_GET['post'])) {
         return $view->theme('home', array('posts' => $post->get_post($_GET['post']), 'date' => date('Y-m-d')));
     } else {
         return $view->theme('home', array('posts' => $post->get_post(), 'date' => date('Y-m-d')));
     }
 }