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;
80 print "<br>goto target = $target<br>";
81 my $string = "<META HTTP-EQUIV=Refresh CONTENT=\"0;URL=http:$target\">";
87 # edit the paths in here
89 if ($type eq 'issue') {
90 open (FILE,"$path/issues-top.inc") || die;
91 } elsif ($type eq 'opac') {
92 open (FILE,"$path/opac-top.inc") || die;
93 } elsif ($type eq 'member') {
94 open (FILE,"$path/members-top.inc") || die;
95 } elsif ($type eq 'acquisitions'){
96 open (FILE,"$path/acquisitions-top.inc")|| die;
97 } elsif ($type eq 'report'){
98 open (FILE,"$path/reports-top.inc") || die;
99 } elsif ($type eq 'circulation') {
100 open (FILE,"$path/circulation-top.inc") || die;
102 open (FILE,"$path/cat-top.inc") || die;
107 # $string[$count]="<BLOCKQUOTE>";
114 if ($type eq 'issue'){
115 open (FILE,"$path/issues-bottom.inc") || die;
116 } elsif ($type eq 'opac') {
117 open (FILE,"$path/opac-bottom.inc") || die;
118 } elsif ($type eq 'member') {
119 open (FILE,"$path/members-bottom.inc") || die;
120 } elsif ($type eq 'acquisitions') {
121 open (FILE,"$path/acquisitions-bottom.inc") || die;
122 } elsif ($type eq 'report') {
123 open (FILE,"$path/reports-bottom.inc") || die;
124 } elsif ($type eq 'circulation') {
125 open (FILE,"$path/circulation-bottom.inc") || die;
127 open (FILE,"$path/cat-bottom.inc") || die;
135 return("<table border=0 cellspacing=0 cellpadding=5>\n");
140 #the last item in data may be a backgroundimage
143 # should this be a foreach (1..$cols) loop?
145 my ($cols,$colour,@data)=@_;
147 my $string="<tr valign=top bgcolor=$colour>";
149 if ($data[$cols] ne ''){
150 #check for backgroundimage
151 $string.="<td background=\"$data[$cols]\">";
155 if ($data[$i] eq "") {
156 $string.=" </td>";
158 $string.="$data[$i]</td>";
162 $string=$string."</tr>\n";
167 return("</table>\n");
171 my ($action,%inputs)=@_;
172 my $string="<form action=$action method=post>\n";
173 $string=$string.mktablehdr();
175 my @keys=sort keys %inputs;
179 while ( $i2<$count) {
180 my $value=$inputs{$keys[$i2]};
181 my @data=split('\t',$value);
182 #my $posn = shift(@data);
183 if ($data[0] eq 'hidden'){
184 $string=$string."<input type=hidden name=$keys[$i2] value=\"$data[1]\">\n";
187 if ($data[0] eq 'radio') {
188 $text="<input type=radio name=$keys[$i2] value=$data[1]>$data[1]
189 <input type=radio name=$keys[$i2] value=$data[2]>$data[2]";
191 if ($data[0] eq 'text') {
192 $text="<input type=$data[0] name=$keys[$i2] value=\"$data[1]\">";
194 if ($data[0] eq 'textarea') {
195 $text="<textarea name=$keys[$i2] wrap=physical cols=40 rows=4>$data[1]</textarea>";
197 if ($data[0] eq 'select') {
198 $text="<select name=$keys[$i2]>";
200 while ($data[$i] ne "") {
201 my $val = $data[$i+1];
202 $text = $text."<option value=$data[$i]>$val";
205 $text=$text."</select>";
207 $string=$string.mktablerow(2,'white',$keys[$i2],$text);
208 #@order[$posn] =mktablerow(2,'white',$keys[$i2],$text);
212 #$string=$string.join("\n",@order);
213 $string=$string.mktablerow(2,'white','<input type=submit>','<input type=reset>');
214 $string=$string.mktableft;
215 $string=$string."</form>";
219 my ($action,%inputs)=@_;
220 my $string="<form action=$action method=post>\n";
221 $string=$string.mktablehdr();
223 my @keys=sort keys %inputs;
227 while ( $i2<$count) {
228 my $value=$inputs{$keys[$i2]};
229 my @data=split('\t',$value);
231 if ($data[0] eq 'hidden'){
232 $order[$posn]="<input type=hidden name=$keys[$i2] value=\"$data[1]\">\n";
235 if ($data[0] eq 'radio') {
236 $text="<input type=radio name=$keys[$i2] value=$data[1]>$data[1]
237 <input type=radio name=$keys[$i2] value=$data[2]>$data[2]";
239 if ($data[0] eq 'text') {
240 $text="<input type=$data[0] name=$keys[$i2] value=\"$data[1]\" size=40>";
242 if ($data[0] eq 'textarea') {
243 $text="<textarea name=$keys[$i2] cols=40 rows=4>$data[1]</textarea>";
245 if ($data[0] eq 'select') {
246 $text="<select name=$keys[$i2]>";
248 while ($data[$i] ne "") {
249 my $val = $data[$i+1];
250 $text = $text."<option value=$data[$i]>$val";
253 $text=$text."</select>";
255 # $string=$string.mktablerow(2,'white',$keys[$i2],$text);
256 $order[$posn]=mktablerow(2,'white',$keys[$i2],$text);
260 my $temp=join("\n",@order);
261 $string=$string.$temp;
262 $string=$string.mktablerow(1,'white','<input type=submit>');
263 $string=$string.mktableft;
264 $string=$string."</form>";
268 my ($action,@inputs)=@_;
269 my $string="<form action=$action method=post>\n";
271 for (my $i=0; $i<$count; $i++){
272 if ($inputs[$i][0] eq 'hidden'){
273 $string=$string."<input type=hidden name=$inputs[$i][1] value=\"$inputs[$i][2]\">\n";
275 if ($inputs[$i][0] eq 'radio') {
276 $string.="<input type=radio name=$inputs[1] value=$inputs[$i][2]>$inputs[$i][2]";
278 if ($inputs[$i][0] eq 'text') {
279 $string.="<input type=$inputs[$i][0] name=$inputs[$i][1] value=\"$inputs[$i][2]\">";
281 if ($inputs[$i][0] eq 'textarea') {
282 $string.="<textarea name=$inputs[$i][1] wrap=physical cols=40 rows=4>$inputs[$i][2]</textarea>";
284 if ($inputs[$i][0] eq 'reset'){
285 $string.="<input type=reset name=$inputs[$i][1] value=\"$inputs[$i][2]\">";
287 if ($inputs[$i][0] eq 'submit'){
288 $string.="<input type=submit name=$inputs[$i][1] value=\"$inputs[$i][2]\">";
291 $string=$string."</form>";
295 my ($action,%inputs)=@_;
296 my $string="<form action=$action method=post>\n";
297 $string=$string.mktablehdr();
300 while ( my ($key, $value) = each %inputs) {
301 my @data=split('\t',$value);
302 my $posn = shift(@data);
303 my $reqd = shift(@data);
304 my $ltext = shift(@data);
305 if ($data[0] eq 'hidden'){
306 $string=$string."<input type=hidden name=$key value=\"$data[1]\">\n";
309 if ($data[0] eq 'radio') {
310 $text="<input type=radio name=$key value=$data[1]>$data[1]
311 <input type=radio name=$key value=$data[2]>$data[2]";
312 } elsif ($data[0] eq 'text') {
317 $text="<input type=$data[0] name=$key size=$size value=\"$data[2]\">";
318 } elsif ($data[0] eq 'textarea') {
319 my @size=split("x",$data[1]);
320 if ($data[1] eq "") {
324 $text="<textarea name=$key wrap=physical cols=$size[0] rows=$size[1]>$data[2]</textarea>";
325 } elsif ($data[0] eq 'select') {
326 $text="<select name=$key>";
329 while ($data[$i] ne "") {
330 my $val = $data[$i+1];
331 $text = $text."<option value=\"$data[$i]\"";
332 if ($data[$i] eq $sel) {
333 $text = $text." selected";
335 $text = $text.">$val";
338 $text=$text."</select>";
341 $ltext = $ltext." (Req)";
343 @order[$posn] =mktablerow(2,'white',$ltext,$text);
346 $string=$string.join("\n",@order);
347 $string=$string.mktablerow(2,'white','<input type=submit>','<input type=reset>');
348 $string=$string.mktableft;
349 $string=$string."</form>";
354 return("</body></html>\n");
359 my $string="<a href=\"$url\">$text</a>";
367 $string="<FONT SIZE=6><em>$text</em></FONT><br>";
370 $string="<FONT SIZE=6><em>$text</em></FONT>";
373 $string="<FONT SIZE=6><em>$text</em></FONT><p>";
379 return ("<CENTER>\n");
383 return ("</CENTER>\n");
388 my $string="<b>$text</b>";
392 END { } # module clean-up code here (global destructor)