IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 9008


Ignore:
Timestamp:
Sep 27, 2006, 12:30:54 PM (20 years ago)
Author:
eugene
Message:

adding inline images, php, html, more restricts, * fields

Location:
trunk/ippMonitor
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippMonitor/Makefile

    r9003 r9008  
    2222$(DESTBIN)/DetrendSteps.php \
    2323$(DESTBIN)/ImfileTables.php \
    24 $(DESTBIN)/phptest.php \
    25 $(DESTBIN)/flat_1_0.b1.jpeg \
    26 $(DESTBIN)/flat_1_0.b2.jpeg \
    27 $(DESTBIN)/pic.png
    28 
     24$(DESTBIN)/phptest.php
    2925
    3026DEFSRC = \
     27$(DESTBIN)/masterDetrendImages.php \
    3128$(DESTBIN)/detInputExp.php \
    3229$(DESTBIN)/detMasterFrame.php \
     
    5653
    5754PICTURES = \
    58 $(DESTBIN)/PScolorlogo2.jpg
     55$(DESTBIN)/PScolorlogo2.jpg \
     56$(DESTBIN)/flat_1_0.b1.jpeg \
     57$(DESTBIN)/flat_1_0.b2.jpeg \
     58$(DESTBIN)/pic.png
    5959
    60 php: $(RAWSRC) $(DEFSRC) $(PICTURES)
     60DEMOPICS = \
     61$(DESTBIN)/806237f.detresid.3.0.b1.jpg \
     62$(DESTBIN)/806237f.detresid.3.0.b2.jpg \
     63$(DESTBIN)/806238f.detresid.3.0.b1.jpg \
     64$(DESTBIN)/806238f.detresid.3.0.b2.jpg \
     65$(DESTBIN)/806239f.detresid.3.0.b1.jpg \
     66$(DESTBIN)/806239f.detresid.3.0.b2.jpg \
     67$(DESTBIN)/838749d.detresid.2.0.b1.jpg \
     68$(DESTBIN)/838749d.detresid.2.0.b2.jpg \
     69$(DESTBIN)/838790d.detresid.2.0.b1.jpg \
     70$(DESTBIN)/838790d.detresid.2.0.b2.jpg \
     71$(DESTBIN)/838791d.detresid.2.0.b1.jpg \
     72$(DESTBIN)/838791d.detresid.2.0.b2.jpg \
     73$(DESTBIN)/850131b.detresid.1.0.b1.jpg \
     74$(DESTBIN)/850131b.detresid.1.0.b2.jpg \
     75$(DESTBIN)/850132b.detresid.1.0.b1.jpg \
     76$(DESTBIN)/850132b.detresid.1.0.b2.jpg \
     77$(DESTBIN)/850133b.detresid.1.0.b1.jpg \
     78$(DESTBIN)/850133b.detresid.1.0.b2.jpg
     79
     80php: $(RAWSRC) $(DEFSRC) $(PICTURES) $(DEMOPICS)
    6181
    6282# dependancy rules for binary code #########################
     
    6484# .PRECIOUS: $(BIN)/%.$(ARCH)
    6585
    66 $(SRC)/%.php: $(DEF)/%.d $(DEF)/autocode.php
     86$(SRC)/%.php: $(DEF)/%.d $(DEF)/autocode.php ./generate
    6787        @if [ ! -d $(SRC) ]; then mkdir -p $(SRC); fi
    6888        ./generate $< $(DEF)/autocode.php $@
    6989
    70 $(SRC)/%.php: $(RAW)/%.php
    71         @if [ ! -d $(SRC) ]; then mkdir -p $(SRC); fi
    72         cp $< $@
     90# $(SRC)/%.php: $(RAW)/%.php
     91#       @if [ ! -d $(SRC) ]; then mkdir -p $(SRC); fi
     92#       cp $< $@
     93#
     94# $(SRC)/%.css: $(RAW)/%.css
     95#       @if [ ! -d $(SRC) ]; then mkdir -p $(SRC); fi
     96#       cp $< $@
     97#
     98# $(SRC)/%.dat: $(RAW)/%.dat
     99#       @if [ ! -d $(SRC) ]; then mkdir -p $(SRC); fi
     100#       cp $< $@
     101#
     102# $(SRC)/%.jpg: $(RAW)/%.jpg
     103#       @if [ ! -d $(SRC) ]; then mkdir -p $(SRC); fi
     104#       cp $< $@
     105#
     106# $(SRC)/%.png: $(RAW)/%.png
     107#       @if [ ! -d $(SRC) ]; then mkdir -p $(SRC); fi
     108#       cp $< $@
     109#
     110# $(SRC)/%.jpeg: $(RAW)/%.jpeg
     111#       @if [ ! -d $(SRC) ]; then mkdir -p $(SRC); fi
     112#       cp $< $@
    73113
    74 $(SRC)/%.css: $(RAW)/%.css
    75         @if [ ! -d $(SRC) ]; then mkdir -p $(SRC); fi
    76         cp $< $@
    77 
    78 $(SRC)/%.dat: $(RAW)/%.dat
    79         @if [ ! -d $(SRC) ]; then mkdir -p $(SRC); fi
    80         cp $< $@
    81 
    82 $(SRC)/%.jpg: $(RAW)/%.jpg
    83         @if [ ! -d $(SRC) ]; then mkdir -p $(SRC); fi
    84         cp $< $@
    85 
    86 $(SRC)/%.png: $(RAW)/%.png
    87         @if [ ! -d $(SRC) ]; then mkdir -p $(SRC); fi
    88         cp $< $@
    89 
    90 $(SRC)/%.jpeg: $(RAW)/%.jpeg
    91         @if [ ! -d $(SRC) ]; then mkdir -p $(SRC); fi
    92         cp $< $@
    93 
     114# generated php code is built into SRC first
    94115$(DESTBIN)/%.php: $(SRC)/%.php
    95116        @if [ ! -d $(DESTBIN) ]; then mkdir -p $(DESTBIN) || exit; fi
     
    97118        cp $(SRC)/$*.php $(DESTBIN)/$*.php || exit
    98119
    99 $(DESTBIN)/%.css: $(SRC)/%.css
     120# non-generated php code is copied directly
     121$(DESTBIN)/%.php: $(RAW)/%.php
     122        @if [ ! -d $(DESTBIN) ]; then mkdir -p $(DESTBIN) || exit; fi
     123        rm -f $(DESTBIN)/$*.php || exit
     124        cp $(RAW)/$*.php $(DESTBIN)/$*.php || exit
     125
     126# all other files are copied directly
     127$(DESTBIN)/%.css: $(RAW)/%.css
    100128        @if [ ! -d $(DESTBIN) ]; then mkdir -p $(DESTBIN) || exit; fi
    101129        rm -f $(DESTBIN)/$*.css || exit
    102         cp $(SRC)/$*.css $(DESTBIN)/$*.css || exit
     130        cp $(RAW)/$*.css $(DESTBIN)/$*.css || exit
    103131
    104 $(DESTBIN)/%.dat: $(SRC)/%.dat
     132$(DESTBIN)/%.dat: $(RAW)/%.dat
    105133        @if [ ! -d $(DESTBIN) ]; then mkdir -p $(DESTBIN) || exit; fi
    106134        rm -f $(DESTBIN)/$*.dat || exit
    107         cp $(SRC)/$*.dat $(DESTBIN)/$*.dat || exit
     135        cp $(RAW)/$*.dat $(DESTBIN)/$*.dat || exit
    108136
    109 $(DESTBIN)/%.jpg: $(SRC)/%.jpg
     137$(DESTBIN)/%.jpg: $(RAW)/%.jpg
    110138        @if [ ! -d $(DESTBIN) ]; then mkdir -p $(DESTBIN) || exit; fi
    111139        rm -f $(DESTBIN)/$*.jpg || exit
    112         cp $(SRC)/$*.jpg $(DESTBIN)/$*.jpg || exit
     140        cp $(RAW)/$*.jpg $(DESTBIN)/$*.jpg || exit
    113141
    114 $(DESTBIN)/%.jpeg: $(SRC)/%.jpeg
     142$(DESTBIN)/%.jpeg: $(RAW)/%.jpeg
    115143        @if [ ! -d $(DESTBIN) ]; then mkdir -p $(DESTBIN) || exit; fi
    116144        rm -f $(DESTBIN)/$*.jpeg || exit
    117         cp $(SRC)/$*.jpeg $(DESTBIN)/$*.jpeg || exit
     145        cp $(RAW)/$*.jpeg $(DESTBIN)/$*.jpeg || exit
    118146
    119 $(DESTBIN)/%.png: $(SRC)/%.png
     147$(DESTBIN)/%.png: $(RAW)/%.png
    120148        @if [ ! -d $(DESTBIN) ]; then mkdir -p $(DESTBIN) || exit; fi
    121149        rm -f $(DESTBIN)/$*.png || exit
    122         cp $(SRC)/$*.png $(DESTBIN)/$*.png || exit
     150        cp $(RAW)/$*.png $(DESTBIN)/$*.png || exit
    123151
    124152# utilities #################################################
     
    132160.PRECIOUS: $(SRC)/%.css
    133161.PRECIOUS: $(SRC)/%.dat
     162.PRECIOUS: $(SRC)/%.png
    134163.PRECIOUS: $(SRC)/%.jpg
     164.PRECIOUS: $(SRC)/%.jpeg
  • trunk/ippMonitor/def/autocode.php

    r9003 r9008  
    2020// ** TABLE RESTRICTIONS **
    2121
     22echo "WHERE: $WHERE<br><br>\n";
     23
    2224// query the database
    2325if ($WHERE) {
     
    2729}
    2830
     31echo "SQL: $sql<br><br>\n";
     32
    2933$qry = $db->query($sql);
    3034if (DB::iserror($db)) {
     
    3337}
    3438
    35 // ** BODY HTML **
     39// ** HEAD CODE **
    3640
    3741// set up the table and form
     
    7276echo "</form>\n";
    7377
    74 // ** TAIL HTML **
     78// ** TAIL CODE **
    7579
    7680menu_end();
  • trunk/ippMonitor/def/detInputExp.d

    r9003 r9008  
    44MENU  ipp.detrend.dat
    55
    6 BODY.HTML  test 1 <br>
    7 BODY.HTML  test 2 <br>
    8 BODY.HTML  test 3 <br>
     6HEAD HTML  test head 1 <br>
     7HEAD HTML  test head 2 <br>
     8HEAD HTML  test head 3 <br>
    99
    1010#     field      name       show        link to                 extras
     
    1515FIELD include,   include
    1616
    17 TAIL.HTML test tail 1 <br>
    18 TAIL.HTML test tail 2 <br>
    19 TAIL.HTML test tail 3 <br>
     17TAIL HTML test tail 1 <br>
     18TAIL HTML test tail 2 <br>
     19TAIL HTML test tail 3 <br>
  • trunk/ippMonitor/def/detResidExp.d

    r9003 r9008  
    44MENU  ipp.detrend.dat
    55
    6 #     field      name       show            link to         extras
     6#     field      name       show            link to             extras
    77FIELD det_id,    det_id,    value
    88FIELD iteration, iteration, value
    99FIELD accept,    accept,    value
    10 FIELD exp_id,    exp_id,    value,          rawImfile.php,  exp_id=$exp_id
    11 FIELD b1_uri,    b1_uri,    image=$b1_uri,  display.php,    image=$b2_uri
    12 FIELD recipe,    recipe,    image=pic.png
     10FIELD exp_id,    exp_id,    value,          rawImfile.php,      exp_id=$exp_id
     11FIELD b2_uri,    b2_uri,    image=$b2_uri,  detResidImfile.php, det_id=$det_id,iteration=$iteration,exp_id=$exp_id,image=$b1_uri
     12FIELD recipe,    recipe,    value
    1313FIELD bg,        backgnd,   value
    1414FIELD bg_stdev,  bg_stdev,  value
    15 FIELD b2_uri,    b2_uri,    none
     15FIELD b1_uri,    b1_uri,    none
    1616# FIELD bg_mean_stdev, bg_mean_stdev
  • trunk/ippMonitor/def/detResidImfile.d

    r9003 r9008  
    1616FIELD b1_uri, b1_uri
    1717FIELD b2_uri, b2_uri
     18
     19TAIL PHP insert_image ('image');
  • trunk/ippMonitor/generate

    r9003 r9008  
    99$template = $ARGV[1];
    1010$output   = $ARGV[2];
     11
     12# global variables:
     13# @key, @value                         : paired list of keys and values
     14# @field, @name, @show, @link, @extras : properties of each table column
     15# @headcode, @tailcode                 : additional HTML or PHP code before or after table
    1116
    1217&parse_schema;
     
    3136        ($key, $value) = split (" ", $line, 2);
    3237       
    33         # strip white space from the following
    34         if ($key eq "TABLE") { ($value) = $value =~ m|\s*(\S+)\s*|; }
    35         if ($key eq "TYPE")  { ($value) = $value =~ m|\s*(\S+)\s*|; }
     38        # strip leading and trailing white space from the following
     39        if ($key eq "TABLE") { ($value) = $value =~ m|^\s*(.+)\s*$|; }
     40        if ($key eq "TYPE")  { ($value) = $value =~ m|^\s*(.+)\s*$|; }
    3641
    3742        &set_keypair ($key, $value);
     
    5257
    5358        # list of the table fields
    54         if ($key eq "BODY.HTML") {
    55             push @bodyhtml, $value;
     59        if ($key eq "HEAD") {
     60            push @headcode, $value;
    5661        }
    5762
    5863        # list of the table fields
    59         if ($key eq "TAIL.HTML") {
    60             push @tailhtml, $value;
     64        if ($key eq "TAIL") {
     65            push @tailcode, $value;
    6166        }
    6267
    6368        # list of the table restrictions
    64         if ($key eq "RESTRICT") {
     69        # replace this with a flexible where statement?
     70        if ($key eq "WHERE") {
    6571            ($field) = split (/,\s+/, $value, 1);
    66             # ($field) = $field =~ m|\s*(\S+)\s*|;
    67 
    6872            if ($VERBOSE) { printf "%-20s\n", $field; }
    69             push @restrict,   $field;
     73            push @where,   $field;
    7074        }
    7175    }
     
    8387    }
    8488
    85     # define query string, add to keypairs
    86     &define_query_fields;
     89    # define FIELDS and WHERE strings, add to keypairs
     90    &define_fields_count;
     91    &define_fields_string (@field);
     92    &define_where_string (@where);
    8793
    8894    if (0) {
     
    139145        }
    140146
    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;
     147        # fill in head HTML or PHP code
     148        if ($line =~ m|// \*\* HEAD CODE \*\*|) {
     149            &write_inline_code (@headcode);
     150        }
     151
     152        # fill in tail HTML or PHP code
     153        if ($line =~ m|// \*\* TAIL CODE \*\*|) {
     154            &write_inline_code (@tailcode);
    149155        }
    150156    }
     
    152158}
    153159
    154 sub write_body_html {
    155     my ($i);
    156 
    157     if (@bodyhtml == 0) { return; }
    158     printf FILE "?>\n";
     160sub write_inline_code {
     161    my (@code) = @_;
     162    my ($i, $code, $type);
    159163   
    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 
     164    for ($i = 0; $i < @code; $i++) {
     165        ($type, $line) = split (" ", $code[$i], 2);
     166        if ($type eq "PHP") {
     167            printf FILE "$line\n";
     168        }
     169        if ($type eq "HTML") {
     170            printf FILE "?> $line <?\n";
     171        }
     172    }
     173}
     174
     175# generate a table header cell (<th> </th>) for each field (show != none)
    178176sub write_table_header {
    179177
     
    184182}
    185183
     184# generate a WHERE test for each field (field != *)
    186185sub write_table_restrict {
    187186
    188     for ($i = 0; $i < @restrict; $i++) {
    189         $value = $restrict[$i];
    190         printf FILE "\$value = \$_GET['$value'];\n";
    191         printf FILE "if (\$value) {\n";
    192         printf FILE "  if (\$WHERE) {\n";
    193         printf FILE "    \$WHERE = \$WHERE . \" AND $value = '\$value'\";\n";
    194         printf FILE "  } else {\n";
    195         printf FILE "    \$WHERE = \"$value = '\$value'\";\n";
    196         printf FILE "  }\n";
    197         printf FILE "}\n";
     187    if ($WHERE) {
     188        printf FILE "\$WHERE = \"$WHERE\";\n";
     189    }   
     190    for ($i = 0; $i < @field; $i++) {
     191        $value = $field[$i];
     192        if ($value eq "*") { next; }
     193        printf FILE "\$WHERE = check_restrict ('$value', \$WHERE);\n";
    198194    }
    199195}
    200196
    201197sub write_table_data {
    202     my ($i);
     198    my ($i, $Nrow);
    203199    my ($label, $value, $string);
    204200
    205201    for ($i = 0; $i < @field; $i++) {
    206202        ($label, $value, $string) = &parse_label ($show[$i]);
     203        $Nrow = $count[$i];
    207204
    208205        # create the link variable if this entry should be linked
     
    211208        if (($label eq "value") && !$link[$i]) {
    212209            # print value without link or image
    213             if (! $value) { $value = "\$row[$i]"; }
     210            if (! $value && ($field[$i] ne "*")) { $value = "\$row[$Nrow]"; }
    214211            print FILE "  echo \"<td class=\\\"list\\\"> $value </td>\\n\";\n";
    215212            next;
     
    222219            if ($extras[$i]) { &parse_extras ($extras[$i]); }
    223220            # print the actual table cell line with the link...
    224             if (! $value) { $value = "\$row[$i]"; }
     221            if (! $value && ($field[$i] ne "*")) { $value = "\$row[$Nrow]"; }
    225222            printf FILE "  echo \"<td class=\\\"list\\\"><a href=\\\"\$link\\\"> $value </a></td>\\n\";\n";
    226223            next;
     
    246243
    247244sub write_table_query {
    248 
     245    my ($i);
    249246    for ($i = 0; $i < @field; $i++) {
    250247        if ($show[$i] eq "none")  { next; }
    251         printf FILE "echo \"<td class=\\\"list\\\"> <input type=\\\"text\\\" name=\\\"$field[$i]\\\"> </td>\\n\";\n";
    252     }
    253 }
    254 
    255 sub define_query_fields {
    256 
    257     $FIELDS = "$field[0]";
    258     for ($i = 1; $i < @field; $i++) {
    259         $FIELDS = "$FIELDS,$field[$i]";
    260     }
    261  
     248        if ($field[$i] eq "*")  {
     249            # * fields create an empty cell
     250            printf FILE "echo \"<td> &nbsp; </td>\\n\";\n";
     251        } else {
     252            printf FILE "write_query_row ('$field[$i]');\n";
     253        }
     254    }
     255}
     256
     257sub define_fields_string {
     258    my (@array) = @_;
     259    my ($i, $FIELDS);
     260
     261    $FIELDS = "$array[0]";
     262    for ($i = 1; $i < @array; $i++) {
     263        # skip * fields (not a valid query element
     264        if ($array[$i] eq "*") { next; }
     265        $FIELDS = "$FIELDS,$array[$i]";
     266    }
    262267    set_keypair ("FIELDS", $FIELDS);
     268}
     269
     270sub define_fields_count {
     271    my ($i, $Nrow);
     272
     273    @count = ();
     274
     275    $Nrow = 0;
     276    for ($i = 0; $i < @field; $i++) {
     277        # skip * fields (not a valid query element
     278        if ($field[$i] eq "*") {
     279            $count[$i] = -1;
     280        } else {
     281            $count[$i] = $Nrow;
     282            $Nrow ++;
     283        }
     284    }
     285}
     286
     287sub define_where_string {
     288    my (@array) = @_;
     289    my ($i, $FIELDS);
     290
     291    if (@array == 0) { return; }
     292
     293    $WHERE = "$array[0]";
     294    for ($i = 1; $i < @array; $i++) {
     295        $WHERE = "$WHERE AND $array[$i]";
     296    }
     297   
     298    set_keypair ("WHERE", $WHERE);
    263299}
    264300
     
    283319    my ($string) = $_[0];
    284320    my ($label, $value, $outline);
    285     my ($N, $i);
     321    my ($Nrow, $i);
    286322
    287323    # unless we replace the value with the db row element, return the original string
     
    297333          MATCH_LABEL:
    298334            for ($i = 0; $i < @field; $i++) {
     335                if ($field[$i] eq "*") { next; }
    299336                if ($value =~ m|^\$$field[$i]|) {
    300                     $value = "\$row[$i]";
     337                    $Nrow = $count[$i];
     338                    $value = "\$row[$Nrow]";
    301339                    last MATCH_LABEL;
    302340                }
  • trunk/ippMonitor/raw/DetrendSteps.php

    r8984 r9008  
    88
    99// document body
    10 echo "Detrend Image Creation Steps<br>\n";
     10echo "Detrend Image Creation<br>\n
     11
     12The pages in this section allow you to examine the master detrend
     13images and the processing steps involved in their creation.  You may
     14search through the detrend images which have been accepted by
     15the detrend analysis system by selecting the Master Detrend Images tab.
     16
     17";
    1118
    1219menu_end();
  • trunk/ippMonitor/raw/ipp.detrend.dat

    r9003 r9008  
    2323
    2424menutop   | menutop      | plain   | &nbsp;                       |
     25menulink  | menuselect   | link    | Master Detrend Images        | masterDetrendImages.php
    2526menulink  | menuselect   | link    | Det Run                      | detRun.php                   
    2627menulink  | menuselect   | link    | Det Run Summary              | detRunSummary.php             
  • trunk/ippMonitor/raw/ipp.php

    r9003 r9008  
    1919  // connect to the database
    2020  require_once('DB.php');
    21   $db = DB::connect("mysql://ipp:ipp@localhost/ipp");
     21#  $db = DB::connect("mysql://ipp:ipp@localhost/ipp");
     22  $db = DB::connect("mysql://ipp:ipp@localhost/detrend");
    2223  if (DB::iserror($db)) {
    2324    echo "<b>error accessing database</b><br>\n";
     
    176177}
    177178
     179function check_restrict ($key, $where) {
     180  // echo "key: $key<br>\n";
     181  if ($_SERVER[REQUEST_METHOD] == 'GET') {
     182    $value = $_GET[$key];
     183    // echo "using GET<br>\n";
     184  } else {
     185    $value = $_POST[$key];
     186    // echo "using POST<br>\n";
     187  }
     188  // echo "value: $value<br>\n";
     189  if ($value) {
     190    if ($where) {
     191      $where = $where . " AND $key = '$value'";
     192      // echo "where 1: $where<br>\n";
     193    } else {
     194      $where = "$key = '$value'";
     195      // echo "where 2: $where<br>\n";
     196    }
     197  }
     198  return $where;
     199}
     200
     201function write_query_row ($key) {
     202  $value = $_POST[$key];
     203  if (($_SERVER[REQUEST_METHOD] == 'POST') && $value) {
     204    echo "<td class=\"list\"> <input type=\"text\" name=\"$key\" value=\"$value\"> </td>\n";
     205  } else {
     206    echo "<td class=\"list\"> <input type=\"text\" name=\"$key\"> </td>\n";
     207  }
     208}
     209
     210// expect image supplied with key=name
     211function insert_image ($key) {
     212
     213  if ($_SERVER[REQUEST_METHOD] == 'GET') {
     214    $name = $_GET[$key];
     215  } else {
     216    $name = $_POST[$key];
     217  }
     218
     219  if ($name) {
     220    echo "<img src=\"$name\">\n";
     221  }
     222}
     223
    178224// $myPage = $_SERVER[SCRIPT_NAME] . "?pass=$pass";
    179225
Note: See TracChangeset for help on using the changeset viewer.