Bug 8332: Add relationships to auth_finder for authority links
authorJared Camins-Esakov <jcamins@cpbibliography.com>
Thu, 28 Jun 2012 22:25:55 +0000 (18:25 -0400)
committerPaul Poulain <paul.poulain@biblibre.com>
Mon, 3 Sep 2012 10:45:44 +0000 (12:45 +0200)
In addition to the work in bug 8207 that enables auth_finder use, it
would be very useful when creating authorities to have the auth_finder
plugin automatically fill out the relationship information in $w (in
MARC21).

To test (note that you must either apply the patch for bug 8207 or
manually add a thesaurus to a 5xx linking field in one of the authority
type frameworks):
1. Create a new authority record.
2. Go to the 5xx tab.
3. Click the authority control plugin ellipsis.
4. Do a search for an authority.
5. Select a relationship type.
6. Note that after you choose an authority, that the $w control field
   is automatically populated with the relationship type.

Signed-off-by: Frédéric Demians <f.demians@tamil.fr>
After applying patch for bug 8207, I had been able to follow the test plan step
by step, and get the expected result.

Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
Rebased on master 1 August 2012

authorities/auth_finder.pl
authorities/blinddetail-biblio-search.pl
koha-tmpl/intranet-tmpl/prog/en/includes/auth-finder-search.inc
koha-tmpl/intranet-tmpl/prog/en/includes/form-blocks.inc [new file with mode: 0644]
koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt
koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist-auth.tt

index a3821ee..8182299 100755 (executable)
@@ -35,6 +35,7 @@ my $authtypecode = $query->param('authtypecode');
 my $index        = $query->param('index');
 my $tagid        = $query->param('tagid');
 my $resultstring = $query->param('result');
+my $relationship = $query->param('relationship');
 my $dbh          = C4::Context->dbh;
 
 my $startfrom = $query->param('startfrom');
@@ -192,6 +193,9 @@ $template->param(
     authtypecode  => $authtypecode,
 );
 
+$template->{VARS}->{source} = $query->param('source') || '';
+$template->{VARS}->{relationship} = $query->param('relationship') || '';
+
 # Print the page
 output_html_with_http_headers $query, $cookie, $template->output;
 
index 7de7db3..4aa2093 100755 (executable)
@@ -54,6 +54,7 @@ my $dbh = C4::Context->dbh;
 my $authid       = $query->param('authid');
 my $index        = $query->param('index');
 my $tagid        = $query->param('tagid');
+my $relationship = $query->param('relationship');
 my $authtypecode = &GetAuthTypeCode($authid);
 my $tagslib      = &GetTagsLabels( 1, $authtypecode );
 
@@ -95,6 +96,8 @@ if ($authid) {
         my $letter = $_ || '@';
         push( @subfield_loop, {marc_subfield => $letter, marc_values => $subfields{$_}} );
     }
+
+    push( @subfield_loop, { marc_subfield => 'w', marc_values => $relationship } ) if ( $relationship );
 }
 else {
     # authid is empty => the user want to empty the entry.
index fe22d6b..4114dfc 100644 (file)
@@ -1,3 +1,4 @@
+[% PROCESS 'form-blocks.inc' %]
 <script type="text/javascript">
 //<![CDATA[
 
@@ -100,10 +101,12 @@ function finderjumpfull(page)
 
 
 <form name="f" method="get" action="auth_finder.pl">
+            <input type="hidden" name="source" value="[% source %]" />
             <input type="hidden" name="op" value="do_search" />
             <input type="hidden" name="type" value="intranet" />
             <input type="hidden" name="index" value="[% index %]" />
-                <fieldset class="rows"><ol><li>
+                <fieldset class="rows"><legend>Search options</legend>
+                <ol><li>
                     <span class="label">Authority type</span>
                     [% authtypecode %]
                     <input type="hidden" name="authtypecode" value="[% authtypecode %]" />
@@ -169,10 +172,33 @@ function finderjumpfull(page)
             <option value="HeadingDsc">Heading descendant</option>
         </select>
         </li></ol></fieldset>
-            <fieldset class="action"> <input type="submit" value="Start search" class="submit" id="search" /> <a id="cancel" class="cancel close" href="#">Cancel</a>
-            <span id="authfinderops">
-            <a href="javascript:finderjumpfull('blinddetail-biblio-search.pl?authid=0&amp;index=[% index %]')" id="clear" class="button">Clear field</a>
-            <a href="javascript:finderjumpfull('authorities.pl?index=[% index %]&authtypecode=[% authtypecode %]')" id="createnew" class="button">Create new</a>
-            </span>
-            </fieldset>
+        [% IF source == 'auth' %]
+        <fieldset class="rows"><legend>Relationship information</legend>
+            <ol>
+            <li>
+                <label for="relationship">Special relationship: </label>
+                <select name="relationship" id="relationship">
+                    [% selected=relationship %]
+                    [% PROCESS selectoption value='' text='None specified' %]
+                    [% PROCESS selectoption value='a' text='a - Earlier heading' %]
+                    [% PROCESS selectoption value='b' text='b - Later heading' %]
+                    [% PROCESS selectoption value='d' text='d - Acronym' %]
+                    [% PROCESS selectoption value='f' text='f - Musical composition' %]
+                    [% PROCESS selectoption value='g' text='g - Broader term' %]
+                    [% PROCESS selectoption value='h' text='h - Narrower term' %]
+                    [% PROCESS selectoption value='i' text='i - Reference instruction phrase in subfield $i' %]
+                    [% PROCESS selectoption value='n' text='n - Not applicable' %]
+                    [% PROCESS selectoption value='r' text='r - Relationship designation in $i or $4' %]
+                    [% PROCESS selectoption value='t' text='t - Immediate parent body' %]
+                </select>
+            </li>
+            </ol>
+        </fieldset>
+        [% END %]
+        <fieldset class="action"> <input type="submit" value="Start search" class="submit" id="search" /> <a id="cancel" class="cancel close" href="#">Cancel</a>
+        <span id="authfinderops">
+        <a href="javascript:finderjumpfull('blinddetail-biblio-search.pl?authid=0&amp;index=[% index %]')" id="clear" class="button">Clear field</a>
+        <a href="javascript:finderjumpfull('authorities.pl?index=[% index %]&authtypecode=[% authtypecode %]')" id="createnew" class="button">Create new</a>
+        </span>
+        </fieldset>
 </form>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/form-blocks.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/form-blocks.inc
new file mode 100644 (file)
index 0000000..4999eec
--- /dev/null
@@ -0,0 +1,5 @@
+[% BLOCK selectoption %]
+    [% IF value == selected %]<option value='[% value %]' selected='selected'>[% text %]</option>
+    [% ELSE %]<option value='[% value %]'>[% text %]</option>
+    [% END %]
+[% END %]
index 352d518..d0c4329 100644 (file)
@@ -153,7 +153,7 @@ function openAuth(tagsubfieldid,authtype) {
             }      
         }
     }           
-       newin=window.open("../authorities/auth_finder.pl?authtypecode="+  authtype+ "&index="+tagsubfieldid+"&value_mainstr="+encodeURI(mainmainstring)+"&value_main="+encodeURI(mainstring), "_blank",'width=700,height=550,toolbar=false,scrollbars=yes');
+    newin=window.open("../authorities/auth_finder.pl?source=auth&authtypecode="+  authtype+ "&index="+tagsubfieldid+"&value_mainstr="+encodeURI(mainmainstring)+"&value_main="+encodeURI(mainstring), "_blank",'width=700,height=550,toolbar=false,scrollbars=yes');
 }
 
 function AddField(field,cntrepeatfield) {
index 8008930..415185a 100644 (file)
@@ -11,6 +11,18 @@ function jumpfull(page)
 {      
     window.open(page,'','fullscreen,scrollbars');
 }
+
+function doauth(authid, index, repet)
+{
+[% IF source == 'auth' %]
+    var e = document.getElementById("relationship");
+    var relationship = e.options[e.selectedIndex].value;
+
+    jumpfull('blinddetail-biblio-search.pl?authid=' + authid + '&index=' + index + '&repet=' + repet + '&relationship=' + relationship);
+[% ELSE %]
+    jumpfull('blinddetail-biblio-search.pl?authid=' + authid + '&index=' + index + '&repet=' + repet);
+[% END %]
+}
 </script>
 </head>
 <body id="auth_searchresultlist_auth" class="auth">
@@ -63,10 +75,10 @@ function jumpfull(page)
                         <td>
                           [% IF resul.repets %]
                             [% FOREACH repet IN resul.repets %]
-                            <a href="javascript:jumpfull('blinddetail-biblio-search.pl?authid=[% resul.authid %]&amp;index=[% repet.index %]&amps;repet=[% repet.repet %]')" title="[% repet.value %]">[% repet.repet %]</a>
+                            <a href="javascript:doauth('[% resul.authid %]', '[% repet.index %]', '[% repet.repet %]')" title="[% repet.value %]">[% repet.repet %]</a>
                             [% END %]
                           [% ELSE %]
-                            <a href="javascript:jumpfull('blinddetail-biblio-search.pl?authid=[% resul.authid %]&amp;index=[% index %]')">Choose</a>
+                            <a href="javascript:doauth('[% resul.authid %]', '[% index %]', '')">choose</a>
                           [% END %]
                         </td>
                         <td><a href="authorities.pl?authid=[% resul.authid %]">Edit authority</a></td>