From 99ae34ba51677b09a7be97fd671db85bfede02a4 Mon Sep 17 00:00:00 2001
From: Tomas Cohen Arazi <tomascohen@gmail.com>
Date: Wed, 18 Sep 2013 11:33:07 -0300
Subject: [PATCH] Bug 10691: 5xx not properly linked by authid in authority
 search result list

This patch changes the URL and data used to show the 'see from' and 'see also' links
on the OPAC's authority search results page.

Bonus points: makes some strings translatable.

To test:
- On your dev setup (master) create some authority records (i created personal name authorities).
- Pick one of them and link 400$a to another one, do the same with 500$a
- Make sure zebra is running and changes got indexed.
- In the OPAC search for the authority that is linked to the others.
- Check the 'see also:' link points to an authority search
- Apply the patch
- Reload/re-do the search
- Check the 'see also:' link points to the authority id.

Regards
To+

Sponsored-by: Universidad Nacional de Cordoba
---
 .../en/includes/authorities-search-results.inc     |   55 +++++++++++++-----
 .../en/modules/opac-authoritiessearchresultlist.tt |   61 ++++++++++----------
 2 files changed, 72 insertions(+), 44 deletions(-)

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 6e6db3c..44c9e27 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
@@ -11,21 +11,35 @@
             <span class="RT">RT: [% heading | html %]</span>
         [% END %]
     [% ELSE %]
-        [% IF ( label ) %]<span class="label">[% label | html %]</span>[% END %]
+        <span class="label">
+        [% IF ( type=='seefrom' ) %]
+            used for/see from:
+        [% ELSIF  ( type=='seealso' ) %]
+            see also:
+        [% END %]
+        </span>
         <span class="heading">
-        [% IF ( linkpath && search ) %]<a href="[% link | url %][% search | url %]">[% heading | html %]</a>
-        [% ELSE %][% heading | html %][% END %]
+        [% IF ( linkpath && search ) %]
+            <a href="[% link | url %][% authid | url %]">[% heading | html %]</a>
+        [% ELSE %]
+            [% heading | html %]
+        [% END %]
         </span>
-        [% UNLESS ( type=='seefrom' || type=='seealso' ) %]<span class="type">[% SWITCH type %]
-        [% CASE 'earlier' %](Earlier heading)
-        [% CASE 'later' %](Later heading)
-        [% CASE 'acronym' %](Acronym)
-        [% CASE 'musical' %](Musical composition)
-        [% CASE 'broader' %](Broader heading)
-        [% CASE 'narrower' %](Narrower heading)
-        [% CASE 'parent' %](Immediate parent body)
-        [% CASE %][% IF type %]([% type | html %])[% END %]
-        [% END %]</span>[% END %]
+        [% UNLESS ( type=='seefrom' || type=='seealso' ) %]
+        <span class="type">
+            [% SWITCH type %]
+            [% CASE 'earlier' %](Earlier heading)
+            [% CASE 'later' %](Later heading)
+            [% CASE 'acronym' %](Acronym)
+            [% CASE 'musical' %](Musical composition)
+            [% CASE 'broader' %](Broader heading)
+            [% CASE 'narrower' %](Narrower heading)
+            [% CASE 'parent' %](Immediate parent body)
+            [% CASE %][% IF type %]([% type | html %])
+            [% END %]
+        [% END %]
+        </span>
+        [% END %]
     [% END %]
 [% END %]
 [% BLOCK authresult %]
@@ -65,14 +79,25 @@
             [% IF ( summary.seefrom ) %]
                 [% FOREACH seefro IN summary.seefrom %]
                     <div class="seefrom authref">
-                    [% PROCESS showreference heading=seefro.heading label="used for/see from:" type=seefro.type search='' %]
+                    [% PROCESS showreference
+                        heading=seefro.heading
+                        type=seefro.type
+                        search=''
+                        authid=seefro.authid
+                    %]
                     </div>
                 [% END %]
             [% END %]
             [% IF ( summary.seealso ) %]
                 [% FOREACH seeals IN summary.seealso %]
                     <div class="seealso authref">
-                    [% PROCESS showreference heading=seeals.heading label="see also:" type=seeals.type linkpath=link search=seeals.search %]
+                    [% PROCESS showreference
+                        heading=seeals.heading
+                        type=seeals.type
+                        linkpath=link
+                        search=seeals.search
+                        authid=seeals.authid
+                    %]
                     </div>
                 [% 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 71ad40e..1bbaac5 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-authoritiessearchresultlist.tt
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-authoritiessearchresultlist.tt
@@ -44,35 +44,38 @@
 
 			[% IF ( total ) %]
 <div class="searchresults">
-		<table>
-			<tr>
-                <th>Authorized headings</th>
-                <th>Type of heading</th>
-				[% UNLESS ( isEDITORS ) %]
-                    <th>Biblio records</th>
-				[% END %]
-                <th>Full heading</th>
-			</tr>
-			[% FOREACH resul IN result %]
-            [% UNLESS ( loop.odd ) %]
-                <tr class="highlight">
-            [% ELSE %]
-                <tr>
-            [% END %]
-                    <td>[% 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=" %]</td>
-                    <td>[% resul.authtype %]</td>
-					[% UNLESS ( resul.isEDITORS ) %]
-						<td>
-							 <a href="/cgi-bin/koha/opac-search.pl?type=opac&amp;op=do_search&amp;q=an=[% resul.authid %]">[% resul.used %] biblios</a>
-						</td>
-					[% END %]
-						<td>
-                            <a href="opac-authoritiesdetail.pl?authid=[% resul.authid %]">View full heading</a>
-						</td>
-				</tr>
-			[% END %]
-		</table>
-	</div>
+    <table>
+        <tr>
+            <th>Authorized headings</th>
+            <th>Type of heading</th>
+        [% UNLESS ( isEDITORS ) %]
+            <th>Biblio records</th>
+        [% END %]
+            <th>Full heading</th>
+        </tr>
+[% FOREACH resul IN result %]
+    [% UNLESS ( loop.odd ) %]
+        <tr class="highlight">
+    [% ELSE %]
+        <tr>
+    [% END %]
+            <td>[% PROCESS authresult
+                    summary=resul.summary
+                    link="/cgi-bin/koha/opac-authoritiesdetail.pl?authid="
+                %]</td>
+            <td>[% resul.authtype %]</td>
+        [% UNLESS ( resul.isEDITORS ) %]
+            <td>
+                <a href="/cgi-bin/koha/opac-search.pl?type=opac&amp;op=do_search&amp;q=an=[% resul.authid %]">[% resul.used %] biblios</a>
+            </td>
+        [% END %]
+            <td>
+                <a href="opac-authoritiesdetail.pl?authid=[% resul.authid %]">View full heading</a>
+            </td>
+        </tr>
+[% END %]
+    </table>
+</div>
 	<div id="resultnumber">
 			[% IF ( displayprev ) %]
 				<a href="opac-authorities-home.pl?startfrom=[% startfromprev %]&amp;[% FOREACH searchdat IN searchdata %][% searchdat.term %]=[% searchdat.val |url %]&amp;[% END %]resultsperpage=[% resultsperpage %]&amp;type=opac&amp;op=do_search&amp;authtypecode=[% authtypecode %]&amp;orderby=[% orderby %]">&lt;&lt;</a>
-- 
1.7.9.5