This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/themes/danbooru/comment.theme.php

109 lines
3.4 KiB
PHP
Raw Normal View History

<?php
class CustomCommentListTheme extends CommentListTheme {
2009-08-04 16:45:09 +00:00
public function display_comment_list($images, $page_number, $total_pages, $can_post) {
global $config, $page;
2009-08-04 16:45:09 +00:00
$page->disable_left();
// parts for the whole page
$prev = $page_number - 1;
$next = $page_number + 1;
$h_prev = ($page_number <= 1) ? "Prev" :
"<a href='".make_link("comment/list/$prev")."'>Prev</a>";
$h_index = "<a href='".make_link()."'>Index</a>";
$h_next = ($page_number >= $total_pages) ? "Next" :
"<a href='".make_link("comment/list/$next")."'>Next</a>";
$nav = "$h_prev | $h_index | $h_next";
2009-08-04 16:45:09 +00:00
$page->set_title("Comments");
$page->set_heading("Comments");
2009-08-04 16:45:09 +00:00
$page->add_block(new Block("Navigation", $nav, "left"));
$this->display_paginator($page, "comment/list", null, $page_number, $total_pages);
2009-08-04 16:45:09 +00:00
// parts for each image
$position = 10;
foreach($images as $pair) {
$image = $pair[0];
$comments = $pair[1];
2009-08-04 16:45:09 +00:00
$thumb_html = $this->build_thumb_html($image);
$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);
$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);
}
2009-08-04 16:45:09 +00:00
foreach($comments as $comment) {
$comment_html .= $this->comment_to_html($comment);
}
if($can_post) {
$comment_html .= $this->build_postbox($image->id);
}
$html = "
<table><tr>
<td style='width: 220px;'>$thumb_html</td>
<td style='text-align: left;'>$comment_html</td>
</tr></table>
";
$page->add_block(new Block("&nbsp;", $html, "main", $position++));
}
2009-08-04 16:45:09 +00:00
}
public function display_recent_comments($comments) {
// no recent comments in this theme
}
2009-07-28 00:09:00 +00:00
protected function comment_to_html(Comment $comment, $trim=false) {
global $user;
$tfe = new TextFormattingEvent($comment->comment);
send_event($tfe);
$i_uid = int_escape($comment->owner_id);
$h_name = html_escape($comment->owner_name);
$h_poster_ip = html_escape($comment->poster_ip);
$h_comment = ($trim ? substr($tfe->stripped, 0, 50)."..." : $tfe->formatted);
$i_comment_id = int_escape($comment->comment_id);
$i_image_id = int_escape($comment->image_id);
2009-07-28 00:09:00 +00:00
$h_posted = autodate($comment->posted);
$h_userlink = "<a class='username' href='".make_link("user/$h_name")."'>$h_name</a>";
$h_dellink = $user->is_admin() ?
2009-08-04 16:45:09 +00:00
"<br>($h_poster_ip, <a ".
"onclick=\"return confirm('Delete comment by $h_name:\\n".$tfe->stripped."');\" ".
"href='".make_link("comment/delete/$i_comment_id/$i_image_id")."'>Del</a>)" : "";
$h_imagelink = $trim ? "<a href='".make_link("post/view/$i_image_id")."'>&gt;&gt;&gt;</a>\n" : "";
2009-08-04 16:45:09 +00:00
if($trim) {
return "<p class='comment'>$h_userlink $h_dellink<br/><b>Posted $h_posted</b><br/>$h_comment</p>";
}
else {
return "
<table class='comment'><tr>
<td style='width: 150px;'>$h_userlink<br/><b>Posted $h_posted</b>$h_dellink</td>
<td>$h_comment</td>
</tr></table>
";
}
}
}
?>