| 1 | package HTML::STable; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | require Exporter; | ||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | @ISA = qw(Exporter AutoLoader); | ||||||||||||||||||||||||||||||||||||||||||
| 9 | # Items to export into callers namespace by default. Note: do not export | ||||||||||||||||||||||||||||||||||||||||||
| 10 | # names by default without a very good reason. Use EXPORT_OK instead. | ||||||||||||||||||||||||||||||||||||||||||
| 11 | # Do not simply export all your public functions/methods/constants. | ||||||||||||||||||||||||||||||||||||||||||
| 12 | @EXPORT = qw( | ||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 15 | $VERSION = '0.02'; | ||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | # Preloaded methods go here. | ||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | package SNode; | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | my $obj_id = 0; | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=20 SCAR=60.4
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | my $P = shift; | |||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | my $format = shift; | |||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | my $O = {}; | |||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | bless $O,ref $P || $P; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $P || $P
MC/DC0%0/2
ref $P || $P
ref $P
$P
Truth table0%0/3
A || B
A= ref $PB= $P
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | $O->{ID} = $obj_id++; | |||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | $format =~ tr/;/,/; | |||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | my @array = split(/,/,$format); | |||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | my %hash = (); | |||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | my $tag; | |||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | foreach $tag (@array) { | |||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | my ($key, $value) = split(/:/,$tag,2); | |||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | $hash{$key} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | $O->{hash} = \%hash; | |||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | if($hash{small}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | $O->{small_h} = "<small>"; | |||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | $O->{small_t} = "</small>"; | |||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | my $align = $hash{"align"}; | |||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | my $valign = $hash{"valign"}; | |||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | my $color = $hash{"color"}; | |||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | my $bgcolor = $hash{"bgcolor"}; | |||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | my $background = $hash{"background"}; | |||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | my $size = $hash{"size"}; | |||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | my $face = $hash{face}; | |||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | my $bolds = $hash{"bold"}; | |||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | my $colspan = $hash{"colspan"}; | |||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | my $rowspan = $hash{"rowspan"}; | |||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | my $header = $hash{"header"}; | |||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | my $width = $hash{"width"}; | |||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | $O->{align} = $align ? " align=$align" : ""; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | $O->{valign} = $valign ? " valign=$valign" : ""; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | $O->{color} = $color ? " color=$color" : ""; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | $O->{size} = $size ? " size=$size" : ""; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | $O->{face} = $face ? " face=$face" : ""; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | $O->{colspan} = $colspan ? " colspan=$colspan" : ""; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | $O->{rowspan} = $rowspan ? " rowspan=$rowspan" : ""; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | $O->{bgcolor} = $bgcolor ? " bgcolor=$bgcolor" : ""; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | $O->{background} = $background ? " background=$background" : ""; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | $O->{width} = $width ? " width=$width" : ""; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | if($header eq "yes") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | $O->{head} = "<TH"; | |||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | $O->{tail} = "</TH>\n"; | |||||||||||||||||||||||||||||||||||||||||
| 71 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | $O->{head} = "<TD"; | |||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | $O->{tail} = "</TD>\n"; | |||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | if($bolds eq "yes") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | $O->{bold_head} = "<B>"; | |||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | $O->{bold_tail} = "</B>"; | |||||||||||||||||||||||||||||||||||||||||
| 78 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | $O->{bold_head} = ""; | |||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | $O->{bold_tail} = ""; | |||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | if($color ne "" || $size ne "" || $face ne "") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$color ne "" or $size ne "" or $face ne ""
$color ne "" or $size ne ""
MC/DC0%0/3
$color ne "" or $size ne "" or $face ne ""
$color ne ""
$size ne ""
$face ne ""
Truth table0%0/4
A or B or C
A= $color ne ""B= $size ne ""C= $face ne ""
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | $O->{color_size_head} = "<font"; | |||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | $O->{color_size_tail} = ">"; | |||||||||||||||||||||||||||||||||||||||||
| 85 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | $O->{color_size_head} = ""; | |||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | $O->{color_size_tail} = ""; | |||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | $O->{emty_format} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | if($format eq "") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | $O->{emty_format} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | return $O; | |||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | sub print { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print: not called CC=26 SCAR=65.5
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | my $O = shift; | |||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | my $print_string; | |||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | if (@_) { $print_string = shift; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | if($O->{emty_format} == 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | if(ref($print_string) eq "CODE") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | print "<TD>"; | |||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | eval($print_string->()); | |||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | print "</TD>\n"; | |||||||||||||||||||||||||||||||||||||||||
| 107 | } elsif(ref($print_string)) { | ||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | if(ref($print_string) eq "HTML::STable") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | if($print_string->{no_table}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | $print_string->print(); | |||||||||||||||||||||||||||||||||||||||||
| 111 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | print "<TD>"; | |||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | $print_string->print(); | |||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | print "</TD>\n"; | |||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||
| 116 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | print "<TD>"; | |||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | $print_string->print(); | |||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | print "</TD>\n"; | |||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | print "<TD>$print_string</TD>\n"; | |||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | my $align = $O->{align}; | |||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | my $valign = $O->{valign}; | |||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | my $color = $O->{color}; | |||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | my $bgcolor = $O->{bgcolor}; | |||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | my $background = $O->{background}; | |||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | my $size = $O->{size}; | |||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | my $face = $O->{face}; | |||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | my $width = $O->{width}; | |||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | my $bolds = $O->{bold}; | |||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | my $colspan = $O->{colspan}; | |||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | my $rowspan = $O->{rowspan}; | |||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | my $head = $O->{head}; | |||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | my $tail = $O->{tail}; | |||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | my $bold_h = $O->{bold_head}; | |||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | my $bold_t = $O->{bold_tail}; | |||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | my $col_si_h= $O->{color_size_head}; | |||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | my $col_si_t= $O->{color_size_tail}; | |||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | if(@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | my $color_size = 0; | |||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | my $format_string = shift; | |||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | $format_string =~ tr/;/,/; | |||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | my @array = split(/,/,$format_string); | |||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | my %hash = (); | |||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | my $tag; | |||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | foreach $tag (@array) { | |||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | my ($key, $value) = split(/:/,$tag,2); | |||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | $hash{$key} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | my $temp; | |||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | if($temp = $hash{"align" }) { $align = " align=$temp"; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | if($temp = $hash{"valign" }) { $valign = " valign=$temp"; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | if($temp = $hash{"width" }) { $width = " width=$temp"; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | if($temp = $hash{"bgcolor"}) { $bgcolor = " bgcolor=$temp"; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | if($temp = $hash{"background"}) { $background = " background=$temp"; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | if($temp = $hash{"colspan"}) { $colspan = " colspan=$temp"; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | if($temp = $hash{"rowspan"}) { $rowspan = " rowspan=$temp"; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | if($temp = $hash{"size" }) { $color_size = 1; $size = " size=$temp"; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | if($temp = $hash{"face" }) { $color_size = 1; $face = " face=$temp"; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | if($temp = $hash{"color" }) { $color_size = 1; $color = " color=$temp"; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | if($color_size == 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | $col_si_h = "<font"; | |||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | $col_si_t = ">"; | |||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | if($temp = $hash{"bolds"}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | if($temp eq "yes") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | $bold_h = "<B>"; | |||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | $bold_t = "</B>"; | |||||||||||||||||||||||||||||||||||||||||
| 174 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | $bold_h = ""; | |||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | $bold_t = ""; | |||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | if($temp = $hash{"header"}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | if($temp eq "yes") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | $head = "<TH"; | |||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | $tail = "</TH>\n"; | |||||||||||||||||||||||||||||||||||||||||
| 183 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | $head = "<TD"; | |||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | $tail = "</TD>\n"; | |||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | print $head; | |||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | print $align; | |||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | print $valign; | |||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | print $width; | |||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | print $colspan; | |||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | print $rowspan; | |||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | print $bgcolor; | |||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | print $background; | |||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | print ">"; | |||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | print $col_si_h; | |||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | print $color; | |||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | print $size; | |||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | print $face; | |||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | print $col_si_t; | |||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | print $bold_h; | |||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | if(ref($print_string) eq "CODE") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | eval($print_string->()); | |||||||||||||||||||||||||||||||||||||||||
| 208 | } elsif(ref($print_string)) { | ||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | $print_string->print(); | |||||||||||||||||||||||||||||||||||||||||
| 210 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | print $O->{small_h}; | |||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | print $print_string; | |||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | print $O->{small_t}; | |||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | print $bold_t; | |||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | print $tail; | |||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | sub string { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
string: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | my $O = shift; | |||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | my $print_string; | |||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | if (@_) { $print_string = shift } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | my $str = ""; | |||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | $str .= $O->{align}; | |||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | $str .= $O->{valign}; | |||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | $str .= $O->{width}; | |||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | $str .= $O->{colspan}; | |||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | $str .= $O->{rowspan}; | |||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | $str .= $O->{bgcolor}; | |||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | $str .= $O->{background}; | |||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | $str .= $O->{color_size_head}; | |||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | $str .= $O->{color}; | |||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | $str .= $O->{size}; | |||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | $str .= $O->{face}; | |||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | $str .= $O->{color_size_tail}; | |||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | if(ref($print_string)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | $str .= $print_string->string(); | |||||||||||||||||||||||||||||||||||||||||
| 239 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | $str .= $print_string; | |||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | print $O->{bold_tail}; | |||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | $str; | |||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | sub print_list { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print_list: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | my($O,@lst) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | my $i; | |||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | for($i = 0; $i <= $#lst; $i++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | $O->print($lst[$i]); | |||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | ############################################## | ||||||||||||||||||||||||||||||||||||||||||
| 256 | ## methods to access per-object data ## | ||||||||||||||||||||||||||||||||||||||||||
| 257 | ## ## | ||||||||||||||||||||||||||||||||||||||||||
| 258 | ## With args, they set the value. Without ## | ||||||||||||||||||||||||||||||||||||||||||
| 259 | ## any, they only retrieve it/them. ## | ||||||||||||||||||||||||||||||||||||||||||
| 260 | ############################################## | ||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | sub AUTOLOAD { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: not called CC=3 SCAR=22.3
| |||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | my $O = shift; | |||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | my $attr = $SNode::AUTOLOAD; | |||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | my $argm = shift; | |||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | $attr =~ s/.*:://; | |||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | return if $attr eq 'DESTROY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||
| 270 | { # this block will turn strick refs off | ||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | *{$SNode::AUTOLOAD} = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | my $O = shift; | |||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | my $argm = shift; | |||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | if($argm != "") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | $O->{$attr} = " $attr=$argm"; | |||||||||||||||||||||||||||||||||||||||||
| 277 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | my ($dummy,$argm) = split(/=/,$O->{$attr}); | |||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | return $argm; | |||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | if($argm != "") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | $O->{$attr} = " $attr=$argm"; | |||||||||||||||||||||||||||||||||||||||||
| 285 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | my ($dummy,$argm) = split(/=/,$O->{$attr}); | |||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | return $argm; | |||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||
| 291 | sub header { | ||||||||||||||||||||||||||||||||||||||||||
| 292 | my($O,$header) = @_; | ||||||||||||||||||||||||||||||||||||||||||
| 293 | my $f = $O->{hash}; | ||||||||||||||||||||||||||||||||||||||||||
| 294 | my $temp = %$f->{"header"}; | ||||||||||||||||||||||||||||||||||||||||||
| 295 | %$f->{"header"} = $header; | ||||||||||||||||||||||||||||||||||||||||||
| 296 | if($header eq "yes") { | ||||||||||||||||||||||||||||||||||||||||||
| 297 | $O->{head} = "<TH"; | ||||||||||||||||||||||||||||||||||||||||||
| 298 | $O->{tail} = "</TH>\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 299 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 300 | $O->{head} = "<TD"; | ||||||||||||||||||||||||||||||||||||||||||
| 301 | $O->{tail} = "</TD>\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||
| 303 | return $temp; | ||||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | sub blank { | ||||||||||||||||||||||||||||||||||||||||||
| 307 | my($O,$num_of_blank) = @_; | ||||||||||||||||||||||||||||||||||||||||||
| 308 | print "<TD>"; | ||||||||||||||||||||||||||||||||||||||||||
| 309 | my $i; | ||||||||||||||||||||||||||||||||||||||||||
| 310 | for($i = 0; $i < $num_of_blank; $i++) { | ||||||||||||||||||||||||||||||||||||||||||
| 311 | print " "; | ||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||
| 313 | print "</TD>\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | sub ID { | ||||||||||||||||||||||||||||||||||||||||||
| 317 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 318 | $O->{ID}; | ||||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||
| 321 | 1; # so the require or use succeeds | ||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | package SDate; | ||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||
| 326 | use POSIX qw(strftime); | ||||||||||||||||||||||||||||||||||||||||||
| 327 | use POSIX; | ||||||||||||||||||||||||||||||||||||||||||
| 328 | use Time::Local; | ||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||
| 330 | my %hs = | ||||||||||||||||||||||||||||||||||||||||||
| 331 | (JAN=>"01", FEB=>"02", MAR=>"03", APR=>"04",MAY=>"05", JUN=>"06", | ||||||||||||||||||||||||||||||||||||||||||
| 332 | JUL=>"07", AUG=>"08", SEP=>"09", OCT=>"10",NOV=>"11", DEC=>"12"); | ||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||
| 334 | # Added by Su-Che to map month numeric value to its string representation | ||||||||||||||||||||||||||||||||||||||||||
| 335 | my @mon_map = | ||||||||||||||||||||||||||||||||||||||||||
| 336 | ("Jan", "Feb", "Mar", "Apr", "May", "Jun", | ||||||||||||||||||||||||||||||||||||||||||
| 337 | "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); | ||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||
| 339 | use overload ( | ||||||||||||||||||||||||||||||||||||||||||
| 340 | '<=>' => \&spaceship, | ||||||||||||||||||||||||||||||||||||||||||
| 341 | '""' => \&stringify, | ||||||||||||||||||||||||||||||||||||||||||
| 342 | 'cmp' => \&compare | ||||||||||||||||||||||||||||||||||||||||||
| 343 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||
| 345 | sub new | ||||||||||||||||||||||||||||||||||||||||||
| 346 | { | ||||||||||||||||||||||||||||||||||||||||||
| 347 | my $P = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 348 | my $O = {}; | ||||||||||||||||||||||||||||||||||||||||||
| 349 | bless $O,ref $P || $P; | ||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||
| 351 | my $date = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||
| 353 | my ($m,$d,$y); | ||||||||||||||||||||||||||||||||||||||||||
| 354 | my ($sec,$min,$hour); | ||||||||||||||||||||||||||||||||||||||||||
| 355 | if($date) { | ||||||||||||||||||||||||||||||||||||||||||
| 356 | if ($date =~ "/" ) { # 12/31/1999 | ||||||||||||||||||||||||||||||||||||||||||
| 357 | ($m,$d,$y) = split("/",$date); | ||||||||||||||||||||||||||||||||||||||||||
| 358 | } elsif ($date =~ "-" ) { # 31-12-1999 | ||||||||||||||||||||||||||||||||||||||||||
| 359 | ($d,$m,$y) = split("-",$date); | ||||||||||||||||||||||||||||||||||||||||||
| 360 | $m = $hs{uc $m}; | ||||||||||||||||||||||||||||||||||||||||||
| 361 | if( $y > 50 ) { | ||||||||||||||||||||||||||||||||||||||||||
| 362 | $y += 1900; | ||||||||||||||||||||||||||||||||||||||||||
| 363 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 364 | $y += 2000; | ||||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||
| 366 | } elsif ($date =~ " " ) { | ||||||||||||||||||||||||||||||||||||||||||
| 367 | $date = uc $date; | ||||||||||||||||||||||||||||||||||||||||||
| 368 | ($m, $d, $y) = split(" ", $date); | ||||||||||||||||||||||||||||||||||||||||||
| 369 | $m = $hs{$m}; | ||||||||||||||||||||||||||||||||||||||||||
| 370 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 371 | my ($a,$b,$c); | ||||||||||||||||||||||||||||||||||||||||||
| 372 | ($a,$b,$c,$d,$m,$y) = localtime($date); | ||||||||||||||||||||||||||||||||||||||||||
| 373 | $y += 1900; | ||||||||||||||||||||||||||||||||||||||||||
| 374 | $m += 1; | ||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||
| 376 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 377 | ($sec,$min,$hour,$d,$m,$y) = (localtime)[0,1,2,3,4,5]; | ||||||||||||||||||||||||||||||||||||||||||
| 378 | $O->{sec} = $sec; | ||||||||||||||||||||||||||||||||||||||||||
| 379 | $O->{min} = $min; | ||||||||||||||||||||||||||||||||||||||||||
| 380 | $O->{hour} = $hour; | ||||||||||||||||||||||||||||||||||||||||||
| 381 | $y += 1900; | ||||||||||||||||||||||||||||||||||||||||||
| 382 | $m += 1; | ||||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | $O->{month} = $m; | ||||||||||||||||||||||||||||||||||||||||||
| 386 | $O->{day} = $d; | ||||||||||||||||||||||||||||||||||||||||||
| 387 | $O->{year} = $y; | ||||||||||||||||||||||||||||||||||||||||||
| 388 | $O->{date} = timelocal(0,0,0,$d,$m-1,$y-1900); | ||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||
| 390 | $O; | ||||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||
| 393 | sub time | ||||||||||||||||||||||||||||||||||||||||||
| 394 | { | ||||||||||||||||||||||||||||||||||||||||||
| 395 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 396 | return $O->{hour}.":".$O->{min}.":".$O->{sec}; | ||||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||
| 399 | sub diff | ||||||||||||||||||||||||||||||||||||||||||
| 400 | { | ||||||||||||||||||||||||||||||||||||||||||
| 401 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 402 | my $date = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 403 | if ($date != 0 || $date ne "") { | ||||||||||||||||||||||||||||||||||||||||||
| 404 | return ceil(($O->{date} - $date->seconds) / 86400); | ||||||||||||||||||||||||||||||||||||||||||
| 405 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 406 | $date = new SDate(); | ||||||||||||||||||||||||||||||||||||||||||
| 407 | return ceil(($O->{date} - $date->{date}) / 86400); | ||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||
| 411 | sub seconds | ||||||||||||||||||||||||||||||||||||||||||
| 412 | { | ||||||||||||||||||||||||||||||||||||||||||
| 413 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 414 | $O->{date}; | ||||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||
| 417 | #+--------------------------------------------------------------+ | ||||||||||||||||||||||||||||||||||||||||||
| 418 | #| Modified by Su-Che Liao on September 14, 1999 | | ||||||||||||||||||||||||||||||||||||||||||
| 419 | #| To add a new date string format "mon dd yyyy" in addition | | ||||||||||||||||||||||||||||||||||||||||||
| 420 | #| to the default format "mm/dd/yyyy" | | ||||||||||||||||||||||||||||||||||||||||||
| 421 | #+--------------------------------------------------------------+ | ||||||||||||||||||||||||||||||||||||||||||
| 422 | sub string | ||||||||||||||||||||||||||||||||||||||||||
| 423 | { | ||||||||||||||||||||||||||||||||||||||||||
| 424 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 425 | my $format = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||
| 427 | my $d = $O->{day}; | ||||||||||||||||||||||||||||||||||||||||||
| 428 | if($d < 10) { | ||||||||||||||||||||||||||||||||||||||||||
| 429 | $d = "0".$d; | ||||||||||||||||||||||||||||||||||||||||||
| 430 | $d =~ s/00/0/; | ||||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||
| 433 | my $m = $O->{month}; | ||||||||||||||||||||||||||||||||||||||||||
| 434 | if ($format eq "mon dd yyyy") { | ||||||||||||||||||||||||||||||||||||||||||
| 435 | return $mon_map[$m-1].' '.$d.' '.$O->{year}; | ||||||||||||||||||||||||||||||||||||||||||
| 436 | } elsif ($format eq "dd-mon-yyyy") { | ||||||||||||||||||||||||||||||||||||||||||
| 437 | return $d.'-'.$mon_map[$m-1].'-'.$O->{year}; | ||||||||||||||||||||||||||||||||||||||||||
| 438 | } elsif ($format eq "yyyy/mm/dd") { # default format | ||||||||||||||||||||||||||||||||||||||||||
| 439 | if($m < 10) { | ||||||||||||||||||||||||||||||||||||||||||
| 440 | $m = "0".$m; | ||||||||||||||||||||||||||||||||||||||||||
| 441 | $m =~ s/00/0/; | ||||||||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||||||
| 443 | return $O->{year}."/".$m."/".$d; | ||||||||||||||||||||||||||||||||||||||||||
| 444 | } elsif ($format eq "" || $format eq "mm/dd/yyyy") { # default format | ||||||||||||||||||||||||||||||||||||||||||
| 445 | if($m < 10) { | ||||||||||||||||||||||||||||||||||||||||||
| 446 | $m = "0".$m; | ||||||||||||||||||||||||||||||||||||||||||
| 447 | $m =~ s/00/0/; | ||||||||||||||||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||||||||||||||||
| 449 | return $m."/".$d."/".$O->{year}; | ||||||||||||||||||||||||||||||||||||||||||
| 450 | } elsif ($format eq "yyyymmdd") { # default format | ||||||||||||||||||||||||||||||||||||||||||
| 451 | if($m < 10) { | ||||||||||||||||||||||||||||||||||||||||||
| 452 | $m = "0".$m; | ||||||||||||||||||||||||||||||||||||||||||
| 453 | $m =~ s/00/0/; | ||||||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||||
| 455 | return $O->{year}.$m.$d; | ||||||||||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||
| 459 | sub add_days | ||||||||||||||||||||||||||||||||||||||||||
| 460 | { | ||||||||||||||||||||||||||||||||||||||||||
| 461 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 462 | my $days = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 463 | my ($sec, $min,$hou,$d,$m,$y) = localtime($O->{date} + 86400 * $days); | ||||||||||||||||||||||||||||||||||||||||||
| 464 | $m = $m+1;; | ||||||||||||||||||||||||||||||||||||||||||
| 465 | $y = $y+1900; | ||||||||||||||||||||||||||||||||||||||||||
| 466 | return SDate->new("$m/$d/$y") | ||||||||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||
| 469 | sub month_day { | ||||||||||||||||||||||||||||||||||||||||||
| 470 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 471 | (localtime $O->{date})[3]; | ||||||||||||||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||
| 474 | sub week_day { | ||||||||||||||||||||||||||||||||||||||||||
| 475 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 476 | (localtime $O->{date})[6]; | ||||||||||||||||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||
| 479 | sub year_day { | ||||||||||||||||||||||||||||||||||||||||||
| 480 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 481 | (localtime $O->{date})[7]; | ||||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||
| 484 | sub week_of_year { | ||||||||||||||||||||||||||||||||||||||||||
| 485 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 486 | int((localtime $O->{date})[7])/7+1; | ||||||||||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||
| 489 | sub print { | ||||||||||||||||||||||||||||||||||||||||||
| 490 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 491 | print "$O->{month}/$O->{day}/$O->{year}"; | ||||||||||||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||
| 494 | sub spaceship { | ||||||||||||||||||||||||||||||||||||||||||
| 495 | my ($this, $that) = @_; | ||||||||||||||||||||||||||||||||||||||||||
| 496 | my $date; | ||||||||||||||||||||||||||||||||||||||||||
| 497 | if(ref($this) ne "SDate") { | ||||||||||||||||||||||||||||||||||||||||||
| 498 | $date = new SDate($this); | ||||||||||||||||||||||||||||||||||||||||||
| 499 | $this = $date; | ||||||||||||||||||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||||||||||||||||
| 501 | if(ref($that) ne "SDate") { | ||||||||||||||||||||||||||||||||||||||||||
| 502 | $date = new SDate($that); | ||||||||||||||||||||||||||||||||||||||||||
| 503 | $that = $date; | ||||||||||||||||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||||||||||||||||
| 505 | $this->{date} <=> $that->{date}; | ||||||||||||||||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||
| 508 | sub stringify { | ||||||||||||||||||||||||||||||||||||||||||
| 509 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 510 | "$O->{month}/$O->{day}/$O->{year}"; | ||||||||||||||||||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||
| 513 | sub business_days { | ||||||||||||||||||||||||||||||||||||||||||
| 514 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 515 | my $date1 = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||
| 517 | my $cycle = $O->diff($date1); | ||||||||||||||||||||||||||||||||||||||||||
| 518 | my $count = 0; | ||||||||||||||||||||||||||||||||||||||||||
| 519 | for( my $i = 0; $i < $cycle; $i++){ | ||||||||||||||||||||||||||||||||||||||||||
| 520 | my $date = $date1->add_days($i); | ||||||||||||||||||||||||||||||||||||||||||
| 521 | my $number = $date->week_day; | ||||||||||||||||||||||||||||||||||||||||||
| 522 | if($number == 0) {next;} | ||||||||||||||||||||||||||||||||||||||||||
| 523 | if($number == 6) {next;} | ||||||||||||||||||||||||||||||||||||||||||
| 524 | $count++; | ||||||||||||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||||||||||
| 526 | return $count; | ||||||||||||||||||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||
| 529 | sub compare { | ||||||||||||||||||||||||||||||||||||||||||
| 530 | spaceship(@_); | ||||||||||||||||||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||
| 533 | 1; | ||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||
| 535 | use strict; | ||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||
| 537 | package HTML::STable; | ||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||
| 539 | sub new { | ||||||||||||||||||||||||||||||||||||||||||
| 540 | my $P = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 541 | my $format; | ||||||||||||||||||||||||||||||||||||||||||
| 542 | if(@_) { | ||||||||||||||||||||||||||||||||||||||||||
| 543 | $format = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 544 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 545 | $format = {}; | ||||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||
| 547 | my $O = {}; | ||||||||||||||||||||||||||||||||||||||||||
| 548 | bless $O,ref $P || $P; | ||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||
| 550 | $O->{column_number} = -1; | ||||||||||||||||||||||||||||||||||||||||||
| 551 | $O->{row_number} = 0; | ||||||||||||||||||||||||||||||||||||||||||
| 552 | $O->{arr} = undef; # holds the table from sql | ||||||||||||||||||||||||||||||||||||||||||
| 553 | $O->{front} = (); # holds strings to put fron | ||||||||||||||||||||||||||||||||||||||||||
| 554 | $O->{back} = (); # holds strings to put back | ||||||||||||||||||||||||||||||||||||||||||
| 555 | $O->{max_row} = -1; | ||||||||||||||||||||||||||||||||||||||||||
| 556 | $O->{datafile} = ""; | ||||||||||||||||||||||||||||||||||||||||||
| 557 | $O->{form} = ""; | ||||||||||||||||||||||||||||||||||||||||||
| 558 | $O->{sort_flag} = 0; | ||||||||||||||||||||||||||||||||||||||||||
| 559 | $O->{sort_hsh} = (); | ||||||||||||||||||||||||||||||||||||||||||
| 560 | $O->{sort_key_array} = (); | ||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||
| 562 | $O->{format} = $format; | ||||||||||||||||||||||||||||||||||||||||||
| 563 | $O->{row_number} = -1; | ||||||||||||||||||||||||||||||||||||||||||
| 564 | $O->{column_number} = -1; | ||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||
| 566 | foreach ( keys %$format ) | ||||||||||||||||||||||||||||||||||||||||||
| 567 | { | ||||||||||||||||||||||||||||||||||||||||||
| 568 | $O->{$_} = $format->{$_}; | ||||||||||||||||||||||||||||||||||||||||||
| 569 | } | ||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||
| 571 | #if table_tag => "off" than we do not want to print <TABLE> and </TABLE> | ||||||||||||||||||||||||||||||||||||||||||
| 572 | if($O->{table_tag}) { | ||||||||||||||||||||||||||||||||||||||||||
| 573 | $O->{no_table} = 1; | ||||||||||||||||||||||||||||||||||||||||||
| 574 | } | ||||||||||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||||||||
| 576 | if($format->{delimiter} eq "") { | ||||||||||||||||||||||||||||||||||||||||||
| 577 | $O->{delimiter} = ", "; | ||||||||||||||||||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||||||||||
| 580 | $O->{flag} = undef; # holds flag for each node, if flag set than format has changed | ||||||||||||||||||||||||||||||||||||||||||
| 581 | # for a particular node | ||||||||||||||||||||||||||||||||||||||||||
| 582 | $O->{max_row} = -1; | ||||||||||||||||||||||||||||||||||||||||||
| 583 | # following information will be used in renew method of Matrix.pm | ||||||||||||||||||||||||||||||||||||||||||
| 584 | $O->{print_columns_keep} = $O->{print_columns}; | ||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||
| 586 | my $i; | ||||||||||||||||||||||||||||||||||||||||||
| 587 | $O->{column_nodes} = (); | ||||||||||||||||||||||||||||||||||||||||||
| 588 | $O->{node_nodes} = (); | ||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||
| 590 | if($format->{filename}) { | ||||||||||||||||||||||||||||||||||||||||||
| 591 | open(FH,">>$format->{filename}") || warn "could not open $format->{filename}"; | ||||||||||||||||||||||||||||||||||||||||||
| 592 | *STDOUT = *FH; | ||||||||||||||||||||||||||||||||||||||||||
| 593 | $O->{fh} = *FH; | ||||||||||||||||||||||||||||||||||||||||||
| 594 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 595 | $O->{fh} = *STDOUT; | ||||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||
| 597 | $O->{cur_row} = 0; | ||||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||
| 599 | $O->{cur_col} = 0; | ||||||||||||||||||||||||||||||||||||||||||
| 600 | return $O; | ||||||||||||||||||||||||||||||||||||||||||
| 601 | } | ||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||
| 603 | sub print { | ||||||||||||||||||||||||||||||||||||||||||
| 604 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 605 | my $i; | ||||||||||||||||||||||||||||||||||||||||||
| 606 | my $row_num = $O->{row_number}; | ||||||||||||||||||||||||||||||||||||||||||
| 607 | $O->print_head; | ||||||||||||||||||||||||||||||||||||||||||
| 608 | if($O->{sort_flag}) { | ||||||||||||||||||||||||||||||||||||||||||
| 609 | my @keys = @{$O->{sort_key_array}}; | ||||||||||||||||||||||||||||||||||||||||||
| 610 | my %hsh = %{$O->{sort_hsh}}; | ||||||||||||||||||||||||||||||||||||||||||
| 611 | my $key; | ||||||||||||||||||||||||||||||||||||||||||
| 612 | my $rn = 0; | ||||||||||||||||||||||||||||||||||||||||||
| 613 | foreach $key (@keys) { | ||||||||||||||||||||||||||||||||||||||||||
| 614 | # we add one therefore we must remove it #@#@ | ||||||||||||||||||||||||||||||||||||||||||
| 615 | $O->print_row($hsh{$key} - 1); #@#@ | ||||||||||||||||||||||||||||||||||||||||||
| 616 | $rn++; | ||||||||||||||||||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||||||||||||||||
| 618 | # this rows added after sort therefore they will be displayed | ||||||||||||||||||||||||||||||||||||||||||
| 619 | # at the bottom without a sort | ||||||||||||||||||||||||||||||||||||||||||
| 620 | for(my $i = $rn; $i <= $row_num; $i++) { | ||||||||||||||||||||||||||||||||||||||||||
| 621 | $O->print_row($i); | ||||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||
| 623 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 624 | #write the rest of the table | ||||||||||||||||||||||||||||||||||||||||||
| 625 | for ($i = 0; $i <= $row_num; $i++) { | ||||||||||||||||||||||||||||||||||||||||||
| 626 | $O->print_row($i); | ||||||||||||||||||||||||||||||||||||||||||
| 627 | } | ||||||||||||||||||||||||||||||||||||||||||
| 628 | } | ||||||||||||||||||||||||||||||||||||||||||
| 629 | $O->print_tail; | ||||||||||||||||||||||||||||||||||||||||||
| 630 | } | ||||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||
| 632 | sub nextrow { | ||||||||||||||||||||||||||||||||||||||||||
| 633 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 634 | $O->{cur_row}++; | ||||||||||||||||||||||||||||||||||||||||||
| 635 | $O->{cur_col} = 0; | ||||||||||||||||||||||||||||||||||||||||||
| 636 | } | ||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||
| 638 | sub insert { | ||||||||||||||||||||||||||||||||||||||||||
| 639 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 640 | my ($arg1,$arg2,$arg3,$arg4) = @_; | ||||||||||||||||||||||||||||||||||||||||||
| 641 | my ($row,$col,$txt,$fmt); | ||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||
| 643 | # insert([ values ], "optional_format") | ||||||||||||||||||||||||||||||||||||||||||
| 644 | # insert([ values ], [optional_format]) | ||||||||||||||||||||||||||||||||||||||||||
| 645 | if(ref($arg1) eq "ARRAY") { | ||||||||||||||||||||||||||||||||||||||||||
| 646 | $col = 0; | ||||||||||||||||||||||||||||||||||||||||||
| 647 | $row = $O->{row_number} + 1; | ||||||||||||||||||||||||||||||||||||||||||
| 648 | $O->{cur_row} = $row; | ||||||||||||||||||||||||||||||||||||||||||
| 649 | $fmt = $arg2; | ||||||||||||||||||||||||||||||||||||||||||
| 650 | if(ref($fmt) eq "ARRAY") { | ||||||||||||||||||||||||||||||||||||||||||
| 651 | foreach (@{$arg1}) { | ||||||||||||||||||||||||||||||||||||||||||
| 652 | $O->insert($row,$col,$arg1->[$col],$fmt->[$col]); | ||||||||||||||||||||||||||||||||||||||||||
| 653 | $col++; | ||||||||||||||||||||||||||||||||||||||||||
| 654 | } | ||||||||||||||||||||||||||||||||||||||||||
| 655 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 656 | foreach (@{$arg1}) { | ||||||||||||||||||||||||||||||||||||||||||
| 657 | $O->insert($row,$col,$_,$fmt); | ||||||||||||||||||||||||||||||||||||||||||
| 658 | $col++; | ||||||||||||||||||||||||||||||||||||||||||
| 659 | } | ||||||||||||||||||||||||||||||||||||||||||
| 660 | } | ||||||||||||||||||||||||||||||||||||||||||
| 661 | return; | ||||||||||||||||||||||||||||||||||||||||||
| 662 | } | ||||||||||||||||||||||||||||||||||||||||||
| 663 | # insert(row, [ values ], "optional_format") | ||||||||||||||||||||||||||||||||||||||||||
| 664 | if(ref($arg2) eq "ARRAY") { | ||||||||||||||||||||||||||||||||||||||||||
| 665 | $col = 0; | ||||||||||||||||||||||||||||||||||||||||||
| 666 | $row = $arg1; | ||||||||||||||||||||||||||||||||||||||||||
| 667 | $fmt = $arg3; | ||||||||||||||||||||||||||||||||||||||||||
| 668 | if(ref($fmt) eq "ARRAY") { | ||||||||||||||||||||||||||||||||||||||||||
| 669 | foreach (@{$arg2}) { | ||||||||||||||||||||||||||||||||||||||||||
| 670 | $O->insert($row,$col,$arg2->[$col],$fmt->[$col]); | ||||||||||||||||||||||||||||||||||||||||||
| 671 | $col++; | ||||||||||||||||||||||||||||||||||||||||||
| 672 | } | ||||||||||||||||||||||||||||||||||||||||||
| 673 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 674 | foreach (@{$arg2}) { | ||||||||||||||||||||||||||||||||||||||||||
| 675 | $O->insert($row,$col,$arg2->[$col],$fmt); | ||||||||||||||||||||||||||||||||||||||||||
| 676 | $col++; | ||||||||||||||||||||||||||||||||||||||||||
| 677 | } | ||||||||||||||||||||||||||||||||||||||||||
| 678 | } | ||||||||||||||||||||||||||||||||||||||||||
| 679 | return; | ||||||||||||||||||||||||||||||||||||||||||
| 680 | } | ||||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||
| 682 | # insert(row, col, [ values ], "optional_format") | ||||||||||||||||||||||||||||||||||||||||||
| 683 | if(ref($arg3) eq "ARRAY") { | ||||||||||||||||||||||||||||||||||||||||||
| 684 | $row = $arg1; | ||||||||||||||||||||||||||||||||||||||||||
| 685 | $col = $arg2; | ||||||||||||||||||||||||||||||||||||||||||
| 686 | $fmt = $arg4; | ||||||||||||||||||||||||||||||||||||||||||
| 687 | my $i = 0; | ||||||||||||||||||||||||||||||||||||||||||
| 688 | if(ref($fmt) eq "ARRAY") { | ||||||||||||||||||||||||||||||||||||||||||
| 689 | foreach (@{$arg3}) { | ||||||||||||||||||||||||||||||||||||||||||
| 690 | $O->insert($row,$col,$arg3->[$i],$fmt->[$i]); | ||||||||||||||||||||||||||||||||||||||||||
| 691 | $i++; | ||||||||||||||||||||||||||||||||||||||||||
| 692 | $col++; | ||||||||||||||||||||||||||||||||||||||||||
| 693 | } | ||||||||||||||||||||||||||||||||||||||||||
| 694 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 695 | foreach (@{$arg3}) { | ||||||||||||||||||||||||||||||||||||||||||
| 696 | $O->insert($row,$col,$arg3->[$i++],$fmt); | ||||||||||||||||||||||||||||||||||||||||||
| 697 | $col++; | ||||||||||||||||||||||||||||||||||||||||||
| 698 | } | ||||||||||||||||||||||||||||||||||||||||||
| 699 | } | ||||||||||||||||||||||||||||||||||||||||||
| 700 | return; | ||||||||||||||||||||||||||||||||||||||||||
| 701 | } | ||||||||||||||||||||||||||||||||||||||||||
| 702 | # insert(value, "optional_format") | ||||||||||||||||||||||||||||||||||||||||||
| 703 | # delete this only keep whatever inside else | ||||||||||||||||||||||||||||||||||||||||||
| 704 | if($#_ <= 1) { | ||||||||||||||||||||||||||||||||||||||||||
| 705 | $txt = $arg1; | ||||||||||||||||||||||||||||||||||||||||||
| 706 | $fmt = $arg2; | ||||||||||||||||||||||||||||||||||||||||||
| 707 | if($txt eq "\n") { | ||||||||||||||||||||||||||||||||||||||||||
| 708 | $O->nextrow; | ||||||||||||||||||||||||||||||||||||||||||
| 709 | return; | ||||||||||||||||||||||||||||||||||||||||||
| 710 | } | ||||||||||||||||||||||||||||||||||||||||||
| 711 | $col = $O->{cur_col}; | ||||||||||||||||||||||||||||||||||||||||||
| 712 | if($O->{cur_row} == $O->{row_number}) { | ||||||||||||||||||||||||||||||||||||||||||
| 713 | $row = $O->{row_number} + 1; | ||||||||||||||||||||||||||||||||||||||||||
| 714 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 715 | $row = $O->{row_number}; | ||||||||||||||||||||||||||||||||||||||||||
| 716 | } | ||||||||||||||||||||||||||||||||||||||||||
| 717 | $O->{cur_col}++; | ||||||||||||||||||||||||||||||||||||||||||
| 718 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 719 | ($row,$col,$txt,$fmt) = ($arg1,$arg2,$arg3,$arg4); | ||||||||||||||||||||||||||||||||||||||||||
| 720 | } | ||||||||||||||||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||||||||||||||||
| 722 | if($row < 0 || $col < 0) { | ||||||||||||||||||||||||||||||||||||||||||
| 723 | my ($package, $filename, $line) = caller(0); | ||||||||||||||||||||||||||||||||||||||||||
| 724 | print ERROR ref($O).": Error at $filename at line $line \n"; | ||||||||||||||||||||||||||||||||||||||||||
| 725 | print ERROR ref($O).": Negative index ROW = $row COL = $col \n"; | ||||||||||||||||||||||||||||||||||||||||||
| 726 | exit; | ||||||||||||||||||||||||||||||||||||||||||
| 727 | } | ||||||||||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||||||||||
| 729 | if($O->{row_number} < $row) { | ||||||||||||||||||||||||||||||||||||||||||
| 730 | $O->{row_number} = $row; | ||||||||||||||||||||||||||||||||||||||||||
| 731 | } | ||||||||||||||||||||||||||||||||||||||||||
| 732 | if($O->{column_number} < $col) { | ||||||||||||||||||||||||||||||||||||||||||
| 733 | $O->{column_number} = $col; | ||||||||||||||||||||||||||||||||||||||||||
| 734 | } | ||||||||||||||||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||||||||||||||||
| 736 | if($O->{alter_row_formats}) { | ||||||||||||||||||||||||||||||||||||||||||
| 737 | my $count = $#{$O->{alter_row_formats}} + 1; | ||||||||||||||||||||||||||||||||||||||||||
| 738 | my $index = $row % $count; | ||||||||||||||||||||||||||||||||||||||||||
| 739 | $count = $#{$O->{headers}}; | ||||||||||||||||||||||||||||||||||||||||||
| 740 | if($count < 0) { $count = $col; } | ||||||||||||||||||||||||||||||||||||||||||
| 741 | for(my $j = $col; $j <= $count; $j++) | ||||||||||||||||||||||||||||||||||||||||||
| 742 | { | ||||||||||||||||||||||||||||||||||||||||||
| 743 | if($O->{chessboard}) { | ||||||||||||||||||||||||||||||||||||||||||
| 744 | $index = ($row + $j) % 2; | ||||||||||||||||||||||||||||||||||||||||||
| 745 | } | ||||||||||||||||||||||||||||||||||||||||||
| 746 | $fmt = $O->{alter_row_formats}[$index]; | ||||||||||||||||||||||||||||||||||||||||||
| 747 | $O->{node_nodes}[$row][$j] = new SNode($fmt); | ||||||||||||||||||||||||||||||||||||||||||
| 748 | $O->{flag}[$row][$j] = 200; | ||||||||||||||||||||||||||||||||||||||||||
| 749 | } | ||||||||||||||||||||||||||||||||||||||||||
| 750 | $O->{arr}[$row][$col] = $txt; | ||||||||||||||||||||||||||||||||||||||||||
| 751 | return; | ||||||||||||||||||||||||||||||||||||||||||
| 752 | } | ||||||||||||||||||||||||||||||||||||||||||
| 753 | $O->{flag}[$row][$col] = 100; # value inserted but no format changes | ||||||||||||||||||||||||||||||||||||||||||
| 754 | if($fmt ne "") { #if there is a format string | ||||||||||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||||||||||
| 756 | # add new format values into front of body_format. First accurance has | ||||||||||||||||||||||||||||||||||||||||||
| 757 | # precedence, if ve redefine color old color will be overridden. | ||||||||||||||||||||||||||||||||||||||||||
| 758 | # $fmt = $fmt.";".$O->{body_format}; | ||||||||||||||||||||||||||||||||||||||||||
| 759 | # node format has higher precedence that column_formats and | ||||||||||||||||||||||||||||||||||||||||||
| 760 | # column formats has higher precedence than body_format | ||||||||||||||||||||||||||||||||||||||||||
| 761 | |||||||||||||||||||||||||||||||||||||||||||
| 762 | $fmt = $O->{body_format}.";".$O->{column_formats}[$col].";".$fmt; | ||||||||||||||||||||||||||||||||||||||||||
| 763 | $O->{node_nodes}[$row][$col] = new SNode($fmt); | ||||||||||||||||||||||||||||||||||||||||||
| 764 | $O->{flag}[$row][$col] = 200; # value inserted and there is format changes | ||||||||||||||||||||||||||||||||||||||||||
| 765 | } | ||||||||||||||||||||||||||||||||||||||||||
| 766 | $O->{arr}[$row][$col] = $txt; | ||||||||||||||||||||||||||||||||||||||||||
| 767 | } | ||||||||||||||||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||||||||||||||||
| 769 | sub column_insert { | ||||||||||||||||||||||||||||||||||||||||||
| 770 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 771 | my ($arg1,$arg2,$arg3,$arg4) = @_; | ||||||||||||||||||||||||||||||||||||||||||
| 772 | my ($row,$col,$ar,$fmt); | ||||||||||||||||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||||||||||||||||
| 774 | if(ref($arg2) eq "ARRAY") | ||||||||||||||||||||||||||||||||||||||||||
| 775 | { | ||||||||||||||||||||||||||||||||||||||||||
| 776 | $row = 0; | ||||||||||||||||||||||||||||||||||||||||||
| 777 | $col = $arg1; | ||||||||||||||||||||||||||||||||||||||||||
| 778 | $ar = $arg2; | ||||||||||||||||||||||||||||||||||||||||||
| 779 | $fmt = $arg3; | ||||||||||||||||||||||||||||||||||||||||||
| 780 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 781 | $row = $arg1; | ||||||||||||||||||||||||||||||||||||||||||
| 782 | $col = $arg2; | ||||||||||||||||||||||||||||||||||||||||||
| 783 | $ar = $arg3; | ||||||||||||||||||||||||||||||||||||||||||
| 784 | $fmt = $arg4; | ||||||||||||||||||||||||||||||||||||||||||
| 785 | } | ||||||||||||||||||||||||||||||||||||||||||
| 786 | foreach (@{$ar}) { | ||||||||||||||||||||||||||||||||||||||||||
| 787 | $O->insert($row,$col,$ar->[$row],$fmt); | ||||||||||||||||||||||||||||||||||||||||||
| 788 | $row++; | ||||||||||||||||||||||||||||||||||||||||||
| 789 | } | ||||||||||||||||||||||||||||||||||||||||||
| 790 | } | ||||||||||||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||||||||||||
| 792 | sub delimiter { | ||||||||||||||||||||||||||||||||||||||||||
| 793 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 794 | return $O->{delimiter}; | ||||||||||||||||||||||||||||||||||||||||||
| 795 | } | ||||||||||||||||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||||||||||||||||
| 797 | sub cell_format | ||||||||||||||||||||||||||||||||||||||||||
| 798 | { | ||||||||||||||||||||||||||||||||||||||||||
| 799 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 800 | my $row = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 801 | my $col = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 802 | my ($ar) = @_; | ||||||||||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||||||||||
| 804 | if(ref($ar)) { | ||||||||||||||||||||||||||||||||||||||||||
| 805 | my $fmt; | ||||||||||||||||||||||||||||||||||||||||||
| 806 | foreach $fmt (@{$ar}) { | ||||||||||||||||||||||||||||||||||||||||||
| 807 | $O->{node_nodes}[$row][$col] = new SNode($fmt); | ||||||||||||||||||||||||||||||||||||||||||
| 808 | # value inserted and there is format changes | ||||||||||||||||||||||||||||||||||||||||||
| 809 | $O->{flag}[$row][$col] = 200; | ||||||||||||||||||||||||||||||||||||||||||
| 810 | $col++; | ||||||||||||||||||||||||||||||||||||||||||
| 811 | } | ||||||||||||||||||||||||||||||||||||||||||
| 812 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 813 | my $fmt = $ar; | ||||||||||||||||||||||||||||||||||||||||||
| 814 | $O->{node_nodes}[$row][$col] = new SNode($fmt); | ||||||||||||||||||||||||||||||||||||||||||
| 815 | # value inserted and there is format changes | ||||||||||||||||||||||||||||||||||||||||||
| 816 | $O->{flag}[$row][$col] = 200; | ||||||||||||||||||||||||||||||||||||||||||
| 817 | } | ||||||||||||||||||||||||||||||||||||||||||
| 818 | } | ||||||||||||||||||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||||||||||||||||
| 820 | sub row_format | ||||||||||||||||||||||||||||||||||||||||||
| 821 | { | ||||||||||||||||||||||||||||||||||||||||||
| 822 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 823 | my $row = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 824 | my $fmt = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 825 | my $cn = $O->{column_number}; | ||||||||||||||||||||||||||||||||||||||||||
| 826 | my $i; | ||||||||||||||||||||||||||||||||||||||||||
| 827 | for($i = 0; $i <= $cn; $i++) { | ||||||||||||||||||||||||||||||||||||||||||
| 828 | $O->cell_format($row,$i,$fmt); | ||||||||||||||||||||||||||||||||||||||||||
| 829 | } | ||||||||||||||||||||||||||||||||||||||||||
| 830 | } | ||||||||||||||||||||||||||||||||||||||||||
| 831 | |||||||||||||||||||||||||||||||||||||||||||
| 832 | sub print_head { | ||||||||||||||||||||||||||||||||||||||||||
| 833 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 834 | my ($i,$j); | ||||||||||||||||||||||||||||||||||||||||||
| 835 | $O->{head_nodes} = new SNode($O->{head_format}); | ||||||||||||||||||||||||||||||||||||||||||
| 836 | my $temp_node; | ||||||||||||||||||||||||||||||||||||||||||
| 837 | my $col_num = $#{$O->{print_columns}}; | ||||||||||||||||||||||||||||||||||||||||||
| 838 | my $row_num = $O->{row_number}; | ||||||||||||||||||||||||||||||||||||||||||
| 839 | |||||||||||||||||||||||||||||||||||||||||||
| 840 | if($col_num <= $O->{column_number}) { | ||||||||||||||||||||||||||||||||||||||||||
| 841 | $col_num = $O->{column_number}; | ||||||||||||||||||||||||||||||||||||||||||
| 842 | if($#{$O->{print_columns}} < 0) { | ||||||||||||||||||||||||||||||||||||||||||
| 843 | $O->{print_columns} = [0..$col_num]; | ||||||||||||||||||||||||||||||||||||||||||
| 844 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 845 | $col_num = $#{$O->{print_columns}}; | ||||||||||||||||||||||||||||||||||||||||||
| 846 | } | ||||||||||||||||||||||||||||||||||||||||||
| 847 | } | ||||||||||||||||||||||||||||||||||||||||||
| 848 | |||||||||||||||||||||||||||||||||||||||||||
| 849 | if($O->{title}) { | ||||||||||||||||||||||||||||||||||||||||||
| 850 | $O->title($O->{title}); | ||||||||||||||||||||||||||||||||||||||||||
| 851 | } | ||||||||||||||||||||||||||||||||||||||||||
| 852 | if($O->{date} eq "yes") { | ||||||||||||||||||||||||||||||||||||||||||
| 853 | $O->date; | ||||||||||||||||||||||||||||||||||||||||||
| 854 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 855 | $O->title($O->{date}); | ||||||||||||||||||||||||||||||||||||||||||
| 856 | } | ||||||||||||||||||||||||||||||||||||||||||
| 857 | if($O->{sub_title}) { | ||||||||||||||||||||||||||||||||||||||||||
| 858 | $O->_sub_title; | ||||||||||||||||||||||||||||||||||||||||||
| 859 | } | ||||||||||||||||||||||||||||||||||||||||||
| 860 | |||||||||||||||||||||||||||||||||||||||||||
| 861 | if($row_num < 0) { | ||||||||||||||||||||||||||||||||||||||||||
| 862 | if(ref($O->{empty_msg}) eq "HTML::STable") { | ||||||||||||||||||||||||||||||||||||||||||
| 863 | $O->{empty_msg}->print; | ||||||||||||||||||||||||||||||||||||||||||
| 864 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 865 | print "<center><font color=red size =5> | ||||||||||||||||||||||||||||||||||||||||||
| 866 | <BR>$O->{empty_msg}<BR></font></center>"; | ||||||||||||||||||||||||||||||||||||||||||
| 867 | } | ||||||||||||||||||||||||||||||||||||||||||
| 868 | return; | ||||||||||||||||||||||||||||||||||||||||||
| 869 | } | ||||||||||||||||||||||||||||||||||||||||||
| 870 | |||||||||||||||||||||||||||||||||||||||||||
| 871 | for($i = 0; $i <= $col_num; $i++) { | ||||||||||||||||||||||||||||||||||||||||||
| 872 | my $k = $O->{print_columns}[$i]; | ||||||||||||||||||||||||||||||||||||||||||
| 873 | if($O->{column_formats}[$k] eq "" ) { | ||||||||||||||||||||||||||||||||||||||||||
| 874 | $O->{column_nodes}[$k] = new SNode($O->{body_format}); | ||||||||||||||||||||||||||||||||||||||||||
| 875 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 876 | my $fmt = $O->{body_format}.";".$O->{column_formats}[$k]; | ||||||||||||||||||||||||||||||||||||||||||
| 877 | $O->{column_nodes}[$k] = new SNode($fmt); | ||||||||||||||||||||||||||||||||||||||||||
| 878 | } | ||||||||||||||||||||||||||||||||||||||||||
| 879 | } | ||||||||||||||||||||||||||||||||||||||||||
| 880 | |||||||||||||||||||||||||||||||||||||||||||
| 881 | if($O->{no_table} != 1) { | ||||||||||||||||||||||||||||||||||||||||||
| 882 | my $fmt = $O->{table_format}; | ||||||||||||||||||||||||||||||||||||||||||
| 883 | $fmt =~ tr/;/ /; | ||||||||||||||||||||||||||||||||||||||||||
| 884 | $fmt =~ tr/:/=/; | ||||||||||||||||||||||||||||||||||||||||||
| 885 | if(!($fmt =~ /align/)) { | ||||||||||||||||||||||||||||||||||||||||||
| 886 | $fmt .= " align=center"; # default alignment for table | ||||||||||||||||||||||||||||||||||||||||||
| 887 | } | ||||||||||||||||||||||||||||||||||||||||||
| 888 | print "\n<TABLE $fmt>\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 889 | } | ||||||||||||||||||||||||||||||||||||||||||
| 890 | |||||||||||||||||||||||||||||||||||||||||||
| 891 | #first write headers | ||||||||||||||||||||||||||||||||||||||||||
| 892 | if($O->{headers}) { # if present than headers will be printed | ||||||||||||||||||||||||||||||||||||||||||
| 893 | print "<TR>\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 894 | $temp_node = $O->{head_nodes}; | ||||||||||||||||||||||||||||||||||||||||||
| 895 | for($j = 0; $j <= $col_num; $j++) { | ||||||||||||||||||||||||||||||||||||||||||
| 896 | my $k = $O->{print_columns}[$j]; | ||||||||||||||||||||||||||||||||||||||||||
| 897 | $temp_node->print($O->{headers}[$k]); | ||||||||||||||||||||||||||||||||||||||||||
| 898 | } | ||||||||||||||||||||||||||||||||||||||||||
| 899 | print "</TR>\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 900 | } | ||||||||||||||||||||||||||||||||||||||||||
| 901 | } | ||||||||||||||||||||||||||||||||||||||||||
| 902 | |||||||||||||||||||||||||||||||||||||||||||
| 903 | sub print_row { | ||||||||||||||||||||||||||||||||||||||||||
| 904 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 905 | my $i = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 906 | my $j; | ||||||||||||||||||||||||||||||||||||||||||
| 907 | my $temp_node; | ||||||||||||||||||||||||||||||||||||||||||
| 908 | my $col_num = $#{$O->{print_columns}}; | ||||||||||||||||||||||||||||||||||||||||||
| 909 | print "<TR>\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 910 | for($j = 0; $j <= $col_num; $j++) { | ||||||||||||||||||||||||||||||||||||||||||
| 911 | my $k = $O->{print_columns}[$j]; | ||||||||||||||||||||||||||||||||||||||||||
| 912 | $temp_node = $O->{column_nodes}[$k]; | ||||||||||||||||||||||||||||||||||||||||||
| 913 | if($O->{flag}[$i][$k] == 100 || $O->{flag}[$i][$k] == 200) { | ||||||||||||||||||||||||||||||||||||||||||
| 914 | if($O->{flag}[$i][$k] == 200) { | ||||||||||||||||||||||||||||||||||||||||||
| 915 | $temp_node = $O->{node_nodes}[$i][$k]; | ||||||||||||||||||||||||||||||||||||||||||
| 916 | } | ||||||||||||||||||||||||||||||||||||||||||
| 917 | # check whether colspan or rowspan has been used or not, | ||||||||||||||||||||||||||||||||||||||||||
| 918 | # if they are used set $O->{flag}[?][?] = 400 | ||||||||||||||||||||||||||||||||||||||||||
| 919 | # by doing that table printing will skip extra cells | ||||||||||||||||||||||||||||||||||||||||||
| 920 | my $col_span = $temp_node->colspan; | ||||||||||||||||||||||||||||||||||||||||||
| 921 | if($col_span != 0) { | ||||||||||||||||||||||||||||||||||||||||||
| 922 | my $c; | ||||||||||||||||||||||||||||||||||||||||||
| 923 | for($c = 1; $c < $col_span; $c++) { | ||||||||||||||||||||||||||||||||||||||||||
| 924 | $O->{flag}[$i][$k+$c] = 400; | ||||||||||||||||||||||||||||||||||||||||||
| 925 | } | ||||||||||||||||||||||||||||||||||||||||||
| 926 | } | ||||||||||||||||||||||||||||||||||||||||||
| 927 | my $row_span = $temp_node->rowspan; | ||||||||||||||||||||||||||||||||||||||||||
| 928 | if($row_span != 0) { | ||||||||||||||||||||||||||||||||||||||||||
| 929 | my $r; | ||||||||||||||||||||||||||||||||||||||||||
| 930 | for($r = 1; $r < $row_span; $r++) { | ||||||||||||||||||||||||||||||||||||||||||
| 931 | $O->{flag}[$i+$r][$k] = 400; | ||||||||||||||||||||||||||||||||||||||||||
| 932 | } | ||||||||||||||||||||||||||||||||||||||||||
| 933 | } | ||||||||||||||||||||||||||||||||||||||||||
| 934 | if($row_span != 0 && $col_span != 0) { | ||||||||||||||||||||||||||||||||||||||||||
| 935 | my ($c,$r); | ||||||||||||||||||||||||||||||||||||||||||
| 936 | for($c = 1; $c < $col_span; $c++) { | ||||||||||||||||||||||||||||||||||||||||||
| 937 | for($r = 1; $r < $row_span; $r++) { | ||||||||||||||||||||||||||||||||||||||||||
| 938 | $O->{flag}[$i+$r][$k+$c] = 400; | ||||||||||||||||||||||||||||||||||||||||||
| 939 | } | ||||||||||||||||||||||||||||||||||||||||||
| 940 | } | ||||||||||||||||||||||||||||||||||||||||||
| 941 | } | ||||||||||||||||||||||||||||||||||||||||||
| 942 | my $tobj = $O->{arr}[$i][$k]; | ||||||||||||||||||||||||||||||||||||||||||
| 943 | if(ref($tobj)) { | ||||||||||||||||||||||||||||||||||||||||||
| 944 | $temp_node->print($tobj); | ||||||||||||||||||||||||||||||||||||||||||
| 945 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 946 | if($tobj =~ "<HR>") { | ||||||||||||||||||||||||||||||||||||||||||
| 947 | $temp_node->print($O->{front}[$i][$j]. | ||||||||||||||||||||||||||||||||||||||||||
| 948 | $tobj. | ||||||||||||||||||||||||||||||||||||||||||
| 949 | $O->{back}[$i][$k]." "); | ||||||||||||||||||||||||||||||||||||||||||
| 950 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 951 | if($tobj eq "" && $O->{empty_cell_text}) { | ||||||||||||||||||||||||||||||||||||||||||
| 952 | $O->_null_empty("empty",$k,$temp_node); | ||||||||||||||||||||||||||||||||||||||||||
| 953 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 954 | $temp_node->print($O->{front}[$i][$j]. | ||||||||||||||||||||||||||||||||||||||||||
| 955 | $tobj. | ||||||||||||||||||||||||||||||||||||||||||
| 956 | $O->{back}[$i][$k]."  "); | ||||||||||||||||||||||||||||||||||||||||||
| 957 | } | ||||||||||||||||||||||||||||||||||||||||||
| 958 | } | ||||||||||||||||||||||||||||||||||||||||||
| 959 | } | ||||||||||||||||||||||||||||||||||||||||||
| 960 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 961 | if($O->{flag}[$i][$k] != 400) { | ||||||||||||||||||||||||||||||||||||||||||
| 962 | if($O->{null_cell_text}) { | ||||||||||||||||||||||||||||||||||||||||||
| 963 | $O->_null_empty("null",$k,$temp_node); | ||||||||||||||||||||||||||||||||||||||||||
| 964 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 965 | $temp_node->print("  "); | ||||||||||||||||||||||||||||||||||||||||||
| 966 | } | ||||||||||||||||||||||||||||||||||||||||||
| 967 | } | ||||||||||||||||||||||||||||||||||||||||||
| 968 | } | ||||||||||||||||||||||||||||||||||||||||||
| 969 | } | ||||||||||||||||||||||||||||||||||||||||||
| 970 | print "</TR>\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 971 | } | ||||||||||||||||||||||||||||||||||||||||||
| 972 | |||||||||||||||||||||||||||||||||||||||||||
| 973 | sub print_tail { | ||||||||||||||||||||||||||||||||||||||||||
| 974 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 975 | if($O->{no_table} != 1) { | ||||||||||||||||||||||||||||||||||||||||||
| 976 | print "</TABLE>\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 977 | } | ||||||||||||||||||||||||||||||||||||||||||
| 978 | |||||||||||||||||||||||||||||||||||||||||||
| 979 | my $str = $O->{download}; | ||||||||||||||||||||||||||||||||||||||||||
| 980 | # if $str ne "" then download the data | ||||||||||||||||||||||||||||||||||||||||||
| 981 | if($str) { | ||||||||||||||||||||||||||||||||||||||||||
| 982 | $O->download; | ||||||||||||||||||||||||||||||||||||||||||
| 983 | $O->show_button($str); | ||||||||||||||||||||||||||||||||||||||||||
| 984 | } | ||||||||||||||||||||||||||||||||||||||||||
| 985 | } | ||||||||||||||||||||||||||||||||||||||||||
| 986 | |||||||||||||||||||||||||||||||||||||||||||
| 987 | sub table_format { | ||||||||||||||||||||||||||||||||||||||||||
| 988 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 989 | my $fmt = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 990 | $fmt =~ tr/;/ /; | ||||||||||||||||||||||||||||||||||||||||||
| 991 | $fmt =~ tr/:/=/; | ||||||||||||||||||||||||||||||||||||||||||
| 992 | $O->{table_format} = $fmt; | ||||||||||||||||||||||||||||||||||||||||||
| 993 | } | ||||||||||||||||||||||||||||||||||||||||||
| 994 | |||||||||||||||||||||||||||||||||||||||||||
| 995 | sub head_format { my $O = shift; $O->{head_format} = shift;} | ||||||||||||||||||||||||||||||||||||||||||
| 996 | sub body_format { my $O = shift; $O->{body_format} = shift;} | ||||||||||||||||||||||||||||||||||||||||||
| 997 | sub column_formats { my $O = shift; $O->{column_formats} = shift;} | ||||||||||||||||||||||||||||||||||||||||||
| 998 | sub print_columns { my $O = shift; $O->{print_columns} = shift;} | ||||||||||||||||||||||||||||||||||||||||||
| 999 | sub headers { my $O = shift; $O->{headers} = shift;} | ||||||||||||||||||||||||||||||||||||||||||
| 1000 | sub empty_msg { my $O = shift; $O->{empty_msg} = shift;} | ||||||||||||||||||||||||||||||||||||||||||
| 1001 | sub sub_title { my $O = shift; $O->{sub_title} = shift;} | ||||||||||||||||||||||||||||||||||||||||||
| 1002 | sub alter_row_formats { my $O = shift; $O->{alter_row_formats} = shift;} | ||||||||||||||||||||||||||||||||||||||||||
| 1003 | |||||||||||||||||||||||||||||||||||||||||||
| 1004 | sub my_insert {my $O = shift; sub { $O->insert(@_)};} | ||||||||||||||||||||||||||||||||||||||||||
| 1005 | sub my_linkto {my $O = shift; sub { $O->linkto(@_)};} | ||||||||||||||||||||||||||||||||||||||||||
| 1006 | sub my_script {my $O = shift; sub { $O->script(@_)};} | ||||||||||||||||||||||||||||||||||||||||||
| 1007 | |||||||||||||||||||||||||||||||||||||||||||
| 1008 | sub sort { | ||||||||||||||||||||||||||||||||||||||||||
| 1009 | require Sort::Fields; | ||||||||||||||||||||||||||||||||||||||||||
| 1010 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1011 | my $cols = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1012 | |||||||||||||||||||||||||||||||||||||||||||
| 1013 | my %hsh; | ||||||||||||||||||||||||||||||||||||||||||
| 1014 | |||||||||||||||||||||||||||||||||||||||||||
| 1015 | my ($i,$j); | ||||||||||||||||||||||||||||||||||||||||||
| 1016 | |||||||||||||||||||||||||||||||||||||||||||
| 1017 | my $row_num = $O->{row_number}; | ||||||||||||||||||||||||||||||||||||||||||
| 1018 | my $col_num = $O->{column_number}; | ||||||||||||||||||||||||||||||||||||||||||
| 1019 | |||||||||||||||||||||||||||||||||||||||||||
| 1020 | my %d_indx = (); | ||||||||||||||||||||||||||||||||||||||||||
| 1021 | my %a_indx = (); | ||||||||||||||||||||||||||||||||||||||||||
| 1022 | # convert d to n for numeric date sort | ||||||||||||||||||||||||||||||||||||||||||
| 1023 | foreach ( @$cols ) { | ||||||||||||||||||||||||||||||||||||||||||
| 1024 | # increment all column numbers by one | ||||||||||||||||||||||||||||||||||||||||||
| 1025 | s/([0-9]+)/$1+1/e; | ||||||||||||||||||||||||||||||||||||||||||
| 1026 | if(/d/) { | ||||||||||||||||||||||||||||||||||||||||||
| 1027 | my $ind = $_; | ||||||||||||||||||||||||||||||||||||||||||
| 1028 | $ind =~ tr/[\-d]/ /; | ||||||||||||||||||||||||||||||||||||||||||
| 1029 | $ind =~ s/ //g; | ||||||||||||||||||||||||||||||||||||||||||
| 1030 | tr/d/n/; | ||||||||||||||||||||||||||||||||||||||||||
| 1031 | $d_indx{$ind} = 1; | ||||||||||||||||||||||||||||||||||||||||||
| 1032 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1033 | # remove "i" from column name | ||||||||||||||||||||||||||||||||||||||||||
| 1034 | if(/i/) { | ||||||||||||||||||||||||||||||||||||||||||
| 1035 | my $ind = $_; | ||||||||||||||||||||||||||||||||||||||||||
| 1036 | $ind =~ tr/[\-i]/ /; | ||||||||||||||||||||||||||||||||||||||||||
| 1037 | $ind =~ s/ //g; | ||||||||||||||||||||||||||||||||||||||||||
| 1038 | s/i//; | ||||||||||||||||||||||||||||||||||||||||||
| 1039 | $a_indx{$ind} = 1; | ||||||||||||||||||||||||||||||||||||||||||
| 1040 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1041 | if(/A/) { # convert A tag to 0 to obey all rules of Sort::Fields | ||||||||||||||||||||||||||||||||||||||||||
| 1042 | tr/A/0/; | ||||||||||||||||||||||||||||||||||||||||||
| 1043 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1044 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1045 | for($i = 0; $i <= $row_num; $i++) { | ||||||||||||||||||||||||||||||||||||||||||
| 1046 | my $tmp = ""; | ||||||||||||||||||||||||||||||||||||||||||
| 1047 | my @arr = (); | ||||||||||||||||||||||||||||||||||||||||||
| 1048 | for($j = 0; $j <= $col_num; $j++) { | ||||||||||||||||||||||||||||||||||||||||||
| 1049 | if($d_indx{$j+1}) { | ||||||||||||||||||||||||||||||||||||||||||
| 1050 | push(@arr, SDate->new($O->node($i,$j))->seconds); | ||||||||||||||||||||||||||||||||||||||||||
| 1051 | } elsif($a_indx{$j+1}) { | ||||||||||||||||||||||||||||||||||||||||||
| 1052 | push(@arr, uc ($O->node($i,$j))); | ||||||||||||||||||||||||||||||||||||||||||
| 1053 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1054 | my $val; | ||||||||||||||||||||||||||||||||||||||||||
| 1055 | if(ref($O->node($i,$j))) { | ||||||||||||||||||||||||||||||||||||||||||
| 1056 | $val = ref($O->node($i,$j)); | ||||||||||||||||||||||||||||||||||||||||||
| 1057 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1058 | $val = $O->node($i,$j); | ||||||||||||||||||||||||||||||||||||||||||
| 1059 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1060 | $val =~ s/\://g; | ||||||||||||||||||||||||||||||||||||||||||
| 1061 | push(@arr, $val); | ||||||||||||||||||||||||||||||||||||||||||
| 1062 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1063 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1064 | $tmp = join("\:",@arr); | ||||||||||||||||||||||||||||||||||||||||||
| 1065 | while(exists($hsh{$tmp})) { | ||||||||||||||||||||||||||||||||||||||||||
| 1066 | $tmp .= "a"; | ||||||||||||||||||||||||||||||||||||||||||
| 1067 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1068 | # we add 1 here to make while loop work with $i = 0 #@#@ | ||||||||||||||||||||||||||||||||||||||||||
| 1069 | $hsh{$tmp} = $i + 1; #@#@ | ||||||||||||||||||||||||||||||||||||||||||
| 1070 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1071 | |||||||||||||||||||||||||||||||||||||||||||
| 1072 | my @keys; | ||||||||||||||||||||||||||||||||||||||||||
| 1073 | |||||||||||||||||||||||||||||||||||||||||||
| 1074 | @keys = Sort::Fields::fieldsort('\:', $cols, (keys %hsh)); | ||||||||||||||||||||||||||||||||||||||||||
| 1075 | |||||||||||||||||||||||||||||||||||||||||||
| 1076 | $O->{sort_hsh} = \%hsh; | ||||||||||||||||||||||||||||||||||||||||||
| 1077 | $O->{sort_key_array} = \@keys; | ||||||||||||||||||||||||||||||||||||||||||
| 1078 | $O->{sort_flag} = 1; | ||||||||||||||||||||||||||||||||||||||||||
| 1079 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1080 | |||||||||||||||||||||||||||||||||||||||||||
| 1081 | sub sum | ||||||||||||||||||||||||||||||||||||||||||
| 1082 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1083 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1084 | my $col = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1085 | my $row = $O->{row_number}; | ||||||||||||||||||||||||||||||||||||||||||
| 1086 | |||||||||||||||||||||||||||||||||||||||||||
| 1087 | my $sum = 0; | ||||||||||||||||||||||||||||||||||||||||||
| 1088 | for(my $i = 0; $i <= $row; $i++) { | ||||||||||||||||||||||||||||||||||||||||||
| 1089 | $_ = $O->node($i,$col); | ||||||||||||||||||||||||||||||||||||||||||
| 1090 | tr/[$a-zA-Z]//; | ||||||||||||||||||||||||||||||||||||||||||
| 1091 | s/,//g; | ||||||||||||||||||||||||||||||||||||||||||
| 1092 | $sum += $_; | ||||||||||||||||||||||||||||||||||||||||||
| 1093 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1094 | if(@_) { | ||||||||||||||||||||||||||||||||||||||||||
| 1095 | if($_[0]->{comma}) | ||||||||||||||||||||||||||||||||||||||||||
| 1096 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1097 | $_ = $sum; | ||||||||||||||||||||||||||||||||||||||||||
| 1098 | 1 while s/^(-?\d+)(\d{3})/$1,$2/; | ||||||||||||||||||||||||||||||||||||||||||
| 1099 | if($_[0]->{dolar}) { | ||||||||||||||||||||||||||||||||||||||||||
| 1100 | return '$'.$_; | ||||||||||||||||||||||||||||||||||||||||||
| 1101 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1102 | return $_; | ||||||||||||||||||||||||||||||||||||||||||
| 1103 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1104 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1105 | |||||||||||||||||||||||||||||||||||||||||||
| 1106 | return $sum; | ||||||||||||||||||||||||||||||||||||||||||
| 1107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1108 | |||||||||||||||||||||||||||||||||||||||||||
| 1109 | sub table_tag_off { | ||||||||||||||||||||||||||||||||||||||||||
| 1110 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1111 | $O->{no_table} = 1; | ||||||||||||||||||||||||||||||||||||||||||
| 1112 | return $O; | ||||||||||||||||||||||||||||||||||||||||||
| 1113 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1114 | |||||||||||||||||||||||||||||||||||||||||||
| 1115 | sub null_cell_text { | ||||||||||||||||||||||||||||||||||||||||||
| 1116 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1117 | $O->{null_cell_text} = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1119 | |||||||||||||||||||||||||||||||||||||||||||
| 1120 | sub null_cell_format { | ||||||||||||||||||||||||||||||||||||||||||
| 1121 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1122 | $O->{null_cell_format} = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1123 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1124 | |||||||||||||||||||||||||||||||||||||||||||
| 1125 | sub empty_cell_text { | ||||||||||||||||||||||||||||||||||||||||||
| 1126 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1127 | $O->{empty_cell_text} = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1129 | |||||||||||||||||||||||||||||||||||||||||||
| 1130 | sub empty_cell_format { | ||||||||||||||||||||||||||||||||||||||||||
| 1131 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1132 | $O->{empty_cell_format} = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1134 | sub _null_empty { | ||||||||||||||||||||||||||||||||||||||||||
| 1135 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1136 | my $typ = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1137 | my $k = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1138 | my $temp_node = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1139 | my $txt = $typ."_cell_text"; | ||||||||||||||||||||||||||||||||||||||||||
| 1140 | my $fmt = $typ."_cell_format"; | ||||||||||||||||||||||||||||||||||||||||||
| 1141 | if(ref($O->{$txt})) { | ||||||||||||||||||||||||||||||||||||||||||
| 1142 | my @val = @{$O->{$txt}}; | ||||||||||||||||||||||||||||||||||||||||||
| 1143 | if(ref($O->{$fmt})) { | ||||||||||||||||||||||||||||||||||||||||||
| 1144 | my @fmt = @{$O->{$fmt}}; | ||||||||||||||||||||||||||||||||||||||||||
| 1145 | my $node = SNode->new($fmt[$k]); | ||||||||||||||||||||||||||||||||||||||||||
| 1146 | $node->print($val[$k]); | ||||||||||||||||||||||||||||||||||||||||||
| 1147 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1148 | if($O->{$fmt}) { | ||||||||||||||||||||||||||||||||||||||||||
| 1149 | my $node = SNode->new($O->{$fmt}); | ||||||||||||||||||||||||||||||||||||||||||
| 1150 | $node->print($val[$k]); | ||||||||||||||||||||||||||||||||||||||||||
| 1151 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1152 | $temp_node->print($val[$k]); | ||||||||||||||||||||||||||||||||||||||||||
| 1153 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1154 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1155 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1156 | if($O->{$fmt}) { | ||||||||||||||||||||||||||||||||||||||||||
| 1157 | if(ref($O->{$fmt})) { | ||||||||||||||||||||||||||||||||||||||||||
| 1158 | my @fmt = @{$O->{$fmt}}; | ||||||||||||||||||||||||||||||||||||||||||
| 1159 | my $node = SNode->new($fmt[$k]); | ||||||||||||||||||||||||||||||||||||||||||
| 1160 | $node->print($O->{$txt}); | ||||||||||||||||||||||||||||||||||||||||||
| 1161 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1162 | my $node = SNode->new($O->{$fmt}); | ||||||||||||||||||||||||||||||||||||||||||
| 1163 | $node->print($O->{$txt}); | ||||||||||||||||||||||||||||||||||||||||||
| 1164 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1165 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1166 | $temp_node->print($O->{$txt}); | ||||||||||||||||||||||||||||||||||||||||||
| 1167 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1168 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1169 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1170 | |||||||||||||||||||||||||||||||||||||||||||
| 1171 | sub rown { | ||||||||||||||||||||||||||||||||||||||||||
| 1172 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1173 | return $O->{row_number}; | ||||||||||||||||||||||||||||||||||||||||||
| 1174 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1175 | |||||||||||||||||||||||||||||||||||||||||||
| 1176 | sub coln { | ||||||||||||||||||||||||||||||||||||||||||
| 1177 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1178 | return $O->{column_number}; | ||||||||||||||||||||||||||||||||||||||||||
| 1179 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1180 | |||||||||||||||||||||||||||||||||||||||||||
| 1181 | sub renew { | ||||||||||||||||||||||||||||||||||||||||||
| 1182 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1183 | $O->{column_number} = -1; | ||||||||||||||||||||||||||||||||||||||||||
| 1184 | $O->{row_number} = -1; | ||||||||||||||||||||||||||||||||||||||||||
| 1185 | $O->{arr} = (); | ||||||||||||||||||||||||||||||||||||||||||
| 1186 | $O->{front} = (); | ||||||||||||||||||||||||||||||||||||||||||
| 1187 | $O->{back} = (); | ||||||||||||||||||||||||||||||||||||||||||
| 1188 | $O->{max_row} = -1; | ||||||||||||||||||||||||||||||||||||||||||
| 1189 | $O->{datafile} = ""; | ||||||||||||||||||||||||||||||||||||||||||
| 1190 | $O->{form} = ""; | ||||||||||||||||||||||||||||||||||||||||||
| 1191 | $O->{print_columns} = $O->{print_columns_keep}; | ||||||||||||||||||||||||||||||||||||||||||
| 1192 | |||||||||||||||||||||||||||||||||||||||||||
| 1193 | return $O; | ||||||||||||||||||||||||||||||||||||||||||
| 1194 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1195 | |||||||||||||||||||||||||||||||||||||||||||
| 1196 | # use display method instead of print; | ||||||||||||||||||||||||||||||||||||||||||
| 1197 | sub display { my $O = shift; $O->print(); }; | ||||||||||||||||||||||||||||||||||||||||||
| 1198 | |||||||||||||||||||||||||||||||||||||||||||
| 1199 | |||||||||||||||||||||||||||||||||||||||||||
| 1200 | # node function without argument returns the scalar value contained in the node | ||||||||||||||||||||||||||||||||||||||||||
| 1201 | # however if node function is called with an argument, it will set node valeue | ||||||||||||||||||||||||||||||||||||||||||
| 1202 | # to the argument, BUT will return whatever value existed in the node before | ||||||||||||||||||||||||||||||||||||||||||
| 1203 | # set operation | ||||||||||||||||||||||||||||||||||||||||||
| 1204 | |||||||||||||||||||||||||||||||||||||||||||
| 1205 | sub node { | ||||||||||||||||||||||||||||||||||||||||||
| 1206 | my ($O,$row,$col) = @_; | ||||||||||||||||||||||||||||||||||||||||||
| 1207 | unless($col =~ /\D/) { | ||||||||||||||||||||||||||||||||||||||||||
| 1208 | return $O->{arr}[$row][$col]; | ||||||||||||||||||||||||||||||||||||||||||
| 1209 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1210 | return $O->{arr}[$row]{$col}; | ||||||||||||||||||||||||||||||||||||||||||
| 1211 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1212 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1213 | |||||||||||||||||||||||||||||||||||||||||||
| 1214 | sub cell { | ||||||||||||||||||||||||||||||||||||||||||
| 1215 | my ($O,$row,$col,$val) = @_; | ||||||||||||||||||||||||||||||||||||||||||
| 1216 | if($val) { | ||||||||||||||||||||||||||||||||||||||||||
| 1217 | $O->{arr}[$row][$col] = $val; | ||||||||||||||||||||||||||||||||||||||||||
| 1218 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1219 | unless($col =~ /\D/) { | ||||||||||||||||||||||||||||||||||||||||||
| 1220 | return $O->{arr}[$row][$col]; | ||||||||||||||||||||||||||||||||||||||||||
| 1221 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1222 | return $O->{arr}[$row]{$col}; | ||||||||||||||||||||||||||||||||||||||||||
| 1223 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1224 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1225 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1226 | |||||||||||||||||||||||||||||||||||||||||||
| 1227 | sub row { | ||||||||||||||||||||||||||||||||||||||||||
| 1228 | my ($O,$row) = @_; | ||||||||||||||||||||||||||||||||||||||||||
| 1229 | if(ref($O->{arr}[$row]) eq "ARRAY") { | ||||||||||||||||||||||||||||||||||||||||||
| 1230 | return @{$O->{arr}[$row]}; | ||||||||||||||||||||||||||||||||||||||||||
| 1231 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1232 | return %{$O->{arr}[$row]}; | ||||||||||||||||||||||||||||||||||||||||||
| 1233 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1234 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1235 | |||||||||||||||||||||||||||||||||||||||||||
| 1236 | sub column { | ||||||||||||||||||||||||||||||||||||||||||
| 1237 | my ($O,$col) = @_; | ||||||||||||||||||||||||||||||||||||||||||
| 1238 | my $rn = $O->{row_number}; | ||||||||||||||||||||||||||||||||||||||||||
| 1239 | my $i; | ||||||||||||||||||||||||||||||||||||||||||
| 1240 | my @arr = (); | ||||||||||||||||||||||||||||||||||||||||||
| 1241 | for($i = 0; $i < $rn; $i++) { | ||||||||||||||||||||||||||||||||||||||||||
| 1242 | $arr[$i] = $O->node($i,$col); | ||||||||||||||||||||||||||||||||||||||||||
| 1243 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1244 | if($O->node($rn,$col) ne "") { | ||||||||||||||||||||||||||||||||||||||||||
| 1245 | $arr[$rn] = $O->node($i,$col); | ||||||||||||||||||||||||||||||||||||||||||
| 1246 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1247 | |||||||||||||||||||||||||||||||||||||||||||
| 1248 | return @arr; | ||||||||||||||||||||||||||||||||||||||||||
| 1249 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1250 | |||||||||||||||||||||||||||||||||||||||||||
| 1251 | sub hash { | ||||||||||||||||||||||||||||||||||||||||||
| 1252 | my ($O,$col1, $col2) = @_; | ||||||||||||||||||||||||||||||||||||||||||
| 1253 | my $rn = $O->{row_number}; | ||||||||||||||||||||||||||||||||||||||||||
| 1254 | my $i; | ||||||||||||||||||||||||||||||||||||||||||
| 1255 | my %hsh = (); | ||||||||||||||||||||||||||||||||||||||||||
| 1256 | for($i = 0; $i < $rn; $i++) { | ||||||||||||||||||||||||||||||||||||||||||
| 1257 | $hsh{$O->node($i,$col1)} = $O->node($i,$col2); | ||||||||||||||||||||||||||||||||||||||||||
| 1258 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1259 | if($O->node($rn,$col2) ne "") { | ||||||||||||||||||||||||||||||||||||||||||
| 1260 | $hsh{$O->node($rn,$col1)} = $O->node($rn,$col2); | ||||||||||||||||||||||||||||||||||||||||||
| 1261 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1262 | return %hsh; | ||||||||||||||||||||||||||||||||||||||||||
| 1263 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1264 | |||||||||||||||||||||||||||||||||||||||||||
| 1265 | # this sub reads content of a file and load's matrix with this data | ||||||||||||||||||||||||||||||||||||||||||
| 1266 | sub read { | ||||||||||||||||||||||||||||||||||||||||||
| 1267 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1268 | my $ch = shift; # character used as field delimiter | ||||||||||||||||||||||||||||||||||||||||||
| 1269 | my $file = shift; # file to be read | ||||||||||||||||||||||||||||||||||||||||||
| 1270 | |||||||||||||||||||||||||||||||||||||||||||
| 1271 | open (FILER, "$file") or warn "Could't open $file\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 1272 | |||||||||||||||||||||||||||||||||||||||||||
| 1273 | my $i = 0; | ||||||||||||||||||||||||||||||||||||||||||
| 1274 | while(<FILER>) { | ||||||||||||||||||||||||||||||||||||||||||
| 1275 | chop; | ||||||||||||||||||||||||||||||||||||||||||
| 1276 | my @larr = split(/$ch/); | ||||||||||||||||||||||||||||||||||||||||||
| 1277 | |||||||||||||||||||||||||||||||||||||||||||
| 1278 | my $len = $#larr; | ||||||||||||||||||||||||||||||||||||||||||
| 1279 | if($len > $O->{column_number}) { | ||||||||||||||||||||||||||||||||||||||||||
| 1280 | $O->{column_number} = $len; | ||||||||||||||||||||||||||||||||||||||||||
| 1281 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1282 | $O->{arr}[$i] = [ split(/$ch/) ]; | ||||||||||||||||||||||||||||||||||||||||||
| 1283 | $i++; | ||||||||||||||||||||||||||||||||||||||||||
| 1284 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1285 | $O->{row_number} = $i; | ||||||||||||||||||||||||||||||||||||||||||
| 1286 | |||||||||||||||||||||||||||||||||||||||||||
| 1287 | close(FILER); | ||||||||||||||||||||||||||||||||||||||||||
| 1288 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1289 | |||||||||||||||||||||||||||||||||||||||||||
| 1290 | sub maxRow { | ||||||||||||||||||||||||||||||||||||||||||
| 1291 | my ($O) = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1292 | $O->{max_row} = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1293 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1294 | |||||||||||||||||||||||||||||||||||||||||||
| 1295 | sub form { | ||||||||||||||||||||||||||||||||||||||||||
| 1296 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1297 | @_ ? $O->{form} = shift : $O->{form}; | ||||||||||||||||||||||||||||||||||||||||||
| 1298 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1299 | |||||||||||||||||||||||||||||||||||||||||||
| 1300 | sub title { | ||||||||||||||||||||||||||||||||||||||||||
| 1301 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1302 | my $title = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1303 | if(ref($title)) { | ||||||||||||||||||||||||||||||||||||||||||
| 1304 | my $tit; | ||||||||||||||||||||||||||||||||||||||||||
| 1305 | foreach $tit (@{$title}) { | ||||||||||||||||||||||||||||||||||||||||||
| 1306 | print "<center> <H2> $tit </H2></center><BR>\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 1307 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1308 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1309 | if($title) { | ||||||||||||||||||||||||||||||||||||||||||
| 1310 | print "<center> <H2> $title </H2></center>\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 1311 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1312 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1313 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1314 | |||||||||||||||||||||||||||||||||||||||||||
| 1315 | sub _sub_title { | ||||||||||||||||||||||||||||||||||||||||||
| 1316 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1317 | my $len = $#{$O->{sub_title}}; | ||||||||||||||||||||||||||||||||||||||||||
| 1318 | my $j; | ||||||||||||||||||||||||||||||||||||||||||
| 1319 | my $node; | ||||||||||||||||||||||||||||||||||||||||||
| 1320 | for($j = 0; $j <= $len; $j++) { | ||||||||||||||||||||||||||||||||||||||||||
| 1321 | if(ref($O->{sub_title_format})) { | ||||||||||||||||||||||||||||||||||||||||||
| 1322 | $node = new SNode($O->{sub_title_format}->[$j]); | ||||||||||||||||||||||||||||||||||||||||||
| 1323 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1324 | $node = new SNode($O->{sub_title_format}); | ||||||||||||||||||||||||||||||||||||||||||
| 1325 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1326 | print '<center>'; | ||||||||||||||||||||||||||||||||||||||||||
| 1327 | $node->print($O->{sub_title}->[$j]); | ||||||||||||||||||||||||||||||||||||||||||
| 1328 | print '</center><BR>'; | ||||||||||||||||||||||||||||||||||||||||||
| 1329 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1330 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1331 | |||||||||||||||||||||||||||||||||||||||||||
| 1332 | sub date { | ||||||||||||||||||||||||||||||||||||||||||
| 1333 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1334 | my $flag = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1335 | my $date; | ||||||||||||||||||||||||||||||||||||||||||
| 1336 | my $date_phrase; | ||||||||||||||||||||||||||||||||||||||||||
| 1337 | $_ = POSIX::ctime(time); | ||||||||||||||||||||||||||||||||||||||||||
| 1338 | # meaning of $[d] is given below | ||||||||||||||||||||||||||||||||||||||||||
| 1339 | # Mon Sep 21 10:49:15 1998 | ||||||||||||||||||||||||||||||||||||||||||
| 1340 | # $1 $2 $3 $4 $5 | ||||||||||||||||||||||||||||||||||||||||||
| 1341 | if (/(\w*)\s*(\w*)\s*(\d*)\s*(..:..:..)\s*(....)/) { | ||||||||||||||||||||||||||||||||||||||||||
| 1342 | $date_phrase = "Report generated $1 $2 $3, $5 at $4"; | ||||||||||||||||||||||||||||||||||||||||||
| 1343 | $date = "$1 $2 $3, $5 at $4"; | ||||||||||||||||||||||||||||||||||||||||||
| 1344 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1345 | |||||||||||||||||||||||||||||||||||||||||||
| 1346 | if($flag == 1) { | ||||||||||||||||||||||||||||||||||||||||||
| 1347 | return $date; | ||||||||||||||||||||||||||||||||||||||||||
| 1348 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1349 | $O->{phrase} = $date_phrase; | ||||||||||||||||||||||||||||||||||||||||||
| 1350 | print "<center> <H3> $date_phrase </H3></center>\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 1351 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1352 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1353 | |||||||||||||||||||||||||||||||||||||||||||
| 1354 | sub clear { | ||||||||||||||||||||||||||||||||||||||||||
| 1355 | my ($O,$row,$col) = @_; | ||||||||||||||||||||||||||||||||||||||||||
| 1356 | $O->{front}[$row][$col] = ""; | ||||||||||||||||||||||||||||||||||||||||||
| 1357 | $O->{back}[$row][$col] = ""; | ||||||||||||||||||||||||||||||||||||||||||
| 1358 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1359 | |||||||||||||||||||||||||||||||||||||||||||
| 1360 | sub change { | ||||||||||||||||||||||||||||||||||||||||||
| 1361 | my ($O,$row,$col,$tx1,$tx2) = @_; | ||||||||||||||||||||||||||||||||||||||||||
| 1362 | $O->{front}[$row][$col] = $tx1.$O->{front}[$row][$col]; | ||||||||||||||||||||||||||||||||||||||||||
| 1363 | $O->{back}[$row][$col] = $O->{back}[$row][$col].$tx2; | ||||||||||||||||||||||||||||||||||||||||||
| 1364 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1365 | |||||||||||||||||||||||||||||||||||||||||||
| 1366 | sub script { | ||||||||||||||||||||||||||||||||||||||||||
| 1367 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1368 | my $arg1 = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1369 | my $arg2 = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1370 | |||||||||||||||||||||||||||||||||||||||||||
| 1371 | if($arg2 =~ /[a-zA-Z]/) { | ||||||||||||||||||||||||||||||||||||||||||
| 1372 | # if user call this function as $ip->javascript(0,"SelectSite",7,8)' | ||||||||||||||||||||||||||||||||||||||||||
| 1373 | # this routine will produce something like | ||||||||||||||||||||||||||||||||||||||||||
| 1374 | # <A HREF=javascript:SelectSite(site_id,cust_id)> Site_Name </A> | ||||||||||||||||||||||||||||||||||||||||||
| 1375 | # at the first line 7 and 8 are column number containing site_id | ||||||||||||||||||||||||||||||||||||||||||
| 1376 | # and cust_id respectively | ||||||||||||||||||||||||||||||||||||||||||
| 1377 | my $col = $arg1; | ||||||||||||||||||||||||||||||||||||||||||
| 1378 | my $prg = $arg2; | ||||||||||||||||||||||||||||||||||||||||||
| 1379 | my $cols = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1380 | |||||||||||||||||||||||||||||||||||||||||||
| 1381 | my ($i,$j); | ||||||||||||||||||||||||||||||||||||||||||
| 1382 | my $rn = $O->{row_number}; | ||||||||||||||||||||||||||||||||||||||||||
| 1383 | my $tx2 = "<A HREF=javascript:".$prg."("; | ||||||||||||||||||||||||||||||||||||||||||
| 1384 | if($O->{form} ne "") { | ||||||||||||||||||||||||||||||||||||||||||
| 1385 | $tx2 .= $O->{form}; | ||||||||||||||||||||||||||||||||||||||||||
| 1386 | if($#$cols > 0) { | ||||||||||||||||||||||||||||||||||||||||||
| 1387 | $tx2 .= ","; | ||||||||||||||||||||||||||||||||||||||||||
| 1388 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1389 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1390 | |||||||||||||||||||||||||||||||||||||||||||
| 1391 | for($i = 0; $i <= $rn; $i++) { | ||||||||||||||||||||||||||||||||||||||||||
| 1392 | my $tx3 = ""; | ||||||||||||||||||||||||||||||||||||||||||
| 1393 | for($j = 0; $j <= $#$cols; $j++) { | ||||||||||||||||||||||||||||||||||||||||||
| 1394 | $_ = $O->{arr}[$i][$cols->[$j]]; | ||||||||||||||||||||||||||||||||||||||||||
| 1395 | if(/^[-+]?[0-9]+(\.[0-9]*)?$/) { | ||||||||||||||||||||||||||||||||||||||||||
| 1396 | $tx3 .= $_; | ||||||||||||||||||||||||||||||||||||||||||
| 1397 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1398 | if(/this\./) { | ||||||||||||||||||||||||||||||||||||||||||
| 1399 | $tx3 .= $_; | ||||||||||||||||||||||||||||||||||||||||||
| 1400 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1401 | $tx3 .= "\"".$_."\""; | ||||||||||||||||||||||||||||||||||||||||||
| 1402 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1403 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1404 | if($j < $#$cols) { | ||||||||||||||||||||||||||||||||||||||||||
| 1405 | $tx3 .= ","; | ||||||||||||||||||||||||||||||||||||||||||
| 1406 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1407 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1408 | $O->{front}[$i][$col] = $tx2.$tx3.")> "; | ||||||||||||||||||||||||||||||||||||||||||
| 1409 | $O->{back}[$i][$col] = " </A>"; | ||||||||||||||||||||||||||||||||||||||||||
| 1410 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1411 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1412 | my $row = $arg1; | ||||||||||||||||||||||||||||||||||||||||||
| 1413 | my $col = $arg2; | ||||||||||||||||||||||||||||||||||||||||||
| 1414 | my $prg = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1415 | my $arg = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1416 | my $tx2 = "<A HREF=javascript:".$prg."("; | ||||||||||||||||||||||||||||||||||||||||||
| 1417 | foreach ( @{$arg}) { | ||||||||||||||||||||||||||||||||||||||||||
| 1418 | # if(/[a-zA-Z_]/) { | ||||||||||||||||||||||||||||||||||||||||||
| 1419 | # $_ = '"'.$_.'"'; | ||||||||||||||||||||||||||||||||||||||||||
| 1420 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 1421 | if(/[a-zA-Z_]/) { | ||||||||||||||||||||||||||||||||||||||||||
| 1422 | if(/this\./) { | ||||||||||||||||||||||||||||||||||||||||||
| 1423 | $_ = $_; | ||||||||||||||||||||||||||||||||||||||||||
| 1424 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1425 | $_ = '"'.$_.'"'; | ||||||||||||||||||||||||||||||||||||||||||
| 1426 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1427 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1428 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1429 | my $tx3 = join(',',@{$arg}); | ||||||||||||||||||||||||||||||||||||||||||
| 1430 | $O->{front}[$row][$col] = $tx2.$tx3.")> "; | ||||||||||||||||||||||||||||||||||||||||||
| 1431 | if($O->{arr}[$row][$col] =~ "</A>") { | ||||||||||||||||||||||||||||||||||||||||||
| 1432 | $O->{back}[$row][$col] = " "; | ||||||||||||||||||||||||||||||||||||||||||
| 1433 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1434 | $O->{back}[$row][$col] = "</A>"; | ||||||||||||||||||||||||||||||||||||||||||
| 1435 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1436 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1437 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1438 | |||||||||||||||||||||||||||||||||||||||||||
| 1439 | |||||||||||||||||||||||||||||||||||||||||||
| 1440 | sub back { | ||||||||||||||||||||||||||||||||||||||||||
| 1441 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1442 | my $row = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1443 | my $col = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1444 | if(@_) { | ||||||||||||||||||||||||||||||||||||||||||
| 1445 | my $tmp = $O->{back}[$row][$col]; | ||||||||||||||||||||||||||||||||||||||||||
| 1446 | $O->{back}[$row][$col] = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1447 | return $tmp; | ||||||||||||||||||||||||||||||||||||||||||
| 1448 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1449 | return $O->{back}[$row][$col]; | ||||||||||||||||||||||||||||||||||||||||||
| 1450 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1451 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1452 | |||||||||||||||||||||||||||||||||||||||||||
| 1453 | sub front { | ||||||||||||||||||||||||||||||||||||||||||
| 1454 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1455 | my $row = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1456 | my $col = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1457 | |||||||||||||||||||||||||||||||||||||||||||
| 1458 | if(@_) { | ||||||||||||||||||||||||||||||||||||||||||
| 1459 | my $tmp = $O->{front}[$row][$col]; | ||||||||||||||||||||||||||||||||||||||||||
| 1460 | $O->{front}[$row][$col] = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1461 | return $tmp; | ||||||||||||||||||||||||||||||||||||||||||
| 1462 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1463 | return $O->{front}[$row][$col]; | ||||||||||||||||||||||||||||||||||||||||||
| 1464 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1465 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1466 | |||||||||||||||||||||||||||||||||||||||||||
| 1467 | sub linkto { | ||||||||||||||||||||||||||||||||||||||||||
| 1468 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1469 | my $row = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1470 | my $col = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1471 | # set back value to anchor closing, user can overrite it | ||||||||||||||||||||||||||||||||||||||||||
| 1472 | # by colling back function | ||||||||||||||||||||||||||||||||||||||||||
| 1473 | $O->{back}[$row][$col] = " </A>"; | ||||||||||||||||||||||||||||||||||||||||||
| 1474 | $_ = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1475 | $O->{front}[$row][$col] = "<A HREF = $_>"; | ||||||||||||||||||||||||||||||||||||||||||
| 1476 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1477 | |||||||||||||||||||||||||||||||||||||||||||
| 1478 | sub download { | ||||||||||||||||||||||||||||||||||||||||||
| 1479 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1480 | |||||||||||||||||||||||||||||||||||||||||||
| 1481 | my $col_num = $#{$O->{print_columns}}; | ||||||||||||||||||||||||||||||||||||||||||
| 1482 | my $row_num = $O->{row_number}; | ||||||||||||||||||||||||||||||||||||||||||
| 1483 | ### This lines moved from print_head method to run | ||||||||||||||||||||||||||||||||||||||||||
| 1484 | ### download function before print function | ||||||||||||||||||||||||||||||||||||||||||
| 1485 | if($col_num <= $O->{column_number}) { | ||||||||||||||||||||||||||||||||||||||||||
| 1486 | $col_num = $O->{column_number}; | ||||||||||||||||||||||||||||||||||||||||||
| 1487 | if($#{$O->{print_columns}} < 0) { | ||||||||||||||||||||||||||||||||||||||||||
| 1488 | $O->{print_columns} = [0..$col_num]; | ||||||||||||||||||||||||||||||||||||||||||
| 1489 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1490 | $col_num = $#{$O->{print_columns}}; | ||||||||||||||||||||||||||||||||||||||||||
| 1491 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1492 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1493 | ##### | ||||||||||||||||||||||||||||||||||||||||||
| 1494 | my $datafile = "data.".$$; | ||||||||||||||||||||||||||||||||||||||||||
| 1495 | $O->{datafile} = $datafile; | ||||||||||||||||||||||||||||||||||||||||||
| 1496 | |||||||||||||||||||||||||||||||||||||||||||
| 1497 | # open (FILE, '>>/tmp/'.$datafile); | ||||||||||||||||||||||||||||||||||||||||||
| 1498 | open (FILE, '>C:/apache/tmp/'.$datafile); | ||||||||||||||||||||||||||||||||||||||||||
| 1499 | |||||||||||||||||||||||||||||||||||||||||||
| 1500 | if(ref($O->{title})) { | ||||||||||||||||||||||||||||||||||||||||||
| 1501 | my $tit; | ||||||||||||||||||||||||||||||||||||||||||
| 1502 | foreach $tit (@{$O->{title}}) { | ||||||||||||||||||||||||||||||||||||||||||
| 1503 | print FILE "$tit\r\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 1504 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1505 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1506 | print FILE "$O->{title}\r\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 1507 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1508 | print FILE "$O->{phrase}\r\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 1509 | my $len = $#{$O->{sub_title}}; | ||||||||||||||||||||||||||||||||||||||||||
| 1510 | my $j; | ||||||||||||||||||||||||||||||||||||||||||
| 1511 | for($j = 0; $j <= $len; $j++) { | ||||||||||||||||||||||||||||||||||||||||||
| 1512 | $_ = $O->{sub_title}[$j]; | ||||||||||||||||||||||||||||||||||||||||||
| 1513 | s/<BR>/ /g; | ||||||||||||||||||||||||||||||||||||||||||
| 1514 | print FILE $_,"\r\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 1515 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1516 | print FILE "<table border=3>\r\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 1517 | #for header | ||||||||||||||||||||||||||||||||||||||||||
| 1518 | print FILE "<tr>"; | ||||||||||||||||||||||||||||||||||||||||||
| 1519 | my $rn = $O->{row_number}; | ||||||||||||||||||||||||||||||||||||||||||
| 1520 | if($rn >= 0) { | ||||||||||||||||||||||||||||||||||||||||||
| 1521 | my $len = $#{$O->{headers}}; | ||||||||||||||||||||||||||||||||||||||||||
| 1522 | for($j = 0; $j <= $len; $j++) | ||||||||||||||||||||||||||||||||||||||||||
| 1523 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1524 | print FILE "<td>"; | ||||||||||||||||||||||||||||||||||||||||||
| 1525 | print FILE $O->{headers}[$j]; | ||||||||||||||||||||||||||||||||||||||||||
| 1526 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1527 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1528 | print FILE $O->{empty_msg}; | ||||||||||||||||||||||||||||||||||||||||||
| 1529 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1530 | print FILE "</tr>\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 1531 | |||||||||||||||||||||||||||||||||||||||||||
| 1532 | #for table | ||||||||||||||||||||||||||||||||||||||||||
| 1533 | my $i; | ||||||||||||||||||||||||||||||||||||||||||
| 1534 | $len = $#{$O->{print_columns}}; | ||||||||||||||||||||||||||||||||||||||||||
| 1535 | if($O->{sort_flag}) { | ||||||||||||||||||||||||||||||||||||||||||
| 1536 | my $tmp1 = $O->{sort_key_array}; | ||||||||||||||||||||||||||||||||||||||||||
| 1537 | my @keys = @$tmp1; | ||||||||||||||||||||||||||||||||||||||||||
| 1538 | my $key; | ||||||||||||||||||||||||||||||||||||||||||
| 1539 | foreach $key (@keys) { | ||||||||||||||||||||||||||||||||||||||||||
| 1540 | print FILE "<tr>"; | ||||||||||||||||||||||||||||||||||||||||||
| 1541 | my $tmp2 = $O->{sort_hsh}; | ||||||||||||||||||||||||||||||||||||||||||
| 1542 | my %tmp = %$tmp2; | ||||||||||||||||||||||||||||||||||||||||||
| 1543 | # we added one in Table.pm to this value #@#@ | ||||||||||||||||||||||||||||||||||||||||||
| 1544 | $i = $tmp{$key} - 1; #@#@ | ||||||||||||||||||||||||||||||||||||||||||
| 1545 | for $j (0 .. $len) { | ||||||||||||||||||||||||||||||||||||||||||
| 1546 | print FILE "<td>"; | ||||||||||||||||||||||||||||||||||||||||||
| 1547 | my $tO = $O->{arr}[$i][$O->{print_columns}[$j]]; | ||||||||||||||||||||||||||||||||||||||||||
| 1548 | if(ref($tO) eq "HTML::STable") { | ||||||||||||||||||||||||||||||||||||||||||
| 1549 | my @tarr = $tO->column(0); | ||||||||||||||||||||||||||||||||||||||||||
| 1550 | $_ = @tarr; | ||||||||||||||||||||||||||||||||||||||||||
| 1551 | } elsif(ref($tO)) { | ||||||||||||||||||||||||||||||||||||||||||
| 1552 | $_ = $tO->download; | ||||||||||||||||||||||||||||||||||||||||||
| 1553 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1554 | $_ = $tO; | ||||||||||||||||||||||||||||||||||||||||||
| 1555 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1556 | if ($_) { | ||||||||||||||||||||||||||||||||||||||||||
| 1557 | s/<BR>/ /g; | ||||||||||||||||||||||||||||||||||||||||||
| 1558 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1559 | $_ = " "; | ||||||||||||||||||||||||||||||||||||||||||
| 1560 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1561 | print FILE $_; | ||||||||||||||||||||||||||||||||||||||||||
| 1562 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1563 | print FILE "</tr>\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 1564 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1565 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1566 | for($i = 0; $i <= $rn; $i++) { | ||||||||||||||||||||||||||||||||||||||||||
| 1567 | print FILE "<tr>"; | ||||||||||||||||||||||||||||||||||||||||||
| 1568 | for $j ( 0 .. $len) { | ||||||||||||||||||||||||||||||||||||||||||
| 1569 | print FILE "<td>"; | ||||||||||||||||||||||||||||||||||||||||||
| 1570 | my $tO = $O->{arr}[$i][$O->{print_columns}[$j]]; | ||||||||||||||||||||||||||||||||||||||||||
| 1571 | if(ref($tO) eq "HTML::STable") { | ||||||||||||||||||||||||||||||||||||||||||
| 1572 | $_ = $tO->column(0); | ||||||||||||||||||||||||||||||||||||||||||
| 1573 | } elsif(ref($tO)) { | ||||||||||||||||||||||||||||||||||||||||||
| 1574 | $_ = $tO->download; | ||||||||||||||||||||||||||||||||||||||||||
| 1575 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1576 | $_ = $tO; | ||||||||||||||||||||||||||||||||||||||||||
| 1577 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1578 | if ($_) { | ||||||||||||||||||||||||||||||||||||||||||
| 1579 | s/<BR>/ /g; | ||||||||||||||||||||||||||||||||||||||||||
| 1580 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1581 | $_ = " "; | ||||||||||||||||||||||||||||||||||||||||||
| 1582 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1583 | print FILE $_; | ||||||||||||||||||||||||||||||||||||||||||
| 1584 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1585 | print FILE "</tr>\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 1586 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1587 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1588 | print FILE "</table>"; | ||||||||||||||||||||||||||||||||||||||||||
| 1589 | close (FILE); | ||||||||||||||||||||||||||||||||||||||||||
| 1590 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1591 | |||||||||||||||||||||||||||||||||||||||||||
| 1592 | sub show_button | ||||||||||||||||||||||||||||||||||||||||||
| 1593 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1594 | my $O = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1595 | my $str = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 1596 | my $datafile = $O->{datafile}; | ||||||||||||||||||||||||||||||||||||||||||
| 1597 | |||||||||||||||||||||||||||||||||||||||||||
| 1598 | if($str) { | ||||||||||||||||||||||||||||||||||||||||||
| 1599 | |||||||||||||||||||||||||||||||||||||||||||
| 1600 | print "<center><BR>"; | ||||||||||||||||||||||||||||||||||||||||||
| 1601 | print qq{<INPUT TYPE="button" | ||||||||||||||||||||||||||||||||||||||||||
| 1602 | NAME="download" | ||||||||||||||||||||||||||||||||||||||||||
| 1603 | VALUE="$str" | ||||||||||||||||||||||||||||||||||||||||||
| 1604 | ONCLICK="location.href='download.pl?process_id=$$';">}; | ||||||||||||||||||||||||||||||||||||||||||
| 1605 | print "</center>"; | ||||||||||||||||||||||||||||||||||||||||||
| 1606 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1607 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1608 | |||||||||||||||||||||||||||||||||||||||||||
| 1609 | 1; | ||||||||||||||||||||||||||||||||||||||||||
| 1610 | # Autoload methods go after =cut, and are processed by the autosplit program. | ||||||||||||||||||||||||||||||||||||||||||
| 1611 | |||||||||||||||||||||||||||||||||||||||||||
| 1612 | __END__ | ||||||||||||||||||||||||||||||||||||||||||