From a16b3db48cc748487c263bf2dc768645d8b32791 Mon Sep 17 00:00:00 2001 From: Shish Date: Tue, 28 Jul 2009 00:54:47 +0100 Subject: [PATCH] somewhat updated danbooru comment theme --- core/util.inc.php | 14 ++++++++++++++ ext/comment/main.php | 2 +- themes/danbooru/comment.theme.php | 30 +++++++++++++++--------------- 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/core/util.inc.php b/core/util.inc.php index 09e3a85c..652db51c 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -90,6 +90,20 @@ function to_shorthand_int($int) { } +/** + * Turn a date into a time, a date, an "X minutes ago...", etc + * + * Currently missing step 2 + * + * @retval string + */ +function autodate($date) { + $ts = strtotime($date); + // Step 2: ... + return $date; +} + + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ * HTML Generation * \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ diff --git a/ext/comment/main.php b/ext/comment/main.php index f6b7fd26..96abf62b 100644 --- a/ext/comment/main.php +++ b/ext/comment/main.php @@ -126,7 +126,7 @@ class CommentList implements Extension { $page, $this->get_comments($event->image->id), $this->can_comment(), - $event->image->id); + $event->image); } if($event instanceof ImageDeletionEvent) { diff --git a/themes/danbooru/comment.theme.php b/themes/danbooru/comment.theme.php index d97afc97..2052ff78 100644 --- a/themes/danbooru/comment.theme.php +++ b/themes/danbooru/comment.theme.php @@ -26,17 +26,16 @@ class CustomCommentListTheme extends CommentListTheme { //$page->add_block(new Block("Comments", $html, "left")); } - public function display_comments($page, $comments, $postbox, $image_id) { + public function display_comments(Page $page, $comments, $postbox, Image $image) { $count = count($comments); + $cs = $count == 1 ? "Comment" : "Comments"; if($postbox) { - $page->add_block(new Block("$count Comments", - $this->comments_to_html($comments). - $this->build_postbox($image_id), "main", 30)); + $html = $this->comments_to_html($comments) . $this->build_postbox($image->id); } else { - $page->add_block(new Block("$count Comments", - $this->comments_to_html($comments), "main", 30)); + $html = $this->comments_to_html($comments); } + $page->add_block(new Block("$count $cs", $html, "main", 30)); } @@ -63,19 +62,20 @@ class CustomCommentListTheme extends CommentListTheme { return "

$h_userlink $h_dellink
Posted on $h_posted
$h_comment

"; } - public function add_comment_list($page, $image, $comments, $position, $with_postbox) { - $count = count($comments); + public function add_comment_list(Page $page, Image $image, $comments, $position, $with_postbox) { + $s = "   "; + $un = $image->get_owner()->name; + $t = ""; + foreach($image->get_tag_array() as $tag) { + $u_tag = url_escape($tag); + $t .= "".html_escape($tag)." "; + } + $p = autodate($image->posted); $html = "
"; $html .= "
" . $this->build_thumb_html($image) . "
"; - $html .= "
"; - foreach($image->get_tag_array() as $tag) { - $u_tag = url_escape($tag); - $html .= "
".html_escape($tag).""; - } - $html .= "
"; $html .= "
"; - $html .= "$count Comments
"; + $html .= "Date $p $s User $un
Tags $t

 "; $html .= $this->comments_to_html($comments); $html .= "

"; $html .= "
";