summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2002-12-29 12:44:33 +0000
committerDries Buytaert <dries@buytaert.net>2002-12-29 12:44:33 +0000
commit1011e874116e5285d9f6999669515d8c12e1eff5 (patch)
treeea6544391985363d3c42de00c408f552c7c2ff22
parent24af61ede43fb2ee93ddf1478064ad72664fbb89 (diff)
downloadbrdo-1011e874116e5285d9f6999669515d8c12e1eff5.tar.gz
brdo-1011e874116e5285d9f6999669515d8c12e1eff5.tar.bz2
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.
-rw-r--r--modules/comment.module45
-rw-r--r--modules/comment/comment.module45
2 files changed, 14 insertions, 76 deletions
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 ? "<h3>" . t("Comments that await approval") . "</h3>\n" : "<h3>" . t("New or updated comments") . "</h3>";
- $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 .= "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">\n";
- $output .= " <tr><th>" . t("subject") . "</th><th>" . t("author") . "</th><th>" . t("date") . "</th><th>" . t("published") . "</th><th colspan=\"2\">" . t("operations") . "</th></tr>\n";
+ $header = array(t("subject"), t("author"), t("status"), array("data" => t("operations"), "colspan" => 2));
while ($comment = db_fetch_object($result)) {
- $output .= " <tr><td>". l(check_output($comment->subject), array("id" => $comment->nid, "cid" => $comment->cid, "pid" => $comment->pid), "node", $comment->cid, array("title" => htmlentities($comment->comment))) ."</td><td>". format_name($comment) ."</td><td>". format_date($comment->timestamp, "small") ."</td><td>". ($comment->status == 0 ? "yes" : "no") ."</td><td>". la(t("edit comment"), array("mod" => "comment", "op" => "edit", "id" => $comment->cid)) ."</td><td>". la(t("delete comment"), array("mod" => "comment", "op" => "delete", "id" => $comment->cid)) ."</td></tr>\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")) ."</td><td>". 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 .= "<tr><td>$prev_link</td><td></td><td></td><td></td><td></td><td>$next_link</td></tr>";
- }
- $output .= "</table>\n";
-
- return $output;
+ return table($header, $rows);
}
function comment_mod_matrix($edit) {
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index 63c275816..9de5302a9 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/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 ? "<h3>" . t("Comments that await approval") . "</h3>\n" : "<h3>" . t("New or updated comments") . "</h3>";
- $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 .= "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">\n";
- $output .= " <tr><th>" . t("subject") . "</th><th>" . t("author") . "</th><th>" . t("date") . "</th><th>" . t("published") . "</th><th colspan=\"2\">" . t("operations") . "</th></tr>\n";
+ $header = array(t("subject"), t("author"), t("status"), array("data" => t("operations"), "colspan" => 2));
while ($comment = db_fetch_object($result)) {
- $output .= " <tr><td>". l(check_output($comment->subject), array("id" => $comment->nid, "cid" => $comment->cid, "pid" => $comment->pid), "node", $comment->cid, array("title" => htmlentities($comment->comment))) ."</td><td>". format_name($comment) ."</td><td>". format_date($comment->timestamp, "small") ."</td><td>". ($comment->status == 0 ? "yes" : "no") ."</td><td>". la(t("edit comment"), array("mod" => "comment", "op" => "edit", "id" => $comment->cid)) ."</td><td>". la(t("delete comment"), array("mod" => "comment", "op" => "delete", "id" => $comment->cid)) ."</td></tr>\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")) ."</td><td>". 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 .= "<tr><td>$prev_link</td><td></td><td></td><td></td><td></td><td>$next_link</td></tr>";
- }
- $output .= "</table>\n";
-
- return $output;
+ return table($header, $rows);
}
function comment_mod_matrix($edit) {