[futaba] fix comment reply button
This commit is contained in:
parent
82b8991fa4
commit
3ba8834c20
2 changed files with 19 additions and 6 deletions
|
@ -7,6 +7,7 @@ namespace Shimmie2;
|
||||||
class CustomCommentListTheme extends CommentListTheme
|
class CustomCommentListTheme extends CommentListTheme
|
||||||
{
|
{
|
||||||
public int $inner_id = 0;
|
public int $inner_id = 0;
|
||||||
|
public bool $post_page = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<array{0: Image, 1: Comment[]}> $images
|
* @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, $this->build_upload_box(), "main", 0));
|
||||||
$page->add_block(new Block(null, "<hr>", "main", 80));
|
$page->add_block(new Block(null, "<hr>", "main", 80));
|
||||||
$this->display_paginator($page, "comment/list", null, $page_number, $total_pages);
|
$this->display_paginator($page, "comment/list", null, $page_number, $total_pages);
|
||||||
|
$this->post_page = false;
|
||||||
|
|
||||||
// parts for each image
|
// parts for each image
|
||||||
$position = 10;
|
$position = 10;
|
||||||
|
@ -58,7 +60,8 @@ class CustomCommentListTheme extends CommentListTheme
|
||||||
|
|
||||||
public function display_recent_comments(array $comments): void
|
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
|
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
|
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;
|
global $user;
|
||||||
|
|
||||||
$tfe = send_event(new TextFormattingEvent($comment->comment));
|
$tfe = send_event(new TextFormattingEvent($comment->comment));
|
||||||
|
@ -89,15 +94,23 @@ class CustomCommentListTheme extends CommentListTheme
|
||||||
$h_date = $comment->posted;
|
$h_date = $comment->posted;
|
||||||
$h_del = "";
|
$h_del = "";
|
||||||
if ($user->can(Permissions::DELETE_COMMENT)) {
|
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) {
|
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>";
|
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 {
|
} else {
|
||||||
return "<table><tr><td nowrap class='doubledash'>>></td><td>".
|
return "<table><tr><td nowrap class='doubledash'>>></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>";
|
"</td></tr></table>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,4 +159,4 @@ TABLE.tag_list>TBODY>TR>TD:after {
|
||||||
}
|
}
|
||||||
.thumb {
|
.thumb {
|
||||||
margin: 16px;
|
margin: 16px;
|
||||||
}
|
}
|
Reference in a new issue