Ejemplo n.º 1
0
 public function index()
 {
     $products_collection = new ProductsCollection();
     $products = $products_collection->get_latest(4);
     $news_collection = new NewsCollection();
     $news = $news_collection->get_latest(3);
     $this->loadView('website/index', array('products' => $products, 'news' => $news));
 }
Ejemplo n.º 2
0
 public function index()
 {
     $news_collection = new NewsCollection();
     $latest_news = $news_collection->get_latest(4);
     $per_page = 4;
     $page = isset($_GET['n']) ? $_GET['n'] : 1;
     $page_all = $news_collection->getTotalCount();
     $page_count = ceil($page_all / $per_page);
     $this->loadView('website/blog', array('latest_news' => $latest_news, 'page_count' => $page_count));
 }
Ejemplo n.º 3
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);
         }
     }
 }
Ejemplo n.º 4
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">
Ejemplo n.º 5
0
 public function delete()
 {
     $news_collection = new NewsCollection();
     $news_collection->delete($_GET['id']);
     header('Location: index.php?controller=news');
 }
Ejemplo n.º 6
0
<?php

require_once __DIR__ . '/../common/autoload_cms.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $entity = new News();
    $entity->setId($_GET['id'])->setTitle($_POST['title'])->setContent($_POST['content'])->setAuthor($_POST['author'])->setDateAdded(date('Y-m-d H:i:s'));
    $newsCollection = new NewsCollection();
    $newsCollection->save($entity);
    header('Location: news_list.php');
    exit;
}
$newsCollection = new NewsCollection();
$article = $newsCollection->one(array('id' => $_GET['id']));
require_once 'include/header.php';
?>

    <div class="container">
        <form method="post" action="" enctype="multipart/form-data">
            <div class="form-group">
                <label for="title">Title:</label>
                <input type="text" name="title" id="title" value="<?php 
echo $article->getTitle();
?>
" class="form-control">
            </div>

            <div class="form-group">
                <label for="content">Content:</label>
                <textarea name="content" id="content" class="form-control" rows="10"><?php 
echo $article->getContent();
?>
Ejemplo n.º 7
0
<?php

require_once __DIR__ . '/../common/autoload_cms.php';
require_once 'include/header.php';
$newsCollection = new NewsCollection();
$news = $newsCollection->all();
?>

<div class="container">
    <a href="news_add.php" class="btn btn-default">Add Article</a>
    <br><br>
    <table class="table table-striped">
        <tr>
            <th>Title</th>
            <th>Author</th>
            <th>Added</th>
            <th>Action?</th>
        </tr>

        <?php 
foreach ($news as $article) {
    ?>
            <tr>
                <td><?php 
    echo $article->getTitle();
    ?>
</td>
                <td><?php 
    echo $article->getAuthor();
    ?>
</td>
Ejemplo n.º 8
0
 public function listall3columnsAction()
 {
     $_blockID = $this->_request->getParam('BlockID');
     $newsObject = new NewsCollection($_blockID);
     $details_page = Cible_FunctionsCategories::getPagePerCategoryView($newsObject->getBlockParam('1'), 'details');
     $this->view->assign('details_page', $details_page);
     $news = $newsObject->getList();
     $paginator = new Zend_Paginator(new Zend_Paginator_Adapter_Array($news));
     $paginator->setItemCountPerPage($newsObject->getBlockParam('2'));
     $paginator->setCurrentPageNumber($this->_request->getParam('page'));
     $this->view->assign('params', $newsObject->getBlockParams());
     $this->view->assign('paginator', $paginator);
 }
Ejemplo n.º 9
0
<?php

require_once __DIR__ . '/../common/autoload_cms.php';
require_once 'include/header.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $entity = new News();
    $entity->setTitle($_POST['title'])->setContent($_POST['content'])->setAuthor($_POST['author'])->setDateAdded(date('Y-m-d H:i:s'));
    $newsCollection = new NewsCollection();
    $newsCollection->save($entity);
    header('Location: news_list.php');
    exit;
}
?>



<div class="container">
    <form method="post" action="" enctype="multipart/form-data">
        <div class="form-group">
            <label for="title">Title:</label>
            <input type="text" name="title" id="title" class="form-control">
        </div>

        <div class="form-group">
            <label for="content">Content:</label>
            <textarea name="content" id="content" class="form-control" rows="10"></textarea>
        </div>

        <div class="form-group">
            <label for="author">Author:</label>
            <input type="text" name="author" id="author" class="form-control">
Ejemplo n.º 10
0
<?php

require_once __DIR__ . '/../common/autoload_cms.php';
require_once 'include/header.php';
if (isset($_GET['id']) && isset($_GET['confirm'])) {
    $newsCollection = new NewsCollection();
    $newsCollection->remove(array('id' => $_GET['id']));
    header('Location: news_list.php');
}
?>

<div class="container">
    <h1>Are you sure you want to delete this article?</h1>

    <a href="news_delete.php?id=<?php 
echo $_GET['id'];
?>
&confirm=1" class="btn btn-danger">Yes</a>
    <a href="news_list.php" class="btn btn-default">No</a>
</div>

<?php 
require_once 'include/footer.php';