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*(.*)/) {
56 # Clean up white space at beginning and end
61 $configfile{$variable}=$value;
64 my $path=$configfile{'includes'};
65 ($path) || ($path="/usr/local/www/hdl/htdocs/includes");
68 # here's a file-private function as a closure,
69 # callable as &$priv_func; it cannot be prototyped.
74 # make all your functions, whether exported or not;
77 my ($includes, $base) = @_;
80 opendir (D, "$includes/templates");
81 my @dirlist=readdir D;
84 #(next) unless (/\.tmpl$/);
85 (next) unless (-e "$includes/templates/$_/$base");
88 my $sth=$dbh->prepare("select value from systempreferences where
89 variable='template'");
91 my ($preftemplate) = $sth->fetchrow;
94 if ($templates->{$preftemplate}) {
110 print "<br>goto target = $target<br>";
111 my $string = "<META HTTP-EQUIV=Refresh CONTENT=\"0;URL=http:$target\">";
117 # edit the paths in here
119 if ($type eq 'issue') {
120 open (FILE,"$path/issues-top.inc") || die;
121 } elsif ($type eq 'opac') {
122 open (FILE,"$path/opac-top.inc") || die;
123 } elsif ($type eq 'member') {
124 open (FILE,"$path/members-top.inc") || die;
125 } elsif ($type eq 'acquisitions'){
126 open (FILE,"$path/acquisitions-top.inc")|| die;
127 } elsif ($type eq 'report'){
128 open (FILE,"$path/reports-top.inc") || die;
129 } elsif ($type eq 'circulation') {
130 open (FILE,"$path/circulation-top.inc") || die;
132 open (FILE,"$path/cat-top.inc") || die;
137 # $string[$count]="<BLOCKQUOTE>";
144 if ($type eq 'issue'){
145 open (FILE,"$path/issues-bottom.inc") || die;
146 } elsif ($type eq 'opac') {
147 open (FILE,"$path/opac-bottom.inc") || die;
148 } elsif ($type eq 'member') {
149 open (FILE,"$path/members-bottom.inc") || die;
150 } elsif ($type eq 'acquisitions') {
151 open (FILE,"$path/acquisitions-bottom.inc") || die;
152 } elsif ($type eq 'report') {
153 open (FILE,"$path/reports-bottom.inc") || die;
154 } elsif ($type eq 'circulation') {
155 open (FILE,"$path/circulation-bottom.inc") || die;
157 open (FILE,"$path/cat-bottom.inc") || die;
165 return("<table border=0 cellspacing=0 cellpadding=5>\n");
170 #the last item in data may be a backgroundimage
173 # should this be a foreach (1..$cols) loop?
175 my ($cols,$colour,@data)=@_;
177 my $string="<tr valign=top bgcolor=$colour>";
179 if ($data[$cols] ne ''){
180 #check for backgroundimage
181 $string.="<td background=\"$data[$cols]\">";
185 if ($data[$i] eq "") {
186 $string.=" </td>";
188 $string.="$data[$i]</td>";
192 $string=$string."</tr>\n";
197 return("</table>\n");
201 my ($action,%inputs)=@_;
202 my $string="<form action=$action method=post>\n";
203 $string=$string.mktablehdr();
205 my @keys=sort keys %inputs;
209 while ( $i2<$count) {
210 my $value=$inputs{$keys[$i2]};
211 my @data=split('\t',$value);
212 #my $posn = shift(@data);
213 if ($data[0] eq 'hidden'){
214 $string=$string."<input type=hidden name=$keys[$i2] value=\"$data[1]\">\n";
217 if ($data[0] eq 'radio') {
218 $text="<input type=radio name=$keys[$i2] value=$data[1]>$data[1]
219 <input type=radio name=$keys[$i2] value=$data[2]>$data[2]";
221 if ($data[0] eq 'text') {
222 $text="<input type=$data[0] name=$keys[$i2] value=\"$data[1]\">";
224 if ($data[0] eq 'textarea') {
225 $text="<textarea name=$keys[$i2] wrap=physical cols=40 rows=4>$data[1]</textarea>";
227 if ($data[0] eq 'select') {
228 $text="<select name=$keys[$i2]>";
230 while ($data[$i] ne "") {
231 my $val = $data[$i+1];
232 $text = $text."<option value=$data[$i]>$val";
235 $text=$text."</select>";
237 $string=$string.mktablerow(2,'white',$keys[$i2],$text);
238 #@order[$posn] =mktablerow(2,'white',$keys[$i2],$text);
242 #$string=$string.join("\n",@order);
243 $string=$string.mktablerow(2,'white','<input type=submit>','<input type=reset>');
244 $string=$string.mktableft;
245 $string=$string."</form>";
249 my ($action, %inputs) = @_;
250 my $string = "<form action=\"$action\" method=\"post\">\n";
251 $string .= mktablehdr();
253 my @keys = sort(keys(%inputs));
257 while ($i2 < $count) {
258 my $value=$inputs{$keys[$i2]};
259 my @data=split('\t',$value);
261 if ($data[0] eq 'hidden'){
262 $order[$posn]="<input type=hidden name=$keys[$i2] value=\"$data[1]\">\n";
265 if ($data[0] eq 'radio') {
266 $text="<input type=radio name=$keys[$i2] value=$data[1]>$data[1]
267 <input type=radio name=$keys[$i2] value=$data[2]>$data[2]";
269 if ($data[0] eq 'text') {
270 $text="<input type=$data[0] name=$keys[$i2] value=\"$data[1]\" size=40>";
272 if ($data[0] eq 'textarea') {
273 $text="<textarea name=$keys[$i2] cols=40 rows=4>$data[1]</textarea>";
275 if ($data[0] eq 'select') {
276 $text="<select name=$keys[$i2]>";
278 while ($data[$i] ne "") {
279 my $val = $data[$i+1];
280 $text = $text."<option value=$data[$i]>$val";
283 $text=$text."</select>";
285 # $string=$string.mktablerow(2,'white',$keys[$i2],$text);
286 $order[$posn]=mktablerow(2,'white',$keys[$i2],$text);
290 my $temp=join("\n",@order);
291 $string=$string.$temp;
292 $string=$string.mktablerow(1,'white','<input type=submit>');
293 $string=$string.mktableft;
294 $string=$string."</form>";
298 my ($action,@inputs)=@_;
299 my $string="<form action=$action method=post>\n";
301 for (my $i=0; $i<$count; $i++){
302 if ($inputs[$i][0] eq 'hidden'){
303 $string=$string."<input type=hidden name=$inputs[$i][1] value=\"$inputs[$i][2]\">\n";
305 if ($inputs[$i][0] eq 'radio') {
306 $string.="<input type=radio name=$inputs[1] value=$inputs[$i][2]>$inputs[$i][2]";
308 if ($inputs[$i][0] eq 'text') {
309 $string.="<input type=$inputs[$i][0] name=$inputs[$i][1] value=\"$inputs[$i][2]\">";
311 if ($inputs[$i][0] eq 'textarea') {
312 $string.="<textarea name=$inputs[$i][1] wrap=physical cols=40 rows=4>$inputs[$i][2]</textarea>";
314 if ($inputs[$i][0] eq 'reset'){
315 $string.="<input type=reset name=$inputs[$i][1] value=\"$inputs[$i][2]\">";
317 if ($inputs[$i][0] eq 'submit'){
318 $string.="<input type=submit name=$inputs[$i][1] value=\"$inputs[$i][2]\">";
321 $string=$string."</form>";
325 my ($action,%inputs)=@_;
326 my $string="<form action=$action method=post>\n";
327 $string=$string.mktablehdr();
330 while ( my ($key, $value) = each %inputs) {
331 my @data=split('\t',$value);
332 my $posn = shift(@data);
333 my $reqd = shift(@data);
334 my $ltext = shift(@data);
335 if ($data[0] eq 'hidden'){
336 $string=$string."<input type=hidden name=$key value=\"$data[1]\">\n";
339 if ($data[0] eq 'radio') {
340 $text="<input type=radio name=$key value=$data[1]>$data[1]
341 <input type=radio name=$key value=$data[2]>$data[2]";
342 } elsif ($data[0] eq 'text') {
347 $text="<input type=$data[0] name=$key size=$size value=\"$data[2]\">";
348 } elsif ($data[0] eq 'textarea') {
349 my @size=split("x",$data[1]);
350 if ($data[1] eq "") {
354 $text="<textarea name=$key wrap=physical cols=$size[0] rows=$size[1]>$data[2]</textarea>";
355 } elsif ($data[0] eq 'select') {
356 $text="<select name=$key>";
359 while ($data[$i] ne "") {
360 my $val = $data[$i+1];
361 $text = $text."<option value=\"$data[$i]\"";
362 if ($data[$i] eq $sel) {
363 $text = $text." selected";
365 $text = $text.">$val";
368 $text=$text."</select>";
371 $ltext = $ltext." (Req)";
373 @order[$posn] =mktablerow(2,'white',$ltext,$text);
376 $string=$string.join("\n",@order);
377 $string=$string.mktablerow(2,'white','<input type=submit>','<input type=reset>');
378 $string=$string.mktableft;
379 $string=$string."</form>";
384 return("</body></html>\n");
389 my $string="<a href=\"$url\">$text</a>";
397 $string="<FONT SIZE=6><em>$text</em></FONT><br>";
400 $string="<FONT SIZE=6><em>$text</em></FONT>";
403 $string="<FONT SIZE=6><em>$text</em></FONT><p>";
409 return ("<CENTER>\n");
413 return ("</CENTER>\n");
418 my $string="<b>$text</b>";
425 END { } # module clean-up code here (global destructor)