public function output(Pagemill_Data $data, Pagemill_Stream $stream) { if (self::$_loaded) { return ''; } self::$_loaded = true; if (defined('COMMENTS_DISABLED') && COMMENTS_DISABLED) { return ''; } $data = $data->fork(); $urlmeta = Model_UrlMeta::GetUrl(); if (!$urlmeta->exists()) { return ''; } $commeta = Model_Comment_Meta::Get($urlmeta['id']); if (!$commeta->exists()) { $commeta['urlmetaid'] = $urlmeta['id']; $commeta->save(); } else { if ($commeta['closed']) { $pm->setVariable('comments_closed', true); } } $data->set('meta', $commeta); $comments = new Model_Comment(); $comments->where('urlmetaid = ?', $urlmeta['id']); if (defined('COMMENTS_REQUIRE_APPROVAL') && 1 == COMMENTS_REQUIRE_APPROVAL) { $comments->where('approved = 1'); } $comments->order('datecreated ASC'); $data->set('comments', $comments); $data->set('comments_require_captcha', COMMENTS_REQUIRE_CAPTCHA); parent::output($data, $stream); }
public function output(Pagemill_Data $data, Pagemill_Stream $stream) { $data = $data->fork(); $comments = new Model_Comment(); if (defined('COMMENTS_REQUIRE_APPROVAL') && 1 == COMMENTS_REQUIRE_APPROVAL) { $comments->select()->where('approved = 1'); } $comments->order('datecreated DESC'); $comments->limit(10); $data->set('comments', $comments); parent::output($data, $stream); }
Comment admin listing controller 24 march 2011: cleaned up 25 march 2011: rewrote to use DAO 29 march 2011: now using getTotal */ // TODO: Consider making a separate admin page for comment sections (i.e., each URL that has a comment plugin) // TODO: Do it by adding filters at the top //$comments = Comment::DAOFactory(); $comments = new Model_Comment(); if (defined('COMMENTS_REQUIRE_APPROVAL')) { $pm->setVariable('comments_require_approval', COMMENTS_REQUIRE_APPROVAL); if (COMMENTS_REQUIRE_APPROVAL) { $comments->where('approved = 0'); $pm->setVariable('totalpending', $comments->getTotal()); //$comments->resetSelect(); $comments = new Model_Comment(); } } if (isset($_REQUEST['show']) && 'unapproved' == $_REQUEST['show']) { $comments->where('approved = 0'); } if (isset($_REQUEST['application'])) { $comments->select()->where('#__page.application = ?', $_REQUEST['application']); } $total = $comments->getTotal(); $comments->order('datecreated DESC'); $comments->setPagination(isset($_REQUEST['page']) ? $_REQUEST['page'] : 1); $pm->setVariable('comments', $comments); $page = !empty($_REQUEST['page']) ? $_REQUEST['page'] : 1; Pagination::Calculate($total, 20, $page);