Changeset 9003 for trunk/ippMonitor/generate
- Timestamp:
- Sep 26, 2006, 6:19:19 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/ippMonitor/generate (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippMonitor/generate
r8984 r9003 39 39 # list of the table fields 40 40 if ($key eq "FIELD") { 41 ($field, $name, $ link, $extras) = split (/,\s+/, $value, 4);41 ($field, $name, $show, $link, $extras) = split (/,\s+/, $value, 5); 42 42 # ($field) = $field =~ m|\s*(\S+)\s*|; 43 43 44 if ($VERBOSE) { printf "%-20s %-20s %-20s %-20s\n", $field, $name, $link, $extras; } 44 if ($VERBOSE) { printf "%-20s %-20s %-20s %-20s %-20s\n", $field, $name, $show, $link, $extras; } 45 if ($show eq "") {$show = "value";} 45 46 push @field, $field; 46 47 push @name, $name; 48 push @show, $show; 47 49 push @link, $link; 48 50 push @extras, $extras; 51 } 52 53 # list of the table fields 54 if ($key eq "BODY.HTML") { 55 push @bodyhtml, $value; 56 } 57 58 # list of the table fields 59 if ($key eq "TAIL.HTML") { 60 push @tailhtml, $value; 49 61 } 50 62 … … 65 77 &check_key ("TITLE", ""); 66 78 &check_key ("FILE", ""); 79 80 # these are used internally (not just a replacement) 81 for ($i = 0; $i < @key; $i++) { 82 if ($key[$i] eq "MENU") { $MENU = $value[$i]; } 83 } 67 84 68 85 # define query string, add to keypairs 69 86 &define_query_fields; 87 88 if (0) { 89 print STDERR "show: $show[0]\n"; 90 ($a, $b, $c) = &parse_label ($show[0]); 91 print STDERR "a: $a, b: $b, c: $c\n"; 92 93 print STDERR "extras: $extras[0]\n"; 94 ($a, $b, $c) = &parse_label ($extras[0]); 95 print STDERR "a: $a, b: $b, c: $c\n"; 96 97 print STDERR "show: $show[1]\n"; 98 ($a, $b, $c) = &parse_label ($show[1]); 99 print STDERR "a: $a, b: $b, c: $c\n"; 100 101 print STDERR "extras: $extras[1]\n"; 102 ($a, $b, $c) = &parse_label ($extras[1]); 103 print STDERR "a: $a, b: $b, c: $c\n"; 104 exit 0; 105 } 70 106 } 71 107 … … 102 138 &write_table_restrict; 103 139 } 140 141 # fill in body HTML 142 if ($line =~ m|// \*\* BODY HTML \*\*|) { 143 &write_body_html; 144 } 145 146 # fill in tail HTML 147 if ($line =~ m|// \*\* TAIL HTML \*\*|) { 148 &write_tail_html; 149 } 104 150 } 105 151 close (FILE); 106 152 } 107 153 154 sub write_body_html { 155 my ($i); 156 157 if (@bodyhtml == 0) { return; } 158 printf FILE "?>\n"; 159 160 for ($i = 0; $i < @bodyhtml; $i++) { 161 printf FILE "$bodyhtml[$i]\n"; 162 } 163 printf FILE "<?\n"; 164 } 165 166 sub write_tail_html { 167 my ($i); 168 169 if (@tailhtml == 0) { return; } 170 printf FILE "?>\n"; 171 172 for ($i = 0; $i < @tailhtml; $i++) { 173 printf FILE "$tailhtml[$i]\n"; 174 } 175 printf FILE "<?\n"; 176 } 177 108 178 sub write_table_header { 109 179 110 180 for ($i = 0; $i < @field; $i++) { 181 if ($show[$i] eq "none") { next; } 111 182 printf FILE "echo \"<th class=\\\"list\\\"> $name[$i] </th>\\n\";\n"; 112 183 } … … 129 200 130 201 sub write_table_data { 202 my ($i); 203 my ($label, $value, $string); 131 204 132 205 for ($i = 0; $i < @field; $i++) { 206 ($label, $value, $string) = &parse_label ($show[$i]); 207 133 208 # create the link variable if this entry should be linked 134 if ($link[$i]) { 209 if ($label eq "none") { next; } 210 211 if (($label eq "value") && !$link[$i]) { 212 # print value without link or image 213 if (! $value) { $value = "\$row[$i]"; } 214 print FILE " echo \"<td class=\\\"list\\\"> $value </td>\\n\";\n"; 215 next; 216 } 217 218 if (($label eq "value") && $link[$i]) { 219 # create the basic link variable 220 printf FILE " \$link = \"$link[$i]\" . \"?menu=$MENU&\" . \$ID['link'];\n"; 221 # add extra GET data to target 222 if ($extras[$i]) { &parse_extras ($extras[$i]); } 223 # print the actual table cell line with the link... 224 if (! $value) { $value = "\$row[$i]"; } 225 printf FILE " echo \"<td class=\\\"list\\\"><a href=\\\"\$link\\\"> $value </a></td>\\n\";\n"; 226 next; 227 } 228 229 if (($label eq "image") && !$link[$i]) { 230 # print the actual table cell line with the image... 231 printf FILE " echo \"<td class=\\\"list\\\"><img src=\\\"$value\\\"></td>\\n\";\n"; 232 next; 233 } 234 235 if (($label eq "image") && $link[$i]) { 135 236 # create the basic link 136 printf FILE " \$link = \"$link[$i]\" . \"?\" . \$ID['link'];\n"; 137 if ($extras[$i]) { 138 # examine the extras and parse the embedded fields 139 @extfields = split (/,/, $extras[$i]); 140 $N = @extfields; 141 if ($VERBOSE) { print STDERR "N extfields: $N\n"; } 142 for ($j = 0; $j < @extfields; $j++) { 143 144 # search for embedded table fields and replace with row[N] 145 $N = -1; 146 $extline = $extfields[$j]; 147 if ($VERBOSE) { print STDERR "extfield: $extfields[$j]\n"; } 148 for ($k = 0; ($k < @field) && ($N == -1); $k++) { 149 if ($extline =~ m|\$$field[$k]|) { 150 $extline =~ s|\$$field[$k]||; 151 $N = $k; 152 } 153 } 154 if ($N == -1) { 155 # no embedded field, print verbatim 156 printf FILE " \$link = \$link . \"&$extline\";\n"; 157 } else { 158 # replace embedded field with row[N] 159 printf FILE " \$link = \$link . \"&$extline\" . \$row[$N];\n"; 160 } 161 } 162 163 } 237 printf FILE " \$link = \"$link[$i]\" . \"?menu=$MENU&\" . \$ID['link'];\n"; 238 # add extra php data to target 239 if ($extras[$i]) { &parse_extras ($extras[$i]); } 164 240 # print the actual table cell line with the link... 165 printf FILE " echo \"<td class=\\\"list\\\"><a href=\\\"\$link\\\"> \$row[$i] </a></td>\\n\";\n"; 166 } else { 167 # or without 168 printf FILE " echo \"<td class=\\\"list\\\"> \$row[$i] </td>\\n\";\n"; 241 printf FILE " echo \"<td class=\\\"list\\\"><a href=\\\"\$link\\\"> <img src=\\\"$value\\\"> </a></td>\\n\";\n"; 242 next; 169 243 } 170 244 } … … 174 248 175 249 for ($i = 0; $i < @field; $i++) { 250 if ($show[$i] eq "none") { next; } 176 251 printf FILE "echo \"<td class=\\\"list\\\"> <input type=\\\"text\\\" name=\\\"$field[$i]\\\"> </td>\\n\";\n"; 177 252 } … … 186 261 187 262 set_keypair ("FIELDS", $FIELDS); 263 } 264 265 sub parse_extras { 266 my ($extras) = $_[0]; 267 my (@extfields); 268 my ($label, $value, $outline); 269 my ($i); 270 271 # examine the extras and parse the embedded fields (comma-separated) 272 @extfields = split (/,/, $extras); 273 for ($i = 0; $i < @extfields; $i++) { 274 ($label, $value, $outline) = &parse_label ($extfields[$i]); 275 printf FILE " \$link = \$link . \"&$outline\";\n"; 276 } 277 } 278 279 # parse strings of the form label=value 280 # if 'value' is of the form $field, try to match with 281 # a supplied DB field, and replace with $row[$n] if found 282 sub parse_label { 283 my ($string) = $_[0]; 284 my ($label, $value, $outline); 285 my ($N, $i); 286 287 # unless we replace the value with the db row element, return the original string 288 $outline = $string; 289 $label = $string; 290 $value = ""; 291 292 # search for embedded table fields and replace with row[N] 293 if ($VERBOSE) { print STDERR "string: $string\n"; } 294 if ($string =~ m|\S+=\S+|) { 295 ($label, $value) = $string =~ m|(\S+)=(\S+)|; 296 if ($value =~ m|^\$|) { 297 MATCH_LABEL: 298 for ($i = 0; $i < @field; $i++) { 299 if ($value =~ m|^\$$field[$i]|) { 300 $value = "\$row[$i]"; 301 last MATCH_LABEL; 302 } 303 } 304 $outline = "$label=$value"; 305 } 306 } 307 return ($label, $value, $outline); 188 308 } 189 309
Note:
See TracChangeset
for help on using the changeset viewer.
