9 use C4::Output; # no contains picktemplate
12 my $type=$query->param('type');
13 my ($loggedinuser, $cookie, $sessionID) = checkauth($query, ($type eq 'opac') ? (1) : (0));
16 my $language='french';
20 open (KC, "/etc/koha.conf");
24 if (/(.*)\s*=\s*(.*)/) {
27 # Clean up white space at beginning and end
32 $configfile{$variable}=$value;
35 #print $query->header;
37 my $includes=$configfile{'includes'};
38 ($includes) || ($includes="/usr/local/www/hdl/htdocs/includes");
39 my $templatebase="catalogue/searchresults.tmpl";
40 my $startfrom=$query->param('startfrom');
41 ($startfrom) || ($startfrom=0);
42 my $theme=picktemplate($includes, $templatebase);
44 my $subject=$query->param('subject');
45 # if its a subject we need to use the subject.tmpl
47 $templatebase=~ s/searchresults\.tmpl/subject\.tmpl/;
48 $theme=picktemplate($includes, $templatebase);
51 my $template = HTML::Template->new(filename => "$includes/templates/$theme/$templatebase", die_on_bad_params => 0, path => [$includes]);
56 # get all the search variables
57 # we assume that C4::Search will validate these values for us
59 my $keyword=$query->param('keyword');
60 $search{'keyword'}=$keyword;
62 $search{'subject'}=$subject;
63 my $author=$query->param('author');
64 $search{'author'}=$author;
65 $search{'authoresc'}=$author;
66 #$search{'authorhtmlescaped'}=~s/ /%20/g;
67 my $illustrator=$query->param('illustrator');
68 $search{'param'}=$illustrator;
69 my $itemnumber=$query->param('itemnumber');
70 $search{'itemnumber'}=$itemnumber;
71 my $isbn=$query->param('isbn');
72 $search{'isbn'}=$isbn;
73 my $datebefore=$query->param('date-before');
74 $search{'date-before'}=$datebefore;
75 my $class=$query->param('class');
76 $search{'class'}=$class;
77 my $dewey=$query->param('dewey');
79 my $branch=$query->param('branch');
80 $search{'branch'}=$branch;
81 my $title=$query->param('title');
82 $search{'title'}=$title;
83 my $abstract=$query->param('abstract');
84 $search{'abstract'}=$abstract;
85 my $publisher=$query->param('publisher');
86 $search{'publisher'}=$publisher;
88 my $ttype=$query->param('ttype');
89 $search{'ttype'}=$ttype;
92 ($keyword) && (push @$forminputs, { line => "keyword=$keyword"});
93 ($subject) && (push @$forminputs, { line => "subject=$subject"});
94 ($author) && (push @$forminputs, { line => "author=$author"});
95 ($illustrator) && (push @$forminputs, { line => "illustrator=$illustrator"});
96 ($itemnumber) && (push @$forminputs, { line => "itemnumber=$itemnumber"});
97 ($isbn) && (push @$forminputs, { line => "isbn=$isbn"});
98 ($datebefore) && (push @$forminputs, { line => "date-before=$datebefore"});
99 ($class) && (push @$forminputs, { line => "class=$class"});
100 ($dewey) && (push @$forminputs, { line => "dewey=$dewey"});
101 ($branch) && (push @$forminputs, { line => "branch=$branch"});
102 ($title) && (push @$forminputs, { line => "title=$title"});
103 ($ttype) && (push @$forminputs, { line => "ttype=$ttype"});
104 ($abstract) && (push @$forminputs, { line => "abstract=$abstract"});
105 ($publisher) && (push @$forminputs, { line => "publisher=$publisher"});
106 ($forminputs) || (@$forminputs=());
107 $template->param(FORMINPUTS => $forminputs);
109 # I think it is (or was) a search from the "front" page... [st]
110 $search{'front'}=$query->param('front');
115 if (my $subject=$query->param('subjectitems')) {
117 @results=subsearch(\$blah,$subject);
120 ($count,@results)=catalogsearch($env,'',\%search,$num,$startfrom);
123 #my $resultsarray=\@results;
126 foreach my $result (@results) {
127 $result->{'authorhtmlescaped'}=$result->{'author'};
128 $result->{'authorhtmlescaped'}=~s/ /%20/g;
129 ($result->{'copyrightdate'}==0) && ($result->{'copyrightdate'}='');
130 ($type eq 'opac') ? ($result->{'opac'}=1) : ($result->{'opac'}=0);
131 push (@$resultsarray, $result);
133 ($resultsarray) || (@$resultsarray=());
137 $search=$search."&keyword=$keyword";
138 $searchdesc.="keyword $keyword, ";
140 if (my $subjectitems=$query->param('subjectitems')){
141 $search=$search."&subjectitems=$subjectitems";
142 $searchdesc.="subject $subjectitems, ";
145 $search=$search."&subject=$subject";
146 $searchdesc.="subject $subject, ";
149 $search=$search."&author=$author";
150 $searchdesc.="author $author, ";
153 $search=$search."&class=$class";
154 $searchdesc.="class $class, ";
157 $search=$search."&title=$title";
158 $searchdesc.="title $title, ";
161 $search=$search."&dewey=$dewey";
162 $searchdesc.="dewey $dewey, ";
164 $search.="&ttype=$ttype";
167 $template->param(startfrom => $startfrom+1);
168 ($startfrom+$num<=$count) ? ($template->param(endat => $startfrom+$num)) : ($template->param(endat => $count));
169 $template->param(numrecords => $count);
170 my $nextstartfrom=($startfrom+$num<$count) ? ($startfrom+$num) : (-1);
171 my $prevstartfrom=($startfrom-$num>=0) ? ($startfrom-$num) : (-1);
172 $template->param(nextstartfrom => $nextstartfrom);
175 ($nextstartfrom==-1) ? ($displaynext=0) : ($displaynext=1);
176 ($prevstartfrom==-1) ? ($displayprev=0) : ($displayprev=1);
177 $template->param(displaynext => $displaynext);
178 $template->param(displayprev => $displayprev);
179 ($type eq 'opac') ? ($template->param(opac => 1)) : ($template->param(opac => 0));
180 $template->param(prevstartfrom => $prevstartfrom);
181 $template->param(search => $search);
182 $template->param(searchdesc => $searchdesc);
183 $template->param(SEARCH_RESULTS => $resultsarray);
184 $template->param(includesdir => $includes);
185 $template->param(loggedinuser => $loggedinuser);
190 for (my $i=1; $i<$count/10+1; $i++) {
191 ($title) && (push @$forminputs, { line => "title=$title"});
193 ($startfrom==($i-1)*10) && ($highlight=1);
195 foreach (@$forminputs) {
197 $formelements.="$line&";
199 $formelements=~s/ /+/g;
200 push @$numbers, { number => $i, highlight => $highlight , FORMELEMENTS => $formelements, FORMINPUTS => $forminputs, startfrom => ($i-1)*10, opac => (($type eq 'opac') ? (1) : (0))};
204 $template->param(numbers => $numbers);
208 print $query->header(-cookie => $cookie), $template->output;