Ejemplo n.º 1
0
 function index()
 {
     if (isset($this->args[0]) && $this->args[0] != "index") {
         system::setParam("page", "layout");
         $cacheID = $this->args[0] . "|ARTICLE";
         $this->smarty->setCacheID($cacheID);
         if (isset($_POST["contentID"]) && $_POST["contentID"]) {
             comments::add(intval($_POST["contentID"]));
         }
         $this->smarty->assign("isFav", blog::isFavorite($this->args[0]));
         if (!$this->smarty->isCached()) {
             $sqlData = blog::getOnePost($this->args[0], "article")->fetch();
             if ($sqlData) {
                 $this->smarty->assign("comments", comments::get(intval($sqlData["contentID"])));
                 $this->smarty->assign("post", $sqlData);
             }
         }
     } else {
         $offset = 1;
         system::setParam("page", "list");
         if (isset($this->get["offset"])) {
             $offset = intval($this->get["offset"]);
         }
         $cacheID = "ARTICLES|artoffset_{$offset}";
         $this->smarty->setCacheID($cacheID);
         if (!$this->smarty->isCached()) {
             $allCount = $this->db->query("SELECT COUNT(*) as cnt FROM `content` WHERE `type`='article'")->fetch();
             $this->smarty->assign("posts", news::getPosts(core::pagination($allCount["cnt"], $offset), "article")->fetchAll());
         }
     }
 }
Ejemplo n.º 2
0
 public function change_rateAction()
 {
     if (!isset($_SESSION['comments_rate'][system::url(2)])) {
         if ($comment = comments::get(system::url(2))) {
             if (system::url(3) == 'up') {
                 $comment->rateUp();
             } else {
                 $comment->rateDown();
             }
             $_SESSION['comments_rate'][$comment->id()] = 1;
             $comment->save();
         }
     }
     system::stop();
 }
Ejemplo n.º 3
0
Archivo: blog.php Proyecto: ygres/sblog
 function index()
 {
     system::setParam("page", "post");
     if ($this->args[0] != "blog") {
         $cacheID = $this->args[0] . "|POST";
         $this->smarty->setCacheID($cacheID);
         if (isset($_POST["SLUG"]) && isset($_POST["comment"])) {
             blog::addCommentBySLUG($_POST["SLUG"]);
         }
         if (!$this->smarty->isCached()) {
             $sqlData = blog::getOnePost($this->args[0])->fetchAll();
             if ($sqlData) {
                 $sqlData = array_shift($sqlData);
                 $comments = comments::get($sqlData["contentID"]);
                 $this->smarty->assign("comments", $comments);
                 blog::highlightCode($sqlData["body"]);
                 $this->smarty->assign("item", $sqlData);
             }
         }
     } else {
         system::redirect("/");
     }
 }
Ejemplo n.º 4
0
 /**
  * @return HTML
  * @param int $comment_id - ID комментария
  * @param string $templ_name - Шаблон оформления комментария
  * @desc МАКРОС: Выводит информацию об указанном комментарии
  */
 public function view($comment_id, $templ_name = 'tree')
 {
     $templ_file = '/comments/' . $templ_name . '.tpl';
     $TEMPLATE = page::getTemplate($templ_file);
     if (!is_array($TEMPLATE)) {
         return page::errorNotFound('comments.view', $templ_file);
     }
     if ($comment = comments::get($comment_id)) {
         if ($comment->isActive() || reg::getKey('/comments/show_noactive')) {
             page::assign('obj.id', $comment->id());
             page::assign('obj.parent_id', $comment->getParentId());
             page::assign('obj.user_id', $comment->getUserId());
             page::assign('obj.publ_date', $comment->getPublDate());
             page::assign('obj.username', $comment->getUserName());
             page::assign('obj.email', $comment->getEmail());
             page::assign('obj.text', $comment->getText());
             page::assign('obj.rate', $comment->getRate());
             if (isset($_SESSION['comments_rate'][$comment->id()])) {
                 page::fParse('rate', $TEMPLATE['rate_change']);
             } else {
                 page::fParse('rate', $TEMPLATE['rate']);
             }
             page::assign('list', '');
             return page::parse($TEMPLATE['list']);
         }
     }
 }
Ejemplo n.º 5
0
 public function act()
 {
     if (system::issetUrl(2) && is_numeric(system::url(2))) {
         if ($obj = comments::get(system::url(2))) {
             $obj->setActive(!$obj->isActive());
             $obj->save();
             echo $obj->isActive() ? 'active' : 'no_active';
         }
     } else {
         if (isset($_POST['objects'])) {
             while (list($id, $val) = each($_POST['objects'])) {
                 if ($obj = comments::get($val)) {
                     $obj->setActive(!$obj->isActive());
                     $obj->save();
                 }
             }
             echo 'invert';
         }
     }
     system::stop();
 }
Ejemplo n.º 6
0
<?php

// +----------------------------------------------------------------------
// | Demila [ Beautiful Digital Content Trading System ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015 http://demila.org All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Email author@demila.org
// +----------------------------------------------------------------------
_setView(__FILE__);
$commentID = get_id(2);
$commentsClass = new comments();
$comment = $commentsClass->get($commentID);
if (!is_array($comment)) {
    addErrorMessage($langArray['wrong_comment'], '', 'error');
} else {
    abr('show_form', 'yes');
    abr('comment', $comment);
}