public function index($id = NULL) { $this->view->setLayout("admin"); $this->view->conf = $this->conf; $this->title_for_layout($this->l10n->__("Comentarios - Codice CMS")); $comment = new comment(); $total_rows = $comment->countCommentsByPost(); $page = $id; $page = is_null($page) ? 1 : $page; $limit = $this->userConf['posts_per_page']; $offset = ($page - 1) * $limit; $limitQuery = $offset . "," . $limit; $targetpage = $this->path . 'comments/'; $pagination = $this->pagination->init($total_rows, $page, $limit, $targetpage); $this->view->pagination = $pagination; $comments = $comment->findAll(NULL, "ID DESC", $limitQuery, NULL); foreach ($comments as $key => $value) { $Post = new post(); $post = $Post->findBy('ID', $value['ID_post']); $value['post'] = array('urlfriendly' => $post['urlfriendly'], 'title' => $post['title']); $value["content"] = utils::htmlentities($value["content"]); $value["content"] = utils::nl2br($value["content"]); $comments[$key] = $value; } $this->registry->comments = $comments; $this->plugin->call("comments_comment_content"); $this->view->comments = $this->registry->comments; $this->render(); }
public function adminNotify() { if ($this->cookie->check("id_user") and $this->cookie->id_user == 1) { //no notificamos a administrador de su propio comentario. return; } $id = $this->registry->lastCommentID; $Comment = new comment(); $comment = $Comment->find($id); $comment['content'] = utils::nl2br($comment['content']); if (!defined('GESHI_VERSION')) { $comment['content'] = $this->comment_source_code_beautifier($comment['content'], 'addTagPRE'); } else { $comment['content'] = $this->comment_source_code_beautifier($comment['content']); } $User = new user(); $user = $User->find(1); $Post = new post(); $post = $Post->find($comment['ID_post']); $commentsWaiting = $Comment->countCommentsByPost(null, 'waiting'); $mailStr = "\n\t\t\t<table width=\"100%\">\n\t\t\t<tr>\n\t\t\t\t<td>\n\t\t\t\t\t<small>\n\t\t\t\t\t\t<strong>From IP</strong>: {$comment['IP']}<br />\n\t\t\t\t\t\t<strong>URL</strong>: <a href=\"{$comment['url']}\">{$comment['url']}</a><br />\n\t\t\t\t\t\t<strong>Email</strong>: <a href=\"mailto:{$comment['email']}\">{$comment['email']}</a><br />\n\t\t\t\t\t\t<strong>DateTime</strong>: {$comment['created']}<br />\n\t\t\t\t\t</small>\n\t\t\t\t\t<hr>\n\t\t\t\t\t<strong>Author</strong>: {$comment['author']}<br />\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t\n\t\t\t<tr><td><strong>Content</strong></td></tr>\n\t\t\t<tr><td bgcolor=\"#f7f7f7\">\n\t\t\t\t{$comment['content']}\n\t\t\t\t<hr />\n\t\t\t</td></tr>\n\t\t\t\n\t\t\t<tr>\n\t\t\t\t<td>\n\t\t\t\t\t<p>\n\t\t\t\t\t\tModerate comment: <a href=\"{$this->registry->path}comments/edit/{$comment['ID']}\">{$this->registry->path}comments/edit/{$comment['ID']}</a><br />\n\t\t\t\t\t\tView entry: <a href=\"{$this->registry->path}{$post['urlfriendly']}\">{$this->registry->path}{$post['urlfriendly']}</a>\n\t\t\t\t\t</p>\n\t\t\n\t\t\t\t\t<p>\n\t\t\t\t\t\tThere are {$commentsWaiting} comments waiting for approbal. <br />\n\t\t\t\t\t\tPlease moderate comments: <a href=\"{$this->registry->path}comments/waiting\">{$this->registry->path}comments</a>\n\t\t\t\t\t</p>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t\n\t\t\t</table>\n\t\t"; $conf = $this->registry->conf; $subject = "[{$conf['blog_name']}] Nuevo Comentario en: {$post['title']}"; $this->enviaMail($user['email'], $subject, $mailStr, $user['email']); }
public function index($id = NULL, $page = 1) { if (is_null($id) or is_numeric($id)) { $this->redirect($this->conf['blog_siteurl']); } $tag = $id; $post = new post(); $link = new link(); $comment = new comment(); $this->html->useTheme($this->conf['blog_current_theme']); $info = array(); $info["isAdmin"] = false; if ($this->cookie->check("logged") and $this->cookie->id_user == 1) { $info["isAdmin"] = true; } $this->themes->info = $info; $includes['charset'] = $this->html->charsetTag("UTF-8"); $includes['rssFeed'] = $this->html->includeRSS(); if ($page > 1) { $includes['canonical'] = "<link rel=\"canonical\" href=\"{$this->conf['blog_siteurl']}/tag/" . rawurlencode($post->sql_escape($id)) . "/{$page}\" />"; } else { $includes['canonical'] = "<link rel=\"canonical\" href=\"{$this->conf['blog_siteurl']}/tag/" . rawurlencode($post->sql_escape($id)) . "\" />"; } $this->registry->includes = $includes; $this->plugin->call('index_includes'); $includes = null; foreach ($this->registry->includes as $include) { $includes .= $include; } $this->themes->includes = $includes; $this->themes->links = $link->findAll(); $this->themes->single = false; $total_rows = $post->countPosts(array('status' => 'publish', 'tag' => $tag)); $page = (int) is_null($page) ? 1 : $page; $limit = $this->conf['blog_posts_per_page']; $offset = ($page - 1) * $limit; $limitQuery = $offset . "," . $limit; $targetpage = $this->path . "tag/{$tag}/"; $this->themes->pagination = $this->pagination->init($total_rows, $page, $limit, $targetpage); $posts = $post->getPostsByTag($tag, $limitQuery); foreach ($posts as $k => $p) { $posts[$k]['title'] = htmlspecialchars($p['title']); $posts[$k]['tags'] = $post->getTags($p['ID']); $posts[$k]['comments_count'] = $comment->countCommentsByPost($posts[$k]['ID']); $user = new user(); if ($posts[$k]['id_user'] < 2) { $posts[$k]['autor'] = $user->find(1); } else { $posts[$k]['autor'] = $user->find($posts[$k]['id_user']); } } $this->registry->posts = $posts; $this->plugin->call("index_post_content"); $this->themes->posts = $this->registry->posts; $this->themes->title_for_layout = "{$this->conf['blog_name']} - {$tag}"; $this->render(); }
public function getPost($urlfriendly, $status = null) { $urlfriendy = rawurlencode($this->sql_escape($urlfriendly)); $post = array(); if (is_null($status) === true) { $post = $this->findBy('urlfriendly', $urlfriendly); } else { $post = $this->findBy(array('urlfriendly', 'status'), array($urlfriendly, $status)); } if ($this->isNew() === false) { if ($post['title']) { $post['title'] = htmlspecialchars($post['title']); } else { $post['title'] = "Untitled"; } $post['tags'] = $this->getTags($post['ID']); $C = new comment(); $post["comments_count"] = $C->countCommentsByPost($post['ID'], "publish"); $post["comments"] = $C->getAll($post['ID'], "publish"); } return $post; }