From e0cc2bd62bde392883969372bb32f54f7bd9e0b4 Mon Sep 17 00:00:00 2001 From: Nicolas Giraud Date: Fri, 26 May 2023 14:20:30 -0400 Subject: [PATCH] cam18603 - changement label bouton + impossible de cliquer si preference pas activee --- Koha/Plugin/PDFtoCover.pm | 42 ++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/Koha/Plugin/PDFtoCover.pm b/Koha/Plugin/PDFtoCover.pm index f9fca45..395bc52 100644 --- a/Koha/Plugin/PDFtoCover.pm +++ b/Koha/Plugin/PDFtoCover.pm @@ -277,24 +277,38 @@ sub intranet_catalog_biblio_enhancements_toolbar_button { # hook koha my ( $self, $params ) = @_; my $cgi = $self->{cgi}; my $biblionumber = $cgi->param('biblionumber'); - if ($self->hasPdfResource($biblionumber)) { # On affiche le bouton que s'il y a une ressource pdf + + # On affiche un bouton que s'il y a une ressource pdf + if ($self->hasPdfResource($biblionumber)) { my $lang = $cgi->cookie('KohaOpacLanguage'); - - my $link = "/cgi-bin/koha/plugins/run.pl?class=" . uri_escape("Koha::Plugin::" . $metadata->{name}) . "&method=genererUneVignette&biblionumber=" . $biblionumber; - my $textbutton = ''; - - if ($self->hasAlreadyLocalImage($biblionumber)) { - $link .= "®enerer=1"; - $textbutton = " "; - $textbutton .= $lang eq "fr-CA" || $lang eq "fr" ? "Regénérer la vignette" : "Regenerate Thumbnail"; + my $hasLocalImage = $self->hasAlreadyLocalImage($biblionumber); + my $stmt = $dbh->prepare("select value from systempreferences where variable='LocalCoverImages'"); + $stmt->execute(); + + my $button = "
"; + my $textbutton = $lang eq "fr-CA" || $lang eq "fr" ? "Générer l'image de couverture" : "Generate cover image"; + if ($hasLocalImage) { + $textbutton = "Reg" . substr($textbutton, 1); + } + + + if ($stmt->fetchrow_array()) { + my $link = "/cgi-bin/koha/plugins/run.pl?class=" . uri_escape("Koha::Plugin::" . $metadata->{name}) . + "&method=genererUneVignette&biblionumber=" . $biblionumber . ($hasLocalImage ? "®enerer=1" : ""); + + my $class = " "; + + $button .= "$class $textbutton"; } else { - $textbutton = " "; - $textbutton .= $lang eq "fr-CA" || $lang eq "fr" ? "Générer la vignette" : "Generate Thumbnail"; + my $title = "You must activate the LocalCoverImages system preference to generate the cover image"; + if ($lang eq "fr-CA" || $lang eq "fr") { + $title = "Vous devez activer la préférence systême LocalCoverImages pour générer l'image de couverture"; + } + + $button .= ""; } - return ""; + return $button . "
"; } - return ""; }