Bug 22445: Add new pattern %normalized_isbn%

Quite bad to use C4::Koha from Koha::Biblio :-/

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:
Martin Renvoize 2019-10-22 14:58:52 +01:00
parent 8c858f50a8
commit 03e4c0bf5d
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
3 changed files with 12 additions and 3 deletions

View File

@ -24,6 +24,7 @@ use List::MoreUtils qw(any);
use URI;
use URI::Escape;
use C4::Koha;
use C4::Biblio qw();
use Koha::Database;
@ -675,6 +676,10 @@ sub custom_cover_image_url {
my $isbn = $self->biblioitem->isbn;
$url =~ s|%isbn%|$isbn|g;
}
if ( $url =~ m|%normalized_isbn%| ) {
my $normalized_isbn = C4::Koha::GetNormalizedISBN($self->biblioitem->isbn);
$url =~ s|%normalized_isbn%|$normalized_isbn|g;
}
if ( $url =~ m|%issn%| ) {
my $issn = $self->biblioitem->issn;
$url =~ s|%issn%|$issn|g;

View File

@ -346,7 +346,7 @@ Enhanced Content:
- "Using the following URL:"
- pref: CustomCoverImagesURL
class: url
- "You can defined it using the following patterns: %isbn%, %issn%."
- "You can define it using the following patterns: %isbn%, %issn%, %normalized_isbn%."
HTML5 Media:
-
- Show a tab with a HTML5 media player for files catalogued in field 856

View File

@ -188,11 +188,11 @@ subtest 'can_be_transferred' => sub {
};
subtest 'custom_cover_image_url' => sub {
plan tests => 2;
plan tests => 3;
t::lib::Mocks::mock_preference( 'CustomCoverImagesURL', 'https://my_url/%isbn%_%issn%.png' );
my $isbn = 'my_isbn';
my $isbn = '0553573403 | 9780553573404 (pbk.).png';
my $issn = 'my_issn';
my $marc_record = MARC::Record->new;
my ( $biblionumber, undef ) = C4::Biblio::AddBiblio($marc_record, '');
@ -208,6 +208,10 @@ subtest 'custom_cover_image_url' => sub {
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' );
my $normalized_isbn = C4::Koha::GetNormalizedISBN($isbn);
is( $biblio->custom_cover_image_url, "https://my_url/$normalized_isbn.png" );
};
$schema->storage->txn_rollback;