From 5555c9d4609935273dbf24757a3dc415253de8ea Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 16 Oct 2019 09:13:20 +0200 Subject: [PATCH] Bug 22445: Replace %% with {} Sponsored-by: Orex Digital Signed-off-by: Hayley Mapley Signed-off-by: Hugo Agud Signed-off-by: Owen Leonard Signed-off-by: Michal Denar Signed-off-by: Kyle Hall Signed-off-by: Katrin Fischer Signed-off-by: Martin Renvoize --- Koha/Biblio.pm | 14 +++++++------- installer/data/mysql/atomicupdate/bug_xxxxx.perl | 2 +- .../admin/preferences/enhanced_content.pref | 3 ++- t/db_dependent/Koha/Biblios.t | 6 +++--- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index 4bf153ae6f..8a450d759c 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -672,20 +672,20 @@ It is built regaring the value of the system preference CustomCoverImagesURL sub custom_cover_image_url { my ( $self ) = @_; my $url = C4::Context->preference('CustomCoverImagesURL'); - if ( $url =~ m|%isbn%| ) { + if ( $url =~ m|{isbn}| ) { my $isbn = $self->biblioitem->isbn; - $url =~ s|%isbn%|$isbn|g; + $url =~ s|{isbn}|$isbn|g; } - if ( $url =~ m|%normalized_isbn%| ) { + if ( $url =~ m|{normalized_isbn}| ) { my $normalized_isbn = C4::Koha::GetNormalizedISBN($self->biblioitem->isbn); - $url =~ s|%normalized_isbn%|$normalized_isbn|g; + $url =~ s|{normalized_isbn}|$normalized_isbn|g; } - if ( $url =~ m|%issn%| ) { + if ( $url =~ m|{issn}| ) { my $issn = $self->biblioitem->issn; - $url =~ s|%issn%|$issn|g; + $url =~ s|{issn}|$issn|g; } - my $re = qr|%(?\d{3})\$(?.)%|; + my $re = qr|{(?\d{3})\$(?.)}|; if ( $url =~ $re ) { my $field = $+{field}; my $subfield = $+{subfield}; diff --git a/installer/data/mysql/atomicupdate/bug_xxxxx.perl b/installer/data/mysql/atomicupdate/bug_xxxxx.perl index 4cf30e86cc..7fbda0f10d 100644 --- a/installer/data/mysql/atomicupdate/bug_xxxxx.perl +++ b/installer/data/mysql/atomicupdate/bug_xxxxx.perl @@ -6,7 +6,7 @@ if( CheckVersion( $DBversion ) ) { VALUES ('CustomCoverImages','0',NULL,'If enabled, the custom cover images will be displayed in the staff client. CustomCoverImagesURL must be defined.','YesNo'), ('OPACCustomCoverImages','0',NULL,'If enabled, the custom cover images will be displayed at the OPAC. CustomCoverImagesURL must be defined.','YesNo'), - ('CustomCoverImagesURL','',NULL,'Define an URL serving book cover images, using the following patterns: %issn%, %isbn%, FIXME ADD MORE (use it with CustomCoverImages and/or OPACCustomCoverImages)','free') + ('CustomCoverImagesURL','',NULL,'Define an URL serving book cover images, using the following patterns: {issn}, {isbn}, {normalized_isbn}, {field$subfield} (use it with CustomCoverImages and/or OPACCustomCoverImages)','free') }); SetVersion( $DBversion ); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref index 099b8eb3fe..8f32cadb2d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref @@ -346,7 +346,8 @@ Enhanced Content: - "Using the following URL:" - pref: CustomCoverImagesURL class: url - - "You can define it using the following patterns: %isbn%, %issn%, %normalized_isbn%." + - "You can define it using the following patterns: {isbn}, {issn}, {normalized_isbn}.
" + - "Or you can use the following syntax to specify a field$subfield value: {field$subfield}. For instance {024$a}." HTML5 Media: - - Show a tab with a HTML5 media player for files catalogued in field 856 diff --git a/t/db_dependent/Koha/Biblios.t b/t/db_dependent/Koha/Biblios.t index 177eda81e8..2f62524505 100644 --- a/t/db_dependent/Koha/Biblios.t +++ b/t/db_dependent/Koha/Biblios.t @@ -190,7 +190,7 @@ subtest 'can_be_transferred' => sub { subtest 'custom_cover_image_url' => sub { plan tests => 3; - t::lib::Mocks::mock_preference( 'CustomCoverImagesURL', 'https://my_url/%isbn%_%issn%.png' ); + t::lib::Mocks::mock_preference( 'CustomCoverImagesURL', 'https://my_url/{isbn}_{issn}.png' ); my $isbn = '0553573403 | 9780553573404 (pbk.).png'; my $issn = 'my_issn'; @@ -206,10 +206,10 @@ subtest 'custom_cover_image_url' => sub { $marc_record->append_fields( MARC::Field->new( '024', '', '', a => $marc_024a ) ); C4::Biblio::ModBiblio( $marc_record, $biblio->biblionumber ); - t::lib::Mocks::mock_preference( 'CustomCoverImagesURL', 'https://my_url/%024$a%.png' ); + t::lib::Mocks::mock_preference( 'CustomCoverImagesURL', 'https://my_url/{024$a}.png' ); is( $biblio->custom_cover_image_url, "https://my_url/$marc_024a.png" ); - t::lib::Mocks::mock_preference( 'CustomCoverImagesURL', 'https://my_url/%normalized_isbn%.png' ); + t::lib::Mocks::mock_preference( 'CustomCoverImagesURL', 'https://my_url/{normalized_isbn}.png' ); my $normalized_isbn = C4::Koha::GetNormalizedISBN($isbn); is( $biblio->custom_cover_image_url, "https://my_url/$normalized_isbn.png" ); }; -- 2.39.5