IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 18143


Ignore:
Timestamp:
Jun 15, 2008, 1:56:02 PM (18 years ago)
Author:
eugene
Message:

adding min/max restriction ranges

Location:
trunk/ippMonitor
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippMonitor/def/autocode.php

    r14113 r18143  
    7474
    7575// query restriction form
    76 echo "<tr>\n";
     76// echo "<tr>\n";
    7777// echo "<td class=list> <input type=\"text\" name=\"expID\"></td>\n";
    7878// ** TABLE QUERY **
    79 echo "</tr>\n";
     79// echo "</tr>\n";
    8080
    8181// list the results
  • trunk/ippMonitor/def/detProcessedImfile.d

    r15954 r18143  
    1212FIELD rawExp.exp_name,                  5, %s,     Exp Name
    1313FIELD detProcessedImfile.class_id,      8, %s,     Chip ID
    14 FIELD detProcessedImfile.bg,            8, %s,     backgnd
     14FIELD detProcessedImfile.bg,            8, %f,     backgnd
    1515FIELD detProcessedImfile.bg_stdev,      8, %s,     stdev
    1616FIELD detProcessedImfile.bg_mean_stdev, 8, %s,     [stdev]
    17 FIELD detProcessedImfile.path_base,     5, %s,     path_base
     17FIELD detProcessedImfile.path_base,     10, %s,     path_base
    1818
    1919TAIL PHP insert_image ('PPIMAGE.JPEG1');
  • trunk/ippMonitor/raw/ipp.php

    r15954 r18143  
    364364}
    365365
    366 function check_restrict ($key, $where) {
     366function check_restrict ($key, $where, $mode) {
    367367  $htmlkey = preg_replace ('|\.|', '_', $key);
     368  if ($mode == 'min') {
     369    $htmlkey = $htmlkey . "_min";
     370  }
     371  if ($mode == 'max') {
     372    $htmlkey = $htmlkey . "_max";
     373  }
     374
    368375  if ($_SERVER[REQUEST_METHOD] == 'GET') {
    369376    $value = $_GET[$htmlkey];
     
    371378    $value = $_POST[$htmlkey];
    372379  }
    373   if ($value != "") {
    374     if ($where) {
    375       $where = $where . " AND $key = '$value'";
    376     } else {
    377       $where = "WHERE $key = '$value'";
    378     }
    379   }
     380  if ($value == "") { return $where; }
     381  if ($where) {
     382    $where = $where . " AND";
     383  } else {
     384    $where = "WHERE";
     385  }
     386
     387  if ($mode == 'string') {
     388    // can we pass the '%' through the html?
     389    $where = $where . " $key like '$value'";
     390  }
     391  if ($mode == 'min') {
     392    // can we pass the '%' through the html?
     393    $where = $where . " $key >= '$value'";
     394  }
     395  if ($mode == 'max') {
     396    // can we pass the '%' through the html?
     397    $where = $where . " $key <= '$value'";
     398  }
     399
    380400  return $where;
    381401}
     
    394414}
    395415
    396 function button_restrict ($key, $line) {
     416// if we have a restriction for a string-valued field, supply it to outgoing links
     417function button_restrict_string ($key, $line) {
    397418  $htmlkey = preg_replace ('|\.|', '_', $key);
    398419  if ($_SERVER[REQUEST_METHOD] == 'GET') {
     
    411432}
    412433
     434// for numerical fields, test for both 'min' and 'max' values
     435function button_restrict_min ($key, $line) {
     436  $htmlkey = preg_replace ('|\.|', '_', $key);
     437  $htmlkey = $htmlkey . '_min';
     438  if ($_SERVER[REQUEST_METHOD] == 'GET') {
     439    $value = $_GET[$htmlkey];
     440  } else {
     441    $value = $_POST[$htmlkey];
     442  }
     443  if ($value != "") {
     444    if ($line) {
     445      $line = $line . "&$htmlkey=$value";
     446    } else {
     447      $line = "$htmlkey=$value";
     448    }
     449  }
     450  return $line;
     451}
     452
     453// for numerical fields, test for both 'min' and 'max' values
     454function button_restrict_max ($key, $line) {
     455  $htmlkey = preg_replace ('|\.|', '_', $key);
     456  $htmlkey = $htmlkey . '_max';
     457  if ($_SERVER[REQUEST_METHOD] == 'GET') {
     458    $value = $_GET[$htmlkey];
     459  } else {
     460    $value = $_POST[$htmlkey];
     461  }
     462  if ($value != "") {
     463    if ($line) {
     464      $line = $line . "&$htmlkey=$value";
     465    } else {
     466      $line = "$htmlkey=$value";
     467    }
     468  }
     469  return $line;
     470}
     471
    413472function write_table_header ($class, $name, $value, $buttonLink, $ID, $file) {
    414473
     
    420479}
    421480
    422 function write_query_row ($key, $width) {
     481// there are two query rows: for strings, only the first is set; for numbers, the first = min, the second = max
     482// mode == string, min, max
     483function write_query_row ($key, $width, $mode) {
    423484  $htmlkey = preg_replace ('|\.|', '_', $key);
     485  if ($mode == 'min') {
     486    $htmlkey = $htmlkey . "_min";
     487  }
     488  if ($mode == 'max') {
     489    $htmlkey = $htmlkey . "_max";
     490  }
    424491  if ($_SERVER[REQUEST_METHOD] == 'GET') {
    425492    $value = $_GET[$htmlkey];
     
    427494    $value = $_POST[$htmlkey];
    428495  }
     496  // XXX need to modify $key (should it be htmlkey here?)
    429497  if ($value != "") {
    430     echo "<td class=\"list\"> <input type=\"text\" name=\"$key\" size=\"$width\" value=\"$value\"> </td>\n";
    431   } else {
    432     echo "<td class=\"list\"> <input type=\"text\" name=\"$key\" size=\"$width\"> </td>\n";
     498    echo "<td class=\"list\"> <input type=\"text\" name=\"$htmlkey\" size=\"$width\" value=\"$value\"> </td>\n";
     499  } else {
     500    echo "<td class=\"list\"> <input type=\"text\" name=\"$htmlkey\" size=\"$width\"> </td>\n";
    433501  }
    434502}
  • trunk/ippMonitor/scripts/generate

    r15969 r18143  
    267267        $value = $field[$i];
    268268        if ($value eq "*") { next; }
    269         print FILE "\$WHERE = check_restrict ('$value', \$WHERE);\n";
     269        if ($format[$i] eq "%s") {
     270            print FILE "\$WHERE = check_restrict ('$value', \$WHERE, 'string');\n";
     271        } else {
     272            print FILE "\$WHERE = check_restrict ('$value', \$WHERE, 'min');\n";
     273            print FILE "\$WHERE = check_restrict ('$value', \$WHERE, 'max');\n";
     274        }
    270275    }
    271276    print FILE "\$WHERE = check_ordering (\$WHERE);\n";
     
    278283        $value = $field[$i];
    279284        if ($value eq "*") { next; }
    280         print FILE "\$buttonLink = button_restrict ('$value', \$buttonLink);\n";
    281     }
     285        if ($format[$i] eq "%s") {
     286            print FILE "\$buttonLink = button_restrict_string ('$value', \$buttonLink);\n";
     287        } else {
     288            print FILE "\$buttonLink = button_restrict_min ('$value', \$buttonLink);\n";
     289            print FILE "\$buttonLink = button_restrict_max ('$value', \$buttonLink);\n";
     290        }
     291    }
     292}
     293
     294# there are two query rows: the first is populated for both strings
     295# and numbers, the second only for numbers
     296sub write_table_query {
     297    my ($i);
     298
     299    print FILE "echo \"<tr>\\n\";\n";
     300    for ($i = 0; $i < @field; $i++) {
     301        if ($show[$i] eq "none")  { next; }
     302        if ($field[$i] eq "*")  {
     303            # * fields create an empty cell
     304            print FILE "echo \"<td> &nbsp; </td>\\n\";\n";
     305        } else {
     306            if ($format[$i] eq "%s") {
     307                print FILE "write_query_row ('$field[$i]', $width[$i], 'string');\n";
     308            } else {
     309                print FILE "write_query_row ('$field[$i]', $width[$i], 'min');\n";
     310            }
     311        }
     312    }
     313    print FILE "echo \"</tr> <tr>\\n\";\n";
     314    for ($i = 0; $i < @field; $i++) {
     315        if ($show[$i] eq "none")  { next; }
     316        if (($field[$i] eq "*") || ($format[$i] eq "%s")) {
     317            # * fields create an empty cell
     318            print FILE "echo \"<td class=\\\"list\\\"> &nbsp; </td>\\n\";\n";
     319        } else {
     320            print FILE "write_query_row ('$field[$i]', $width[$i], 'max');\n";
     321        }
     322    }
     323    print FILE "echo \"</tr>\\n\";\n";
    282324}
    283325
     
    342384}
    343385
    344 sub write_table_query {
    345     my ($i);
    346     for ($i = 0; $i < @field; $i++) {
    347         if ($show[$i] eq "none")  { next; }
    348         if ($field[$i] eq "*")  {
    349             # * fields create an empty cell
    350             print FILE "echo \"<td> &nbsp; </td>\\n\";\n";
    351         } else {
    352             print FILE "write_query_row ('$field[$i]', $width[$i]);\n";
    353         }
    354     }
    355 }
    356 
    357386sub define_fields_string {
    358387    my (@array) = @_;
Note: See TracChangeset for help on using the changeset viewer.