From 2361eb68505a3fae8c0e96ee4a96705d80a95548 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 26 Jan 2018 16:15:05 +0000 Subject: [PATCH] Bug 19360 - Give items URL a link text This patch allows a user to write in a link text when adding an item to a MARC record in addition to a URI. The link text is displayed instead of the URI (only if a link text has been entered, otherwise the URI value is displayed) which makes the link more readable. Test plan: 1. Add a MARC record (of any framework) 2. Add an item making sure to write in a URL e.g. https://www.google.com 3. Notice on the additem page there is no 'Link text' input 4. Submit the add item form 5. Search for the item in the intranet and OPAC and notice that the whole URL is displayed, which would get annoying if the URL is long 6. Apply patch 7. Update the database by going to Administration->Global system preferences-> local use and change the 'version' system preference to an previous version and then click 'Save' 8. This will prompt the update process 9. After going through the update process repeat step 1 and add an item. When adding the item notice there is a 'Link text' option write in an appropriate name e.g. 'Google' and write in the URI value 10. Submit the form 11. Repeat step 5 and notice that the link text value is displayed instead of the URL 12. Click on the link and check that it works 13. Add another item to a record and write in a URI but no link text value 14. Search for the item in intranet and OPAC and notice that when no link text is entered but a URI is then the URI is displayed Sponsored-By: Catalyst IT Signed-off-by: David Bourgault --- C4/Items.pm | 5 ++++- catalogue/detail.pl | 3 ++- installer/data/mysql/kohastructure.sql | 2 ++ .../intranet-tmpl/prog/en/modules/catalogue/detail.tt | 10 +++++++--- koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt | 17 +++++++++++++---- opac/opac-detail.pl | 3 ++- 6 files changed, 30 insertions(+), 10 deletions(-) diff --git a/C4/Items.pm b/C4/Items.pm index a7154be..ba2f882 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -479,6 +479,7 @@ sub _build_default_values_for_mod_marc { stocknumber => undef, uri => undef, withdrawn => 0, + link_text => undef, }; my %default_values_for_mod_from_marc; while ( my ( $field, $default_value ) = each %$default_values ) { @@ -1793,7 +1794,8 @@ sub _koha_new_item { more_subfields_xml = ?, copynumber = ?, stocknumber = ?, - new_status = ? + new_status = ?, + link_text = ? "; my $sth = $dbh->prepare($query); my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); @@ -1838,6 +1840,7 @@ sub _koha_new_item { $item->{'copynumber'}, $item->{'stocknumber'}, $item->{'new_status'}, + $item->{'link_text'} ); my $itemnumber; diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 1359c0b..7fd682a 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -249,7 +249,7 @@ foreach my $item (@items) { $item->{'ccode'} = $collections->{$ccode} if ( defined( $ccode ) && defined($collections) && exists( $collections->{$ccode} ) ); my $copynumber = $item->{'copynumber'}; $item->{'copynumber'} = $copynumbers->{$copynumber} if ( defined($copynumber) && defined($copynumbers) && exists( $copynumbers->{$copynumber} ) ); - foreach (qw(ccode enumchron copynumber stocknumber itemnotes itemnotes_nonpublic uri)) { + foreach (qw(ccode enumchron copynumber stocknumber itemnotes itemnotes_nonpublic uri link_text)) { $itemfields{$_} = 1 if ( $item->{$_} ); } @@ -362,6 +362,7 @@ $template->param( volinfo => $itemfields{enumchron}, itemdata_itemnotes => $itemfields{itemnotes}, itemdata_nonpublicnotes => $itemfields{itemnotes_nonpublic}, + itemdata_linktext => $itemfields{link_text}, z3950_search_params => C4::Search::z3950_search_args($dat), hostrecords => $hostrecords, analytics_flag => $analytics_flag, diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index f031503..127f29b 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -696,6 +696,7 @@ CREATE TABLE `deleteditems` ( `copynumber` varchar(32) default NULL, -- copy number (MARC21 952$t) `stocknumber` varchar(32) default NULL, -- inventory number (MARC21 952$i) `new_status` VARCHAR(32) DEFAULT NULL, -- 'new' value, you can put whatever free-text information. This field is intented to be managed by the automatic_item_modification_by_age cronjob. + `link_text` VARCHAR(200) DEFAULT NULL, -- text displayed when uri present in item record. PRIMARY KEY (`itemnumber`), KEY `delitembarcodeidx` (`barcode`), KEY `delitemstocknumberidx` (`stocknumber`), @@ -956,6 +957,7 @@ CREATE TABLE `items` ( -- holdings/item information `copynumber` varchar(32) default NULL, -- copy number (MARC21 952$t) `stocknumber` varchar(32) default NULL, -- inventory number (MARC21 952$i) `new_status` VARCHAR(32) DEFAULT NULL, -- 'new' value, you can put whatever free-text information. This field is intented to be managed by the automatic_item_modification_by_age cronjob. + `link_text` VARCHAR(200) DEFAULT NULL, -- text displayed when uri present in item record. PRIMARY KEY (`itemnumber`), UNIQUE KEY `itembarcodeidx` (`barcode`), KEY `itemstocknumberidx` (`stocknumber`), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index c3d9df3..9a0174b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -251,7 +251,7 @@
  • Dewey: [% dewey %]
  • [% END %] [% IF ( urlS ) %] -
  • URL: +
  • URL/Link: [% FOREACH url IN urlS %] [% url.url %] [% END %] @@ -338,7 +338,7 @@ Last seen Barcode [% IF ( volinfo ) %]Serial enumeration / chronology[% END %] - [% IF ( itemdata_uri ) %]URL[% END %] + [% IF ( itemdata_uri ) %]URL/Link[% END %] [% IF ( itemdata_copynumber ) %]Copy number[% END %] [% IF ( itemdata_stocknumber ) %]Inventory number[% END %] [% IF materials %]Materials specified[% END %] @@ -481,7 +481,11 @@ [% END %] [% IF ( itemdata_uri ) %] - [% item.uri %] + [% IF ( itemdata_linktext ) %] + [% item.link_text %] + [% ELSE %] + [% item.uri %] + [% END %] [% END %] [% IF ( itemdata_copynumber ) %] [% item.copynumber %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt index 270fc08..76efe61 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt @@ -1201,7 +1201,7 @@ [% IF ( itemdata_enumchron ) %] Vol info[% END %] [% IF ( itemdata_uri ) %] - URL[% END %] + URL/Link[% END %] [% IF ( itemdata_copynumber ) %] Copy number[% END %] Status @@ -1215,7 +1215,8 @@ Item hold queue priority [% END %] [% IF ( ShowCourseReservesHeader ) %] - Course reserves[% END %] + Course reserves + [% END %] @@ -1330,9 +1331,17 @@ [% ELSE %] [% IF Koha.Preference("OPACURLOpenInNewWindow") %] - [% ITEM_RESULT.uri %] + [% IF ITEM_RESULT.link_text %] + [% ITEM_RESULT.link_text %] + [% ELSE %] + [% ITEM_RESULT.uri %] + [% END %] [% ELSE %] - [% ITEM_RESULT.uri %] + [% IF ITEM_RESULT.link_text %] + [% ITEM_RESULT.link_text %] + [% ELSE %] + [% ITEM_RESULT.uri %] + [% END %] [% END %] [% END %] [% END %] diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index bdef7d8..bad60bd 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -686,7 +686,7 @@ if ( not $viewallitems and @items > $max_items_to_display ) { $itm->{'imageurl'} = getitemtypeimagelocation( 'opac', $itemtypes->{ $itm->{itype} }->{'imageurl'} ); $itm->{'description'} = $itemtypes->{ $itm->{itype} }->{translated_description}; } - foreach (qw(ccode enumchron copynumber itemnotes location_description uri)) { + foreach (qw(ccode enumchron copynumber itemnotes location_description uri link_text)) { $itemfields{$_} = 1 if ($itm->{$_}); } @@ -760,6 +760,7 @@ my $subtitle = GetRecordValue('subtitle', $record, GetFrameworkCode($bib itemdata_copynumber => $itemfields{copynumber}, itemdata_itemnotes => $itemfields{itemnotes}, itemdata_location => $itemfields{location_description}, + itemdata_linktext => $itemfields{link_text}, subtitle => $subtitle, OpacStarRatings => C4::Context->preference("OpacStarRatings"), ); -- 2.1.4