Bugzilla – Attachment 67706 Details for
Bug 19360
Give items URL a link text
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19360 - Give items URL a link text
Bug-19360---Give-items-URL-a-link-text.patch (text/plain), 10.64 KB, created by
David Bourgault
on 2017-10-06 13:31:14 UTC
(
hide
)
Description:
Bug 19360 - Give items URL a link text
Filename:
MIME Type:
Creator:
David Bourgault
Created:
2017-10-06 13:31:14 UTC
Size:
10.64 KB
patch
obsolete
>From d28764c77397627915acbd2038a9d73dfc5ed362 Mon Sep 17 00:00:00 2001 >From: Alex Buckley <alexbuckley@catalyst.net.nz> >Date: Sun, 24 Sep 2017 15:12:47 +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 <david.bourgault@inlibro.com> >--- > C4/Items.pm | 5 ++++- > Koha/Schema/Result/Item.pm | 8 ++++++++ > catalogue/detail.pl | 3 ++- > .../intranet-tmpl/prog/en/modules/catalogue/detail.tt | 10 +++++++--- > koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt | 14 +++++++++++--- > opac/opac-detail.pl | 6 ++++-- > 6 files changed, 36 insertions(+), 10 deletions(-) > >diff --git a/C4/Items.pm b/C4/Items.pm >index b64aa60..fbd209f 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -478,6 +478,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 ) { >@@ -1789,7 +1790,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 }); >@@ -1834,6 +1836,7 @@ sub _koha_new_item { > $item->{'copynumber'}, > $item->{'stocknumber'}, > $item->{'new_status'}, >+ $item->{'link_text'} > ); > > my $itemnumber; >diff --git a/Koha/Schema/Result/Item.pm b/Koha/Schema/Result/Item.pm >index ce85bd7..33a2b7b 100644 >--- a/Koha/Schema/Result/Item.pm >+++ b/Koha/Schema/Result/Item.pm >@@ -280,6 +280,12 @@ __PACKAGE__->table("items"); > is_nullable: 1 > size: 32 > >+=head2 link_text >+ >+ data_type: 'varchar' >+ is_nullable: 1 >+ size: 200 >+ > =cut > > __PACKAGE__->add_columns( >@@ -394,6 +400,8 @@ __PACKAGE__->add_columns( > { data_type => "varchar", is_nullable => 1, size => 32 }, > "new_status", > { data_type => "varchar", is_nullable => 1, size => 32 }, >+ "link_text", >+ { data_type => "varchar", is_nullable => 1, size => 200 }, > ); > > =head1 PRIMARY KEY >diff --git a/catalogue/detail.pl b/catalogue/detail.pl >index 1e18a1d..3414609 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/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >index be5932b..d4b4bf6 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 @@ > <li><strong>Dewey:</strong> [% dewey %]</li> > [% END %] > [% IF ( urlS ) %] >- <li><strong>URL:</strong> >+ <li><strong>URL/Link:</strong> > [% FOREACH url IN urlS %] > <a href="[% url.url %]">[% url.url %]</a> > [% END %] >@@ -338,7 +338,7 @@ > <th>Last seen</th> > <th>Barcode</th> > [% IF ( volinfo ) %]<th>Serial enumeration / chronology</th>[% END %] >- [% IF ( itemdata_uri ) %]<th>URL</th>[% END %] >+ [% IF ( itemdata_uri ) %]<th>URL/Link</th>[% END %] > [% IF ( itemdata_copynumber ) %]<th>Copy number</th>[% END %] > [% IF ( itemdata_stocknumber ) %]<th>Inventory number</th>[% END %] > [% IF materials %]<th>Materials specified</th>[% END %] >@@ -481,7 +481,11 @@ > </td> > [% END %] > [% IF ( itemdata_uri ) %] >- <td class="uri"><a href="[% item.uri %]">[% item.uri %]</a></td> >+ [% IF ( itemdata_linktext ) %] >+ <td class="uri"><a href="[% item.uri %]">[% item.link_text %]</a></td> >+ [% ELSE %] >+ <td class="uri"><a href="[% item.uri %]">[% item.uri %]</a></td> >+ [% END %] > [% END %] > [% IF ( itemdata_copynumber ) %] > <td class="copynumber">[% item.copynumber %]</td> >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 9d1f2b9..1c11b8d 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >@@ -1191,7 +1191,7 @@ > [% IF ( itemdata_ccode ) %]<th id="item_ccode" class="collection">Collection</th>[% END %] > <th id="item_callnumber" class="call_no">Call number</th> > [% IF ( itemdata_enumchron ) %]<th id="item_enumchron" class="vol_info">Vol info</th>[% END %] >- [% IF ( itemdata_uri ) %]<th id="item_url" class="url">URL</th>[% END %] >+ [% IF ( itemdata_uri ) %]<th id="item_url" class="url">URL/Link</th>[% END %] > [% IF ( itemdata_copynumber ) %]<th id="item_copy" class="copynumber">Copy number</th>[% END %] > <th id="item_status" class="status">Status</th> > [% IF ( itemdata_itemnotes ) %]<th id="item_notes" class="notes">Notes</th>[% END %] >@@ -1317,9 +1317,17 @@ > > [% ELSE %] > [% IF Koha.Preference("OPACURLOpenInNewWindow") %] >- <a target="_blank" rel="noreferrer" href="[% ITEM_RESULT.uri %]" property="url">[% ITEM_RESULT.uri %]</a> >+ [% IF ITEM_RESULT.link_text %] >+ <a target="_blank" rel="noreferrer" href="[% ITEM_RESULT.uri %]" property="url">[% ITEM_RESULT.link_text %]</a> >+ [% ELSE %] >+ <a target="_blank" rel="noreferrer" href="[% ITEM_RESULT.uri %]" property="url">[% ITEM_RESULT.uri %]</a> >+ [% END %] > [% ELSE %] >- <a href="[% ITEM_RESULT.uri %]" property="url">[% ITEM_RESULT.uri %]</a> >+ [% IF ITEM_RESULT.link_text %] >+ <a href="[% ITEM_RESULT.uri %]" property="url">[% ITEM_RESULT.link_text %]</a> >+ [% ELSE %] >+ <a href="[% ITEM_RESULT.uri %]" property="url">[% ITEM_RESULT.uri %]</a> >+ [% END %] > [% END %] > [% END %] > [% END %] >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index 8252e50..d295d0a 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -685,7 +685,8 @@ 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 uri)) { >+ >+ foreach (qw(ccode enumchron copynumber itemnotes uri link_text)) { > $itemfields{$_} = 1 if ($itm->{$_}); > } > >@@ -759,7 +760,8 @@ my $subtitle = GetRecordValue('subtitle', $record, GetFrameworkCode($bib > itemdata_enumchron => $itemfields{enumchron}, > itemdata_uri => $itemfields{uri}, > itemdata_copynumber => $itemfields{copynumber}, >- itemdata_itemnotes => $itemfields{itemnotes}, >+ itemdata_itemnotes => $itemfields{itemnotes}, >+ itemdata_linktext => $itemfields{link_text}, > subtitle => $subtitle, > OpacStarRatings => C4::Context->preference("OpacStarRatings"), > ); >-- >2.7.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 19360
:
67343
|
67662
|
67706
|
67707
|
67711
|
70967
|
70968
|
70969