Bug 22445: Replace %% with {}

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>
This commit is contained in:
Jonathan Druart 2019-10-16 09:13:20 +02:00 committed by Martin Renvoize
parent 03e4c0bf5d
commit 5555c9d460
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
4 changed files with 13 additions and 12 deletions

View 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};

View 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 );

View 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

View 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" );
};