[futaba] fix comment reply button

This commit is contained in:
discomrade 2024-02-20 00:54:36 +00:00 committed by Shish
parent 82b8991fa4
commit 3ba8834c20
2 changed files with 19 additions and 6 deletions

View file

@ -7,6 +7,7 @@ namespace Shimmie2;
class CustomCommentListTheme extends CommentListTheme
{
public int $inner_id = 0;
public bool $post_page = true;
/**
* @param array<array{0: Image, 1: Comment[]}> $images
@ -25,6 +26,7 @@ class CustomCommentListTheme extends CommentListTheme
$page->add_block(new Block(null, $this->build_upload_box(), "main", 0));
$page->add_block(new Block(null, "<hr>", "main", 80));
$this->display_paginator($page, "comment/list", null, $page_number, $total_pages);
$this->post_page = false;
// parts for each image
$position = 10;
@ -58,7 +60,8 @@ class CustomCommentListTheme extends CommentListTheme
public function display_recent_comments(array $comments): void
{
// sidebar fails in this theme
$this->post_page = false;
parent::display_recent_comments($comments);
}
public function build_upload_box(): string
@ -69,7 +72,9 @@ class CustomCommentListTheme extends CommentListTheme
protected function comment_to_html(Comment $comment, bool $trim = false): string
{
$inner_id = $this->inner_id; // because custom themes can't add params, because PHP
// because custom themes can't add params, because PHP
$post_page = $this->post_page;
$inner_id = $this->inner_id;
global $user;
$tfe = send_event(new TextFormattingEvent($comment->comment));
@ -89,15 +94,23 @@ class CustomCommentListTheme extends CommentListTheme
$h_date = $comment->posted;
$h_del = "";
if ($user->can(Permissions::DELETE_COMMENT)) {
$h_del = " - " . $this->delete_link($i_comment_id, $i_image_id, $comment->owner_name, $tfe->stripped);
$comment_preview = substr(html_unescape($tfe->stripped), 0, 50);
$j_delete_confirm_message = json_encode("Delete comment by {$comment->owner_name}:\n$comment_preview");
$h_delete_script = html_escape("return confirm($j_delete_confirm_message);");
$h_delete_link = make_link("comment/delete/$i_comment_id/$i_image_id");
$h_del = " - [<a onclick='$h_delete_script' href='$h_delete_link'>Delete</a>]";
}
if ($this->post_page) {
$h_reply = "[<a href='javascript: replyTo($i_image_id, $i_comment_id, \"$h_name\")'>Reply</a>]";
} else {
$h_reply = "[<a href='".make_link("post/view/$i_image_id")."'>Reply</a>]";
}
$h_reply = "[<a href='".make_link("post/view/$i_image_id")."'>Reply</a>]";
if ($inner_id == 0) {
return "<div class='comment' style='margin-top: 8px;'>$h_userlink$h_del $h_date No.$i_comment_id $h_reply<p>$h_comment</p></div>";
} else {
return "<table><tr><td nowrap class='doubledash'>&gt;&gt;</td><td>".
"<div class='reply'>$h_userlink$h_del $h_date No.$i_comment_id $h_reply<p>$h_comment</p></div>" .
"<div class='reply'>$h_userlink$h_del $h_date No.$i_comment_id<p>$h_comment</p></div>" .
"</td></tr></table>";
}
}

View file

@ -159,4 +159,4 @@ TABLE.tag_list>TBODY>TR>TD:after {
}
.thumb {
margin: 16px;
}
}