only show the recent few comments on each image (for the long comment list)

This commit is contained in:
Shish 2009-08-19 00:33:18 +01:00
parent 685d079da8
commit a1725f7fe3
3 changed files with 28 additions and 6 deletions

View file

@ -50,6 +50,7 @@ class CommentList extends SimpleExtension {
$config->set_default_bool('comment_anon', true);
$config->set_default_int('comment_window', 5);
$config->set_default_int('comment_limit', 10);
$config->set_default_int('comment_list_count', 10);
$config->set_default_int('comment_count', 5);
if($config->get_int("ext_comments_version") < 2) {
@ -187,6 +188,9 @@ class CommentList extends SimpleExtension {
$sb->add_label("<br>Show ");
$sb->add_int_option("comment_count");
$sb->add_label(" recent comments on the index");
$sb->add_label("<br>Show ");
$sb->add_int_option("comment_list_count");
$sb->add_label(" comments per image on the list");
$sb->add_text_option("comment_wordpress_key", "<br>Akismet Key ");
$event->panel->add_block($sb);
}

View file

@ -2,13 +2,17 @@
class CommentListTheme extends Themelet {
/**
* Do the basics of the comments page
*
* $page_number = the current page number
* $total_pages = the total number of comment pages
* Display a page with a list of images, and for each image,
* the image's comments
*/
public function display_comment_list($images, $page_number, $total_pages, $can_post) {
global $page;
global $config, $page;
// aaaaaaargh php
assert(is_array($images));
assert(is_int($page_number));
assert(is_int($total_pages));
assert(is_bool($can_post));
// parts for the whole page
$prev = $page_number - 1;
@ -36,6 +40,13 @@ class CommentListTheme extends Themelet {
$thumb_html = $this->build_thumb_html($image);
$comment_html = "";
$comment_limit = $config->get_int("comment_list_count", 10);
$comment_count = count($comments);
if($comment_limit > 0 && $comment_count > $comment_limit) {
$hidden = $comment_count - $comment_limit;
$comment_html .= "<p>showing $comment_limit of $comment_count comments</p>";
$comments = array_slice($comments, -$comment_limit);
}
foreach($comments as $comment) {
$comment_html .= $this->comment_to_html($comment);
}

View file

@ -2,7 +2,7 @@
class CustomCommentListTheme extends CommentListTheme {
public function display_comment_list($images, $page_number, $total_pages, $can_post) {
global $page;
global $config, $page;
$page->disable_left();
@ -41,6 +41,13 @@ class CustomCommentListTheme extends CommentListTheme {
$p = autodate($image->posted);
$comment_html = "<b>Date</b> $p $s <b>User</b> $un<br><b>Tags</b> $t<p>&nbsp;";
$comment_limit = $config->get_int("comment_list_count", 10);
$comment_count = count($comments);
if($comment_limit > 0 && $comment_count > $comment_limit) {
$hidden = $comment_count - $comment_limit;
$comment_html .= "<p>showing $comment_limit of $comment_count comments</p>";
$comments = array_slice($comments, -$comment_limit);
}
foreach($comments as $comment) {
$comment_html .= $this->comment_to_html($comment);
}