From 1011e874116e5285d9f6999669515d8c12e1eff5 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 29 Dec 2002 12:44:33 +0000 Subject: CHANGES: - Usability improvement: made the comment administration pages use the new table rendering functions. - Usability improvement: new comments will also be marked as new in the administration pages. - Code improvement: changed the comment administration pages to use the default pager instead of a custom pager. - Bugfix: "yes" and "no" were not translatable. - $ diffstat comment.patch comment.module | 45 +++++++-------------------------------------- 1 files changed, 7 insertions, 38 deletions TODO: - Comment module: remove other custom pagers in the comment module. - Pager/database: it would be nice if the functions db_query_range() and pager_query() would have the same semantic as db_query(); that is, using a variable number of arguments that are automatically escaped/checked. --- modules/comment.module | 45 +++++++-------------------------------------- 1 file changed, 7 insertions(+), 38 deletions(-) (limited to 'modules/comment.module') diff --git a/modules/comment.module b/modules/comment.module index 63c275816..9de5302a9 100644 --- a/modules/comment.module +++ b/modules/comment.module @@ -789,51 +789,20 @@ function comment_save($id, $edit) { return "Comment updated."; } -function comment_admin_overview($status = 0, $comment_page = 0) { - global $comment_settings; +function comment_admin_overview($status = 0) { - $comments_per_page = 50; + $result = pager_query("SELECT c.*, u.name, u.uid FROM comments c LEFT JOIN users u ON u.uid = c.uid WHERE c.status = '". check_query($status) ."' ORDER BY c.timestamp DESC"); - /* - ** Save location to come back here after a edit/delete - */ - - $comment_settings["status"] = $status; - $comment_settings["comment_page"] = $comment_page; - session_register("comment_settings"); - - - /* - ** Now render the page - */ - - $start = $comment_page * $comments_per_page; - - $output .= $status ? "

" . t("Comments that await approval") . "

\n" : "

" . t("New or updated comments") . "

"; - $result = db_query("SELECT c.*, u.name, u.uid FROM comments c LEFT JOIN users u ON u.uid = c.uid WHERE c.status = '%d' ORDER BY timestamp DESC LIMIT $start, $comments_per_page", $status); - - $output .= "\n"; - $output .= " \n"; + $header = array(t("subject"), t("author"), t("status"), array("data" => t("operations"), "colspan" => 2)); while ($comment = db_fetch_object($result)) { - $output .= " \n"; - } - - if ($comment_page > 0) { - // show previous - $prev_link = la(t("previous comments"), array("mod" => "comment", "status" => $status, "comment_page" => ($comment_page - 1))); + $rows[] = array(l(check_output($comment->subject), array("id" => $comment->nid, "cid" => $comment->cid, "pid" => $comment->pid), "node", $comment->cid, array("title" => htmlentities(substr($comment->comment, 0, 128)))) ." ". (comment_is_new($comment) ? theme_mark() : ""), format_name($comment), ($comment->status == 0 ? t("published") : t("not published")) .""; - } - $output .= "
" . t("subject") . "" . t("author") . "" . t("date") . "" . t("published") . "" . t("operations") . "
". l(check_output($comment->subject), array("id" => $comment->nid, "cid" => $comment->cid, "pid" => $comment->pid), "node", $comment->cid, array("title" => htmlentities($comment->comment))) ."". format_name($comment) ."". format_date($comment->timestamp, "small") ."". ($comment->status == 0 ? "yes" : "no") ."". la(t("edit comment"), array("mod" => "comment", "op" => "edit", "id" => $comment->cid)) ."". la(t("delete comment"), array("mod" => "comment", "op" => "delete", "id" => $comment->cid)) ."
". la(t("edit comment"), array("mod" => "comment", "op" => "edit", "id" => $comment->cid)), la(t("delete comment"), array("mod" => "comment", "op" => "delete", "id" => $comment->cid))); } - if (db_num_rows($result) == $comments_per_page) { - // show next - $next_link = la(t("next comments"), array("mod" => "comment", "status" => $status, "comment_page" => ($comment_page + 1))); + if ($pager = pager_display(NULL, 50, 0, "admin")) { + $rows[] = array(array("data" => $pager, "colspan" => 5)); } - if ($prev_link || $next_link) { - $output .= "
$prev_link$next_link
\n"; - - return $output; + return table($header, $rows); } function comment_mod_matrix($edit) { -- cgit v1.2.3