1 package C4::Output; #asummes C4/Output
3 #package to deal with marking up output
4 #You will need to edit parts of this pm
5 #set the value of path to be where your html lives
12 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
14 # set the version for version checking
18 @EXPORT = qw(&startpage &endpage &mktablehdr &mktableft &mktablerow &mklink
19 &startmenu &endmenu &mkheadr ¢er &endcenter &mkform &mkform2 &bold
20 &gotopage &mkformnotable &mkform3 picktemplate);
21 %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
23 # your exported package globals go here,
24 # as well as any optionally exported functions
26 @EXPORT_OK = qw($Var1 %Hashit);
29 # non-exported package globals go here
30 use vars qw(@more $stuff);
32 # initalize package globals, first exported ones
38 # then the others (which are still accessible as $Some::Module::stuff)
42 # all file-scoped lexicals must be created before
43 # the functions below that use them.
46 # Change this value to reflect where you will store your includes
49 open (KC, "/etc/koha.conf");
53 if (/(.*)\s*=\s*(.*)/) {
57 $variable =~ s/^\s*//g;
58 $variable =~ s/\s*$//g;
61 $configfile{$variable}=$value;
66 my $path=$configfile{'includes'};
67 ($path) || ($path="/usr/local/www/hdl/htdocs/includes");
69 # make all your functions, whether exported or not;
72 my ($includes, $base) = @_;
75 opendir (D, "$includes/templates");
76 my @dirlist=readdir D;
79 #(next) unless (/\.tmpl$/);
80 (next) unless (-e "$includes/templates/$_/$base");
83 my $sth=$dbh->prepare("select value from systempreferences where
84 variable='template'");
86 my ($preftemplate) = $sth->fetchrow;
89 if ($templates->{$preftemplate}) {
105 print "<br>goto target = $target<br>";
106 my $string = "<META HTTP-EQUIV=Refresh CONTENT=\"0;URL=http:$target\">";
112 # edit the paths in here
114 if ($type eq 'issue') {
115 open (FILE,"$path/issues-top.inc") || die;
116 } elsif ($type eq 'opac') {
117 open (FILE,"$path/opac-top.inc") || die;
118 } elsif ($type eq 'member') {
119 open (FILE,"$path/members-top.inc") || die;
120 } elsif ($type eq 'acquisitions'){
121 open (FILE,"$path/acquisitions-top.inc")
122 || die "Cannot open $path/acquisitions-top.inc";
123 } elsif ($type eq 'report'){
124 open (FILE,"$path/reports-top.inc") || die;
125 } elsif ($type eq 'circulation') {
126 open (FILE,"$path/circulation-top.inc") || die;
128 open (FILE,"$path/cat-top.inc") || die;
133 # $string[$count]="<BLOCKQUOTE>";
140 if ($type eq 'issue') {
141 open (FILE,"$path/issues-bottom.inc") || die;
142 } elsif ($type eq 'opac') {
143 open (FILE,"$path/opac-bottom.inc") || die;
144 } elsif ($type eq 'member') {
145 open (FILE,"$path/members-bottom.inc") || die;
146 } elsif ($type eq 'acquisitions') {
147 open (FILE,"$path/acquisitions-bottom.inc") || die;
148 } elsif ($type eq 'report') {
149 open (FILE,"$path/reports-bottom.inc") || die;
150 } elsif ($type eq 'circulation') {
151 open (FILE,"$path/circulation-bottom.inc") || die;
153 open (FILE,"$path/cat-bottom.inc") || die;
161 return("<table border=0 cellspacing=0 cellpadding=5>\n");
166 #the last item in data may be a backgroundimage
169 # should this be a foreach (1..$cols) loop?
171 my ($cols,$colour,@data)=@_;
173 my $string="<tr valign=top bgcolor=$colour>";
175 if ($data[$cols] ne ''){
176 #check for backgroundimage
177 $string.="<td background=\"$data[$cols]\">";
181 if ($data[$i] eq "") {
182 $string.=" </td>";
184 $string.="$data[$i]</td>";
188 $string=$string."</tr>\n";
193 return("</table>\n");
197 my ($action,%inputs)=@_;
198 my $string="<form action=$action method=post>\n";
199 $string=$string.mktablehdr();
201 my @keys=sort keys %inputs;
205 while ( $i2<$count) {
206 my $value=$inputs{$keys[$i2]};
207 my @data=split('\t',$value);
208 #my $posn = shift(@data);
209 if ($data[0] eq 'hidden'){
210 $string=$string."<input type=hidden name=$keys[$i2] value=\"$data[1]\">\n";
213 if ($data[0] eq 'radio') {
214 $text="<input type=radio name=$keys[$i2] value=$data[1]>$data[1]
215 <input type=radio name=$keys[$i2] value=$data[2]>$data[2]";
217 if ($data[0] eq 'text') {
218 $text="<input type=$data[0] name=$keys[$i2] value=\"$data[1]\">";
220 if ($data[0] eq 'textarea') {
221 $text="<textarea name=$keys[$i2] wrap=physical cols=40 rows=4>$data[1]</textarea>";
223 if ($data[0] eq 'select') {
224 $text="<select name=$keys[$i2]>";
226 while ($data[$i] ne "") {
227 my $val = $data[$i+1];
228 $text = $text."<option value=$data[$i]>$val";
231 $text=$text."</select>";
233 $string=$string.mktablerow(2,'white',$keys[$i2],$text);
234 #@order[$posn] =mktablerow(2,'white',$keys[$i2],$text);
238 #$string=$string.join("\n",@order);
239 $string=$string.mktablerow(2,'white','<input type=submit>','<input type=reset>');
240 $string=$string.mktableft;
241 $string=$string."</form>";
245 my ($action, %inputs) = @_;
246 my $string = "<form action=\"$action\" method=\"post\">\n";
247 $string .= mktablehdr();
249 my @keys = sort(keys(%inputs));
253 while ($i2 < $count) {
254 my $value=$inputs{$keys[$i2]};
255 my @data=split('\t',$value);
257 if ($data[0] eq 'hidden'){
258 $order[$posn]="<input type=hidden name=$keys[$i2] value=\"$data[1]\">\n";
261 if ($data[0] eq 'radio') {
262 $text="<input type=radio name=$keys[$i2] value=$data[1]>$data[1]
263 <input type=radio name=$keys[$i2] value=$data[2]>$data[2]";
265 if ($data[0] eq 'text') {
266 $text="<input type=$data[0] name=$keys[$i2] value=\"$data[1]\" size=40>";
268 if ($data[0] eq 'textarea') {
269 $text="<textarea name=$keys[$i2] cols=40 rows=4>$data[1]</textarea>";
271 if ($data[0] eq 'select') {
272 $text="<select name=$keys[$i2]>";
274 while ($data[$i] ne "") {
275 my $val = $data[$i+1];
276 $text = $text."<option value=$data[$i]>$val";
279 $text=$text."</select>";
281 # $string=$string.mktablerow(2,'white',$keys[$i2],$text);
282 $order[$posn]=mktablerow(2,'white',$keys[$i2],$text);
286 my $temp=join("\n",@order);
287 $string=$string.$temp;
288 $string=$string.mktablerow(1,'white','<input type=submit>');
289 $string=$string.mktableft;
290 $string=$string."</form>";
294 my ($action,@inputs)=@_;
295 my $string="<form action=$action method=post>\n";
297 for (my $i=0; $i<$count; $i++){
298 if ($inputs[$i][0] eq 'hidden'){
299 $string=$string."<input type=hidden name=$inputs[$i][1] value=\"$inputs[$i][2]\">\n";
301 if ($inputs[$i][0] eq 'radio') {
302 $string.="<input type=radio name=$inputs[1] value=$inputs[$i][2]>$inputs[$i][2]";
304 if ($inputs[$i][0] eq 'text') {
305 $string.="<input type=$inputs[$i][0] name=$inputs[$i][1] value=\"$inputs[$i][2]\">";
307 if ($inputs[$i][0] eq 'textarea') {
308 $string.="<textarea name=$inputs[$i][1] wrap=physical cols=40 rows=4>$inputs[$i][2]</textarea>";
310 if ($inputs[$i][0] eq 'reset'){
311 $string.="<input type=reset name=$inputs[$i][1] value=\"$inputs[$i][2]\">";
313 if ($inputs[$i][0] eq 'submit'){
314 $string.="<input type=submit name=$inputs[$i][1] value=\"$inputs[$i][2]\">";
317 $string=$string."</form>";
321 my ($action,%inputs)=@_;
322 my $string="<form action=$action method=post>\n";
323 $string=$string.mktablehdr();
326 while ( my ($key, $value) = each %inputs) {
327 my @data=split('\t',$value);
328 my $posn = shift(@data);
329 my $reqd = shift(@data);
330 my $ltext = shift(@data);
331 if ($data[0] eq 'hidden'){
332 $string=$string."<input type=hidden name=$key value=\"$data[1]\">\n";
335 if ($data[0] eq 'radio') {
336 $text="<input type=radio name=$key value=$data[1]>$data[1]
337 <input type=radio name=$key value=$data[2]>$data[2]";
338 } elsif ($data[0] eq 'text') {
343 $text="<input type=$data[0] name=$key size=$size value=\"$data[2]\">";
344 } elsif ($data[0] eq 'textarea') {
345 my @size=split("x",$data[1]);
346 if ($data[1] eq "") {
350 $text="<textarea name=$key wrap=physical cols=$size[0] rows=$size[1]>$data[2]</textarea>";
351 } elsif ($data[0] eq 'select') {
352 $text="<select name=$key>";
355 while ($data[$i] ne "") {
356 my $val = $data[$i+1];
357 $text = $text."<option value=\"$data[$i]\"";
358 if ($data[$i] eq $sel) {
359 $text = $text." selected";
361 $text = $text.">$val";
364 $text=$text."</select>";
367 $ltext = $ltext." (Req)";
369 $order[$posn] =mktablerow(2,'white',$ltext,$text);
372 $string=$string.join("\n",@order);
373 $string=$string.mktablerow(2,'white','<input type=submit>','<input type=reset>');
374 $string=$string.mktableft;
375 $string=$string."</form>";
380 return("</body></html>\n");
385 my $string="<a href=\"$url\">$text</a>";
393 $string="<FONT SIZE=6><em>$text</em></FONT><br>";
396 $string="<FONT SIZE=6><em>$text</em></FONT>";
399 $string="<FONT SIZE=6><em>$text</em></FONT><p>";
405 return ("<CENTER>\n");
409 return ("</CENTER>\n");
414 my $string="<b>$text</b>";
421 END { } # module clean-up code here (global destructor)