protected function addedAction($title, $content)
 {
     ArticlesModel::add($title, $content);
     $view = new View();
     $view->item = $single_article;
     $view->display('NewAddedArticle.php');
 }
Example #2
0
 /**
  * Akce pro zobrazení jednoho článku
  * @param int $id
  * @throws BadRequestException
  */
 public function renderView($id)
 {
     $article = $this->articlesModel->find($id);
     if ($article) {
         $this->template->article = $article;
     } else {
         throw new BadRequestException('Požadovaný článek nebyl nalezen');
     }
 }
 protected function addAction()
 {
     if ('' !== $_POST['title'] && '' !== $_POST['content']) {
         $article = new ArticlesModel();
         $article->title = htmlspecialchars($_POST['title']);
         $article->content = htmlspecialchars($_POST['content']);
         $article->save();
         header('Location: ../Articles/added');
     } else {
         echo '<p>Вы не заполнили поля заголовка и/или контента.</p>';
     }
 }
Example #4
0
 public function view()
 {
     $map['id'] = isset($_GET['id']) ? $_GET['id'] : null;
     $db = new ArticlesModel();
     $rs = $db->relation(true)->where($map)->find();
     if ($rs['id'] == null || $rs['id'] === false || $map['id'] === null) {
         $this->error('你请求的页面不存在!');
     }
     $this->assign('rs', $rs);
     $this->display('Index:article');
     //dump($rs);
 }
 public function deleteAction()
 {
     try {
         $article = new ArticlesModel();
         $article->id = intval($_POST['id']);
         $article->delete();
         $view = new View();
         $view->display('DeletedArticle.php');
     } catch (Exception $e) {
         // echo $e->getMessage();
         $view = new ErrorController();
         $view->error();
     }
 }
Example #6
0
 public function indexAction()
 {
     $articles = ArticlesModel::getList($this->pdo);
     $commentaires = CommentModel::getList($this->pdo);
     include "../view/home.php";
     return;
 }
Example #7
0
 public function deleteAction()
 {
     if (!isset($_SESSION['id_user'])) {
         return json_encode(["error" => "id_user missing"]);
     }
     $id_user = $_POST['id_user'];
     ArticlesModel::delete($this->pdo, $id_user);
     return json_encode(["message" => "Supprimé !", "id_user" => $id_user]);
 }
Example #8
0
 public function deleteAction()
 {
     if (!isset($_POST['id_article'])) {
         return json_encode(["error" => "id_article missing"]);
     }
     $id_article = $_POST['id_article'];
     ArticlesModel::delete($this->pdo, $id_article);
     return json_encode(["message" => "Supprimé !", "id_article" => $id_article]);
 }
Example #9
0
 /**
  * Akce pro zobrazení jednoho článku
  */
 public function viewAction()
 {
     $articlesModel = ArticlesModel::getInstance();
     if (!($article = $articlesModel->find(@$_GET['id']))) {
         $this->generateError(404, 'Požadovaný článek nebyl nalezen.');
         return;
     }
     $this->setTitle($article['title']);
     $view = $this->getView();
     $view->article = $article;
     $view->display();
 }
 protected function addedAction()
 {
     $title = $_POST['title'];
     $content = $_POST['content'];
     if ('' !== $title && '' !== $content) {
         ArticlesModel::add($title, $content);
         $view = new View();
         $view->title = $title;
         $view->content = $content;
         $view->display('NewAddedArticle.php');
         echo "Вы успешно добавили статью. ";
         echo "Хотите опубликовать <a href='?ctrl=Articles&action=New'>еще одну</a>?";
     } else {
         echo '<p>Вы не заполнили поля заголовка и/или контента.</p>';
     }
 }
Example #11
0
<?php

$articlesModel = new ArticlesModel();
$galleryModel = new GalleryModel();
/**
 * Articles block
 */
$articles = array(array('label' => 'Додати статтю', 'controller' => 'articles', 'top' => true, 'action' => 'add', 'privilege' => 'add', 'params' => array()));
foreach ($articlesModel->listAll() as $item) {
    $articles[] = array('label' => $item->title, 'action' => 'view', 'controller' => 'articles', 'params' => array('id' => $item->id), 'pages' => array(array('label' => 'Редагувати', 'action' => 'edit', 'controller' => 'articles', 'privilege' => 'edit', 'params' => array('id' => $item->id)), array('label' => 'Видалити', 'action' => 'delete', 'controller' => 'articles', 'privilege' => 'delete', 'params' => array('id' => $item->id))));
}
/**
 * Gallery block
 */
$controller = 'gallery';
$gallery = array(array('label' => 'Додати картинку', 'controller' => $controller, 'top' => true, 'action' => 'add', 'privilege' => 'add', 'params' => array()));
$action = 'view';
foreach ($galleryModel->listAll() as $item) {
    $params = array('id' => $item->id);
    $gallery[] = array('label' => $item->getTitle(), 'action' => $action, 'controller' => $controller, 'params' => $params, 'pages' => array(array('label' => 'Редагувати', 'action' => 'edit', 'privilege' => 'edit', 'controller' => $controller, 'params' => $params), array('label' => 'Видалити', 'action' => 'delete', 'privilege' => 'delete', 'controller' => $controller, 'params' => $params)));
}
return array(array('id' => 'main', 'controller' => 'index', 'action' => 'index', 'label' => 'Головна', 'pages' => array(array('label' => 'Реєстрація', 'controller' => 'user', 'action' => 'register', 'privilege' => 'register'), array('id' => 'login', 'label' => 'Авторизація', 'controller' => 'user', 'action' => 'login', 'privilege' => 'login'), array('label' => 'Статті', 'controller' => 'articles', 'action' => 'list', 'pages' => $articles), array('label' => 'Галерея', 'controller' => 'gallery', 'action' => 'list', 'pages' => $gallery), array('label' => 'Дошка оголошень', 'controller' => 'mboard', 'action' => 'index', 'pages' => array(array('label' => 'Додати оголошення', 'controller' => 'mboard', 'action' => 'add', 'privilege' => 'addToMboard', 'id' => 'addM'))))));
 protected function AddedAction($title, $content)
 {
     ArticlesModel::add($title, $content);
     include __DIR__ . '/../views/NewAddedArticle.php';
 }
 public function deleteAction()
 {
     $id = $_POST['id'];
     ArticlesModel::delete($id);
     include __DIR__ . '/../views/DeletedArticle.php';
 }
 public function deleteAction()
 {
     $id = intval($_GET['id']);
     ArticlesModel::delete($id);
     include __DIR__ . '/../views/DeletedArticle.php';
 }
Example #15
0
 protected function _add($post)
 {
     if ($_POST['title'] == '' || $_POST['text'] == '') {
         $this->error('标题或内容不能为空!');
     }
     $data = array('title' => Input::getVar($_POST['title']), 'date' => date('Y-m-d H:i:s'));
     //存入日志基本信息
     $db = new ArticlesModel();
     //dump($data);exit;
     $id = $db->add($data);
     if ($id === false || $id === null) {
         $this->error('保存文章基本信息时出现错误' . $db->getError());
     }
     //存入日志内容信息
     $db = new ArticlesContentModel();
     unset($data);
     $data = array('id' => $id, 'text' => str_replace('\\', '', str_replace("&quot;", '', $_POST['text'])));
     $rs = $db->add($data);
     if ($rs === false || $rs === null) {
         $this->error('保存文章内容时出现错误' . $db->getError());
     }
     $c = $this->getConfig();
     $msg = '发表文章《' . Input::getVar($_POST['title']) . '》 详细:' . $c['domain'] . '/index.php/Note/view/id/' . $data['id'];
     //同步到本站微博
     $db = new WorldsModel();
     $data = array('text' => Input::makeLink($msg), 'time' => date('Y-m-d H:i:s'));
     $db->add($data);
     //同步到新浪微博
     $this->sina_update($msg);
     $this->redirect('Note/view/id/' . $id);
 }