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()); } } }
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("/"); } }