Esempio n. 1
0
 public function edit()
 {
     $news_collection = new NewsCollection();
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $news = new NewsEntity();
         $news->setId($_GET['id'])->setTitle($_POST['title'])->setContent($_POST['content'])->setAuthor($_POST['author'])->setDate($_POST['date_added']);
         if ($_FILES['image']['tmp_name'] != '') {
             $news->saveImage($_FILES['image']);
         }
         $news_collection->save($news);
         header('Location: index.php?controller=news');
     }
     $data = $news_collection->get($_GET['id']);
     $this->loadView('cms/news_edit', array('data' => $data));
 }
Esempio n. 2
0
 public function index()
 {
     $news_collection = new NewsCollection();
     $news = $news_collection->get($_GET['id']);
     $news_comment_collection = new NewsCommentCollection($_GET['id']);
     $comment = $news_comment_collection->get_all();
     $this->loadView('website/article', array('news' => $news, 'comment' => $comment));
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         if ($_POST['name'] && $_POST['comment'] != '') {
             $comment = new NewsCommentEntity();
             $comment->setName($_POST['name']);
             $comment->setContent($_POST['comment']);
             $comment->setNewsId($_GET['id']);
             $comment->setDate(date('Y-m-d H:i:s'));
             $news_comment_collection->save($comment);
         }
     }
 }
Esempio n. 3
0
<?php

require_once '../common/bootstrap.php';
$news_collection = new NewsCollection();
$article = $news_collection->get($_GET['id']);
$news_comment_collection = new NewsCommentCollection($_GET['id']);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if ($_POST['name'] != '' && $_POST['comment'] != '') {
        $comment = new NewsComment();
        $comment->setName($_POST['name']);
        $comment->setContent($_POST['comment']);
        $news_comment_collection->save($comment);
    }
}
$comment = $news_comment_collection->get_all();
require_once 'includes/header.php';
?>
<article class="container-news">
<h2><?php 
echo $article->getTitle();
?>
</h2>
<em>posted on <?php 
echo $article->getDate();
?>
by <?php 
echo $article->getAuthor();
?>
</em>
<section>
	<img src="../storage/image1 laptop.png">