Bug 11516: make OPAC search term highlighting work in results browser
authorFridolin SOMERS <fridolin.somers@biblibre.com>
Fri, 10 Jan 2014 10:42:06 +0000 (11:42 +0100)
committerGalen Charlton <gmc@esilibrary.com>
Mon, 10 Mar 2014 21:30:38 +0000 (21:30 +0000)
When OpacHighlightedWords syspref is on, the current search terms are
highlighted in results and detail pages.

This workes in detail page with the URL param 'query_desc'.

This parameter must be managed in results browser (appears when
OpacBrowseResults syspref is on) links.

This patch adds query_desc parameter in results list and changes next
nd previous links to be build into TT instead of perl to manage
query_desc parameter only into TT.

Test plan :
- Edit sysprefs :  OpacHighlightedWords on, OpacBrowseResults on.
- Perform a search with a term existing into title
=> You see the term highlighted in search results
- Go to detail of a result with highlight
=> You see the term highlighted
- Click on "Next"
=> you see query_desc in URL, and if search term is present it is
   highlighted
- Same for "Previous"
- Click on "Browse results"
- Click on a result
=> you see query_desc in URL, and if search term is present it is
   highlighted

Signed-off-by: Aurélie <aurelie.fichot@gmail.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt
koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt
opac/opac-detail.pl

index 8c85f3b..6afb240 100644 (file)
                         </div>
                         <ul class="pg_menu clearfix">
                             <li class="left_results">
-                                [% IF ( previous ) %]<a href="[% previous |url %]" title="See: [% IF ( previousTitle ) %][% previousTitle |html %][% ELSE %]previous biblio[% END %]">&laquo; Previous</a>
+                                [% IF ( previousBiblionumber ) %]
+                                    <a href="opac-detail.pl?biblionumber=[% previousBiblionumber %][% IF ( query_desc && OpacHighlightedWords ) %]&query_desc=[% query_desc |uri %][% END %]" title="See: [% IF ( previousTitle ) %][% previousTitle |html %][% ELSE %]previous biblio[% END %]">&laquo; Previous</a>
                                 [% ELSE %]
                                     <span>Previous</span>
                                 [% END %]
                             </li>
                             <li class="back_results"><a href="opac-search.pl?[% busc |url %]" title="Back to the results search list">Back to results</a></li>
                             <li class="right_results">
-                                [% IF ( next ) %]<a href="[% next %]" title="See: [% IF ( nextTitle ) %][% nextTitle |html %][% ELSE %]next biblio[% END %]">Next &raquo;</a>
+                                [% IF ( nextBiblionumber ) %]
+                                    <a href="opac-detail.pl?biblionumber=[% nextBiblionumber %][% IF ( query_desc && OpacHighlightedWords ) %]&query_desc=[% query_desc |uri %][% END %]" title="See: [% IF ( nextTitle ) %][% nextTitle |html %][% ELSE %]next biblio[% END %]">Next &raquo;</a>
                                 [% ELSE %]
                                     <span>Next</span>
                                 [% END %]
         var pag_index_ini = [% indexPag %];
         [% IF ( listResults ) %]
             [% FOREACH listResult IN listResults %]
-                arrPagination[[% listResult.index %]] = {url:"[% listResult.url %]", title:"[% listResult.title|remove('\n')|html %]", author:"[% listResult.author|html %]", biblionumber:[% listResult.biblionumber %]};
+                arrPagination[[% listResult.index %]] = {
+                    url:"[% listResult.url %][% IF ( listResult.url && query_desc && OpacHighlightedWords ) %]&query_desc=[% query_desc |uri %][% END %]",
+                    title:"[% listResult.title|remove('\n')|html %]",
+                    author:"[% listResult.author|html %]",
+                    biblionumber:[% listResult.biblionumber %]
+                };
            [% END %]
         [% END %]
     [% END %]
index f60b3d7..fce873c 100644 (file)
         var pag_index_ini = [% indexPag %];
         [% IF ( listResults ) %]
             [% FOREACH listResult IN listResults %]
-                arrPagination[[% listResult.index %]] = {url:"[% listResult.url %]", title:"[% listResult.title|remove('\n')|html %]", author:"[% listResult.author|html %]", biblionumber:[% listResult.biblionumber %]};
+                arrPagination[[% listResult.index %]] = {
+                    url:"[% listResult.url %][% IF ( listResult.url && query_desc && OpacHighlightedWords ) %]&query_desc=[% query_desc |uri %][% END %]",
+                    title:"[% listResult.title|remove('\n')|html %]",
+                    author:"[% listResult.author|html %]",
+                    biblionumber:[% listResult.biblionumber %]
+                };
            [% END %]
         [% END %]
     [% END %]
@@ -1417,9 +1422,21 @@ YAHOO.util.Event.onContentReady("furtherm", function () {
     <div class="nav_results">
         <div class="l_Results">[% IF ( listResults ) %]<a href="#" id="a_listResults" title="Show pagination list ([% indexPag %]-[% indexPagEnd %] / [% totalPag %])">Browse results</a>[% ELSE %]<span>Browse results</span>[% END %]</div>
         <ul class="pg_menu clearfix">
-            <li class="left_results">[% IF ( previous ) %]<a href="[% previous %]" title="See: [% IF ( previousTitle ) %][% previousTitle |html %][% ELSE %]previous biblio[% END %]">&laquo; Previous</a>[% ELSE %]<span>Previous</span>[% END %]</li>
+            <li class="left_results">
+                [% IF ( previousBiblionumber ) %]
+                    <a href="opac-detail.pl?biblionumber=[% previousBiblionumber %][% IF ( query_desc && OpacHighlightedWords ) %]&query_desc=[% query_desc |uri %][% END %]" title="See: [% IF ( previousTitle ) %][% previousTitle |html %][% ELSE %]previous biblio[% END %]">&laquo; Previous</a>
+                [% ELSE %]
+                    <span>Previous</span>
+                [% END %]
+            </li>
             <li class="back_results"><a href="opac-search.pl?[% busc %]" title="Back to the results search list">Back to results</a></li>
-            <li class="right_results">[% IF ( next ) %]<a href="[% next %]" title="See: [% IF ( nextTitle ) %][% nextTitle |html %][% ELSE %]next biblio[% END %]">Next &raquo;</a>[% ELSE %]<span>Next</span>[% END %]</li>
+            <li class="right_results">
+                [% IF ( nextBiblionumber ) %]
+                    <a href="opac-detail.pl?biblionumber=[% nextBiblionumber %][% IF ( query_desc && OpacHighlightedWords ) %]&query_desc=[% query_desc |uri %][% END %]" title="See: [% IF ( nextTitle ) %][% nextTitle |html %][% ELSE %]next biblio[% END %]">Next &raquo;</a>
+                [% ELSE %]
+                    <span>Next</span>
+                [% END %]
+            </li>
         </ul>
         [% IF ( listResults ) %]
         <div class="pagination">
index 0c2a6d9..46f76fb 100755 (executable)
@@ -374,20 +374,21 @@ if ($session->param('busc')) {
         my $newbusc = rebuildBuscParam(\%arrParamsBusc);
         $session->param("busc" => $newbusc);
     }
-    my ($previous, $next, $dataBiblioPaging);
+    my ($numberBiblioPaging, $dataBiblioPaging);
     # Previous biblio
-    if ($paging{'previous'}->{biblionumber}) {
-        $previous = 'opac-detail.pl?biblionumber=' . $paging{'previous'}->{biblionumber}  . '&query_desc=' . $query->param('query_desc');
-        $dataBiblioPaging = GetBiblioData($paging{'previous'}->{biblionumber});
+    $numberBiblioPaging = $paging{'previous'}->{biblionumber};
+    if ($numberBiblioPaging) {
+        $template->param( 'previousBiblionumber' => $numberBiblioPaging );
+        $dataBiblioPaging = GetBiblioData($numberBiblioPaging);
         $template->param('previousTitle' => $dataBiblioPaging->{'title'}) if ($dataBiblioPaging);
     }
     # Next biblio
-    if ($paging{'next'}->{biblionumber}) {
-        $next = 'opac-detail.pl?biblionumber=' . $paging{'next'}->{biblionumber} . '&query_desc=' . $query->param('query_desc');
-        $dataBiblioPaging = GetBiblioData($paging{'next'}->{biblionumber});
+    $numberBiblioPaging = $paging{'next'}->{biblionumber};
+    if ($numberBiblioPaging) {
+        $template->param( 'nextBiblionumber' => $numberBiblioPaging );
+        $dataBiblioPaging = GetBiblioData($numberBiblioPaging);
         $template->param('nextTitle' => $dataBiblioPaging->{'title'}) if ($dataBiblioPaging);
     }
-    $template->param('previous' => $previous, 'next' => $next);
     # Partial list of biblio results
     my @listResults;
     for (my $j = 0; $j < @arrBiblios; $j++) {