Exemplo n.º 1
0
<?php

/**
 * Created by PhpStorm.
 * User: Даниил
 * Date: 02.10.2015
 * Time: 16:30
 */
require_once "DBClient.php";
require_once "models/ArticlesCollection.php";
$link = DBClient::connect();
$articles_collection = new ArticlesCollection($link);
$articles = $articles_collection->get_all();
$articles = array_reverse($articles, true);
$count = count($articles);
DBClient::close($link);
include "views/articles.php";
Exemplo n.º 2
0
<?php

/**
 * Created by PhpStorm.
 * User: Даниил
 * Date: 03.10.2015
 * Time: 16:05
 */
require_once "DBClient.php";
require_once "models/ArticlesCollection.php";
require_once "models/CommentsCollection.php";
$link = DBClient::connect();
$articles_collection = new ArticlesCollection($link);
$article = $articles_collection->get_one($_GET["id"]);
$comments_collection = new CommentsCollection($link);
$comments = $comments_collection->get_all_for_article($_GET["id"]);
$comments = array_reverse($comments, true);
$count = count($comments);
if (!empty($_GET["action"])) {
    $action = $_GET["action"];
    switch ($action) {
        case "delete":
            $comments_collection->delete($_GET["comment_id"]);
            header("Location: article.php?id=" . $_GET["id"]);
            DBClient::close($link);
            die;
            break;
    }
}
if (empty($_POST)) {
    include "views/article.php";
Exemplo n.º 3
0
 /**
  * @param $link MongoClient
  */
 public function __construct($link)
 {
     $this->link = $link;
     //коллекция articles
     ArticlesCollection::$collection = $link->blog->articles;
 }
Exemplo n.º 4
0
<?php

/**
 * Created by PhpStorm.
 * User: Даниил
 * Date: 03.10.2015
 * Time: 14:03
 */
require_once "../DBClient.php";
require_once "../models/ArticlesCollection.php";
$link = DBClient::connect();
$articles_collection = new ArticlesCollection($link);
//проверка, установлен ли параметр action
if (isset($_GET["action"])) {
    $action = $_GET["action"];
} else {
    $action = "";
}
switch ($action) {
    case "add":
        if (!empty($_POST)) {
            $article = ["date" => $_POST["date"], "title" => $_POST["title"], "content" => $_POST["content"]];
            $articles_collection->add($article);
            header("Location: index.php");
        }
        $article = ["date" => "", "title" => "", "content" => ""];
        include "../views/article_admin.php";
        break;
    case "delete":
        //получаем параметр id
        $id = $_GET["id"];