From 2a5295b4a1c5dc6321239e87587111ea081c302d 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 --- Koha/Biblio.pm | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index 1627d235c37..0d120b85c2c 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -1545,6 +1545,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.25.1