9 use C4::Output; # now contains picktemplate
12 #my $type=$query->param('type');
13 #(-e "opac") && ($type='opac');
16 my ($loggedinuser, $cookie, $sessionID) = checkauth($query, ($type eq 'opac') ? (1) : (0));
19 my $language='french';
23 open (KC, "/etc/koha.conf");
27 if (/(.*)\s*=\s*(.*)/) {
30 # Clean up white space at beginning and end
35 $configfile{$variable}=$value;
38 #print $query->header;
40 my $includes=$configfile{'includes'};
41 ($includes) || ($includes="/usr/local/www/hdl/htdocs/includes");
42 my $templatebase="opac/searchresults.tmpl";
43 my $startfrom=$query->param('startfrom');
44 ($startfrom) || ($startfrom=0);
45 my $theme=picktemplate($includes, $templatebase);
47 my $subject=$query->param('subject');
48 # if its a subject we need to use the subject.tmpl
50 $templatebase=~ s/searchresults\.tmpl/subject\.tmpl/;
51 $theme=picktemplate($includes, $templatebase);
54 my $template = HTML::Template->new(filename => "$includes/templates/$theme/$templatebase", die_on_bad_params => 0, path => [$includes]);
59 # get all the search variables
60 # we assume that C4::Search will validate these values for us
62 my $keyword=$query->param('keyword');
63 $search{'keyword'}=$keyword;
65 $search{'subject'}=$subject;
66 my $author=$query->param('author');
67 $search{'author'}=$author;
68 $search{'authoresc'}=$author;
69 #$search{'authorhtmlescaped'}=~s/ /%20/g;
70 my $illustrator=$query->param('illustrator');
71 $search{'param'}=$illustrator;
72 my $itemnumber=$query->param('itemnumber');
73 $search{'itemnumber'}=$itemnumber;
74 my $isbn=$query->param('isbn');
75 $search{'isbn'}=$isbn;
76 my $datebefore=$query->param('date-before');
77 $search{'date-before'}=$datebefore;
78 my $class=$query->param('class');
79 $search{'class'}=$class;
80 my $dewey=$query->param('dewey');
82 my $branch=$query->param('branch');
83 $search{'branch'}=$branch;
84 my $title=$query->param('title');
85 $search{'title'}=$title;
86 my $abstract=$query->param('abstract');
87 $search{'abstract'}=$abstract;
88 my $publisher=$query->param('publisher');
89 $search{'publisher'}=$publisher;
91 my $ttype=$query->param('ttype');
92 $search{'ttype'}=$ttype;
95 ($keyword) && (push @$forminputs, { line => "keyword=$keyword"});
96 ($subject) && (push @$forminputs, { line => "subject=$subject"});
97 ($author) && (push @$forminputs, { line => "author=$author"});
98 ($illustrator) && (push @$forminputs, { line => "illustrator=$illustrator"});
99 ($itemnumber) && (push @$forminputs, { line => "itemnumber=$itemnumber"});
100 ($isbn) && (push @$forminputs, { line => "isbn=$isbn"});
101 ($datebefore) && (push @$forminputs, { line => "date-before=$datebefore"});
102 ($class) && (push @$forminputs, { line => "class=$class"});
103 ($dewey) && (push @$forminputs, { line => "dewey=$dewey"});
104 ($branch) && (push @$forminputs, { line => "branch=$branch"});
105 ($title) && (push @$forminputs, { line => "title=$title"});
106 ($ttype) && (push @$forminputs, { line => "ttype=$ttype"});
107 ($abstract) && (push @$forminputs, { line => "abstract=$abstract"});
108 ($publisher) && (push @$forminputs, { line => "publisher=$publisher"});
109 ($forminputs) || (@$forminputs=());
110 $template->param(FORMINPUTS => $forminputs);
112 # I think it is (or was) a search from the "front" page... [st]
113 $search{'front'}=$query->param('front');
118 if (my $subject=$query->param('subjectitems')) {
120 @results=subsearch(\$blah,$subject);
123 ($count,@results)=catalogsearch($env,'',\%search,$num,$startfrom);
126 #my $resultsarray=\@results;
129 foreach my $result (@results) {
130 $result->{'authorhtmlescaped'}=$result->{'author'};
131 $result->{'authorhtmlescaped'}=~s/ /%20/g;
132 ($result->{'copyrightdate'}==0) && ($result->{'copyrightdate'}='');
133 ($type eq 'opac') ? ($result->{'opac'}=1) : ($result->{'opac'}=0);
134 push (@$resultsarray, $result);
136 ($resultsarray) || (@$resultsarray=());
140 $search=$search."&keyword=$keyword";
141 $searchdesc.="keyword $keyword, ";
143 if (my $subjectitems=$query->param('subjectitems')){
144 $search=$search."&subjectitems=$subjectitems";
145 $searchdesc.="subject $subjectitems, ";
148 $search=$search."&subject=$subject";
149 $searchdesc.="subject $subject, ";
152 $search=$search."&author=$author";
153 $searchdesc.="author $author, ";
156 $search=$search."&class=$class";
157 $searchdesc.="class $class, ";
160 $search=$search."&title=$title";
161 $searchdesc.="title $title, ";
164 $search=$search."&dewey=$dewey";
165 $searchdesc.="dewey $dewey, ";
167 $search.="&ttype=$ttype";
170 $template->param(startfrom => $startfrom+1);
171 ($startfrom+$num<=$count) ? ($template->param(endat => $startfrom+$num)) : ($template->param(endat => $count));
172 $template->param(numrecords => $count);
173 my $nextstartfrom=($startfrom+$num<$count) ? ($startfrom+$num) : (-1);
174 my $prevstartfrom=($startfrom-$num>=0) ? ($startfrom-$num) : (-1);
175 $template->param(nextstartfrom => $nextstartfrom);
178 ($nextstartfrom==-1) ? ($displaynext=0) : ($displaynext=1);
179 ($prevstartfrom==-1) ? ($displayprev=0) : ($displayprev=1);
180 $template->param(displaynext => $displaynext);
181 $template->param(displayprev => $displayprev);
182 ($type eq 'opac') ? ($template->param(opac => 1)) : ($template->param(opac => 0));
183 $template->param(prevstartfrom => $prevstartfrom);
184 $template->param(search => $search);
185 $template->param(searchdesc => $searchdesc);
186 $template->param(SEARCH_RESULTS => $resultsarray);
187 $template->param(includesdir => $includes);
188 $template->param(loggedinuser => $loggedinuser);
193 for (my $i=1; $i<$count/10+1; $i++) {
194 ($title) && (push @$forminputs, { line => "title=$title"});
196 ($startfrom==($i-1)*10) && ($highlight=1);
198 foreach (@$forminputs) {
200 $formelements.="$line&";
202 $formelements=~s/ /+/g;
203 push @$numbers, { number => $i, highlight => $highlight , FORMELEMENTS => $formelements, FORMINPUTS => $forminputs, startfrom => ($i-1)*10, opac => (($type eq 'opac') ? (1) : (0))};
207 $template->param(numbers => $numbers);
211 print $query->header(-cookie => $cookie), $template->output;