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 ( ! defined $type ) { $type=''; }
141 if ($type eq 'issue') {
142 open (FILE,"$path/issues-bottom.inc") || die;
143 } elsif ($type eq 'opac') {
144 open (FILE,"$path/opac-bottom.inc") || die;
145 } elsif ($type eq 'member') {
146 open (FILE,"$path/members-bottom.inc") || die;
147 } elsif ($type eq 'acquisitions') {
148 open (FILE,"$path/acquisitions-bottom.inc") || die;
149 } elsif ($type eq 'report') {
150 open (FILE,"$path/reports-bottom.inc") || die;
151 } elsif ($type eq 'circulation') {
152 open (FILE,"$path/circulation-bottom.inc") || die;
154 open (FILE,"$path/cat-bottom.inc") || die;
162 return("<table border=0 cellspacing=0 cellpadding=5>\n");
167 #the last item in data may be a backgroundimage
170 # should this be a foreach (1..$cols) loop?
172 my ($cols,$colour,@data)=@_;
174 my $string="<tr valign=top bgcolor=$colour>";
176 if ($data[$cols] ne ''){
177 #check for backgroundimage
178 $string.="<td background=\"$data[$cols]\">";
182 if ($data[$i] eq "") {
183 $string.=" </td>";
185 $string.="$data[$i]</td>";
189 $string=$string."</tr>\n";
194 return("</table>\n");
198 my ($action,%inputs)=@_;
199 my $string="<form action=$action method=post>\n";
200 $string=$string.mktablehdr();
202 my @keys=sort keys %inputs;
206 while ( $i2<$count) {
207 my $value=$inputs{$keys[$i2]};
208 my @data=split('\t',$value);
209 #my $posn = shift(@data);
210 if ($data[0] eq 'hidden'){
211 $string=$string."<input type=hidden name=$keys[$i2] value=\"$data[1]\">\n";
214 if ($data[0] eq 'radio') {
215 $text="<input type=radio name=$keys[$i2] value=$data[1]>$data[1]
216 <input type=radio name=$keys[$i2] value=$data[2]>$data[2]";
218 if ($data[0] eq 'text') {
219 $text="<input type=$data[0] name=$keys[$i2] value=\"$data[1]\">";
221 if ($data[0] eq 'textarea') {
222 $text="<textarea name=$keys[$i2] wrap=physical cols=40 rows=4>$data[1]</textarea>";
224 if ($data[0] eq 'select') {
225 $text="<select name=$keys[$i2]>";
227 while ($data[$i] ne "") {
228 my $val = $data[$i+1];
229 $text = $text."<option value=$data[$i]>$val";
232 $text=$text."</select>";
234 $string=$string.mktablerow(2,'white',$keys[$i2],$text);
235 #@order[$posn] =mktablerow(2,'white',$keys[$i2],$text);
239 #$string=$string.join("\n",@order);
240 $string=$string.mktablerow(2,'white','<input type=submit>','<input type=reset>');
241 $string=$string.mktableft;
242 $string=$string."</form>";
246 my ($action, %inputs) = @_;
247 my $string = "<form action=\"$action\" method=\"post\">\n";
248 $string .= mktablehdr();
250 my @keys = sort(keys(%inputs));
254 while ($i2 < $count) {
255 my $value=$inputs{$keys[$i2]};
256 my @data=split('\t',$value);
258 if ($data[0] eq 'hidden'){
259 $order[$posn]="<input type=hidden name=$keys[$i2] value=\"$data[1]\">\n";
262 if ($data[0] eq 'radio') {
263 $text="<input type=radio name=$keys[$i2] value=$data[1]>$data[1]
264 <input type=radio name=$keys[$i2] value=$data[2]>$data[2]";
266 if ($data[0] eq 'text') {
267 $text="<input type=$data[0] name=$keys[$i2] value=\"$data[1]\" size=40>";
269 if ($data[0] eq 'textarea') {
270 $text="<textarea name=$keys[$i2] cols=40 rows=4>$data[1]</textarea>";
272 if ($data[0] eq 'select') {
273 $text="<select name=$keys[$i2]>";
275 while ($data[$i] ne "") {
276 my $val = $data[$i+1];
277 $text = $text."<option value=$data[$i]>$val";
280 $text=$text."</select>";
282 # $string=$string.mktablerow(2,'white',$keys[$i2],$text);
283 $order[$posn]=mktablerow(2,'white',$keys[$i2],$text);
287 my $temp=join("\n",@order);
288 $string=$string.$temp;
289 $string=$string.mktablerow(1,'white','<input type=submit>');
290 $string=$string.mktableft;
291 $string=$string."</form>";
295 my ($action,@inputs)=@_;
296 my $string="<form action=$action method=post>\n";
298 for (my $i=0; $i<$count; $i++){
299 if ($inputs[$i][0] eq 'hidden'){
300 $string=$string."<input type=hidden name=$inputs[$i][1] value=\"$inputs[$i][2]\">\n";
302 if ($inputs[$i][0] eq 'radio') {
303 $string.="<input type=radio name=$inputs[1] value=$inputs[$i][2]>$inputs[$i][2]";
305 if ($inputs[$i][0] eq 'text') {
306 $string.="<input type=$inputs[$i][0] name=$inputs[$i][1] value=\"$inputs[$i][2]\">";
308 if ($inputs[$i][0] eq 'textarea') {
309 $string.="<textarea name=$inputs[$i][1] wrap=physical cols=40 rows=4>$inputs[$i][2]</textarea>";
311 if ($inputs[$i][0] eq 'reset'){
312 $string.="<input type=reset name=$inputs[$i][1] value=\"$inputs[$i][2]\">";
314 if ($inputs[$i][0] eq 'submit'){
315 $string.="<input type=submit name=$inputs[$i][1] value=\"$inputs[$i][2]\">";
318 $string=$string."</form>";
322 my ($action,%inputs)=@_;
323 my $string="<form action=$action method=post>\n";
324 $string=$string.mktablehdr();
327 while ( my ($key, $value) = each %inputs) {
328 my @data=split('\t',$value);
329 my $posn = shift(@data);
330 my $reqd = shift(@data);
331 my $ltext = shift(@data);
332 if ($data[0] eq 'hidden'){
333 $string=$string."<input type=hidden name=$key value=\"$data[1]\">\n";
336 if ($data[0] eq 'radio') {
337 $text="<input type=radio name=$key value=$data[1]>$data[1]
338 <input type=radio name=$key value=$data[2]>$data[2]";
339 } elsif ($data[0] eq 'text') {
344 $text="<input type=$data[0] name=$key size=$size value=\"$data[2]\">";
345 } elsif ($data[0] eq 'textarea') {
346 my @size=split("x",$data[1]);
347 if ($data[1] eq "") {
351 $text="<textarea name=$key wrap=physical cols=$size[0] rows=$size[1]>$data[2]</textarea>";
352 } elsif ($data[0] eq 'select') {
353 $text="<select name=$key>";
356 while ($data[$i] ne "") {
357 my $val = $data[$i+1];
358 $text = $text."<option value=\"$data[$i]\"";
359 if ($data[$i] eq $sel) {
360 $text = $text." selected";
362 $text = $text.">$val";
365 $text=$text."</select>";
368 $ltext = $ltext." (Req)";
370 $order[$posn] =mktablerow(2,'white',$ltext,$text);
373 $string=$string.join("\n",@order);
374 $string=$string.mktablerow(2,'white','<input type=submit>','<input type=reset>');
375 $string=$string.mktableft;
376 $string=$string."</form>";
381 return("</body></html>\n");
386 my $string="<a href=\"$url\">$text</a>";
394 $string="<FONT SIZE=6><em>$text</em></FONT><br>";
397 $string="<FONT SIZE=6><em>$text</em></FONT>";
400 $string="<FONT SIZE=6><em>$text</em></FONT><p>";
406 return ("<CENTER>\n");
410 return ("</CENTER>\n");
415 my $string="<b>$text</b>";
422 END { } # module clean-up code here (global destructor)