IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 4, 2007, 3:07:41 PM (19 years ago)
Author:
eugene
Message:

updates to use new API for images

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippMonitor/generate

    r11490 r13264  
    1414# @headcode, @tailcode                 : additional HTML or PHP code before or after table
    1515# @field, @width, @name, @show, @link, @extras : properties of each table column
     16# @imagedefs, %image: array of image defines
    1617
    1718&parse_schema;
     
    6162        if ($key eq "HEAD") {
    6263            push @headcode, $value;
     64        }
     65
     66        # the IMAGE commands sets up a reference name
     67        if ($key eq "IMAGE") {
     68            push @imagedefs, $value;
     69        }
     70
     71        # the IMAGE commands sets up a reference name
     72        if ($key eq "ARGS") {
     73            push @linkargs, $value;
    6374        }
    6475
     
    94105    &define_where_string (@where);
    95106
     107    foreach $linkarg (@linkargs) {
     108        &parse_linkarg ($linkarg);
     109    }
     110
     111    foreach $imagedef (@imagedefs) {
     112        &parse_imagedef ($imagedef);
     113    }
     114
    96115    if (0) {
    97116        print STDERR "show: $show[0]\n";
     
    220239            printf FILE "  \$link = \"$link[$i]\" . \"?menu=$MENU&\" . \$ID['link'];\n";
    221240            # add extra GET data to target
    222             if ($extras[$i]) { &parse_extras ($extras[$i]); }
     241            if ($extras[$i]) { &parse_extras ($linkarg{$extras[$i]}); }
    223242            # print the actual table cell line with the link...
    224243            if (! $value && ($field[$i] ne "*")) { $value = "\$row[$Nrow]"; }
     
    229248        if (($label eq "image") && !$link[$i]) {
    230249            # print the actual table cell line with the image...
    231             printf FILE "  echo \"<td class=\\\"list\\\"><img src=\\\"getimage.php?name=$value\\\"></td>\\n\";\n";
     250            printf FILE "  echo \"<td class=\\\"list\\\"><img src=\\\"$image{$value}\\\"></td>\\n\";\n";
    232251            next;
    233252        }
     
    237256            printf FILE "  \$link = \"$link[$i]\" . \"?menu=$MENU&\" . \$ID['link'];\n";
    238257            # add extra php data to target
    239             if ($extras[$i]) { &parse_extras ($extras[$i]); }
     258            if ($extras[$i]) { &parse_extras ($linkarg{$extras[$i]}); }
    240259            # print the actual table cell line with the link...
    241             printf FILE "  echo \"<td class=\\\"list\\\"><a href=\\\"\$link\\\"> <img src=\\\"getimage.php?name=$value\\\"> </a></td>\\n\";\n";
     260            printf FILE "  echo \"<td class=\\\"list\\\"><a href=\\\"\$link\\\"> <img src=\\\"$image{$value}\\\"> </a></td>\\n\";\n";
    242261            next;
    243262        }
     
    314333        printf FILE "  \$link = \$link . \"&$outline\";\n";
    315334    }
     335}
     336
     337# each linkarg is an entry of the form "word name=value"
     338# the entries for matching words are concatenated together
     339# separated by commas to create the value $linkarg{word}
     340sub parse_linkarg {
     341    my ($word, $value);
     342
     343    ($word, $value) = split (" ", $_[0]);
     344
     345    if ($linkarg{$word}) {
     346        $linkarg{$word} = "$linkarg{$word},$value";
     347    } else {
     348        $linkarg{$word} = $value;
     349    }   
    316350}
    317351
     
    360394}
    361395
     396# given a variable of the form $fieldname, return the corresponding
     397# row entry in the form $row[N], otherwise return $fieldname
     398# globals: field (list of field names), count (list of sequence)
     399sub parse_fieldname {
     400    my ($variable) = $_[0];
     401    my ($i);
     402   
     403    unless ($variable =~ m|^\$|) {
     404        return $variable;
     405    }
     406
     407    $fieldname = substr ($variable, 1);
     408
     409    print STDERR "fieldname: $fieldname\n";
     410
     411    for ($i = 0; $i < @field; $i++) {
     412        print STDERR "$i: $field[$i] : $fieldname\n";
     413
     414        if ($field[$i] eq "*") { next; }
     415        if ($fieldname ne $field[$i]) { next; }
     416
     417
     418        $Nrow = $count[$i];
     419
     420        $value = "\$row[$Nrow]";
     421
     422        print STDERR "found : $i : $count[$i] : $Nrow : $value\n";
     423        return $value;
     424    }
     425    return $variable;
     426}
     427
     428sub parse_imagedef {
     429    my ($value) = $_[0];
     430
     431    ($var, $name, $rule, $camera, $class) = split (" ", $value);
     432    $name   = &parse_fieldname ($name);
     433    $camera = &parse_fieldname ($camera);
     434    $class  = &parse_fieldname ($class);
     435    $image{$var} = "getimage.php?name=$name&rule=$rule&camera=$camera&class_id=$class";
     436    return 1;
     437}
     438
    362439sub init_key {
    363440    my ($key)   = $_[0];
Note: See TracChangeset for help on using the changeset viewer.