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
10 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
12 # set the version for version checking
16 @EXPORT = qw(&startpage &endpage &mktablehdr &mktableft &mktablerow &mklink
17 &startmenu &endmenu &mkheadr ¢er &endcenter &mkform &mkform2 &bold
18 &gotopage &mkformnotable &mkform3);
19 %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
21 # your exported package globals go here,
22 # as well as any optionally exported functions
24 @EXPORT_OK = qw($Var1 %Hashit);
27 # non-exported package globals go here
28 use vars qw(@more $stuff);
30 # initalize package globals, first exported ones
36 # then the others (which are still accessible as $Some::Module::stuff)
40 # all file-scoped lexicals must be created before
41 # the functions below that use them.
44 # Change this value to reflect where you will store your includes
47 open (KC, "/etc/koha.conf");
51 if (/(.*)\s*=\s*(.*)/) {
54 # Clean up white space at beginning and end
59 $configfile{$variable}=$value;
62 my $path=$configfile{'includes'};
63 ($path) || ($path="/usr/local/www/hdl/htdocs/includes");
66 # here's a file-private function as a closure,
67 # callable as &$priv_func; it cannot be prototyped.
72 # make all your functions, whether exported or not;
75 my $string="<html>\n";
81 print "<br>goto target = $target<br>";
82 my $string = "<META HTTP-EQUIV=Refresh CONTENT=\"0;URL=http:$target\">";
88 # edit the paths in here
90 if ($type eq 'issue') {
91 open (FILE,"$path/issues-top.inc") || die;
92 } elsif ($type eq 'opac') {
93 open (FILE,"$path/opac-top.inc") || die;
94 } elsif ($type eq 'member') {
95 open (FILE,"$path/members-top.inc") || die;
96 } elsif ($type eq 'acquisitions'){
97 open (FILE,"$path/aquisitions-top.inc")|| die;
98 } elsif ($type eq 'report'){
99 open (FILE,"$path/reports-top.inc") || die;
101 open (FILE,"$path/cat-top.inc") || die;
106 # $string[$count]="<BLOCKQUOTE>";
113 if ($type eq 'issue'){
114 open (FILE,"$path/issues-bottom.inc") || die;
115 } elsif ($type eq 'opac') {
116 open (FILE,"$path/opac-bottom.inc") || die;
117 } elsif ($type eq 'member') {
118 open (FILE,"$path/members-bottom.inc") || die;
119 } elsif ($type eq 'acquisitions') {
120 open (FILE,"$path/aquisitions-bottom.inc") || die;
121 } elsif ($type eq 'report') {
122 open (FILE,"$path/reports-bottom.inc") || die;
124 open (FILE,"$path/cat-bottom.inc") || die;
132 my $string="<table border=0 cellspacing=0 cellpadding=5>\n";
138 #the last item in data may be a backgroundimage
139 my ($cols,$colour,@data)=@_;
141 my $string="<tr valign=top bgcolor=$colour>";
143 if ($data[$cols] ne ''){
144 #check for backgroundimage
145 $string.="<td background=\"$data[$cols]\">";
149 if ($data[$i] eq "") {
150 $string.=" </td>";
152 $string.="$data[$i]</td>";
156 $string=$string."</tr>\n";
161 my $string="</table>\n";
166 my ($action,%inputs)=@_;
167 my $string="<form action=$action method=post>\n";
168 $string=$string.mktablehdr();
170 my @keys=sort keys %inputs;
174 while ( $i2<$count) {
175 my $value=$inputs{$keys[$i2]};
176 my @data=split('\t',$value);
177 #my $posn = shift(@data);
178 if ($data[0] eq 'hidden'){
179 $string=$string."<input type=hidden name=$keys[$i2] value=\"$data[1]\">\n";
182 if ($data[0] eq 'radio') {
183 $text="<input type=radio name=$keys[$i2] value=$data[1]>$data[1]
184 <input type=radio name=$keys[$i2] value=$data[2]>$data[2]";
186 if ($data[0] eq 'text') {
187 $text="<input type=$data[0] name=$keys[$i2] value=\"$data[1]\">";
189 if ($data[0] eq 'textarea') {
190 $text="<textarea name=$keys[$i2] wrap=physical cols=40 rows=4>$data[1]</textarea>";
192 if ($data[0] eq 'select') {
193 $text="<select name=$keys[$i2]>";
195 while ($data[$i] ne "") {
196 my $val = $data[$i+1];
197 $text = $text."<option value=$data[$i]>$val";
200 $text=$text."</select>";
202 $string=$string.mktablerow(2,'white',$keys[$i2],$text);
203 #@order[$posn] =mktablerow(2,'white',$keys[$i2],$text);
207 #$string=$string.join("\n",@order);
208 $string=$string.mktablerow(2,'white','<input type=submit>','<input type=reset>');
209 $string=$string.mktableft;
210 $string=$string."</form>";
214 my ($action,%inputs)=@_;
215 my $string="<form action=$action method=post>\n";
216 $string=$string.mktablehdr();
218 my @keys=sort keys %inputs;
222 while ( $i2<$count) {
223 my $value=$inputs{$keys[$i2]};
224 my @data=split('\t',$value);
226 if ($data[0] eq 'hidden'){
227 $order[$posn]="<input type=hidden name=$keys[$i2] value=\"$data[1]\">\n";
230 if ($data[0] eq 'radio') {
231 $text="<input type=radio name=$keys[$i2] value=$data[1]>$data[1]
232 <input type=radio name=$keys[$i2] value=$data[2]>$data[2]";
234 if ($data[0] eq 'text') {
235 $text="<input type=$data[0] name=$keys[$i2] value=\"$data[1]\" size=40>";
237 if ($data[0] eq 'textarea') {
238 $text="<textarea name=$keys[$i2] cols=40 rows=4>$data[1]</textarea>";
240 if ($data[0] eq 'select') {
241 $text="<select name=$keys[$i2]>";
243 while ($data[$i] ne "") {
244 my $val = $data[$i+1];
245 $text = $text."<option value=$data[$i]>$val";
248 $text=$text."</select>";
250 # $string=$string.mktablerow(2,'white',$keys[$i2],$text);
251 $order[$posn]=mktablerow(2,'white',$keys[$i2],$text);
255 my $temp=join("\n",@order);
256 $string=$string.$temp;
257 $string=$string.mktablerow(1,'white','<input type=submit>');
258 $string=$string.mktableft;
259 $string=$string."</form>";
263 my ($action,@inputs)=@_;
264 my $string="<form action=$action method=post>\n";
266 for (my $i=0; $i<$count; $i++){
267 if ($inputs[$i][0] eq 'hidden'){
268 $string=$string."<input type=hidden name=$inputs[$i][1] value=\"$inputs[$i][2]\">\n";
270 if ($inputs[$i][0] eq 'radio') {
271 $string.="<input type=radio name=$inputs[1] value=$inputs[$i][2]>$inputs[$i][2]";
273 if ($inputs[$i][0] eq 'text') {
274 $string.="<input type=$inputs[$i][0] name=$inputs[$i][1] value=\"$inputs[$i][2]\">";
276 if ($inputs[$i][0] eq 'textarea') {
277 $string.="<textarea name=$inputs[$i][1] wrap=physical cols=40 rows=4>$inputs[$i][2]</textarea>";
279 if ($inputs[$i][0] eq 'reset'){
280 $string.="<input type=reset name=$inputs[$i][1] value=\"$inputs[$i][2]\">";
282 if ($inputs[$i][0] eq 'submit'){
283 $string.="<input type=submit name=$inputs[$i][1] value=\"$inputs[$i][2]\">";
286 $string=$string."</form>";
290 my ($action,%inputs)=@_;
291 my $string="<form action=$action method=post>\n";
292 $string=$string.mktablehdr();
295 while ( my ($key, $value) = each %inputs) {
296 my @data=split('\t',$value);
297 my $posn = shift(@data);
298 my $reqd = shift(@data);
299 my $ltext = shift(@data);
300 if ($data[0] eq 'hidden'){
301 $string=$string."<input type=hidden name=$key value=\"$data[1]\">\n";
304 if ($data[0] eq 'radio') {
305 $text="<input type=radio name=$key value=$data[1]>$data[1]
306 <input type=radio name=$key value=$data[2]>$data[2]";
307 } elsif ($data[0] eq 'text') {
312 $text="<input type=$data[0] name=$key size=$size value=\"$data[2]\">";
313 } elsif ($data[0] eq 'textarea') {
314 my @size=split("x",$data[1]);
315 if ($data[1] eq "") {
319 $text="<textarea name=$key wrap=physical cols=$size[0] rows=$size[1]>$data[2]</textarea>";
320 } elsif ($data[0] eq 'select') {
321 $text="<select name=$key>";
324 while ($data[$i] ne "") {
325 my $val = $data[$i+1];
326 $text = $text."<option value=\"$data[$i]\"";
327 if ($data[$i] eq $sel) {
328 $text = $text." selected";
330 $text = $text.">$val";
333 $text=$text."</select>";
336 $ltext = $ltext." (Req)";
338 @order[$posn] =mktablerow(2,'white',$ltext,$text);
341 $string=$string.join("\n",@order);
342 $string=$string.mktablerow(2,'white','<input type=submit>','<input type=reset>');
343 $string=$string.mktableft;
344 $string=$string."</form>";
349 my $string="</body></html>\n";
355 my $string="<a href=\"$url\">$text</a>";
363 $string="<FONT SIZE=6><em>$text</em></FONT><br>";
366 $string="<FONT SIZE=6><em>$text</em></FONT>";
369 $string="<FONT SIZE=6><em>$text</em></FONT><p>";
376 my $string="<CENTER>\n";
382 my $string="</CENTER>\n";
388 my $string="<b>$text</b>";
392 END { } # module clean-up code here (global destructor)