From 3ba8834c209d1ef6922a129cc2a940b788d0fefe Mon Sep 17 00:00:00 2001 From: discomrade <83621080+discomrade@users.noreply.github.com> Date: Tue, 20 Feb 2024 00:54:36 +0000 Subject: [PATCH] [futaba] fix comment reply button --- themes/futaba/comment.theme.php | 23 ++++++++++++++++++----- themes/futaba/style.css | 2 +- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/themes/futaba/comment.theme.php b/themes/futaba/comment.theme.php index c4ea8c88..3a73a56f 100644 --- a/themes/futaba/comment.theme.php +++ b/themes/futaba/comment.theme.php @@ -7,6 +7,7 @@ namespace Shimmie2; class CustomCommentListTheme extends CommentListTheme { public int $inner_id = 0; + public bool $post_page = true; /** * @param array $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, "
", "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 = " - [Delete]"; + } + if ($this->post_page) { + $h_reply = "[Reply]"; + } else { + $h_reply = "[Reply]"; } - $h_reply = "[Reply]"; if ($inner_id == 0) { return "
$h_userlink$h_del $h_date No.$i_comment_id $h_reply

$h_comment

"; } else { return "
>>". - "
$h_userlink$h_del $h_date No.$i_comment_id $h_reply

$h_comment

" . + "
$h_userlink$h_del $h_date No.$i_comment_id

$h_comment

" . "
"; } } diff --git a/themes/futaba/style.css b/themes/futaba/style.css index 3d07afa8..f75b6a21 100644 --- a/themes/futaba/style.css +++ b/themes/futaba/style.css @@ -159,4 +159,4 @@ TABLE.tag_list>TBODY>TR>TD:after { } .thumb { margin: 16px; -} +} \ No newline at end of file