From 057fd6af5c81982b1dd50a2f7700df41a7645ab5 Mon Sep 17 00:00:00 2001 From: tipaul Date: Wed, 3 Jul 2002 12:41:01 +0000 Subject: [PATCH] merging 1.2 and main branches --- C4/Output.pm | 205 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 162 insertions(+), 43 deletions(-) diff --git a/C4/Output.pm b/C4/Output.pm index 7961aa5e00..329b52137f 100644 --- a/C4/Output.pm +++ b/C4/Output.pm @@ -1,13 +1,14 @@ -package C4::Output; #asummes C4/Output +package C4::Output; #package to deal with marking up output #You will need to edit parts of this pm #set the value of path to be where your html lives use strict; +require Exporter; use warnings; + use C4::Database; -require Exporter; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); @@ -15,9 +16,14 @@ use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); $VERSION = 0.01; @ISA = qw(Exporter); -@EXPORT = qw(&startpage &endpage &mktablehdr &mktableft &mktablerow &mklink -&startmenu &endmenu &mkheadr ¢er &endcenter &mkform &mkform2 &bold -&gotopage &mkformnotable &mkform3 picktemplate); +@EXPORT = qw(&startpage &endpage + &mktablehdr &mktableft &mktablerow &mklink + &startmenu &endmenu &mkheadr + ¢er &endcenter + &mkform &mkform2 &bold + &gotopage &mkformnotable &mkform3 + &getkeytableselectoptions + &picktemplate); %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ], # your exported package globals go here, @@ -94,23 +100,21 @@ sub picktemplate { } - - -sub startpage{ +sub startpage() { return("\n"); } -sub gotopage{ - my ($target) = @_; - print "
goto target = $target
"; +sub gotopage($) { + my ($target) = shif; + #print "
goto target = $target
"; my $string = ""; return $string; } -sub startmenu{ +sub startmenu($) { # edit the paths in here - my ($type)=@_; + my ($type)=shift; if ($type eq 'issue') { open (FILE,"$path/issues-top.inc") || die; } elsif ($type eq 'opac') { @@ -118,8 +122,7 @@ sub startmenu{ } elsif ($type eq 'member') { open (FILE,"$path/members-top.inc") || die; } elsif ($type eq 'acquisitions'){ - open (FILE,"$path/acquisitions-top.inc") - || die "Cannot open $path/acquisitions-top.inc"; + open (FILE,"$path/acquisitions-top.inc") || die; } elsif ($type eq 'report'){ open (FILE,"$path/reports-top.inc") || die; } elsif ($type eq 'circulation') { @@ -129,8 +132,8 @@ sub startmenu{ } my @string=; close FILE; - my $count=@string; - # $string[$count]="
"; + # my $count=@string; + # $string[$count]="
"; return @string; } @@ -158,7 +161,7 @@ sub endmenu { return @string; } -sub mktablehdr { +sub mktablehdr() { return("\n"); } @@ -173,24 +176,23 @@ sub mktablerow { my $i=0; my $string=""; while ($i <$cols){ - if ($data[$cols] ne ''){ - #check for backgroundimage - $string.=""; - } else { - $string.="$data[$i]"; - } - $i++; + if (defined $data[$cols]) { # if there is a background image + $string.=""; + } else { + $string.="$data[$i]"; + } + $i++; } $string=$string."\n"; return($string); } -sub mktableft { +sub mktableft() { return("
"; - } else { - $string.=""; - } - if ($data[$i] eq "") { - $string.="   "; + } else { # if there's no background image + $string.=""; + } + if ($data[$i] eq "") { + $string.="  
\n"); } @@ -248,7 +250,7 @@ sub mkform3 { $string .= mktablehdr(); my $key; my @keys = sort(keys(%inputs)); - my @order; + my @order; my $count = @keys; my $i2 = 0; while ($i2 < $count) { @@ -319,6 +321,13 @@ sub mkformnotable{ } sub mkform2{ + # FIXME + # no POD and no tests yet. Once tests are written, + # this function can be cleaned up with the following steps: + # turn the while loop into a foreach loop + # pull the nested if,elsif structure back up to the main level + # pull the code for the different kinds of inputs into separate + # functions my ($action,%inputs)=@_; my $string="
\n"; $string=$string.mktablehdr(); @@ -376,48 +385,158 @@ sub mkform2{ $string=$string."
"; } +=pod + +=head2 &endpage + + &endpage does not expect any arguments, it returns the string: + \n -sub endpage{ +=cut + +sub endpage() { return("\n"); } -sub mklink { +=pod + +=head2 &mklink + + &mklink expects two arguments, the url to link to and the text of the link. + It returns this string: + $text + where $url is the first argument and $text is the second. + +=cut + +sub mklink($$) { my ($url,$text)=@_; my $string="$text"; return ($string); } +=pod + +=head2 &mkheadr + + &mkeadr expects two strings, a type and the text to use in the header. + types are: + +=over + +=item 1 ends with
+ +=item 2 no special ending tag + +=item 3 ends with

+ +=back + + Other than this, the return value is the same: + $text$string + Where $test is the text passed in and $string is the tag generated from + the type value. + +=cut + sub mkheadr { + # FIXME + # would it be better to make this more generic by accepting an optional + # argument with a closing tag instead of a numeric type? + my ($type,$text)=@_; my $string; if ($type eq '1'){ $string="$text
"; } if ($type eq '2'){ - $string="$text"; + $string="$text
"; } - if ($type eq '3'){ + if ($type eq '3'){ $string="$text

"; } return ($string); } -sub center { +=pod + +=head2 ¢er and &endcenter + + ¢er and &endcenter take no arguments and return html tags

and +
respectivley. + +=cut + +sub center() { return ("
\n"); } -sub endcenter { +sub endcenter() { return ("
\n"); } -sub bold { - my ($text)=@_; - my $string="$text"; - return($string); -} +=pod + +=head2 &bold + &bold requires that a single string be passed in by the caller. &bold + will return "$text" where $text is the string passed in. +=cut + +sub bold($) { + my ($text)=shift; + return("$text"); +} + +#--------------------------------------------- +# Create an HTML option list for a