From 4f043f3f7783c2457b38858e181b8dbd3b8b8ae6 Mon Sep 17 00:00:00 2001 From: Jared Camins-Esakov Date: Wed, 30 May 2012 16:29:54 -0400 Subject: [PATCH] Bug 3462: Links in authorities should be hyperlinks Make see also links in both the OPAC and authority module search results into hyperlinks and not just textual strings. To test: 1. Do a search for an authority that will bring up a heading with a see also reference in the staff client and the OPAC. 2. Confirm that the see also references listed in the search results are now hyperlinks, which work. Also quiets an unnecessary warning about an uninitialized value. Signed-off-by: Jared Camins-Esakov Rebased 26 July 2012 Signed-off-by: Jared Camins-Esakov Rebased on master 1 August 2012 Signed-off-by: Jared Camins-Esakov Rebased on master 6 August 2012 Signed-off-by: Jared Camins-Esakov Rebased on master 11 September 2012 Signed-off-by: Katrin Fischer Patch works nicely and is a great improvement. Tests: - Checked links for existing and non existing "see alsos" give correct search results - Verified links show up for all "see alsos" in a result list - Verified links are properly linked with the correct names - Checked logs don't show errors Signed-off-by: Paul Poulain --- C4/AuthoritiesMarc.pm | 48 +++++++++++++++---- .../includes/authorities-search-results.inc | 32 +++++++------ .../modules/authorities/searchresultlist.tt | 2 +- .../includes/authorities-search-results.inc | 32 +++++++------ .../opac-authoritiessearchresultlist.tt | 2 +- 5 files changed, 77 insertions(+), 39 deletions(-) diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index ba3c41b727..a4954ed215 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -945,7 +945,7 @@ sub BuildSummary { $summary{type} = $authref->{authtypetext}; $summary{summary} = $authref->{summary}; } - my $marc21subfields = 'abcdfghjklmnopqrstuvxyz'; + my $marc21subfields = 'abcdfghjklmnopqrstuvxyz68'; my %marc21controlrefs = ( 'a' => 'earlier', 'b' => 'later', 'd' => 'acronym', @@ -1023,11 +1023,29 @@ sub BuildSummary { # see : foreach my $field ($record->field('5..')) { if (($field->subfield('5')) && ($field->subfield('a')) && ($field->subfield('5') eq 'g')) { - push @seealso, { $field->as_string('abcdefgjxyz'), type => 'broader', field => $field->tag() }; + push @seealso, { + heading => $field->as_string('abcdefgjxyz'), + type => 'broader', + field => $field->tag(), + search => $field->as_string('abcdefgjxyz'), + authid => $field->subfield('9') + }; } elsif (($field->subfield('5')) && ($field->as_string) && ($field->subfield('5') eq 'h')){ - push @seealso, { heading => $field->as_string('abcdefgjxyz'), type => 'narrower', field => $field->tag() }; + push @seealso, { + heading => $field->as_string('abcdefgjxyz'), + type => 'narrower', + field => $field->tag(), + search => $field->as_string('abcdefgjxyz'), + authid => $field->subfield('9') + }; } elsif ($field->subfield('a')) { - push @seealso, { heading => $field->as_string('abcdefgxyz'), type => 'seealso', field => $field->tag() }; + push @seealso, { + heading => $field->as_string('abcdefgxyz'), + type => 'seealso', + field => $field->tag(), + search => $field->as_string('abcdefgjxyz'), + authid => $field->subfield('9') + }; } } # // form @@ -1079,28 +1097,40 @@ sub BuildSummary { } foreach my $field ($record->field('4..')) { #See From my $type = 'seefrom'; - $type = $marc21controlrefs{substr $field->subfield('w'), 0, 1} if ($field->subfield('w')); + $type = ($marc21controlrefs{substr $field->subfield('w'), 0, 1} || '') if ($field->subfield('w')); if ($type eq 'notapplicable') { $type = substr $field->subfield('w'), 2, 1; $type = 'earlier' if $type && $type ne 'n'; } if ($type eq 'subfi') { - push @seefrom, { heading => $field->as_string($marc21subfields), type => $field->subfield('i'), field => $field->tag() }; + push @seefrom, { heading => $field->as_string($marc21subfields), type => ($field->subfield('i') || ''), field => $field->tag() }; } else { push @seefrom, { heading => $field->as_string($marc21subfields), type => $type, field => $field->tag() }; } } foreach my $field ($record->field('5..')) { #See Also my $type = 'seealso'; - $type = $marc21controlrefs{substr $field->subfield('w'), 0, 1} if ($field->subfield('w')); + $type = ($marc21controlrefs{substr $field->subfield('w'), 0, 1} || '') if ($field->subfield('w')); if ($type eq 'notapplicable') { $type = substr $field->subfield('w'), 2, 1; $type = 'earlier' if $type && $type ne 'n'; } if ($type eq 'subfi') { - push @seealso, { heading => $field->as_string($marc21subfields), type => $field->subfield('i'), field => $field->tag() }; + push @seealso, { + heading => $field->as_string($marc21subfields), + type => $field->subfield('i'), + field => $field->tag(), + search => $field->as_string($marc21subfields) || '', + authid => $field->subfield('9') || '' + }; } else { - push @seealso, { heading => $field->as_string($marc21subfields), type => $type, field => $field->tag() }; + push @seealso, { + heading => $field->as_string($marc21subfields), + type => $type, + field => $field->tag(), + search => $field->as_string($marc21subfields) || '', + authid => $field->subfield('9') || '' + }; } } foreach my $field ($record->field('6..')) { diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/authorities-search-results.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/authorities-search-results.inc index 3defe48347..cd994439eb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/authorities-search-results.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/authorities-search-results.inc @@ -2,19 +2,22 @@ [% IF marcflavour == 'UNIMARC' %] [% SWITCH type %] [% CASE 'broader' %] - [% heading %] -- + [% heading | html %] -- [% CASE 'narrower' %] - [% heading %] -- + [% heading | html %] -- [% CASE 'narrower' %] - [% heading %] -- + [% heading | html %] -- [% CASE 'seefrom' %] - [% heading %] -- + [% heading | html %] -- [% CASE 'seealso' %] - [% heading %] -- + [% heading | html %] -- [% END %] [% ELSE %] - [% IF ( label ) %][% label %][% END %] - [% heading %] + [% IF ( label ) %][% label | html %][% END %] + + [% IF ( linkpath && search ) %][% heading | html %] + [% ELSE %][% heading | html %][% END %] + [% UNLESS ( type=='seefrom' || type=='seealso' ) %][% SWITCH type %] [% CASE 'earlier' %](Earlier heading) [% CASE 'later' %](Later heading) @@ -22,35 +25,36 @@ [% CASE 'musical' %](Musical composition) [% CASE 'broader' %](Broader heading) [% CASE 'narrower' %](Narrower heading) - [% CASE %]([% type %]) + [% CASE 'parent' %](Immediate parent body) + [% CASE %]([% type | html %]) [% END %][% END %] [% END %] [% END %] [% BLOCK authresult %] - [% IF ( summary.summary ) %][% summary.summary %]:[% END %] + [% IF ( summary.summary ) %][% summary.summary | html %]:[% END %] [% UNLESS ( summary.summaryonly ) %] [% FOREACH authorize IN summary.authorized %] - [% authorize.heading %] + [% authorize.heading | html %] [% END %] [% IF ( marcflavour == 'UNIMARC' ) %] [% FOREACH note IN summary.notes %] - [% note %] + [% note | html %] [% END %] [% FOREACH seefro IN summary.seefrom %] - [% PROCESS showreference heading=seefro.heading label="" type=seefro.type %] + [% PROCESS showreference heading=seefro.heading label="" type=seefro.type search='' %] [% END %] [% ELSE %] [% IF ( summary.seefrom ) %] [% FOREACH seefro IN summary.seefrom %]
- [% PROCESS showreference heading=seefro.heading label="used for/see from:" type=seefro.type %] + [% PROCESS showreference heading=seefro.heading label="used for/see from:" type=seefro.type search='' %]
[% END %] [% END %] [% IF ( summary.seealso ) %] [% FOREACH seeals IN summary.seealso %]
- [% PROCESS showreference heading=seeals.heading label="see also:" type=seeals.type %] + [% PROCESS showreference heading=seeals.heading label="see also:" type=seeals.type linkpath=link search=seeals.search %]
[% END %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt index 6ac139aa4d..c6035ef9f8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt @@ -66,7 +66,7 @@ function searchauthority() { [% ELSE %] [% END %] - [% PROCESS authresult summary=resul.summary %] + [% PROCESS authresult summary=resul.summary link="/cgi-bin/koha/authorities/authorities-home.pl?op=do_search&type=intranet&marclist=any&operator=contains&orderby=HeadingAsc&value=" %] Details [% UNLESS ( resul.isEDITORS ) %] diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/authorities-search-results.inc b/koha-tmpl/opac-tmpl/prog/en/includes/authorities-search-results.inc index 3defe48347..cd994439eb 100644 --- a/koha-tmpl/opac-tmpl/prog/en/includes/authorities-search-results.inc +++ b/koha-tmpl/opac-tmpl/prog/en/includes/authorities-search-results.inc @@ -2,19 +2,22 @@ [% IF marcflavour == 'UNIMARC' %] [% SWITCH type %] [% CASE 'broader' %] - [% heading %] -- + [% heading | html %] -- [% CASE 'narrower' %] - [% heading %] -- + [% heading | html %] -- [% CASE 'narrower' %] - [% heading %] -- + [% heading | html %] -- [% CASE 'seefrom' %] - [% heading %] -- + [% heading | html %] -- [% CASE 'seealso' %] - [% heading %] -- + [% heading | html %] -- [% END %] [% ELSE %] - [% IF ( label ) %][% label %][% END %] - [% heading %] + [% IF ( label ) %][% label | html %][% END %] + + [% IF ( linkpath && search ) %][% heading | html %] + [% ELSE %][% heading | html %][% END %] + [% UNLESS ( type=='seefrom' || type=='seealso' ) %][% SWITCH type %] [% CASE 'earlier' %](Earlier heading) [% CASE 'later' %](Later heading) @@ -22,35 +25,36 @@ [% CASE 'musical' %](Musical composition) [% CASE 'broader' %](Broader heading) [% CASE 'narrower' %](Narrower heading) - [% CASE %]([% type %]) + [% CASE 'parent' %](Immediate parent body) + [% CASE %]([% type | html %]) [% END %][% END %] [% END %] [% END %] [% BLOCK authresult %] - [% IF ( summary.summary ) %][% summary.summary %]:[% END %] + [% IF ( summary.summary ) %][% summary.summary | html %]:[% END %] [% UNLESS ( summary.summaryonly ) %] [% FOREACH authorize IN summary.authorized %] - [% authorize.heading %] + [% authorize.heading | html %] [% END %] [% IF ( marcflavour == 'UNIMARC' ) %] [% FOREACH note IN summary.notes %] - [% note %] + [% note | html %] [% END %] [% FOREACH seefro IN summary.seefrom %] - [% PROCESS showreference heading=seefro.heading label="" type=seefro.type %] + [% PROCESS showreference heading=seefro.heading label="" type=seefro.type search='' %] [% END %] [% ELSE %] [% IF ( summary.seefrom ) %] [% FOREACH seefro IN summary.seefrom %]
- [% PROCESS showreference heading=seefro.heading label="used for/see from:" type=seefro.type %] + [% PROCESS showreference heading=seefro.heading label="used for/see from:" type=seefro.type search='' %]
[% END %] [% END %] [% IF ( summary.seealso ) %] [% FOREACH seeals IN summary.seealso %]
- [% PROCESS showreference heading=seeals.heading label="see also:" type=seeals.type %] + [% PROCESS showreference heading=seeals.heading label="see also:" type=seeals.type linkpath=link search=seeals.search %]
[% END %] [% END %] diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-authoritiessearchresultlist.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-authoritiessearchresultlist.tt index 2f0f3a06ac..96fa3e032f 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-authoritiessearchresultlist.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-authoritiessearchresultlist.tt @@ -57,7 +57,7 @@ [% ELSE %] [% END %] - [% PROCESS authresult summary=resul.summary %] + [% PROCESS authresult summary=resul.summary link="/cgi-bin/koha/opac-authorities-home.pl?op=do_search&type=opac&operatorc=contains&marclistc=mainentry&and_orc=and&orderby=HeadingAsc&valuec=" %] [% resul.authtype %] [% UNLESS ( resul.isEDITORS ) %] -- 2.39.5