From b1dcab3077d352d89ec2013d4cc9d30a9f7ed132 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 8 Jun 2023 11:38:01 +0200 Subject: [PATCH] Bug 33954: Koha::Biblio->opac_summary_html Signed-off-by: Owen Leonard Signed-off-by: Nick Clemens Signed-off-by: Tomas Cohen Arazi --- Koha/Biblio.pm | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index 6d2116b39f..26dc83f2d4 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -1565,6 +1565,36 @@ sub ratings { return Koha::Ratings->_new_from_dbic($rs); } +=head3 opac_summary_html + + my $summary_html = $biblio->opac_summary_html + +Based on the syspref OPACMySummaryHTML, returns a string representing the +summary of this bibliographic record. +{AUTHOR}, {TITLE}, {ISBN} and {BIBLIONUMBER} will be replaced. + +=cut + +sub opac_summary_html { + my ($self) = @_; + + my $summary_html = C4::Context->preference('OPACMySummaryHTML'); + return q{} unless $summary_html; + my $author = $self->author || q{}; + my $title = $self->title || q{}; + $title =~ s/\/+$//; # remove trailing slash + $title =~ s/\s+$//; # remove trailing space + my $normalized_isbn = $self->normalized_isbn || q{}; + my $biblionumber = $self->biblionumber; + + $summary_html =~ s/{AUTHOR}/$author/g; + $summary_html =~ s/{TITLE}/$title/g; + $summary_html =~ s/{ISBN}/$normalized_isbn/g; + $summary_html =~ s/{BIBLIONUMBER}/$biblionumber/g; + + return $summary_html; +} + =head2 Internal methods =head3 type -- 2.39.5