IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 3, 2010, 8:50:52 AM (16 years ago)
Author:
eugene
Message:

updates from trunk

Location:
branches/simtest_nebulous_branches
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/simtest_nebulous_branches

  • branches/simtest_nebulous_branches/ippMonitor/scripts/generate

    r24758 r27840  
    2828    &init_key ("STYLE");
    2929    &init_key ("MODE");
     30    &init_key ("UNRESTRICTED");
    3031    &init_key ("TABLE");
    3132    &init_key ("TITLE");
     
    3637
    3738    foreach $line (@list) {
    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         }
     39        chop $line;
     40        ($key, $value) = split (" ", $line, 2);
     41
     42        # strip leading and trailing white space from the following
     43        if ($key eq "TABLE") { ($value) = $value =~ m|^\s*(.+)\s*$|; }
     44        if ($key eq "TYPE")  { ($value) = $value =~ m|^\s*(.+)\s*$|; }
     45
     46        &set_keypair ($key, $value);
     47
     48        # list of the table fields
     49        if ($key eq "FIELD") {
     50            ($field, $width, $format, $name, $show, $link, $extras) = split (/,\s+/, $value, 7);
     51            if (! $name) { die "table $ARGV[0] missing required elements\n"; }
     52            if ($field =~ m|\S+\s+as\s+\S+|) {
     53                ($fieldreal) = $field =~ m|\S+\s+as\s+(\S+)|;
     54            } else {
     55                $fieldreal = $field;
     56            }
     57
     58            if ($VERBOSE) { printf "%-20s %-20s %-20s %-20s %-20s %-20s\n", $field, $name, $format, $show, $link, $extras; }
     59
     60            if ($show eq "") {$show = "value";}
     61            push @field,     $field;
     62            push @fieldreal, $fieldreal;
     63            push @width,     $width;
     64            push @format,    $format;
     65            push @name,      $name;
     66            push @show,      $show;
     67            push @link,      $link;
     68            push @extras,    $extras;
     69        }
     70
     71        if ($key eq "FILE") {
     72            $myFile = $value;
     73        }
     74
     75        # list of the table fields
     76        if ($key eq "HEAD") {
     77            push @headcode, $value;
     78        }
     79
     80        # the IMAGE commands sets up a reference name
     81        if ($key eq "IMAGE") {
     82            push @imagedefs, $value;
     83        }
     84
     85        # the GROUP entries are used in summary tables as arguments to the GROUP BY sql statement
     86        if ($key eq "GROUP") {
     87            push @group, $value;
     88        }
     89
     90        # the ARGS commands define arguments to FIELDS commands
     91        if ($key eq "ARGS") {
     92            push @linkargs, $value;
     93        }
     94
     95        # the OP commands define field operations
     96        if ($key eq "OP") {
     97            push @opwords, $value;
     98        }
     99
     100        # the TD_CLASS command sets up an alternate TD class
     101        if ($key eq "TD_CLASS") {
     102            push @tdClasses, $value;
     103            # print STDERR "found TD_CLASS\n";
     104        }
     105
     106        # list of the table fields
     107        if ($key eq "TAIL") {
     108            push @tailcode, $value;
     109        }
     110
     111        # list of the table restrictions
     112        # replace this with a flexible where statement?
     113        if ($key eq "WHERE") {
     114            ($field) = split (/,\s+/, $value, 1);
     115            if ($VERBOSE) { printf "%-20s\n", $field; }
     116            push @where,   $field;
     117        }
    117118    }
    118119
     
    121122    &check_key ("STYLE", "ipp.css");
    122123    &check_key ("MODE", "basic");
     124    &check_key ("UNRESTRICTED", "none");
    123125    &check_key ("TABLE", "");
    124126    &check_key ("TITLE", "");
    125127    &check_key ("FILE", "");
    126    
     128
    127129    # these are used internally (not just a replacement)
    128130    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         }
     131        if ($key[$i] eq "MENU") { $MENU = $value[$i]; }
     132        if ($key[$i] eq "MODE") {
     133            if ($value[$i] eq "summary") {
     134                if (@group == 0) {
     135                    print STDERR "a summary table must have at least one group\n";
     136                    exit 1;
     137                }
     138                &define_groups_string (@group);
     139            }
     140        }
    139141    }
    140142
     
    147149
    148150    foreach $linkarg (@linkargs) {
    149         &parse_linkarg ($linkarg);
     151        # print STDERR "linkarg: $linkarg\n";
     152        &parse_linkarg ($linkarg);
    150153    }
    151154
    152155    foreach $imagedef (@imagedefs) {
    153         &parse_imagedef ($imagedef);
     156        &parse_imagedef ($imagedef);
    154157    }
    155158
    156159    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;
     160        &parse_opwords ($opword);
     161    }
     162
     163    if ($VERBOSE) {
     164        print STDERR "show: $show[0]\n";
     165        ($a, $b, $c) = &parse_label ($show[0]);
     166        print STDERR "a: $a, b: $b, c: $c\n";
     167
     168        print STDERR "extras: $extras[0]\n";
     169        ($a, $b, $c) = &parse_label ($extras[0]);
     170        print STDERR "a: $a, b: $b, c: $c\n";
     171
     172        print STDERR "show: $show[1]\n";
     173        ($a, $b, $c) = &parse_label ($show[1]);
     174        print STDERR "a: $a, b: $b, c: $c\n";
     175
     176        print STDERR "extras: $extras[1]\n";
     177        ($a, $b, $c) = &parse_label ($extras[1]);
     178        print STDERR "a: $a, b: $b, c: $c\n";
    177179    }
    178180}
     
    186188
    187189    foreach $line (@list) {
    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         }
     190
     191        &check_keypairs;
     192
     193        print FILE $line;
     194
     195        # fill in table header
     196        if ($line =~ m|// \*\* TABLE HEADER \*\*|) {
     197            &write_table_header;
     198        }
     199
     200        # fill in TD_CLASS test
     201        if ($line =~ m|// \*\* TD CLASS \*\*|) {
     202            &write_td_class;
     203        }
     204
     205        # fill in table data
     206        if ($line =~ m|// \*\* TABLE DATA \*\*|) {
     207            &write_table_data;
     208        }
     209
     210        # fill in table query
     211        if ($line =~ m|// \*\* TABLE QUERY \*\*|) {
     212            &write_table_query;
     213        }
     214
     215        # fill in table restricts
     216        if ($line =~ m|// \*\* TABLE RESTRICTIONS \*\*|) {
     217            &write_table_restrict;
     218        }
     219
     220        # fill in table restricts
     221        if ($line =~ m|// \*\* BUTTON RESTRICTIONS \*\*|) {
     222            &write_button_restrict;
     223        }
     224
     225        # fill in head HTML or PHP code
     226        if ($line =~ m|// \*\* HEAD CODE \*\*|) {
     227            &write_inline_code (@headcode);
     228        }
     229
     230        # fill in tail HTML or PHP code
     231        if ($line =~ m|// \*\* TAIL CODE \*\*|) {
     232            &write_inline_code (@tailcode);
     233        }
    232234    }
    233235    close (FILE);
     
    237239    my (@code) = @_;
    238240    my ($i, $code, $type);
    239    
     241
    240242    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         }
     243        ($type, $line) = split (" ", $code[$i], 2);
     244        if ($type eq "PHP") {
     245            print FILE "$line\n";
     246        }
     247        if ($type eq "HTML") {
     248            print FILE "?> $line <?\n";
     249        }
    248250    }
    249251}
     
    253255
    254256    # 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";
     257    print FILE "echo \"<tr><td></td>\\n\";\n";
     258    for ($i = 0; $i < @field; $i++) {
     259        ($label, $value, $string) = &parse_label ($show[$i]);
     260        if ($show[$i] eq "none")  { next; }
     261        print FILE "write_header_cell (\"list\", \"$name[$i]\");\n";
    260262    }
    261263    print FILE "echo \"</tr>\\n\";\n";
    262264
    263265    # 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         }
     266    print FILE "echo \"<tr><td></td>\\n\";\n";
     267    for ($i = 0; $i < @field; $i++) {
     268        ($label, $value, $string) = &parse_label ($show[$i]);
     269        if ($show[$i] eq "none")  { next; }
     270        if ($field[$i] eq "*") { print FILE "echo \"<td></td>\\n\";\n"; next; } # empty cell (no sort for such fields)
     271        if ($label eq "op") {
     272            print FILE "write_sort_cell (\"list\", \"$opf{$value}\", \$buttonLink, \$ID, '$myFile');\n";
     273        } else {
     274            print FILE "write_sort_cell (\"list\", \"$fieldreal[$i]\", \$buttonLink, \$ID, '$myFile');\n";
     275        }
    274276    }
    275277    print FILE "echo \"</tr>\\n\";\n";
     
    282284    foreach $tdClass (@tdClasses) {
    283285
    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";
     286        # TD_CLASS class field expression
     287        ($class, $testline) = split (" ", $tdClass, 2);
     288
     289        $testlineFixed = "";
     290        @testlineBits = split (" ", $testline);
     291        foreach my $bit (@testlineBits) {
     292            $newbit = &parse_fieldname ($bit);
     293            $testlineFixed = "$testlineFixed $newbit";
     294        }
     295
     296        print FILE "  if ($testlineFixed) {\n";
     297        print FILE "    \$class = \"$class\";\n";
     298        print FILE "  }\n";
    297299    }
    298300}
     
    302304
    303305    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 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";
     306        print FILE "\$WHERE = \"WHERE $WHERE\";\n";
     307    }
     308    for ($i = 0; $i < @field; $i++) {
     309        $value = $fieldreal[$i];
     310        if ($value eq "*") { next; }
     311        if ($format[$i] eq "%s") {
     312            print FILE "\$WHERE = check_restrict ('$value', \$WHERE, 'string', 1.0);\n";
     313            next;
     314        }
     315        if ($format[$i] eq "%C") {
     316            # convert the RA & DEC limits to radians for comparison
     317            print FILE "\$WHERE = check_restrict ('$value', \$WHERE, 'min', 0.017453);\n";
     318            print FILE "\$WHERE = check_restrict ('$value', \$WHERE, 'max', 0.017453);\n";
     319            next;
     320        }
     321        print FILE "\$WHERE = check_restrict ('$value', \$WHERE, 'string', 1.0);\n";
     322        print FILE "\$WHERE = check_restrict ('$value', \$WHERE, 'min', 1.0);\n";
     323        print FILE "\$WHERE = check_restrict ('$value', \$WHERE, 'max', 1.0);\n";
    322324    }
    323325    print FILE "\$WHERE = check_ordering ('$GROUPS', \$WHERE);\n";
     
    328330
    329331    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         }
     332        $value = $fieldreal[$i];
     333        if ($value eq "*") { next; }
     334        if ($format[$i] eq "%s") {
     335            print FILE "\$buttonLink = button_restrict_string ('$value', \$buttonLink);\n";
     336        } else {
     337            print FILE "\$buttonLink = button_restrict_string ('$value', \$buttonLink);\n";
     338            print FILE "\$buttonLink = button_restrict_min ('$value', \$buttonLink);\n";
     339            print FILE "\$buttonLink = button_restrict_max ('$value', \$buttonLink);\n";
     340        }
    339341    }
    340342}
     
    347349    print FILE "echo \"<tr><td>&ge;</td>\\n\";\n";
    348350    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> &nbsp; </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         }
     351        if ($show[$i] eq "none")  { next; }
     352        if ($field[$i] eq "*")  {
     353            # * fields create an empty cell
     354            print FILE "echo \"<td> &nbsp; </td>\\n\";\n";
     355        } else {
     356            if ($format[$i] eq "%s") {
     357                print FILE "write_query_row ('$fieldreal[$i]', $width[$i], 'string');\n";
     358            } else {
     359                print FILE "write_query_row ('$fieldreal[$i]', $width[$i], 'min');\n";
     360            }
     361        }
    360362    }
    361363    print FILE "echo \"</tr><tr><td>&le;</td>\\n\";\n";
    362364    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> &nbsp; </td>\\n\";\n";
    367         } else {
    368             print FILE "write_query_row ('$fieldreal[$i]', $width[$i], 'max');\n";
    369         }
     365        if ($show[$i] eq "none")  { next; }
     366        if (($field[$i] eq "*") || ($format[$i] eq "%s")) {
     367            # * fields create an empty cell
     368            print FILE "echo \"<td> &nbsp; </td>\\n\";\n";
     369        } else {
     370            print FILE "write_query_row ('$fieldreal[$i]', $width[$i], 'max');\n";
     371        }
    370372    }
    371373    print FILE "echo \"</tr>\\n\";\n";
     
    377379
    378380    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         }
     381        ($label, $value, $string) = &parse_label ($show[$i]);
     382        $Nrow = $count[$i];
     383
     384        # create the link variable if this entry should be linked
     385        if ($label eq "none")  { next; }
     386
     387        if ($label eq "value") {
     388            # create the basic link variable
     389            # print STDERR "value: $link[$i]\n";
     390            if ($link[$i]) {
     391                print FILE "  \$link = \"$link[$i]\" . \"?menu=$MENU&\" . \$ID['link'];\n";
     392                # add extra GET data to target
     393                if ($extras[$i]) { &parse_extras ($linkarg{$extras[$i]}); }
     394                $myLink = "\$link";
     395            } else {
     396                $myLink = "\"\"";
     397            }
     398            # print the actual table cell line with the link...
     399            if (! $value && ($field[$i] ne "*")) { $value = "\$row[$Nrow]"; }
     400
     401            # add special format elements
     402            # $realFormat = $format[$i];
     403            # if ($format[$i] eq '%T') {
     404            #   $realFormat = '%s';
     405            # }
     406            print FILE "  write_table_cell (\$class, '$format[$i]', $myLink, $value);\n";
     407            next;
     408        }
     409
     410        if ($label eq "op") {
     411            # create the basic link variable
     412            if ($link[$i]) {
     413                print FILE "  \$link = \"$link[$i]\" . \"?menu=$MENU&\" . \$ID['link'];\n";
     414                # add extra GET data to target
     415                if ($extras[$i]) { &parse_extras ($linkarg{$extras[$i]}); }
     416                $myLink = "\$link";
     417            } else {
     418                $myLink = "\"\"";
     419            }
     420            print FILE "  write_table_cell (\$class, '$format[$i]', $myLink, $ops{$value});\n";
     421            next;
     422        }
     423
     424        if (($label eq "image") && !$link[$i]) {
     425            # print the actual table cell line with the image...
     426            print FILE "  echo \"<td class=\\\"\$class\\\">\n";
     427            print FILE "  echo \"              <img src=\\\"$image{$value}\\\"></td>\\n\";\n";
     428            next;
     429        }
     430
     431        if (($label eq "image") && $link[$i]) {
     432            # create the basic link
     433            print FILE "  \$link = \"$link[$i]\" . \"?menu=$MENU&\" . \$ID['link'];\n";
     434            # add extra php data to target
     435            if ($extras[$i]) { &parse_extras ($linkarg{$extras[$i]}); }
     436            # print the actual table cell line with the link...
     437            print FILE "  echo \"<td class=\\\"\$class\\\"><a href=\\\"\$link\\\"> <img src=\\\"$image{$value}\\\"> </a></td>\\n\";\n";
     438            next;
     439        }
    437440    }
    438441}
     
    444447    $FIELDS = "$array[0]";
    445448    for ($i = 1; $i < @array; $i++) {
    446         # skip * fields (not a valid query element
    447         if ($array[$i] eq "*") { next; }
    448         $FIELDS = "$FIELDS,$array[$i]";
     449        # skip * fields (not a valid query element
     450        if ($array[$i] eq "*") { next; }
     451        $FIELDS = "$FIELDS,$array[$i]";
    449452    }
    450453    set_keypair ("FIELDS", $FIELDS);
     
    457460    $GROUPS = "$array[0]";
    458461    for ($i = 1; $i < @array; $i++) {
    459         # skip * fields (not a valid query element
    460         if ($array[$i] eq "*") { next; }
    461         $GROUPS = "$GROUPS,$array[$i]";
     462        # skip * fields (not a valid query element
     463        if ($array[$i] eq "*") { next; }
     464        $GROUPS = "$GROUPS,$array[$i]";
    462465    }
    463466    set_keypair ("GROUPS", $GROUPS);
     
    471474    $Nrow = 0;
    472475    for ($i = 0; $i < @field; $i++) {
    473         # skip * fields (not a valid query element
    474         if ($field[$i] eq "*") {
    475             $count[$i] = -1;
    476         } else {
    477             $count[$i] = $Nrow;
    478             $Nrow ++;
    479         }
     476        # skip * fields (not a valid query element
     477        if ($field[$i] eq "*") {
     478            $count[$i] = -1;
     479        } else {
     480            $count[$i] = $Nrow;
     481            $Nrow ++;
     482        }
    480483    }
    481484}
     
    489492    $WHERE = "$array[0]";
    490493    for ($i = 1; $i < @array; $i++) {
    491         $WHERE = "$WHERE AND $array[$i]";
    492     }
    493    
     494        $WHERE = "$WHERE AND $array[$i]";
     495    }
     496
    494497    set_keypair ("WHERE", $WHERE);
    495498}
     
    502505
    503506    # examine the extras and parse the embedded fields (comma-separated)
     507
    504508    @extfields = split (/,/, $extras);
    505509    for ($i = 0; $i < @extfields; $i++) {
    506         ($label, $value, $outline) = &parse_label ($extfields[$i]);
    507         print FILE "  \$link = \$link . \"&$outline\";\n";
     510        ($label, $value, $outline) = &parse_label ($extfields[$i]);
     511        print FILE "  \$link = \$link . \"&$outline\";\n";
    508512    }
    509513}
     
    517521    ($word, $value) = split (" ", $_[0]);
    518522
     523    # print STDERR "0: $_[0], $word, $value\n";
     524
    519525    if ($linkarg{$word}) {
    520         $linkarg{$word} = "$linkarg{$word},$value";
     526        $linkarg{$word} = "$linkarg{$word},$value";
    521527    } else {
    522         $linkarg{$word} = $value;
    523     }   
     528        $linkarg{$word} = $value;
     529    }
     530    # print STDERR "linkarg($word) : $linkarg{$word}\n";
    524531}
    525532
    526533# parse strings of the form label=value
    527 # if 'value' is of the form $field, try to match with 
     534# if 'value' is of the form $field, try to match with
    528535# a supplied DB field, and replace with $row[$n] if found
    529536sub parse_label {
     
    540547    if ($VERBOSE) { print STDERR "string: $string\n"; }
    541548    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         }
     549        ($label, $value) = $string =~ m|(\S+)=(\S+)|;
     550        if ($value =~ m|^\$|) {
     551          MATCH_LABEL:
     552            for ($i = 0; $i < @field; $i++) {
     553                if ($field[$i] eq "*") { next; }
     554                while ($value =~ m|\$$fieldreal[$i]|) {
     555                    # print "field: $fieldreal[$i]\n";
     556                    # ($part1, $name, $part2) = $value =~ m|\$($fieldreal[$i])\@(\S+)|;
     557                    ($part1, $name, $part2) = $value =~ m|(\S*)\$($fieldreal[$i])(\S*)|;
     558                    # print "name: $name\n";
     559                    # print "part1: $part1\n";
     560                    # print "part2: $part2\n";
     561                    # print "value: $value\n";
     562
     563                    $Nrow = $count[$i];
     564                    $value = $part1 . "\$row[$Nrow]" . $part2;
     565
     566                    # if ($part1 || $part2) {
     567                    # } else {
     568                    #     $value = "\$row[$Nrow]";
     569                    # }
     570                    # print "outval: $value\n";
     571                    # last MATCH_LABEL;
     572                }
     573            }
     574            $outline = "$label=$value";
     575        }
    566576    }
    567577    return ($label, $value, $outline);
     
    574584    my ($variable) = $_[0];
    575585    my ($i);
    576    
     586
    577587    # print STDERR "variable: $variable\n";
    578588
    579589    unless ($variable =~ m|^\$|) {
    580         return $variable;
     590        return $variable;
    581591    }
    582592
     
    586596
    587597    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;
     598        # print STDERR "$i: $fieldreal[$i] : $fieldname\n";
     599
     600        if ($field[$i] eq "*") { next; }
     601        if ($fieldname ne $fieldreal[$i]) { next; }
     602
     603
     604        $Nrow = $count[$i];
     605
     606        $value = "\$row[$Nrow]";
     607
     608        # print STDERR "found : $i : $count[$i] : $Nrow : $value\n";
     609        return $value;
    600610    }
    601611    return $variable;
     
    623633    @outfields = ();
    624634    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;
     635        $fword = &parse_fieldname ($word);
     636        # print "field: $word -> $fword\n";
     637        push @outwords, $fword;
     638        if ($word =~ m|^\$|) {
     639            $word = substr ($word, 1);
     640        }
     641        push @outfields, $word;
    632642    }
    633643    $outline = join (" ", @outwords);
     
    655665
    656666    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         }
     667        if ($key eq $key[$i]) {
     668            if ($value[$i] ne "") { die "key is multiply defined\n"; }
     669            $value[$i] = $value;
     670            if ($VERBOSE) { print STDERR "setting $key = $value\n"; }
     671            return;
     672        }
    663673    }
    664674}
     
    670680
    671681    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         }
     682        if ($key eq $key[$i]) {
     683            if ($VERBOSE) { print "found $key: $key[$i]  -- $value[$i] (def: $default)\n"; }
     684            if (($default eq "") && ($value[$i] eq "")) { die "missing value for required key $key[$i]\n"; }
     685            if ($value[$i] eq "") { $value[$i] = $default; }
     686            return;
     687        }
    678688    }
    679689    die "unknown key $key\n";
     
    683693    my ($i);
    684694    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 
     695        if ($VERBOSE) { print "$key[$i]  -- $value[$i]\n"; }
     696        if ($line =~ m|\$$key[$i]|) {
     697            if ($value[$i] eq "") { die "missing value for required key $key[$i]\n"; }
     698            $line =~ s|\$$key[$i]|$value[$i]|g;
     699        }
     700    }
     701}
     702
     703# we need to find the structure size, including padding
     704# i'm not sure I know the answer to this: it is probably
     705# the total number of bytes rounded up to the largest
    696706# data item in the structure (ie, 8 for a double, etc)
    697707# if we have the size, then we can double check the structure
    698708# against the expectation at runtime.  for the moment,
    699 # calculate by hand and add to def.d file 
    700 
     709# calculate by hand and add to def.d file
     710
Note: See TracChangeset for help on using the changeset viewer.