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
46 my $path="/usr/local/www/hdl/htdocs/includes";
49 # here's a file-private function as a closure,
50 # callable as &$priv_func; it cannot be prototyped.
55 # make all your functions, whether exported or not;
58 my $string="<html>\n";
64 print "<br>goto target = $target<br>";
65 my $string = "<META HTTP-EQUIV=Refresh CONTENT=\"0;URL=http:$target\">";
71 # edit the paths in here
73 if ($type eq 'issue') {
74 open (FILE,"$path/issues-top.inc") || die;
75 } elsif ($type eq 'opac') {
76 open (FILE,"$path/opac-top.inc") || die;
77 } elsif ($type eq 'member') {
78 open (FILE,"$path/members-top.inc") || die;
79 } elsif ($type eq 'acquisitions'){
80 open (FILE,"$path/aquisitions-top.inc")|| die;
81 } elsif ($type eq 'report'){
82 open (FILE,"$path/reports-top.inc") || die;
84 open (FILE,"$path/cat-top.inc") || die;
89 # $string[$count]="<BLOCKQUOTE>";
96 if ($type eq 'issue'){
97 open (FILE,"$path/issues-bottom.inc") || die;
98 } elsif ($type eq 'opac') {
99 open (FILE,"$path/opac-bottom.inc") || die;
100 } elsif ($type eq 'member') {
101 open (FILE,"$path/members-bottom.inc") || die;
102 } elsif ($type eq 'acquisitions') {
103 open (FILE,"$path/aquisitions-bottom.inc") || die;
104 } elsif ($type eq 'report') {
105 open (FILE,"$path/reports-bottom.inc") || die;
107 open (FILE,"$path/cat-bottom.inc") || die;
115 my $string="<table border=0 cellspacing=0 cellpadding=5>\n";
121 #the last item in data may be a backgroundimage
122 my ($cols,$colour,@data)=@_;
124 my $string="<tr valign=top bgcolor=$colour>";
126 if ($data[$cols] ne ''){
127 #check for backgroundimage
128 $string.="<td background=\"$data[$cols]\">";
132 if ($data[$i] eq "") {
133 $string.=" </td>";
135 $string.="$data[$i]</td>";
139 $string=$string."</tr>\n";
144 my $string="</table>\n";
149 my ($action,%inputs)=@_;
150 my $string="<form action=$action method=post>\n";
151 $string=$string.mktablehdr();
153 my @keys=sort keys %inputs;
157 while ( $i2<$count) {
158 my $value=$inputs{$keys[$i2]};
159 my @data=split('\t',$value);
160 #my $posn = shift(@data);
161 if ($data[0] eq 'hidden'){
162 $string=$string."<input type=hidden name=$keys[$i2] value=\"$data[1]\">\n";
165 if ($data[0] eq 'radio') {
166 $text="<input type=radio name=$keys[$i2] value=$data[1]>$data[1]
167 <input type=radio name=$keys[$i2] value=$data[2]>$data[2]";
169 if ($data[0] eq 'text') {
170 $text="<input type=$data[0] name=$keys[$i2] value=\"$data[1]\">";
172 if ($data[0] eq 'textarea') {
173 $text="<textarea name=$keys[$i2] wrap=physical cols=40 rows=4>$data[1]</textarea>";
175 if ($data[0] eq 'select') {
176 $text="<select name=$keys[$i2]>";
178 while ($data[$i] ne "") {
179 my $val = $data[$i+1];
180 $text = $text."<option value=$data[$i]>$val";
183 $text=$text."</select>";
185 $string=$string.mktablerow(2,'white',$keys[$i2],$text);
186 #@order[$posn] =mktablerow(2,'white',$keys[$i2],$text);
190 #$string=$string.join("\n",@order);
191 $string=$string.mktablerow(2,'white','<input type=submit>','<input type=reset>');
192 $string=$string.mktableft;
193 $string=$string."</form>";
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);
209 if ($data[0] eq 'hidden'){
210 $order[$posn]="<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]\" size=40>";
220 if ($data[0] eq 'textarea') {
221 $text="<textarea name=$keys[$i2] 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 my $temp=join("\n",@order);
239 $string=$string.$temp;
240 $string=$string.mktablerow(1,'white','<input type=submit>');
241 $string=$string.mktableft;
242 $string=$string."</form>";
246 my ($action,@inputs)=@_;
247 my $string="<form action=$action method=post>\n";
249 for (my $i=0; $i<$count; $i++){
250 if ($inputs[$i][0] eq 'hidden'){
251 $string=$string."<input type=hidden name=$inputs[$i][1] value=\"$inputs[$i][2]\">\n";
253 if ($inputs[$i][0] eq 'radio') {
254 $string.="<input type=radio name=$inputs[1] value=$inputs[$i][2]>$inputs[$i][2]";
256 if ($inputs[$i][0] eq 'text') {
257 $string.="<input type=$inputs[$i][0] name=$inputs[$i][1] value=\"$inputs[$i][2]\">";
259 if ($inputs[$i][0] eq 'textarea') {
260 $string.="<textarea name=$inputs[$i][1] wrap=physical cols=40 rows=4>$inputs[$i][2]</textarea>";
262 if ($inputs[$i][0] eq 'reset'){
263 $string.="<input type=reset name=$inputs[$i][1] value=\"$inputs[$i][2]\">";
265 if ($inputs[$i][0] eq 'submit'){
266 $string.="<input type=submit name=$inputs[$i][1] value=\"$inputs[$i][2]\">";
269 $string=$string."</form>";
273 my ($action,%inputs)=@_;
274 my $string="<form action=$action method=post>\n";
275 $string=$string.mktablehdr();
278 while ( my ($key, $value) = each %inputs) {
279 my @data=split('\t',$value);
280 my $posn = shift(@data);
281 my $reqd = shift(@data);
282 my $ltext = shift(@data);
283 if ($data[0] eq 'hidden'){
284 $string=$string."<input type=hidden name=$key value=\"$data[1]\">\n";
287 if ($data[0] eq 'radio') {
288 $text="<input type=radio name=$key value=$data[1]>$data[1]
289 <input type=radio name=$key value=$data[2]>$data[2]";
290 } elsif ($data[0] eq 'text') {
295 $text="<input type=$data[0] name=$key size=$size value=\"$data[2]\">";
296 } elsif ($data[0] eq 'textarea') {
297 my @size=split("x",$data[1]);
298 if ($data[1] eq "") {
302 $text="<textarea name=$key wrap=physical cols=$size[0] rows=$size[1]>$data[2]</textarea>";
303 } elsif ($data[0] eq 'select') {
304 $text="<select name=$key>";
307 while ($data[$i] ne "") {
308 my $val = $data[$i+1];
309 $text = $text."<option value=\"$data[$i]\"";
310 if ($data[$i] eq $sel) {
311 $text = $text." selected";
313 $text = $text.">$val";
316 $text=$text."</select>";
319 $ltext = $ltext." (Req)";
321 @order[$posn] =mktablerow(2,'white',$ltext,$text);
324 $string=$string.join("\n",@order);
325 $string=$string.mktablerow(2,'white','<input type=submit>','<input type=reset>');
326 $string=$string.mktableft;
327 $string=$string."</form>";
332 my $string="</body></html>\n";
338 my $string="<a href=\"$url\">$text</a>";
346 $string="<FONT SIZE=6><em>$text</em></FONT><br>";
349 $string="<FONT SIZE=6><em>$text</em></FONT>";
352 $string="<FONT SIZE=6><em>$text</em></FONT><p>";
359 my $string="<CENTER>\n";
365 my $string="</CENTER>\n";
371 my $string="<b>$text</b>";
375 END { } # module clean-up code here (global destructor)