somewhat updated danbooru comment theme

This commit is contained in:
Shish 2009-07-28 00:54:47 +01:00
parent 759ee2fe30
commit a16b3db48c
3 changed files with 30 additions and 16 deletions

View file

@ -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 *
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

View file

@ -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) {

View file

@ -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 "<p class='comment'>$h_userlink $h_dellink<br/><b>Posted on $h_posted</b><br/>$h_comment</p>";
}
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 = "&nbsp;&nbsp;&nbsp;";
$un = $image->get_owner()->name;
$t = "";
foreach($image->get_tag_array() as $tag) {
$u_tag = url_escape($tag);
$t .= "<a href='".make_link("post/list/$u_tag/1")."'>".html_escape($tag)."</a> ";
}
$p = autodate($image->posted);
$html = "<div style='text-align: left'>";
$html .= "<div style='float: left; margin-right: 16px;'>" . $this->build_thumb_html($image) . "</div>";
$html .= "<div style='float: right; margin-left: 16px; width: 200px; margin-bottom: 32px;'>";
foreach($image->get_tag_array() as $tag) {
$u_tag = url_escape($tag);
$html .= "<br><a href='".make_link("post/list/$u_tag/1")."'>".html_escape($tag)."</a>";
}
$html .= "</div>";
$html .= "<div style='margin-left: 250px;'>";
$html .= "<b>$count Comments</b><br>";
$html .= "<b>Date</b> $p $s <b>User</b> $un<br><b>Tags</b> $t<p>&nbsp;";
$html .= $this->comments_to_html($comments);
$html .= "</div>";
$html .= "</div>";