Bug 22445: Replace %% with {}
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 16 Oct 2019 07:13:20 +0000 (09:13 +0200)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Tue, 22 Oct 2019 14:02:51 +0000 (15:02 +0100)
Sponsored-by: Orex Digital
Signed-off-by: Hayley Mapley <hayleymapley@catalyst.net.nz>
Signed-off-by: Hugo Agud <hagud@orex.es>
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Michal Denar <black23@gmail.com>
Signed-off-by: Kyle Hall <kyle@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Koha/Biblio.pm
installer/data/mysql/atomicupdate/bug_xxxxx.perl
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref
t/db_dependent/Koha/Biblios.t

index 4bf153a..8a450d7 100644 (file)
@@ -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|%(?<field>\d{3})\$(?<subfield>.)%|;
+    my $re = qr|{(?<field>\d{3})\$(?<subfield>.)}|;
     if ( $url =~ $re ) {
         my $field = $+{field};
         my $subfield = $+{subfield};
index 4cf30e8..7fbda0f 100644 (file)
@@ -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 );
index 099b8eb..8f32cad 100644 (file)
@@ -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}.<br/>"
+            - "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
index 177eda8..2f62524 100644 (file)
@@ -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" );
 };