9 use C4::Output; # no contains picktemplate
12 my $type=$query->param('type');
13 (-e "opac") && ($type='opac');
15 my ($loggedinuser, $cookie, $sessionID) = checkauth($query, ($type eq 'opac') ? (1) : (0));
18 my $language='french';
22 open (KC, "/etc/koha.conf");
26 if (/(.*)\s*=\s*(.*)/) {
29 # Clean up white space at beginning and end
34 $configfile{$variable}=$value;
37 #print $query->header;
39 my $includes=$configfile{'includes'};
40 ($includes) || ($includes="/usr/local/www/hdl/htdocs/includes");
41 my $templatebase="catalogue/searchresults.tmpl";
42 my $startfrom=$query->param('startfrom');
43 ($startfrom) || ($startfrom=0);
44 my $theme=picktemplate($includes, $templatebase);
46 my $subject=$query->param('subject');
47 # if its a subject we need to use the subject.tmpl
49 $templatebase=~ s/searchresults\.tmpl/subject\.tmpl/;
50 $theme=picktemplate($includes, $templatebase);
53 my $template = HTML::Template->new(filename => "$includes/templates/$theme/$templatebase", die_on_bad_params => 0, path => [$includes]);
58 # get all the search variables
59 # we assume that C4::Search will validate these values for us
61 my $keyword=$query->param('keyword');
62 $search{'keyword'}=$keyword;
64 $search{'subject'}=$subject;
65 my $author=$query->param('author');
66 $search{'author'}=$author;
67 $search{'authoresc'}=$author;
68 #$search{'authorhtmlescaped'}=~s/ /%20/g;
69 my $illustrator=$query->param('illustrator');
70 $search{'param'}=$illustrator;
71 my $itemnumber=$query->param('itemnumber');
72 $search{'itemnumber'}=$itemnumber;
73 my $isbn=$query->param('isbn');
74 $search{'isbn'}=$isbn;
75 my $datebefore=$query->param('date-before');
76 $search{'date-before'}=$datebefore;
77 my $class=$query->param('class');
78 $search{'class'}=$class;
79 my $dewey=$query->param('dewey');
81 my $branch=$query->param('branch');
82 $search{'branch'}=$branch;
83 my $title=$query->param('title');
84 $search{'title'}=$title;
85 my $abstract=$query->param('abstract');
86 $search{'abstract'}=$abstract;
87 my $publisher=$query->param('publisher');
88 $search{'publisher'}=$publisher;
90 my $ttype=$query->param('ttype');
91 $search{'ttype'}=$ttype;
94 ($keyword) && (push @$forminputs, { line => "keyword=$keyword"});
95 ($subject) && (push @$forminputs, { line => "subject=$subject"});
96 ($author) && (push @$forminputs, { line => "author=$author"});
97 ($illustrator) && (push @$forminputs, { line => "illustrator=$illustrator"});
98 ($itemnumber) && (push @$forminputs, { line => "itemnumber=$itemnumber"});
99 ($isbn) && (push @$forminputs, { line => "isbn=$isbn"});
100 ($datebefore) && (push @$forminputs, { line => "date-before=$datebefore"});
101 ($class) && (push @$forminputs, { line => "class=$class"});
102 ($dewey) && (push @$forminputs, { line => "dewey=$dewey"});
103 ($branch) && (push @$forminputs, { line => "branch=$branch"});
104 ($title) && (push @$forminputs, { line => "title=$title"});
105 ($ttype) && (push @$forminputs, { line => "ttype=$ttype"});
106 ($abstract) && (push @$forminputs, { line => "abstract=$abstract"});
107 ($publisher) && (push @$forminputs, { line => "publisher=$publisher"});
108 ($forminputs) || (@$forminputs=());
109 $template->param(FORMINPUTS => $forminputs);
111 # I think it is (or was) a search from the "front" page... [st]
112 $search{'front'}=$query->param('front');
117 if (my $subject=$query->param('subjectitems')) {
119 @results=subsearch(\$blah,$subject);
122 ($count,@results)=catalogsearch($env,'',\%search,$num,$startfrom);
125 #my $resultsarray=\@results;
128 foreach my $result (@results) {
129 $result->{'authorhtmlescaped'}=$result->{'author'};
130 $result->{'authorhtmlescaped'}=~s/ /%20/g;
131 ($result->{'copyrightdate'}==0) && ($result->{'copyrightdate'}='');
132 ($type eq 'opac') ? ($result->{'opac'}=1) : ($result->{'opac'}=0);
133 push (@$resultsarray, $result);
135 ($resultsarray) || (@$resultsarray=());
139 $search=$search."&keyword=$keyword";
140 $searchdesc.="keyword $keyword, ";
142 if (my $subjectitems=$query->param('subjectitems')){
143 $search=$search."&subjectitems=$subjectitems";
144 $searchdesc.="subject $subjectitems, ";
147 $search=$search."&subject=$subject";
148 $searchdesc.="subject $subject, ";
151 $search=$search."&author=$author";
152 $searchdesc.="author $author, ";
155 $search=$search."&class=$class";
156 $searchdesc.="class $class, ";
159 $search=$search."&title=$title";
160 $searchdesc.="title $title, ";
163 $search=$search."&dewey=$dewey";
164 $searchdesc.="dewey $dewey, ";
166 $search.="&ttype=$ttype";
169 $template->param(startfrom => $startfrom+1);
170 ($startfrom+$num<=$count) ? ($template->param(endat => $startfrom+$num)) : ($template->param(endat => $count));
171 $template->param(numrecords => $count);
172 my $nextstartfrom=($startfrom+$num<$count) ? ($startfrom+$num) : (-1);
173 my $prevstartfrom=($startfrom-$num>=0) ? ($startfrom-$num) : (-1);
174 $template->param(nextstartfrom => $nextstartfrom);
177 ($nextstartfrom==-1) ? ($displaynext=0) : ($displaynext=1);
178 ($prevstartfrom==-1) ? ($displayprev=0) : ($displayprev=1);
179 $template->param(displaynext => $displaynext);
180 $template->param(displayprev => $displayprev);
181 ($type eq 'opac') ? ($template->param(opac => 1)) : ($template->param(opac => 0));
182 $template->param(prevstartfrom => $prevstartfrom);
183 $template->param(search => $search);
184 $template->param(searchdesc => $searchdesc);
185 $template->param(SEARCH_RESULTS => $resultsarray);
186 $template->param(includesdir => $includes);
187 $template->param(loggedinuser => $loggedinuser);
192 for (my $i=1; $i<$count/10+1; $i++) {
193 ($title) && (push @$forminputs, { line => "title=$title"});
195 ($startfrom==($i-1)*10) && ($highlight=1);
197 foreach (@$forminputs) {
199 $formelements.="$line&";
201 $formelements=~s/ /+/g;
202 push @$numbers, { number => $i, highlight => $highlight , FORMELEMENTS => $formelements, FORMINPUTS => $forminputs, startfrom => ($i-1)*10, opac => (($type eq 'opac') ? (1) : (0))};
206 $template->param(numbers => $numbers);
210 print $query->header(-cookie => $cookie), $template->output;