IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

adding min/max restriction ranges

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.