Bug 11944: replace uri_escape with uri_escape_utf8 everywhere
[koha.git] / authorities / authorities-home.pl
index f67f5c9..f41775c 100755 (executable)
@@ -31,6 +31,7 @@ use C4::AuthoritiesMarc;
 use C4::Acquisition;
 use C4::Koha;    # XXX subfield_is_koha_internal_p
 use C4::Biblio;
+use C4::Search::History;
 
 my $query = new CGI;
 my $dbh   = C4::Context->dbh;
@@ -60,7 +61,7 @@ foreach my $thisauthtype (
 if ( $op eq "delete" ) {
     ( $template, $loggedinuser, $cookie ) = get_template_and_user(
         {
-            template_name   => "authorities/authorities-home.tmpl",
+            template_name   => "authorities/authorities-home.tt",
             query           => $query,
             type            => 'intranet',
             authnotrequired => 0,
@@ -97,9 +98,10 @@ if ( $op eq "do_search" ) {
         $orderby
     );
 
+
     ( $template, $loggedinuser, $cookie ) = get_template_and_user(
         {
-            template_name   => "authorities/searchresultlist.tmpl",
+            template_name   => "authorities/searchresultlist.tt",
             query           => $query,
             type            => 'intranet',
             authnotrequired => 0,
@@ -108,6 +110,25 @@ if ( $op eq "do_search" ) {
         }
     );
 
+    # search history
+    if (C4::Context->preference('EnableSearchHistory')) {
+        if ( $startfrom == 1) {
+            my $path_info = $query->url(-path_info=>1);
+            my $query_cgi_history = $query->url(-query=>1);
+            $query_cgi_history =~ s/^$path_info\?//;
+            $query_cgi_history =~ s/;/&/g;
+
+            C4::Search::History::add({
+                userid => $loggedinuser,
+                sessionid => $query->cookie("CGISESSID"),
+                query_desc => $value,
+                query_cgi => $query_cgi_history,
+                total => $total,
+                type => "authority",
+            });
+        }
+    }
+
     $template->param(
         marclist       => $marclist,
         and_or         => $and_or,
@@ -125,7 +146,7 @@ if ( $op eq "do_search" ) {
     # next/previous would not work anymore
 
     # construction of the url of each page
-    my $value_url = uri_escape($value);
+    my $value_url = uri_escape_utf8($value);
     my $base_url = "authorities-home.pl?"
       ."marclist=$marclist"
       ."&and_or=$and_or"
@@ -168,7 +189,7 @@ if ( $op eq "do_search" ) {
 if ( $op eq '' ) {
     ( $template, $loggedinuser, $cookie ) = get_template_and_user(
         {
-            template_name   => "authorities/authorities-home.tmpl",
+            template_name   => "authorities/authorities-home.tt",
             query           => $query,
             type            => 'intranet',
             authnotrequired => 0,