Changeset 26820
- Timestamp:
- Feb 8, 2010, 7:19:33 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20091201/ippMonitor/scripts/generate
r24758 r26820 36 36 37 37 foreach $line (@list) { 38 chop $line;39 ($key, $value) = split (" ", $line, 2);40 41 # strip leading and trailing white space from the following42 if ($key eq "TABLE") { ($value) = $value =~ m|^\s*(.+)\s*$|; }43 if ($key eq "TYPE") { ($value) = $value =~ m|^\s*(.+)\s*$|; }44 45 &set_keypair ($key, $value);46 47 # list of the table fields48 if ($key eq "FIELD") {49 ($field, $width, $format, $name, $show, $link, $extras) = split (/,\s+/, $value, 7);50 if (! $name) { die "table $ARGV[0] missing required elements\n"; }51 if ($field =~ m|\S+\s+as\s+\S+|) {52 ($fieldreal) = $field =~ m|\S+\s+as\s+(\S+)|;53 } else {54 $fieldreal = $field;55 }56 57 if ($VERBOSE) { printf "%-20s %-20s %-20s %-20s %-20s %-20s\n", $field, $name, $format, $show, $link, $extras; }58 59 if ($show eq "") {$show = "value";}60 push @field, $field;61 push @fieldreal, $fieldreal;62 push @width, $width;63 push @format, $format;64 push @name, $name;65 push @show, $show;66 push @link, $link;67 push @extras, $extras;68 }69 70 if ($key eq "FILE") {71 $myFile = $value;72 }73 74 # list of the table fields75 if ($key eq "HEAD") {76 push @headcode, $value;77 }78 79 # the IMAGE commands sets up a reference name80 if ($key eq "IMAGE") {81 push @imagedefs, $value;82 }83 84 # the GROUP entries are used in summary tables as arguments to the GROUP BY sql statement85 if ($key eq "GROUP") {86 push @group, $value;87 }88 89 # the ARGS commands define arguments to FIELDS commands90 if ($key eq "ARGS") {91 push @linkargs, $value;92 }93 94 # the OP commands define field operations95 if ($key eq "OP") {96 push @opwords, $value;97 }98 99 # the TD_CLASS command sets up an alternate TD class100 if ($key eq "TD_CLASS") {101 push @tdClasses, $value;102 # print STDERR "found TD_CLASS\n";103 }104 105 # list of the table fields106 if ($key eq "TAIL") {107 push @tailcode, $value;108 }109 110 # list of the table restrictions111 # replace this with a flexible where statement?112 if ($key eq "WHERE") {113 ($field) = split (/,\s+/, $value, 1);114 if ($VERBOSE) { printf "%-20s\n", $field; }115 push @where, $field;116 }38 chop $line; 39 ($key, $value) = split (" ", $line, 2); 40 41 # strip leading and trailing white space from the following 42 if ($key eq "TABLE") { ($value) = $value =~ m|^\s*(.+)\s*$|; } 43 if ($key eq "TYPE") { ($value) = $value =~ m|^\s*(.+)\s*$|; } 44 45 &set_keypair ($key, $value); 46 47 # list of the table fields 48 if ($key eq "FIELD") { 49 ($field, $width, $format, $name, $show, $link, $extras) = split (/,\s+/, $value, 7); 50 if (! $name) { die "table $ARGV[0] missing required elements\n"; } 51 if ($field =~ m|\S+\s+as\s+\S+|) { 52 ($fieldreal) = $field =~ m|\S+\s+as\s+(\S+)|; 53 } else { 54 $fieldreal = $field; 55 } 56 57 if ($VERBOSE) { printf "%-20s %-20s %-20s %-20s %-20s %-20s\n", $field, $name, $format, $show, $link, $extras; } 58 59 if ($show eq "") {$show = "value";} 60 push @field, $field; 61 push @fieldreal, $fieldreal; 62 push @width, $width; 63 push @format, $format; 64 push @name, $name; 65 push @show, $show; 66 push @link, $link; 67 push @extras, $extras; 68 } 69 70 if ($key eq "FILE") { 71 $myFile = $value; 72 } 73 74 # list of the table fields 75 if ($key eq "HEAD") { 76 push @headcode, $value; 77 } 78 79 # the IMAGE commands sets up a reference name 80 if ($key eq "IMAGE") { 81 push @imagedefs, $value; 82 } 83 84 # the GROUP entries are used in summary tables as arguments to the GROUP BY sql statement 85 if ($key eq "GROUP") { 86 push @group, $value; 87 } 88 89 # the ARGS commands define arguments to FIELDS commands 90 if ($key eq "ARGS") { 91 push @linkargs, $value; 92 } 93 94 # the OP commands define field operations 95 if ($key eq "OP") { 96 push @opwords, $value; 97 } 98 99 # the TD_CLASS command sets up an alternate TD class 100 if ($key eq "TD_CLASS") { 101 push @tdClasses, $value; 102 # print STDERR "found TD_CLASS\n"; 103 } 104 105 # list of the table fields 106 if ($key eq "TAIL") { 107 push @tailcode, $value; 108 } 109 110 # list of the table restrictions 111 # replace this with a flexible where statement? 112 if ($key eq "WHERE") { 113 ($field) = split (/,\s+/, $value, 1); 114 if ($VERBOSE) { printf "%-20s\n", $field; } 115 push @where, $field; 116 } 117 117 } 118 118 … … 124 124 &check_key ("TITLE", ""); 125 125 &check_key ("FILE", ""); 126 126 127 127 # these are used internally (not just a replacement) 128 128 for ($i = 0; $i < @key; $i++) { 129 if ($key[$i] eq "MENU") { $MENU = $value[$i]; }130 if ($key[$i] eq "MODE") { 131 if ($value[$i] eq "summary") {132 if (@group == 0) {133 print STDERR "a summary table must have at least one group\n";134 exit 1;135 }136 &define_groups_string (@group);137 }138 }129 if ($key[$i] eq "MENU") { $MENU = $value[$i]; } 130 if ($key[$i] eq "MODE") { 131 if ($value[$i] eq "summary") { 132 if (@group == 0) { 133 print STDERR "a summary table must have at least one group\n"; 134 exit 1; 135 } 136 &define_groups_string (@group); 137 } 138 } 139 139 } 140 140 … … 147 147 148 148 foreach $linkarg (@linkargs) { 149 &parse_linkarg ($linkarg); 149 # print STDERR "linkarg: $linkarg\n"; 150 &parse_linkarg ($linkarg); 150 151 } 151 152 152 153 foreach $imagedef (@imagedefs) { 153 &parse_imagedef ($imagedef);154 &parse_imagedef ($imagedef); 154 155 } 155 156 156 157 foreach $opword (@opwords) { 157 &parse_opwords ($opword); 158 } 159 160 if (0) { 161 print STDERR "show: $show[0]\n"; 162 ($a, $b, $c) = &parse_label ($show[0]); 163 print STDERR "a: $a, b: $b, c: $c\n"; 164 165 print STDERR "extras: $extras[0]\n"; 166 ($a, $b, $c) = &parse_label ($extras[0]); 167 print STDERR "a: $a, b: $b, c: $c\n"; 168 169 print STDERR "show: $show[1]\n"; 170 ($a, $b, $c) = &parse_label ($show[1]); 171 print STDERR "a: $a, b: $b, c: $c\n"; 172 173 print STDERR "extras: $extras[1]\n"; 174 ($a, $b, $c) = &parse_label ($extras[1]); 175 print STDERR "a: $a, b: $b, c: $c\n"; 176 exit 0; 158 &parse_opwords ($opword); 159 } 160 161 if ($VERBOSE) { 162 print STDERR "show: $show[0]\n"; 163 ($a, $b, $c) = &parse_label ($show[0]); 164 print STDERR "a: $a, b: $b, c: $c\n"; 165 166 print STDERR "extras: $extras[0]\n"; 167 ($a, $b, $c) = &parse_label ($extras[0]); 168 print STDERR "a: $a, b: $b, c: $c\n"; 169 170 print STDERR "show: $show[1]\n"; 171 ($a, $b, $c) = &parse_label ($show[1]); 172 print STDERR "a: $a, b: $b, c: $c\n"; 173 174 print STDERR "extras: $extras[1]\n"; 175 ($a, $b, $c) = &parse_label ($extras[1]); 176 print STDERR "a: $a, b: $b, c: $c\n"; 177 177 } 178 178 } … … 186 186 187 187 foreach $line (@list) { 188 189 &check_keypairs;190 191 print FILE $line;192 193 # fill in table header194 if ($line =~ m|// \*\* TABLE HEADER \*\*|) {195 &write_table_header;196 }197 198 # fill in TD_CLASS test199 if ($line =~ m|// \*\* TD CLASS \*\*|) {200 &write_td_class;201 }202 203 # fill in table data204 if ($line =~ m|// \*\* TABLE DATA \*\*|) {205 &write_table_data;206 }207 208 # fill in table query209 if ($line =~ m|// \*\* TABLE QUERY \*\*|) {210 &write_table_query;211 }212 213 # fill in table restricts214 if ($line =~ m|// \*\* TABLE RESTRICTIONS \*\*|) {215 &write_table_restrict;216 }217 218 # fill in table restricts219 if ($line =~ m|// \*\* BUTTON RESTRICTIONS \*\*|) {220 &write_button_restrict;221 }222 223 # fill in head HTML or PHP code224 if ($line =~ m|// \*\* HEAD CODE \*\*|) {225 &write_inline_code (@headcode);226 }227 228 # fill in tail HTML or PHP code229 if ($line =~ m|// \*\* TAIL CODE \*\*|) {230 &write_inline_code (@tailcode);231 }188 189 &check_keypairs; 190 191 print FILE $line; 192 193 # fill in table header 194 if ($line =~ m|// \*\* TABLE HEADER \*\*|) { 195 &write_table_header; 196 } 197 198 # fill in TD_CLASS test 199 if ($line =~ m|// \*\* TD CLASS \*\*|) { 200 &write_td_class; 201 } 202 203 # fill in table data 204 if ($line =~ m|// \*\* TABLE DATA \*\*|) { 205 &write_table_data; 206 } 207 208 # fill in table query 209 if ($line =~ m|// \*\* TABLE QUERY \*\*|) { 210 &write_table_query; 211 } 212 213 # fill in table restricts 214 if ($line =~ m|// \*\* TABLE RESTRICTIONS \*\*|) { 215 &write_table_restrict; 216 } 217 218 # fill in table restricts 219 if ($line =~ m|// \*\* BUTTON RESTRICTIONS \*\*|) { 220 &write_button_restrict; 221 } 222 223 # fill in head HTML or PHP code 224 if ($line =~ m|// \*\* HEAD CODE \*\*|) { 225 &write_inline_code (@headcode); 226 } 227 228 # fill in tail HTML or PHP code 229 if ($line =~ m|// \*\* TAIL CODE \*\*|) { 230 &write_inline_code (@tailcode); 231 } 232 232 } 233 233 close (FILE); … … 237 237 my (@code) = @_; 238 238 my ($i, $code, $type); 239 239 240 240 for ($i = 0; $i < @code; $i++) { 241 ($type, $line) = split (" ", $code[$i], 2);242 if ($type eq "PHP") {243 print FILE "$line\n";244 }245 if ($type eq "HTML") {246 print FILE "?> $line <?\n";247 }241 ($type, $line) = split (" ", $code[$i], 2); 242 if ($type eq "PHP") { 243 print FILE "$line\n"; 244 } 245 if ($type eq "HTML") { 246 print FILE "?> $line <?\n"; 247 } 248 248 } 249 249 } … … 253 253 254 254 # print the table header (field labels) 255 print FILE "echo \"<tr><td></td>\\n\";\n"; 256 for ($i = 0; $i < @field; $i++) { 257 ($label, $value, $string) = &parse_label ($show[$i]);258 if ($show[$i] eq "none") { next; }259 print FILE "write_header_cell (\"list\", \"$name[$i]\");\n";255 print FILE "echo \"<tr><td></td>\\n\";\n"; 256 for ($i = 0; $i < @field; $i++) { 257 ($label, $value, $string) = &parse_label ($show[$i]); 258 if ($show[$i] eq "none") { next; } 259 print FILE "write_header_cell (\"list\", \"$name[$i]\");\n"; 260 260 } 261 261 print FILE "echo \"</tr>\\n\";\n"; 262 262 263 263 # print the column sort cells 264 print FILE "echo \"<tr><td></td>\\n\";\n"; 265 for ($i = 0; $i < @field; $i++) { 266 ($label, $value, $string) = &parse_label ($show[$i]);267 if ($show[$i] eq "none") { next; }268 if ($field[$i] eq "*") { print FILE "echo \"<td></td>\\n\";\n"; next; } # empty cell (no sort for such fields)269 if ($label eq "op") {270 print FILE "write_sort_cell (\"list\", \"$opf{$value}\", \$buttonLink, \$ID, '$myFile');\n";271 } else {272 print FILE "write_sort_cell (\"list\", \"$fieldreal[$i]\", \$buttonLink, \$ID, '$myFile');\n";273 }264 print FILE "echo \"<tr><td></td>\\n\";\n"; 265 for ($i = 0; $i < @field; $i++) { 266 ($label, $value, $string) = &parse_label ($show[$i]); 267 if ($show[$i] eq "none") { next; } 268 if ($field[$i] eq "*") { print FILE "echo \"<td></td>\\n\";\n"; next; } # empty cell (no sort for such fields) 269 if ($label eq "op") { 270 print FILE "write_sort_cell (\"list\", \"$opf{$value}\", \$buttonLink, \$ID, '$myFile');\n"; 271 } else { 272 print FILE "write_sort_cell (\"list\", \"$fieldreal[$i]\", \$buttonLink, \$ID, '$myFile');\n"; 273 } 274 274 } 275 275 print FILE "echo \"</tr>\\n\";\n"; … … 282 282 foreach $tdClass (@tdClasses) { 283 283 284 # TD_CLASS class field expression285 ($class, $testline) = split (" ", $tdClass, 2);286 287 $testlineFixed = "";288 @testlineBits = split (" ", $testline);289 foreach my $bit (@testlineBits) {290 $newbit = &parse_fieldname ($bit);291 $testlineFixed = "$testlineFixed $newbit";292 }293 294 print FILE " if ($testlineFixed) {\n";295 print FILE " \$class = \"$class\";\n";296 print FILE " }\n";284 # TD_CLASS class field expression 285 ($class, $testline) = split (" ", $tdClass, 2); 286 287 $testlineFixed = ""; 288 @testlineBits = split (" ", $testline); 289 foreach my $bit (@testlineBits) { 290 $newbit = &parse_fieldname ($bit); 291 $testlineFixed = "$testlineFixed $newbit"; 292 } 293 294 print FILE " if ($testlineFixed) {\n"; 295 print FILE " \$class = \"$class\";\n"; 296 print FILE " }\n"; 297 297 } 298 298 } … … 302 302 303 303 if ($WHERE) { 304 print FILE "\$WHERE = \"WHERE $WHERE\";\n";305 } 306 for ($i = 0; $i < @field; $i++) { 307 $value = $fieldreal[$i];308 if ($value eq "*") { next; }309 if ($format[$i] eq "%s") {310 print FILE "\$WHERE = check_restrict ('$value', \$WHERE, 'string', 1.0);\n";311 next;312 } 313 if ($format[$i] eq "%C") {314 # convert the RA & DEC limits to radians for comparison315 print FILE "\$WHERE = check_restrict ('$value', \$WHERE, 'min', 0.017453);\n";316 print FILE "\$WHERE = check_restrict ('$value', \$WHERE, 'max', 0.017453);\n";317 next;318 } 319 print FILE "\$WHERE = check_restrict ('$value', \$WHERE, 'string', 1.0);\n";320 print FILE "\$WHERE = check_restrict ('$value', \$WHERE, 'min', 1.0);\n";321 print FILE "\$WHERE = check_restrict ('$value', \$WHERE, 'max', 1.0);\n";304 print FILE "\$WHERE = \"WHERE $WHERE\";\n"; 305 } 306 for ($i = 0; $i < @field; $i++) { 307 $value = $fieldreal[$i]; 308 if ($value eq "*") { next; } 309 if ($format[$i] eq "%s") { 310 print FILE "\$WHERE = check_restrict ('$value', \$WHERE, 'string', 1.0);\n"; 311 next; 312 } 313 if ($format[$i] eq "%C") { 314 # convert the RA & DEC limits to radians for comparison 315 print FILE "\$WHERE = check_restrict ('$value', \$WHERE, 'min', 0.017453);\n"; 316 print FILE "\$WHERE = check_restrict ('$value', \$WHERE, 'max', 0.017453);\n"; 317 next; 318 } 319 print FILE "\$WHERE = check_restrict ('$value', \$WHERE, 'string', 1.0);\n"; 320 print FILE "\$WHERE = check_restrict ('$value', \$WHERE, 'min', 1.0);\n"; 321 print FILE "\$WHERE = check_restrict ('$value', \$WHERE, 'max', 1.0);\n"; 322 322 } 323 323 print FILE "\$WHERE = check_ordering ('$GROUPS', \$WHERE);\n"; … … 328 328 329 329 for ($i = 0; $i < @field; $i++) { 330 $value = $fieldreal[$i];331 if ($value eq "*") { next; }332 if ($format[$i] eq "%s") {333 print FILE "\$buttonLink = button_restrict_string ('$value', \$buttonLink);\n";334 } else {335 print FILE "\$buttonLink = button_restrict_string ('$value', \$buttonLink);\n";336 print FILE "\$buttonLink = button_restrict_min ('$value', \$buttonLink);\n";337 print FILE "\$buttonLink = button_restrict_max ('$value', \$buttonLink);\n";338 }330 $value = $fieldreal[$i]; 331 if ($value eq "*") { next; } 332 if ($format[$i] eq "%s") { 333 print FILE "\$buttonLink = button_restrict_string ('$value', \$buttonLink);\n"; 334 } else { 335 print FILE "\$buttonLink = button_restrict_string ('$value', \$buttonLink);\n"; 336 print FILE "\$buttonLink = button_restrict_min ('$value', \$buttonLink);\n"; 337 print FILE "\$buttonLink = button_restrict_max ('$value', \$buttonLink);\n"; 338 } 339 339 } 340 340 } … … 347 347 print FILE "echo \"<tr><td>≥</td>\\n\";\n"; 348 348 for ($i = 0; $i < @field; $i++) { 349 if ($show[$i] eq "none") { next; }350 if ($field[$i] eq "*") { 351 # * fields create an empty cell 352 print FILE "echo \"<td> </td>\\n\";\n";353 } else {354 if ($format[$i] eq "%s") {355 print FILE "write_query_row ('$fieldreal[$i]', $width[$i], 'string');\n";356 } else {357 print FILE "write_query_row ('$fieldreal[$i]', $width[$i], 'min');\n";358 }359 }349 if ($show[$i] eq "none") { next; } 350 if ($field[$i] eq "*") { 351 # * fields create an empty cell 352 print FILE "echo \"<td> </td>\\n\";\n"; 353 } else { 354 if ($format[$i] eq "%s") { 355 print FILE "write_query_row ('$fieldreal[$i]', $width[$i], 'string');\n"; 356 } else { 357 print FILE "write_query_row ('$fieldreal[$i]', $width[$i], 'min');\n"; 358 } 359 } 360 360 } 361 361 print FILE "echo \"</tr><tr><td>≤</td>\\n\";\n"; 362 362 for ($i = 0; $i < @field; $i++) { 363 if ($show[$i] eq "none") { next; }364 if (($field[$i] eq "*") || ($format[$i] eq "%s")) { 365 # * fields create an empty cell 366 print FILE "echo \"<td> </td>\\n\";\n";367 } else {368 print FILE "write_query_row ('$fieldreal[$i]', $width[$i], 'max');\n";369 }363 if ($show[$i] eq "none") { next; } 364 if (($field[$i] eq "*") || ($format[$i] eq "%s")) { 365 # * fields create an empty cell 366 print FILE "echo \"<td> </td>\\n\";\n"; 367 } else { 368 print FILE "write_query_row ('$fieldreal[$i]', $width[$i], 'max');\n"; 369 } 370 370 } 371 371 print FILE "echo \"</tr>\\n\";\n"; … … 377 377 378 378 for ($i = 0; $i < @field; $i++) { 379 ($label, $value, $string) = &parse_label ($show[$i]); 380 $Nrow = $count[$i]; 381 382 # create the link variable if this entry should be linked 383 if ($label eq "none") { next; } 384 385 if ($label eq "value") { 386 # create the basic link variable 387 if ($link[$i]) { 388 print FILE " \$link = \"$link[$i]\" . \"?menu=$MENU&\" . \$ID['link'];\n"; 389 # add extra GET data to target 390 if ($extras[$i]) { &parse_extras ($linkarg{$extras[$i]}); } 391 $myLink = "\$link"; 392 } else { 393 $myLink = "\"\""; 394 } 395 # print the actual table cell line with the link... 396 if (! $value && ($field[$i] ne "*")) { $value = "\$row[$Nrow]"; } 397 398 # add special format elements 399 # $realFormat = $format[$i]; 400 # if ($format[$i] eq '%T') { 401 # $realFormat = '%s'; 402 # } 403 print FILE " write_table_cell (\$class, '$format[$i]', $myLink, $value);\n"; 404 next; 405 } 406 407 if ($label eq "op") { 408 # create the basic link variable 409 if ($link[$i]) { 410 print FILE " \$link = \"$link[$i]\" . \"?menu=$MENU&\" . \$ID['link'];\n"; 411 # add extra GET data to target 412 if ($extras[$i]) { &parse_extras ($linkarg{$extras[$i]}); } 413 $myLink = "\$link"; 414 } else { 415 $myLink = "\"\""; 416 } 417 print FILE " write_table_cell (\$class, '$format[$i]', $myLink, $ops{$value});\n"; 418 next; 419 } 420 421 if (($label eq "image") && !$link[$i]) { 422 # print the actual table cell line with the image... 423 print FILE " echo \"<td class=\\\"\$class\\\">\n"; 424 print FILE " echo \" <img src=\\\"$image{$value}\\\"></td>\\n\";\n"; 425 next; 426 } 427 428 if (($label eq "image") && $link[$i]) { 429 # create the basic link 430 print FILE " \$link = \"$link[$i]\" . \"?menu=$MENU&\" . \$ID['link'];\n"; 431 # add extra php data to target 432 if ($extras[$i]) { &parse_extras ($linkarg{$extras[$i]}); } 433 # print the actual table cell line with the link... 434 print FILE " echo \"<td class=\\\"\$class\\\"><a href=\\\"\$link\\\"> <img src=\\\"$image{$value}\\\"> </a></td>\\n\";\n"; 435 next; 436 } 379 ($label, $value, $string) = &parse_label ($show[$i]); 380 $Nrow = $count[$i]; 381 382 # create the link variable if this entry should be linked 383 if ($label eq "none") { next; } 384 385 if ($label eq "value") { 386 # create the basic link variable 387 # print STDERR "value: $link[$i]\n"; 388 if ($link[$i]) { 389 print FILE " \$link = \"$link[$i]\" . \"?menu=$MENU&\" . \$ID['link'];\n"; 390 # add extra GET data to target 391 if ($extras[$i]) { &parse_extras ($linkarg{$extras[$i]}); } 392 $myLink = "\$link"; 393 } else { 394 $myLink = "\"\""; 395 } 396 # print the actual table cell line with the link... 397 if (! $value && ($field[$i] ne "*")) { $value = "\$row[$Nrow]"; } 398 399 # add special format elements 400 # $realFormat = $format[$i]; 401 # if ($format[$i] eq '%T') { 402 # $realFormat = '%s'; 403 # } 404 print FILE " write_table_cell (\$class, '$format[$i]', $myLink, $value);\n"; 405 next; 406 } 407 408 if ($label eq "op") { 409 # create the basic link variable 410 if ($link[$i]) { 411 print FILE " \$link = \"$link[$i]\" . \"?menu=$MENU&\" . \$ID['link'];\n"; 412 # add extra GET data to target 413 if ($extras[$i]) { &parse_extras ($linkarg{$extras[$i]}); } 414 $myLink = "\$link"; 415 } else { 416 $myLink = "\"\""; 417 } 418 print FILE " write_table_cell (\$class, '$format[$i]', $myLink, $ops{$value});\n"; 419 next; 420 } 421 422 if (($label eq "image") && !$link[$i]) { 423 # print the actual table cell line with the image... 424 print FILE " echo \"<td class=\\\"\$class\\\">\n"; 425 print FILE " echo \" <img src=\\\"$image{$value}\\\"></td>\\n\";\n"; 426 next; 427 } 428 429 if (($label eq "image") && $link[$i]) { 430 # create the basic link 431 print FILE " \$link = \"$link[$i]\" . \"?menu=$MENU&\" . \$ID['link'];\n"; 432 # add extra php data to target 433 if ($extras[$i]) { &parse_extras ($linkarg{$extras[$i]}); } 434 # print the actual table cell line with the link... 435 print FILE " echo \"<td class=\\\"\$class\\\"><a href=\\\"\$link\\\"> <img src=\\\"$image{$value}\\\"> </a></td>\\n\";\n"; 436 next; 437 } 437 438 } 438 439 } … … 444 445 $FIELDS = "$array[0]"; 445 446 for ($i = 1; $i < @array; $i++) { 446 # skip * fields (not a valid query element447 if ($array[$i] eq "*") { next; }448 $FIELDS = "$FIELDS,$array[$i]";447 # skip * fields (not a valid query element 448 if ($array[$i] eq "*") { next; } 449 $FIELDS = "$FIELDS,$array[$i]"; 449 450 } 450 451 set_keypair ("FIELDS", $FIELDS); … … 457 458 $GROUPS = "$array[0]"; 458 459 for ($i = 1; $i < @array; $i++) { 459 # skip * fields (not a valid query element460 if ($array[$i] eq "*") { next; }461 $GROUPS = "$GROUPS,$array[$i]";460 # skip * fields (not a valid query element 461 if ($array[$i] eq "*") { next; } 462 $GROUPS = "$GROUPS,$array[$i]"; 462 463 } 463 464 set_keypair ("GROUPS", $GROUPS); … … 471 472 $Nrow = 0; 472 473 for ($i = 0; $i < @field; $i++) { 473 # skip * fields (not a valid query element474 if ($field[$i] eq "*") { 475 $count[$i] = -1;476 } else {477 $count[$i] = $Nrow;478 $Nrow ++;479 }474 # skip * fields (not a valid query element 475 if ($field[$i] eq "*") { 476 $count[$i] = -1; 477 } else { 478 $count[$i] = $Nrow; 479 $Nrow ++; 480 } 480 481 } 481 482 } … … 489 490 $WHERE = "$array[0]"; 490 491 for ($i = 1; $i < @array; $i++) { 491 $WHERE = "$WHERE AND $array[$i]";492 } 493 492 $WHERE = "$WHERE AND $array[$i]"; 493 } 494 494 495 set_keypair ("WHERE", $WHERE); 495 496 } … … 502 503 503 504 # examine the extras and parse the embedded fields (comma-separated) 505 504 506 @extfields = split (/,/, $extras); 505 507 for ($i = 0; $i < @extfields; $i++) { 506 ($label, $value, $outline) = &parse_label ($extfields[$i]);507 print FILE " \$link = \$link . \"&$outline\";\n";508 ($label, $value, $outline) = &parse_label ($extfields[$i]); 509 print FILE " \$link = \$link . \"&$outline\";\n"; 508 510 } 509 511 } … … 517 519 ($word, $value) = split (" ", $_[0]); 518 520 521 # print STDERR "0: $_[0], $word, $value\n"; 522 519 523 if ($linkarg{$word}) { 520 $linkarg{$word} = "$linkarg{$word},$value";524 $linkarg{$word} = "$linkarg{$word},$value"; 521 525 } else { 522 $linkarg{$word} = $value; 523 } 526 $linkarg{$word} = $value; 527 } 528 # print STDERR "linkarg($word) : $linkarg{$word}\n"; 524 529 } 525 530 526 531 # parse strings of the form label=value 527 # if 'value' is of the form $field, try to match with 532 # if 'value' is of the form $field, try to match with 528 533 # a supplied DB field, and replace with $row[$n] if found 529 534 sub parse_label { … … 540 545 if ($VERBOSE) { print STDERR "string: $string\n"; } 541 546 if ($string =~ m|\S+=\S+|) { 542 ($label, $value) = $string =~ m|(\S+)=(\S+)|; 543 if ($value =~ m|^\$|) { 544 MATCH_LABEL: 545 for ($i = 0; $i < @field; $i++) { 546 if ($field[$i] eq "*") { next; } 547 if ($value =~ m|^\$$fieldreal[$i]|) { 548 # print "field: $fieldreal[$i]\n"; 549 ($name, $extra) = $value =~ m|^\$($fieldreal[$i])\@(\S+)|; 550 # print "name: $name\n"; 551 # print "extra: $extra\n"; 552 # print "value: $value\n"; 553 554 $Nrow = $count[$i]; 555 if ($extra) { 556 $value = "\$row[$Nrow]\@$extra"; 557 } else { 558 $value = "\$row[$Nrow]"; 559 } 560 # print "outval: $value\n"; 561 last MATCH_LABEL; 562 } 563 } 564 $outline = "$label=$value"; 565 } 547 ($label, $value) = $string =~ m|(\S+)=(\S+)|; 548 if ($value =~ m|^\$|) { 549 MATCH_LABEL: 550 for ($i = 0; $i < @field; $i++) { 551 if ($field[$i] eq "*") { next; } 552 while ($value =~ m|\$$fieldreal[$i]|) { 553 # print "field: $fieldreal[$i]\n"; 554 # ($part1, $name, $part2) = $value =~ m|\$($fieldreal[$i])\@(\S+)|; 555 ($part1, $name, $part2) = $value =~ m|(\S*)\$($fieldreal[$i])(\S*)|; 556 # print "name: $name\n"; 557 # print "part1: $part1\n"; 558 # print "part2: $part2\n"; 559 # print "value: $value\n"; 560 561 $Nrow = $count[$i]; 562 $value = $part1 . "\$row[$Nrow]" . $part2; 563 564 # if ($part1 || $part2) { 565 # } else { 566 # $value = "\$row[$Nrow]"; 567 # } 568 # print "outval: $value\n"; 569 # last MATCH_LABEL; 570 } 571 } 572 $outline = "$label=$value"; 573 } 566 574 } 567 575 return ($label, $value, $outline); … … 574 582 my ($variable) = $_[0]; 575 583 my ($i); 576 584 577 585 # print STDERR "variable: $variable\n"; 578 586 579 587 unless ($variable =~ m|^\$|) { 580 return $variable;588 return $variable; 581 589 } 582 590 … … 586 594 587 595 for ($i = 0; $i < @field; $i++) { 588 # print STDERR "$i: $fieldreal[$i] : $fieldname\n";589 590 if ($field[$i] eq "*") { next; }591 if ($fieldname ne $fieldreal[$i]) { next; }592 593 594 $Nrow = $count[$i];595 596 $value = "\$row[$Nrow]";597 598 # print STDERR "found : $i : $count[$i] : $Nrow : $value\n";599 return $value;596 # print STDERR "$i: $fieldreal[$i] : $fieldname\n"; 597 598 if ($field[$i] eq "*") { next; } 599 if ($fieldname ne $fieldreal[$i]) { next; } 600 601 602 $Nrow = $count[$i]; 603 604 $value = "\$row[$Nrow]"; 605 606 # print STDERR "found : $i : $count[$i] : $Nrow : $value\n"; 607 return $value; 600 608 } 601 609 return $variable; … … 623 631 @outfields = (); 624 632 foreach $word (@words) { 625 $fword = &parse_fieldname ($word);626 # print "field: $word -> $fword\n";627 push @outwords, $fword;628 if ($word =~ m|^\$|) {629 $word = substr ($word, 1);630 }631 push @outfields, $word;633 $fword = &parse_fieldname ($word); 634 # print "field: $word -> $fword\n"; 635 push @outwords, $fword; 636 if ($word =~ m|^\$|) { 637 $word = substr ($word, 1); 638 } 639 push @outfields, $word; 632 640 } 633 641 $outline = join (" ", @outwords); … … 655 663 656 664 for ($i = 0; $i < @key; $i++) { 657 if ($key eq $key[$i]) {658 if ($value[$i] ne "") { die "key is multiply defined\n"; }659 $value[$i] = $value;660 if ($VERBOSE) { print STDERR "setting $key = $value\n"; }661 return;662 }665 if ($key eq $key[$i]) { 666 if ($value[$i] ne "") { die "key is multiply defined\n"; } 667 $value[$i] = $value; 668 if ($VERBOSE) { print STDERR "setting $key = $value\n"; } 669 return; 670 } 663 671 } 664 672 } … … 670 678 671 679 for ($i = 0; $i < @key; $i++) { 672 if ($key eq $key[$i]) {673 if ($VERBOSE) { print "found $key: $key[$i] -- $value[$i] (def: $default)\n"; }674 if (($default eq "") && ($value[$i] eq "")) { die "missing value for required key $key[$i]\n"; }675 if ($value[$i] eq "") { $value[$i] = $default; }676 return;677 }680 if ($key eq $key[$i]) { 681 if ($VERBOSE) { print "found $key: $key[$i] -- $value[$i] (def: $default)\n"; } 682 if (($default eq "") && ($value[$i] eq "")) { die "missing value for required key $key[$i]\n"; } 683 if ($value[$i] eq "") { $value[$i] = $default; } 684 return; 685 } 678 686 } 679 687 die "unknown key $key\n"; … … 683 691 my ($i); 684 692 for ($i = 0; $i < @key; $i++) { 685 if ($VERBOSE) { print "$key[$i] -- $value[$i]\n"; }686 if ($line =~ m|\$$key[$i]|) {687 if ($value[$i] eq "") { die "missing value for required key $key[$i]\n"; }688 $line =~ s|\$$key[$i]|$value[$i]|g;689 }690 } 691 } 692 693 # we need to find the structure size, including padding 694 # i'm not sure I know the answer to this: it is probably 695 # the total number of bytes rounded up to the largest 693 if ($VERBOSE) { print "$key[$i] -- $value[$i]\n"; } 694 if ($line =~ m|\$$key[$i]|) { 695 if ($value[$i] eq "") { die "missing value for required key $key[$i]\n"; } 696 $line =~ s|\$$key[$i]|$value[$i]|g; 697 } 698 } 699 } 700 701 # we need to find the structure size, including padding 702 # i'm not sure I know the answer to this: it is probably 703 # the total number of bytes rounded up to the largest 696 704 # data item in the structure (ie, 8 for a double, etc) 697 705 # if we have the size, then we can double check the structure 698 706 # against the expectation at runtime. for the moment, 699 # calculate by hand and add to def.d file 700 707 # calculate by hand and add to def.d file 708
Note:
See TracChangeset
for help on using the changeset viewer.
