Add Syndetics Summaries and TOC
[koha_fer] / opac / opac-search.pl
index 3a177af..f9d51f9 100755 (executable)
@@ -9,7 +9,7 @@ use strict;            # always use
 ## load Koha modules
 use C4::Context;
 use C4::Output;
-use C4::Auth;
+use C4::Auth qw(:DEFAULT get_session);
 use C4::Search;
 use C4::Biblio;  # GetBiblioData
 use C4::Koha;
@@ -116,11 +116,12 @@ if (C4::Context->preference('TagsEnabled')) {
 
 # load the branches
 my $branches = GetBranches();
-my @branch_loop;
-
-for my $branch_hash (sort keys %$branches) {
-    push @branch_loop, {value => "$branch_hash" , branchname => $branches->{$branch_hash}->{'branchname'}, };
-}
+# FIXME: next line duplicates GetBranchesLoop(0,0);
+my @branch_loop = map {
+                    {value => $_, branchname => $branches->{$_}->{branchname}}
+                } sort {
+                    $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname}
+                } keys %$branches;
 
 my $categories = GetBranchCategories(undef,'searchdomain');
 
@@ -133,18 +134,17 @@ my $itype_or_itemtype = (C4::Context->preference("item-level_itypes"))?'itype':'
 my @itemtypesloop;
 my $selected=1;
 my $cnt;
-my $imgdir = getitemtypeimagesrc('opac');
 my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes");
 
 if (!$advanced_search_types or $advanced_search_types eq 'itemtypes') {
        foreach my $thisitemtype ( sort {$itemtypes->{$a}->{'description'} cmp $itemtypes->{$b}->{'description'} } keys %$itemtypes ) {
     my %row =(  number=>$cnt++,
-                imageurl=> $itemtypes->{$thisitemtype}->{'imageurl'}?($imgdir."/".$itemtypes->{$thisitemtype}->{'imageurl'}):"",
                                ccl => $itype_or_itemtype,
                 code => $thisitemtype,
                 selected => $selected,
                 description => $itemtypes->{$thisitemtype}->{'description'},
                 count5 => $cnt % 4,
+                imageurl=> getitemtypeimagelocation( 'opac', $itemtypes->{$thisitemtype}->{'imageurl'} ),
             );
        $selected = 0 if ($selected) ;
        push @itemtypesloop, \%row;
@@ -155,12 +155,12 @@ if (!$advanced_search_types or $advanced_search_types eq 'itemtypes') {
        for my $thisitemtype (@$advsearchtypes) {
                my %row =(
                                number=>$cnt++,
-                imageurl=> $imgdir."/".$thisitemtype->{'imageurl'},
                                ccl => $advanced_search_types,
                 code => $thisitemtype->{authorised_value},
                 selected => $selected,
                 description => $thisitemtype->{'lib'},
                 count5 => $cnt % 4,
+                imageurl=> getitemtypeimagelocation( 'opac', $thisitemtype->{'imageurl'} ),
             );
                push @itemtypesloop, \%row;
        }
@@ -180,7 +180,12 @@ if ( $template_type eq 'advsearch' ) {
     
     my $secondary_servers_loop;# = displaySecondaryServers();
     $template->param(outer_sup_servers_loop => $secondary_servers_loop,);
-    
+
+    # set the default sorting
+    my $default_sort_by = C4::Context->preference('OPACdefaultSortField')."_".C4::Context->preference('OPACdefaultSortOrder') 
+        if (C4::Context->preference('OPACdefaultSortField') && C4::Context->preference('OPACdefaultSortOrder'));
+    $template->param($default_sort_by => 1);
+
     # determine what to display next to the search boxes (ie, boolean option
     # shouldn't appear on the first one, scan indexes should, adding a new
     # box should only appear on the last, etc.
@@ -335,7 +340,7 @@ sub _input_cgi_parse ($) {
     my @elements;
     for my $this_cgi ( split('&',shift) ) {
         next unless $this_cgi;
-        $this_cgi =~ /(.*)=(.*)/;
+        $this_cgi =~ /(.*?)=(.*)/;
         push @elements, { input_name => $1, input_value => $2 };
     }
     return @elements;
@@ -603,4 +608,25 @@ if ( C4::Context->preference("kohaspsuggest") ) {
 # see bug 2078.
 my $content_type = $cgi->param('format') =~ /rss|atom/ ? "application/xml" :
                    "text/html";
+
+# Build drop-down list for 'Add To:' menu...
+my $session = get_session($cgi->cookie("CGISESSID"));
+my @addpubshelves;
+my $pubshelves = $session->param('pubshelves');
+my $barshelves = $session->param('barshelves');
+foreach my $shelf (@$pubshelves) {
+       next if ( ($shelf->{'owner'} != ($borrowernumber ? $borrowernumber : -1)) && ($shelf->{'category'} < 3) );
+       push (@addpubshelves, $shelf);
+}
+
+if (defined @addpubshelves) {
+       $template->param( addpubshelves     => scalar (@addpubshelves));
+       $template->param( addpubshelvesloop => \@addpubshelves);
+}
+
+if (defined $barshelves) {
+       $template->param( addbarshelves     => scalar (@$barshelves));
+       $template->param( addbarshelvesloop => $barshelves);
+}
+
 output_html_with_http_headers $cgi, $cookie, $template->output, $content_type;