9 use C4::Output; # no contains gettemplate
12 my $type=$query->param('type');
13 (-e "opac") && ($type='opac');
15 my ($loggedinuser, $cookie, $sessionID) = checkauth($query, ($type eq 'opac') ? (1) : (0));
19 my $startfrom=$query->param('startfrom');
20 ($startfrom) || ($startfrom=0);
22 my $subject=$query->param('subject');
26 $template=gettemplate('catalogue/subject.tmpl');
28 $template=gettemplate('catalogue/searchresults.tmpl');
35 # get all the search variables
36 # we assume that C4::Search will validate these values for us
38 my $keyword=$query->param('keyword');
39 $search{'keyword'}=$keyword;
41 $search{'subject'}=$subject;
42 my $author=$query->param('author');
43 $search{'author'}=$author;
44 $search{'authoresc'}=$author;
45 #$search{'authorhtmlescaped'}=~s/ /%20/g;
46 my $illustrator=$query->param('illustrator');
47 $search{'param'}=$illustrator;
48 my $itemnumber=$query->param('itemnumber');
49 $search{'itemnumber'}=$itemnumber;
50 my $isbn=$query->param('isbn');
51 $search{'isbn'}=$isbn;
52 my $datebefore=$query->param('date-before');
53 $search{'date-before'}=$datebefore;
54 my $class=$query->param('class');
55 $search{'class'}=$class;
56 my $dewey=$query->param('dewey');
57 $search{'dewey'}=$dewey;
58 my $branch=$query->param('branch');
59 $search{'branch'}=$branch;
60 my $title=$query->param('title');
61 $search{'title'}=$title;
62 my $abstract=$query->param('abstract');
63 $search{'abstract'}=$abstract;
64 my $publisher=$query->param('publisher');
65 $search{'publisher'}=$publisher;
67 my $ttype=$query->param('ttype');
68 $search{'ttype'}=$ttype;
71 ($keyword) && (push @$forminputs, { line => "keyword=$keyword"});
72 ($subject) && (push @$forminputs, { line => "subject=$subject"});
73 ($author) && (push @$forminputs, { line => "author=$author"});
74 ($illustrator) && (push @$forminputs, { line => "illustrator=$illustrator"});
75 ($itemnumber) && (push @$forminputs, { line => "itemnumber=$itemnumber"});
76 ($isbn) && (push @$forminputs, { line => "isbn=$isbn"});
77 ($datebefore) && (push @$forminputs, { line => "date-before=$datebefore"});
78 ($class) && (push @$forminputs, { line => "class=$class"});
79 ($dewey) && (push @$forminputs, { line => "dewey=$dewey"});
80 ($branch) && (push @$forminputs, { line => "branch=$branch"});
81 ($title) && (push @$forminputs, { line => "title=$title"});
82 ($ttype) && (push @$forminputs, { line => "ttype=$ttype"});
83 ($abstract) && (push @$forminputs, { line => "abstract=$abstract"});
84 ($publisher) && (push @$forminputs, { line => "publisher=$publisher"});
85 ($forminputs) || (@$forminputs=());
86 $template->param(FORMINPUTS => $forminputs);
88 # I think it is (or was) a search from the "front" page... [st]
89 $search{'front'}=$query->param('front');
94 if (my $subject=$query->param('subjectitems')) {
96 @results=subsearch(\$blah,$subject,$num,$startfrom);
99 ($count,@results)=catalogsearch($env,'',\%search,$num,$startfrom);
102 #my $resultsarray=\@results;
105 foreach my $result (@results) {
106 $result->{'authorhtmlescaped'}=$result->{'author'};
107 $result->{'authorhtmlescaped'}=~s/ /%20/g;
108 ($result->{'copyrightdate'}==0) && ($result->{'copyrightdate'}='');
109 ($type eq 'opac') ? ($result->{'opac'}=1) : ($result->{'opac'}=0);
110 push (@$resultsarray, $result);
112 ($resultsarray) || (@$resultsarray=());
116 $search=$search."&keyword=$keyword";
117 $searchdesc.="keyword $keyword, ";
119 if (my $subjectitems=$query->param('subjectitems')){
120 $search=$search."&subjectitems=$subjectitems";
121 $searchdesc.="subject $subjectitems, ";
124 $search=$search."&subject=$subject";
125 $searchdesc.="subject $subject, ";
128 $search=$search."&author=$author";
129 $searchdesc.="author $author, ";
132 $search=$search."&class=$class";
133 $searchdesc.="class $class, ";
136 $search=$search."&title=$title";
137 $searchdesc.="title $title, ";
140 $search=$search."&dewey=$dewey";
141 $searchdesc.="dewey $dewey, ";
143 $search.="&ttype=$ttype";
146 $template->param(startfrom => $startfrom+1);
147 ($startfrom+$num<=$count) ? ($template->param(endat => $startfrom+$num)) : ($template->param(endat => $count));
148 $template->param(numrecords => $count);
149 my $nextstartfrom=($startfrom+$num<$count) ? ($startfrom+$num) : (-1);
150 my $prevstartfrom=($startfrom-$num>=0) ? ($startfrom-$num) : (-1);
151 $template->param(nextstartfrom => $nextstartfrom);
154 ($nextstartfrom==-1) ? ($displaynext=0) : ($displaynext=1);
155 ($prevstartfrom==-1) ? ($displayprev=0) : ($displayprev=1);
156 $template->param(displaynext => $displaynext);
157 $template->param(displayprev => $displayprev);
158 ($type eq 'opac') ? ($template->param(opac => 1)) : ($template->param(opac => 0));
159 $template->param(prevstartfrom => $prevstartfrom);
160 $template->param(search => $search);
161 $template->param(searchdesc => $searchdesc);
162 $template->param(SEARCH_RESULTS => $resultsarray);
163 #$template->param(includesdir => $includes);
164 $template->param(loggedinuser => $loggedinuser);
169 for (my $i=1; $i<$count/10+1; $i++) {
171 ($title) && (push @$forminputs, { line => "title=$title"});
173 ($startfrom==($i-1)*10) && ($highlight=1);
175 foreach (@$forminputs) {
177 $formelements.="$line&";
179 $formelements=~s/ /+/g;
180 push @$numbers, { number => $i, highlight => $highlight , FORMELEMENTS => $formelements, FORMINPUTS => $forminputs, startfrom => ($i-1)*10, opac => (($type eq 'opac') ? (1) : (0))};
185 $template->param(numbers => $numbers);
189 print $query->header(-cookie => $cookie), $template->output;