diff --git a/plugins/AttachmentShowRelated/AttachmentShowRelated.php b/plugins/AttachmentShowRelated/AttachmentShowRelated.php new file mode 100644 index 0000000000..5959e4f444 --- /dev/null +++ b/plugins/AttachmentShowRelated/AttachmentShowRelated.php @@ -0,0 +1,45 @@ +. + +// }}} + +namespace Plugin\AttachmentShowRelated; + +use App\Core\DB\DB; +use App\Core\Event; +use App\Core\Modules\Plugin; +use App\Util\Formatting; + +class AttachmentShowRelated extends Plugin +{ + public function onAppendRightPanelBlock($vars, &$res): bool + { + if ($vars['path'] == 'attachment_show') { + $related_notes = DB::dql('select n from attachment_to_note an ' . + 'join note n with n.id = an.note_id ' . + 'where an.attachment_id = :attachment_id', ['attachment_id' => $vars['vars']['attachment_id']]); + $related_tags = DB::dql('select distinct t.tag ' . + 'from attachment_to_note an join note_tag t with an.note_id = t.note_id ' . + 'where an.attachment_id = :attachment_id', ['attachment_id' => $vars['vars']['attachment_id']]); + $res[] = Formatting::twigRender(file_get_contents(__DIR__ . '/templates/AttachmentRelatedNotes.html.twig'), ['related_notes' => $related_notes]); + $res[] = Formatting::twigRender(file_get_contents(__DIR__ . '/templates/AttachmentRelatedTags.html.twig'), ['related_tags' => $related_tags]); + } + return Event::next; + } +} \ No newline at end of file diff --git a/plugins/AttachmentShowRelated/templates/AttachmentRelatedNotes.html.twig b/plugins/AttachmentShowRelated/templates/AttachmentRelatedNotes.html.twig new file mode 100644 index 0000000000..3a9df248f8 --- /dev/null +++ b/plugins/AttachmentShowRelated/templates/AttachmentRelatedNotes.html.twig @@ -0,0 +1,6 @@ +
diff --git a/plugins/AttachmentShowRelated/templates/AttachmentRelatedTags.html.twig b/plugins/AttachmentShowRelated/templates/AttachmentRelatedTags.html.twig new file mode 100644 index 0000000000..881dc2cdec --- /dev/null +++ b/plugins/AttachmentShowRelated/templates/AttachmentRelatedTags.html.twig @@ -0,0 +1,9 @@ + \ No newline at end of file diff --git a/plugins/Favourite/Favourite.php b/plugins/Favourite/Favourite.php index 2921debc6b..7f542f2f22 100644 --- a/plugins/Favourite/Favourite.php +++ b/plugins/Favourite/Favourite.php @@ -40,7 +40,7 @@ class Favourite extends Plugin * HTML rendering event that adds the favourite form as a note * action, if a user is logged in */ - public function onAddNoteActions(Request $request, Note $note, array &$actions) + public function onAddNoteActions(Request $request, Note $note, array &$actions): bool { if (($user = Common::user()) == null) { return Event::next; @@ -75,15 +75,16 @@ class Favourite extends Plugin return Event::next; } - public function onInsertLeftPanelLink(string $user_nickname, &$res) + public function onInsertLeftPanelLink(string $user_nickname, &$res): bool { $res[] = Formatting::twigRender(<<