Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Friday, March 29, 2024

Diff for phpMyEdit/phpMyEdit.class.php between version 1.14 and 1.15

version 1.14, 2002/10/17 21:06:46 version 1.15, 2002/10/18 20:58:11
Line 19 
Line 19 
  * http://www.platon.sk/projects/phpMyEdit/   * http://www.platon.sk/projects/phpMyEdit/
  */   */
   
 /* $Platon: phpWebFileManager/index.php,v 1.32 2002/10/16 21:19:20 nepto Exp $ */  /* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.14 2002/10/17 21:06:46 nepto Exp $ */
   
 /*      phpMyEdit intro {{{ */  /*      phpMyEdit intro {{{ */
 /*  /*
Line 101  if (@require_once dirname(__FILE__).'/ti
Line 101  if (@require_once dirname(__FILE__).'/ti
         $phpMyEdit_timer = new timerClass();          $phpMyEdit_timer = new timerClass();
 }  }
   
 #function debug_var($name,$val) /* {{{ */  
 #{  
 #       if (is_array($val)) {  
 #               echo "<pre>$name\n";  
 #               print_r($val);  
 #               echo "</pre>\n";  
 #       } else {  
 #               echo "$name::$val::<br>\n";  
 #       }  
 #} /* }}} */  
   
 if (! function_exists('array_search')) { /* {{{ */  if (! function_exists('array_search')) { /* {{{ */
         function array_search($needle, $haystack)          function array_search($needle, $haystack)
         {          {
Line 162  class phpMyEdit
Line 151  class phpMyEdit
   
         var $logtable;   // name of optional logtable          var $logtable;   // name of optional logtable
         var $navigation; // navigation style          var $navigation; // navigation style
   
           function debug_var($name, $val) /* {{{ */
           {
                   if (is_array($val) || is_object($val)) {
                           echo "<pre>$name\n";
                           ob_start();
                           //print_r($val);
                           var_dump($val);
                           $content = ob_get_contents();
                           ob_end_clean();
                           echo htmlspecialchars($content);
                           echo "</pre>\n";
                   } else {
                           echo 'debug_var()::<i>'.htmlspecialchars($name).'</i>::<b>'
                                   .htmlspecialchars($val).'</b>::'."<br>\n";
                   }
           } /* }}} */
   
         function myquery($qry, $line = 0, $debug = 0) /* {{{ */          function myquery($qry, $line = 0, $debug = 0) /* {{{ */
         {          {
Line 558  class phpMyEdit
Line 564  class phpMyEdit
                         $mc   = $this->web2plain($$lc); // get the comparison operator for numeric/date types                          $mc   = $this->web2plain($$lc); // get the comparison operator for numeric/date types
                         $type = $this->fdd[$k]['type'];                          $type = $this->fdd[$k]['type'];
   
                         if ($m != '') {                          if ($m == '') {
                                 if (is_array($m)) { // multiple selection has been used                                  continue;
                                         if (!in_array('*',$m))  { // one '*' in a multiple selection is all you need                          }
                                                 $qf_op = '';                          if (is_array($m)) { // multiple selection has been used
                                                 foreach (array_keys($m) as $key) {                                  if (!in_array('*',$m))  { // one '*' in a multiple selection is all you need
                                                         if ($qf_op == '') {                                          $qf_op = '';
                                                                 $qf_op   = 'IN';                                          foreach (array_keys($m) as $key) {
                                                                 $qf_val  = "'".addslashes($m[$key])."'";                                                  if ($qf_op == '') {
                                                                 $afilter =" IN ('".addslashes($m[$key])."'";                                                          $qf_op   = 'IN';
                                                         } else {                                                          $qf_val  = "'".addslashes($m[$key])."'";
                                                                 $afilter = $afilter.",'".addslashes($m[$key])."'";                                                          $afilter =" IN ('".addslashes($m[$key])."'";
                                                                 $qf_val .= ",'".addslashes($m[$key])."'";                                                  } else {
                                                         }                                                          $afilter = $afilter.",'".addslashes($m[$key])."'";
                                                           $qf_val .= ",'".addslashes($m[$key])."'";
                                                 }                                                  }
                                                 $afilter = $afilter.')';  
                                                 // XXX: $dont_desc and $dont_cols hack  
                                                 $dont_desc = isset($this->fdd[$k]['values']['description']);  
                                                 $dont_cols = isset($this->fdd[$k]['values']['column']);  
                                                 $qo[$this->fqn($k, false, $dont_desc, $dont_cols)] =  
                                                         array( 'oper'  => $qf_op, 'value' => '('.$qf_val.')');  
                                         }                                          }
                                 } else {                                          $afilter = $afilter.')';
                                         $afilter = $m;                                          // XXX: $dont_desc and $dont_cols hack
                                         if ($afilter != '*') {                                          $dont_desc = isset($this->fdd[$k]['values']['description']);
                                                 /* XXX: This is ugly fqn() hack. We must pass third                                          $dont_cols = isset($this->fdd[$k]['values']['column']);
                                                    $dont_desc parameter to fqn() method, as far as we                                          $qo[$this->fqn($k, false, $dont_desc, $dont_cols)] =
                                                    want to return not description column, but ID one. */                                                  array( 'oper'  => $qf_op, 'value' => '('.$qf_val.')');
                                                 if ($this->fdd[$k]['values']['description']) {                                  }
                                                         // DEBUG                          } else {
                                                         // echo htmlspecialchars(' k = '.$k.' | fqn($k) = '.$this->fqn($k, false, true));                                  $afilter = $m;
                                                         $qo[$this->fqn($k, false, true, true)] =                                  if ($afilter != '*') {
                                                                 array('oper'  => '=', 'value' => "'".$afilter."'");                                          /* XXX: This is ugly fqn() hack. We must pass third
                                                 } elseif ($this->fdd[$k]['values']['column']) {                                             $dont_desc parameter to fqn() method, as far as we
                                                         $qo[$this->fqn($k, false, true, true)] =                                             want to return not description column, but ID one. */
                                                                 array('oper'  => '=', 'value' => "'".$afilter."'");                                          if ($this->fdd[$k]['values']['description']) {
                                                 } elseif ($this->col_is_string($k)) {                                                  // DEBUG
                                                         // massage the filter for a string comparison                                                  // echo htmlspecialchars(' k = '.$k.' | fqn($k) = '.$this->fqn($k, false, true));
                                                         if (($afilter != '') AND ($afilter != '*')) {                                                  $qo[$this->fqn($k, false, true, true)] =
                                                                 $afilter = addslashes(addslashes('%'                                                          array('oper'  => '=', 'value' => "'".$afilter."'");
                                                                                         .str_replace('*', '%', $afilter).'%'));                                          } elseif ($this->fdd[$k]['values']['column']) {
                                                                 $qo[$this->fqn($k)] =                                                  $qo[$this->fqn($k, false, true, true)] =
                                                                         array('oper'  => 'like', 'value' => "'".$afilter."'");                                                          array('oper'  => '=', 'value' => "'".$afilter."'");
                                                         }                                          } elseif ($this->col_is_string($k)) {
                                                 } elseif ($this->col_is_number($k) && ($$lc != '')) {                                                  // massage the filter for a string comparison
                                                         if ($$lc != '') {                                                  if (($afilter != '') AND ($afilter != '*')) {
                                                                 $qo[$this->fqn($k)] =                                                          $afilter = addslashes(addslashes('%'
                                                                         array('oper'  => $mc, 'value' => $afilter);                                                                                  .str_replace('*', '%', $afilter).'%'));
                                                         }  
                                                 } elseif ($this->col_is_date($k)) {  
                                                         #if ($$lc != '') {  
                                                         #       $val = $this->gather_date_fields_into_type($$l,$type);  
                                                         #       $val = $this->mdate_set(date($this->mdate_masks[$type],$this->mdate_getFromPost($k)),$type);  
                                                         #       $val = $this->mdate_getFromPost($k);  
                                                         #       if ($val != '') {  
                                                         #               $qo[$this->fqn($k)] =  
                                                         #                       array( 'oper'  => $mc, 'value' => '"'.$val.'"');  
                                                         #       }  
                                                         #}  
                                                         # massage the filter for a string comparison  
                                                         if (($afilter != '') AND ($afilter != '*')) {  
                                                                 $afilter = addslashes(addslashes('%'  
                                                                                 .str_replace ('*', '%', $afilter).'%'));  
                                                                 $qo[$this->fqn($k)] =  
                                                                         array('oper'  => 'like', 'value' => "'".$afilter."'");  
                                                         }  
                                                 } elseif($this->col_has_values($k)) {  
 //debug_var('col_is_string',$this->fdd[$k]['name'].'::'.$this->fdd[$k]['type']);  
                                                         $qo[$this->fqn($k)] =                                                          $qo[$this->fqn($k)] =
                                                                 array( 'oper'  => '=', 'value' => "'".$afilter."'");                                                                  array('oper'  => 'like', 'value' => "'".$afilter."'");
                                                 } else {                                                  }
                                                         // unknown (to mysql/php interface) field type massage the filter for a string comparison                                          } elseif ($this->col_is_number($k) && ($$lc != '')) {
                                                         $afilter = addslashes(addslashes('%'.str_replace ('*', '%', $afilter).'%'));                                                  if ($$lc != '') {
                                                           $qo[$this->fqn($k)] =
                                                                   array('oper'  => $mc, 'value' => $afilter);
                                                   }
                                           } elseif ($this->col_is_date($k)) {
   #if ($$lc != '') {
   #       $val = $this->gather_date_fields_into_type($$l,$type);
   #       $val = $this->mdate_set(date($this->mdate_masks[$type],$this->mdate_getFromPost($k)),$type);
   #       $val = $this->mdate_getFromPost($k);
   #       if ($val != '') {
   #               $qo[$this->fqn($k)] =
   #                       array( 'oper'  => $mc, 'value' => '"'.$val.'"');
   #       }
   #}
   # massage the filter for a string comparison
                                                   if (($afilter != '') AND ($afilter != '*')) {
                                                           $afilter = addslashes(addslashes('%'
                                                                                   .str_replace ('*', '%', $afilter).'%'));
                                                         $qo[$this->fqn($k)] =                                                          $qo[$this->fqn($k)] =
                                                                 array('oper'  => 'like', 'value' => "'".$afilter."'");                                                                  array('oper'  => 'like', 'value' => "'".$afilter."'");
                                                 }                                                  }
                                           } elseif($this->col_has_values($k)) {
                                                   //debug_var('col_is_string',$this->fdd[$k]['name'].'::'.$this->fdd[$k]['type']);
                                                   $qo[$this->fqn($k)] =
                                                           array( 'oper'  => '=', 'value' => "'".$afilter."'");
                                           } else {
                                                   // unknown (to mysql/php interface) field type massage the filter for a string comparison
                                                   $afilter = addslashes(addslashes('%'.str_replace ('*', '%', $afilter).'%'));
                                                   $qo[$this->fqn($k)] =
                                                           array('oper'  => 'like', 'value' => "'".$afilter."'");
                                         }                                          }
                                 }                                  }
                         } // if                          }
                 } // for                  } // for
   
                 $this->query_opts = $qo;                  $this->query_opts = $qo;
Line 713  class phpMyEdit
Line 720  class phpMyEdit
         function copy_operation()   { return $this->operation == $this->labels['Copy']   && $this->add_enabled();    }          function copy_operation()   { return $this->operation == $this->labels['Copy']   && $this->add_enabled();    }
         function delete_operation() { return $this->operation == $this->labels['Delete'] && $this->delete_enabled(); }          function delete_operation() { return $this->operation == $this->labels['Delete'] && $this->delete_enabled(); }
         function view_operation()   { return $this->operation == $this->labels['View']   && $this->view_enabled();   }          function view_operation()   { return $this->operation == $this->labels['View']   && $this->view_enabled();   }
         function filter_operation() { return isset($this->filter) && $this->filter_enabled(); }          function filter_operation() { return $this->fl && $this->filter_enabled(); } // huh?! XXX FIXME
   
         function processed($k) /* {{{ */          function processed($k) /* {{{ */
         {          {
Line 1046  return true;
Line 1053  return true;
                 } // if elseif else                  } // if elseif else
                 echo '</td>'."\n";                  echo '</td>'."\n";
         } // display_change_field($row, $k)  /* }}} */          } // display_change_field($row, $k)  /* }}} */
   
           function display_delete_field($row, $k) /* {{{ */
           {
                   echo '<td>';
                   if ($row["qf$k"] === null) {
                           echo $this->fdd[$k]['values2'][$row['qf'.$k.'_idx']];
                   } else if ($row["qf$k"] == '') {
                           echo '&nbsp;';
                   } else {
                           echo nl2br($this->htmlDisplay($this->fdd[$k], $row["qf$k"]));
                   }
                   echo '</td>'."\n";
           } /* }}} */
   
         function htmlHidden($name,$value) /* {{{ */          function htmlHidden($name,$value) /* {{{ */
         {          {
Line 1097  return true;
Line 1117  return true;
                 return $ret;                  return $ret;
         } /* }}} */          } /* }}} */
   
         function display_delete_field($row, $k) /* {{{ */  
           function get_qf_hidden_fields() /* {{{ */
         {          {
                 echo '<td>';                  /* If the filter input boxes are not displayed, we need to preserve
                 if ($row["qf$k"] === null) {                     the filter by its emulaion. */
                         echo $this->fdd[$k]['values2'][$row['qf'.$k.'_idx']];                  $this->qfn  = '';
                 } else if ($row["qf$k"] == '') {                  $hidden_qfs = '';
                         echo '&nbsp;';                  for ($k = 0; $k < $this->num_fds; $k++) {
                 } else {                          $l   = 'qf'.$k;
                         echo nl2br($this->htmlDisplay($this->fdd[$k], $row["qf$k"]));                          $lc  = 'qf'.$k.'_comp';
                           $$l  = $this->get_cgi_var($l);
                           $$lc = $this->get_cgi_var($lc);
                           $m   = $this->web2plain($$l);  // get the field name and value
                           $mc  = $this->web2plain($$lc); // get the comparison operator for numeric/date types
   
                           if (!isset($m)) {
                                   continue;
                           }
                           if (is_array($m)) { // multiple selection has been used
                                   if (!in_array('*',$m)) {// one '*' in a multiple selection is all you need
                                           for ($n=0; $n<count($m); $n++) {
                                                   if ($this->plain2web($m[$n]) != '') {
                                                           $this->qfn = $this->qfn.'&qf'.$k.'['.$n.']='
                                                                   .$this->plain2web($m[$n]); }
                                                   $hidden_qfs .= '<input type="hidden" name="qf'.$k.'['.$n
                                                           .']" value="'.$this->plain2web($m[$n]).'">'."\n";
                                           }
                                   }
                           } else {
                                   // query field comparison operator (if any)
                                   if ($this->plain2web($mc) != '') {
                                           $this->qfn   = $this->qfn.'&qf'.$k.'_comp='.$this->plain2web($mc);
                                           $hidden_qfs .= '<input type="hidden" name="'.$lc.'" value="'.$mc.'">'."\n";
                                   }
                                   // preserve query field & value
                                   if ($this->plain2web($m) != '') {
                                           $this->qfn   = $this->qfn.'&qf'.$k.'='.$this->plain2web($m);
                                           $hidden_qfs .= '<input type="hidden" name="'.$l.'" value="'.$m.'">'."\n";
                                   }
                           }
                 }                  }
                 echo '</td>'."\n";                  return $hidden_qfs;
         } /* }}} */          } /* }}} */
   
         function web2plain($x) /* {{{ */          function web2plain($x) /* {{{ */
Line 1301  return true;
Line 1352  return true;
                 // display page and records statistics                  // display page and records statistics
                 echo '<td align=right style="text-align:right;border:0;padding:0;" nowrap>' . "\n";                  echo '<td align=right style="text-align:right;border:0;padding:0;" nowrap>' . "\n";
                 if ($listall) {                  if ($listall) {
                         echo $this->labels['Page'].': 1 of 1';                          echo $this->labels['Page'].': 1 '.$this->labels['of'].' 1';
                 } else {                  } else {
                         echo $this->labels['Page'].': ';                          echo $this->labels['Page'].': ';
                         echo (($this->fm/$this->inc)+1).' '.$this->labels['of'];                          echo (($this->fm/$this->inc)+1);
                         echo ' '.max(1,ceil($total_recs/abs($this->inc)));                          echo ' '.$this->labels['of'].' ';
                           echo max(1,ceil($total_recs/abs($this->inc)));
                 }                  }
                 echo '&nbsp;&nbsp;'.$this->labels['Records'].': '.$total_recs;                  echo '&nbsp;&nbsp;'.$this->labels['Records'].': '.$total_recs;
                 echo '</td></tr></table>'."\n";                  echo '</td></tr></table>'."\n";
Line 1365  return true;
Line 1417  return true;
                         $this->fm += $this->inc;                          $this->fm += $this->inc;
                 }                  }
   
                 // Process filters  
   
                 if (!isset ($this->fl)) {  
                         $this->fl = 0;  
                 }  // by default, no filters  
   
                 // filter switch has been pressed  
                 if (isset ($this->sw)) {  
                         if ($this->sw == $this->labels['Search']) {  
                                 $this->fl = 1;  
                         }  
                         if ($this->sw == $this->labels['Hide']) {  
                                 $this->fl = 0;  
                         }  
                 }  
   
                 /*                  /*
                  * If user is allowed to Change/Delete records, we need an extra column                   * If user is allowed to Change/Delete records, we need an extra column
                  * to allow users to select a record                   * to allow users to select a record
                  */                   */
   
                 $select_recs = (($this->change_enabled()                  $select_recs = $this->key != '' &&
                         or $this->delete_enabled()                          ($this->change_enabled() || $this->delete_enabled() || $this->view_enabled());
                         or $this->view_enabled())  
                         and ($this->key != ''));  
   
                 //echo "sfn::".$this->sfn."::<br>\n";                  //echo "sfn::".$this->sfn."::<br>\n";
   
                 // Default is to sort on first displayed field                  // Default is to sort on first displayed field
                 if (! is_numeric($this->sfn) && ! $this->initial_sort_suppressed()                  if (! is_numeric($this->sfn) && ! $this->initial_sort_suppressed()
                                 && ! isset($this->default_sort_columns)) {                                  && ! isset($this->default_sort_columns)) {
                         $k = 0;                          for ($k = 0; ! $this->displayed[$k]; $k++);
                         while (! $this->displayed[$k]) {  
                                 $k++;  
                         }  
                         $this->sfn = $k;                          $this->sfn = $k;
                 }                  }
   
Line 1414  return true;
Line 1445  return true;
                                 ''=>'','%3C'=>'%3C','%3C%3D'=>'%3C%3D',                                  ''=>'','%3C'=>'%3C','%3C%3D'=>'%3C%3D',
                                 '%3D'=>'%3D','%3E%3D'=>'%3E%3D','%3E'=>'%3E');                                  '%3D'=>'%3D','%3E%3D'=>'%3E%3D','%3E'=>'%3E');
                 echo '<form action="'.$this->page_name.'" method="POST">'."\n";                  echo '<form action="'.$this->page_name.'" method="POST">'."\n";
                 echo '  <input type="hidden" name="sfn" value="';                  echo '<input type="hidden" name="sfn" value="';
                 echo ($this->sort_asc?'':'-').$this->sfn.'" />'."\n";                  echo ($this->sort_asc?'':'-').$this->sfn.'" />'."\n";
                 echo '  <input type="hidden" name="fl" value="'.$this->fl.'" />'."\n";                  echo '<input type="hidden" name="fl" value="'.$this->fl.'" />'."\n";
   
                   $prev_qfn   = $this->qfn;
                   $hidden_qfs = $this->get_qf_hidden_fields();
                   // if sort sequence has changed, restart listing
                   $this->qfn != $prev_qfn && $this->fm = 0;
   
                   if (0) { // TODO: delete me!
                           echo '$this->qfn vs. $prev_qfn comparsion:::::';
                           echo '<b>'.htmlspecialchars($this->qfn).'</b>:::::';
                           echo '<b>'.htmlspecialchars($prev_qfn).'</b>:::::<br>';
                           echo 'comparsion <u>'.($this->qfn == $prev_qfn ? 'proved' : 'failed').'</u>';
                           echo '<hr>';
                   }
   
                 //display buttons at top of page - sparky                  //display buttons at top of page - sparky
                 // setup query to get num_rows                  // setup query to get num_rows
                 $total_recs = 0;                  $total_recs  = 0;
                 $count_parts = array(                  $count_parts = array(
                                 'type'   => 'select',                                  'type'   => 'select',
                                 'select' => 'count(*) as num_rows',                                  'select' => 'count(*) as num_rows',
                                 'from'   => $this->create_join_clause(),                                  'from'   => $this->create_join_clause(),
                                 'where'  => $this->make_where_from_query_opts()                                  'where'  => $this->make_where_from_query_opts());
                                 );                  $res = $this->myquery($this->query_make($count_parts), __LINE__);
                 $res = $this->myquery($this->query_make($count_parts),__LINE__);  
                 $row = @mysql_fetch_array($res, MYSQL_ASSOC);                  $row = @mysql_fetch_array($res, MYSQL_ASSOC);
                 $total_recs = $row['num_rows'];                  $total_recs = $row['num_rows'];
   
Line 1436  return true;
Line 1479  return true;
                         echo '<hr>'."\n";                          echo '<hr>'."\n";
                 }                  }
   
                 // if the filter input boxes are not displayed, we need to preserve the filter  
                 if (!$this->fl) {                  if (!$this->fl) {
                         for ($k = 0; $k < $this->num_fds; $k++) {                          echo($hidden_qfs);
                                 $l   = 'qf'.$k;  
                                 $lc  = 'qf'.$k.'_comp';  
                                 $$l  = $this->get_cgi_var($l);  
                                 $$lc = $this->get_cgi_var($lc);  
                                 $m   = $this->web2plain($$l);  // get the field name and value  
                                 $mc  = $this->web2plain($$lc); // get the comparison operator for numeric/date types  
   
                                 if (isset($m)) {  
                                         if (is_array($m)) { // multiple selection has been used  
                                                 if (!in_array('*',$m)) {// one '*' in a multiple selection is all you need  
                                                         for ($n=0; $n<count($m); $n++) {  
                                                                 if ($this->plain2web($m[$n]) != '') {  
                                                                         echo '  <input type="hidden" name="qf'.$k.'['.$n  
                                                                                 .']" value="'.$this->plain2web($m[$n]).'">'."\n";  
                                                                 }  
                                                         }  
                                                 }  
                                         } else {  
                                                 // query field comparison operator (if any)  
                                                 if ($this->plain2web($mc) != '') {  
                                                         $this->qfn = $this->qfn.'&qf'.$k.'_comp='.$this->plain2web($mc);  
                                                         echo '  <input type="hidden" name="'.$lc.'" value="'.$mc.'">'."\n";  
                                                 }  
                                                 // preserve query field & value  
                                                 if ($this->plain2web($m) != '') {  
                                                         $this->qfn = $this->qfn.'&qf'.$k.'='.$this->plain2web($m);  
                                                         echo '  <input type="hidden" name="'.$l.'" value="'.$m.'">'."\n";  
                                                 }  
                                         }  
                                 }  
                         }  
                 }  
   
                 /*  
                  * Set up the URLs which allow sorting by clicking on column headings  
                  */  
                 $prev_qfn  = $this->qfn;  
                 $this->qfn = '';  
                 for ($k = 0; $k < $this->num_fds; $k++) {  
                         $l   = 'qf'.$k;  
                         $lc  = 'qf'.$k.'_comp';  
                         $$l  = $this->get_cgi_var($l);  
                         $$lc = $this->get_cgi_var($lc);  
                         $m   = $this->web2plain($$l);  // get the field name and value  
                         $mc  = $this->web2plain($$lc); // get the comparison operator for numeric/date types  
   
                         if (isset ($m)) {  
                                 if (is_array($m)) { // multiple selection has been used  
                                         if (!in_array('*',$m)) { // one '*' in a multiple selection is all you need  
                                                 for ($n=0; $n<count($m); $n++) {  
                                                         if ($this->plain2web($m[$n]) != '') {  
                                                                 $this->qfn = $this->qfn.'&qf'.$k.'['.$n.']='  
                                                                         .$this->plain2web($m[$n]); }  
                                                 }  
                                         }  
                                 } else {  
                                         if ($this->plain2web($m)!='') {  
                                                 if ($$lc) {  
                                                         $this->qfn .= '&'.$lc.'='.$$lc;  
                                                 }  
                                                 $this->qfn = $this->qfn.'&qf'.$k.'='.$this->plain2web($m);  
   
                                                 /*  
                                                 // check for multipart date/time/datetime/timestamp/years  
                                                 $qfyear = "qf".$k."_ye";  
                                                 $qfhour = "qf".$k."_ho";  
                                                 global $$qfyear,$$qfhour;  
                                                 if ($$qfyear || $$qfhour) {  
                                                         // we have a multi part date/time thingy  
                                                         $qfmont = "qf".$k."_mo";  
                                                         $qfday  = "qf".$k."_da";  
                                                         $qfminu = "qf".$k."_mi";  
                                                         $qfsec  = "qf".$k."_se";  
                                                         global $$qfmont,$$qfday,$$qfminu,$$qfsec;  
                                                         foreach (  
                                                                 array(  
                                                                         $qfyear=>$$qfyear,$qfmonth=>$$qfmonth,  
                                                                         $qfday=>$$qfday,$qfhour=>$$qfhour,  
                                                                         $qfminute=>$$qfminute,$qfsecond=>$$qfsecond  
                                                                 ) as $qfk => $qfv  
                                                         )  
                                                                 if ($qfv)  
                                                                         $this->qfn .= "&$qfk=".$this->plain2web($qfv);  
                                                 }  
                                                 */  
                                         }  
                                 }  
                         }  
                 }                  }
                 echo '  <input type="hidden" name="qfn" value="'.htmlspecialchars($this->qfn).'" />'."\n";                  echo '<input type=hidden name=qfn value="'.htmlspecialchars($this->qfn).'">'."\n";
                   echo '<input type=hidden name=fm value="'.htmlspecialchars($this->fm).'">'."\n";
                 // if sort sequence has changed, restart listing                  echo '<table width="100%" border="1" cellpadding="1" cellspacing="0"';
                 if ($this->qfn != $prev_qfn) {  
                         $this->fm = 0;  
                         //var_dump($this->qfn);  
                         //var_dump($prev_qfn);  
                 }  
   
                 echo '  <input type="hidden" name="fm" value="'.$this->fm.'" />'."\n";  
   
                 //$this->print_nav_buttons();  
   
                 echo '  <table width="100%" border="1" cellpadding="1" cellspacing="0"';  
                 echo ' summary="'.$this->tb.'">'."\n";                  echo ' summary="'.$this->tb.'">'."\n";
                 echo '    <tr>'."\n";                  echo '<tr>'."\n";
   
                 /*                  /*
                  * System (navigation, selection) columns counting                   * System (navigation, selection) columns counting
                  */                   */
                 $sys_cols = 0;                  $sys_cols  = 0;
                 $sys_cols += intval($this->filter_enabled() || $select_recs);                  $sys_cols += intval($this->filter_enabled() || $select_recs);
                 if ($sys_cols > 0) {                  if ($sys_cols > 0) {
                         $sys_cols += intval($this->nav_buttons()                          $sys_cols += intval($this->nav_buttons()
Line 1561  return true;
Line 1504  return true;
                  */                   */
                 if ($sys_cols) {                  if ($sys_cols) {
                         echo '<th colspan='.$sys_cols.' align="center">';                          echo '<th colspan='.$sys_cols.' align="center">';
                         if ($this->filter_enabled ()) {                          if ($this->filter_enabled()) {
                                 echo '<input type="submit" name="sw" value="'                                  echo '<input type="submit" name="sw" value="'
                                         .($this->fl ? $this->labels['Hide'] : $this->labels['Search']).'">';                                          .($this->fl ? $this->labels['Hide'] : $this->labels['Search']).'">';
                         } else {                          } else {
Line 1638  return true;
Line 1581  return true;
                                         $sort_field     = $this->fqn($this->sfn);                                          $sort_field     = $this->fqn($this->sfn);
                                         $sort_field_w   = $this->fdd[$this->sfn]['name'];                                          $sort_field_w   = $this->fdd[$this->sfn]['name'];
                                 }                                  }
                                 if ( ! $this->sort_asc) {                                  if (! $this->sort_asc) {
                                         $sort_field .= ' DESC';                                          $sort_field   .= ' DESC';
                                         $sort_field_w .= ' descending';                                          $sort_field_w .= ' descending';
                                 }                                  }
                                 $raw_sort_fields[] = $raw_sort_field;                                  $raw_sort_fields[] = $raw_sort_field;
                                 $sort_fields[] = $sort_field;                                  $sort_fields[]     = $sort_field;
                                 $sort_fields_w[] = $sort_field_w;                                  $sort_fields_w[]   = $sort_field_w;
                         }                          }
                         if (isset($this->default_sort_columns)) {                          if (isset($this->default_sort_columns)) {
                                 foreach ($this->default_sort_columns as $dsc) {                                  foreach ($this->default_sort_columns as $dsc) {
                                         if (substr($dsc,0,1)=='-') {                                          if (substr($dsc, 0, 1) == '-') {
                                                 $field = substr($dsc,1);                                                  $field = substr($dsc, 1);
                                                 $desc = true;                                                  $desc  = true;
                                         } else {                                          } else {
                                                 $field = $dsc;                                                  $field = $dsc;
                                                 $desc = false;                                                  $desc  = false;
                                         }                                          }
                                         $raw_candidate = $this->fqn($field);                                          $raw_candidate = $this->fqn($field);
                                         $candidate = $this->fqn($field,true);                                          $candidate     = $this->fqn($field,true);
                                         $sort_field_w = $this->fdd[$field]['name'];                                          $sort_field_w  = $this->fdd[$field]['name'];
                                         if ($desc) {                                          if ($desc) {
                                                 $candidate .= ' DESC';                                                  $candidate    .= ' DESC';
                                                 $sort_field_w .= ' descending';                                                  $sort_field_w .= ' descending';
                                         }                                          }
                                         if (! in_array($raw_candidate,$raw_sort_fields)) {                                          if (! in_array($raw_candidate,$raw_sort_fields)) {
                                                 $sort_fields[] = $candidate;                                                  $sort_fields[]   = $candidate;
                                                 $sort_fields_w[] = $sort_field_w;                                                  $sort_fields_w[] = $sort_field_w;
                                         }                                          }
                                 }                                  }
Line 1737  return true;
Line 1680  return true;
                                         !isset ($this->fdd[$fd]['options'])                                          !isset ($this->fdd[$fd]['options'])
                                 )                                  )
                                 */                                  */
                                 if ($this->displayed[$k]) {                                  if (! $this->displayed[$k]) {
                                         if ($this->fdd[$fd]['select'] == 'D' or $this->fdd[$fd]['select'] == 'M') {                                          continue;
                                                 /*                                  }
                                                  * Multiple fields processing - default size is 2 and array required for values                                  if ($this->fdd[$fd]['select'] == 'D' or $this->fdd[$fd]['select'] == 'M') {
                                                  */                                          /*
                                                 $multiple = $this->fdd[$fd]['select'] == 'M';                                           * Multiple fields processing - default size is 2 and array required for values
                                                 $selected = $m;                                           */
                                                 $x = isset($this->fdd[$k]['values']['table']) || !$this->col_has_values($k)                                          $multiple = $this->fdd[$fd]['select'] == 'M';
                                                         ? $this->set_values_from_table($k, array('*' => '*'))                                          $selected = $m;
                                                         : array('*' => '*') + (array) $this->fdd[$k]['values2'] + (array) $this->fdd[$k]['values'];                                          $x = isset($this->fdd[$k]['values']['table']) || !$this->col_has_values($k)
                                                 echo $this->htmlSelect($l, $x, $selected, $multiple);                                                  ? $this->set_values_from_table($k, array('*' => '*'))
                                         } elseif ($this->fdd[$fd]['select'] == 'T') {                                                  : array('*' => '*') + (array) $this->fdd[$k]['values2'] + (array) $this->fdd[$k]['values'];
                                                 // this is where we put the comparison selects                                          echo $this->htmlSelect($l, $x, $selected, $multiple);
                                                 if (! $this->password($k) && ! $this->hidden($k)) {                                  } elseif ($this->fdd[$fd]['select'] == 'T') {
                                                         if ($this->col_is_string($k)) {                                          // this is where we put the comparison selects
                                                                 // it's treated as a string                                          if (! $this->password($k) && ! $this->hidden($k)) {
                                                                 echo '<input type="text" name="qf'.$k.'"';                                                  if ($this->col_is_string($k)) {
                                                                 echo ' value="'.stripslashes($m).'"';                                                          // it's treated as a string
                                                                 if ($type != 'blob') {                                                          echo '<input type="text" name="qf'.$k.'"';
                                                                         echo ' size="'.min($this->fdd[$k]['maxlen'],20).'"';                                                          echo ' value="'.stripslashes($m).'"';
                                                                         echo ' maxlength="'.$this->fdd[$k]['maxlen'].'"';                                                          if ($type != 'blob') {
                                                                 }                                                                  echo ' size="'.min($this->fdd[$k]['maxlen'],20).'"';
                                                                 echo '/>';                                                                  echo ' maxlength="'.$this->fdd[$k]['maxlen'].'"';
                                                         } elseif ($this->col_is_date($k)) {  
                                                                 // it's a date  
                                                                 //echo $this->htmlSelect($l.'_comp',$comp_ops,$$lc);  
                                                                 // first get any date elements that were passed in  
                                                                 //$filter_val = $this->gather_search_date_fields_into_mysql_timestamp('qf'.$k);  
                                                                 // display the search formlet  
                                                                 //if ($mc) {  
                                                                 //      //echo $this->display_search_field_date($type,'qf'.$k,$filter_val,$this->fdd[$k]['datemask']);  
                                                                 //      //echo $this->mdate_displayForm($filter_val,$type,'qf'.$k,$this->fdd[$k]['datemask'],true);  
                                                                 //      echo $this->mdate_disperse($k,true,$filter_val);  
                                                                 //}  
                                                                 //else {  
                                                                 //      //echo $this->display_search_field_date( $type,'qf'.$k,'',$this->fdd[$k]['datemask']);  
                                                                 //      echo $this->mdate_displayForm('',$type,'qf'.$k,$this->fdd[$k]['datemask'],true);  
                                                                 //}  
                                                                 // it's treated as a string  
                                                                 echo '<input type="text" name="qf'.$k.'"';  
                                                                 echo ' value="'.stripslashes($m).'"';  
                                                                 if ($type != 'blob') {  
                                                                         echo ' size="'.min($this->fdd[$k]['maxlen'],20).'"';  
                                                                         echo ' maxlength="'.$this->fdd[$k]['maxlen'].'"';  
                                                                 }  
                                                                 echo '/>';  
                                                         } elseif ($this->col_is_number($k)) {  
                                                                 // it's a number  
                                                                 echo $this->htmlSelect($l.'_comp',$comp_ops,$$lc);  
                                                                 // it's treated as a string  
                                                                 echo '<input type="text" name="qf'.$k.'"'.  
                                                                         ' value="'.$m.'"'.  
                                                                         ' size="'.min($this->fdd[$k]['maxlen'],20).'"'.  
                                                                         ' maxlength="'.$this->fdd[$k]['maxlen'].'"'.  
                                                                         '/>';  
                                                         } else {  
                                                                 // type is 'unknown' or not set, it's treated as a string  
                                                                 echo '<input type="text" name="qf'.$k.'"';  
                                                                 echo ' value="'.stripslashes($m).'"';  
                                                                 if ($type != 'blob') {  
                                                                         echo ' size="'.min($this->fdd[$k]['maxlen'],20).'"';  
                                                                         echo ' maxlength="'.$this->fdd[$k]['maxlen'].'"';  
                                                                 }  
                                                                 echo '/>';  
                                                         }  
                                                 } else {  
                                                         echo "&nbsp;";  
                                                 }  
   
                                                 // if it's int or real and if not password or hidden, display aggr options  
                                                 /* XXX Disabled until we have time to work on this  
   
                                                 if ((! $this->password($k) && ! $this->hidden($k))  
                                                 && (($this->col_is_number($k)) && (! isset($this->fdd[$k]['values'])))) {  
   
                                                         $var_to_total = 'qf'.$k.'_aggr';  
                                                         global $$var_to_total;  
                                                         $aggr_function = $$var_to_total;  
                                                         if (isset($$var_to_total)) {  
                                                                 $vars_to_total[] = $this->fqn($k);  
                                                                 $aggr_from_clause .=  
                                                                         ' '.$aggr_function.'('.  
                                                                         $this->fqn($k).  
                                                                         ') as '.$var_to_total;  
                                                         }                                                          }
                                                         echo '<br>Aggr: ';                                                          echo '/>';
                                                         echo $this->htmlSelect($var_to_total,$this->sql_aggrs,$$var_to_total);                                                  } elseif ($this->col_is_date($k)) {
                                                         if ($$var_to_total != '') {                                                          // it's a date
                                                                 $listall = true;                                                          //echo $this->htmlSelect($l.'_comp',$comp_ops,$$lc);
                                                           // first get any date elements that were passed in
                                                           //$filter_val = $this->gather_search_date_fields_into_mysql_timestamp('qf'.$k);
                                                           // display the search formlet
                                                           //if ($mc) {
                                                           //      //echo $this->display_search_field_date($type,'qf'.$k,$filter_val,$this->fdd[$k]['datemask']);
                                                           //      //echo $this->mdate_displayForm($filter_val,$type,'qf'.$k,$this->fdd[$k]['datemask'],true);
                                                           //      echo $this->mdate_disperse($k,true,$filter_val);
                                                           //}
                                                           //else {
                                                           //      //echo $this->display_search_field_date( $type,'qf'.$k,'',$this->fdd[$k]['datemask']);
                                                           //      echo $this->mdate_displayForm('',$type,'qf'.$k,$this->fdd[$k]['datemask'],true);
                                                           //}
                                                           // it's treated as a string
                                                           echo '<input type="text" name="qf'.$k.'"';
                                                           echo ' value="'.stripslashes($m).'"';
                                                           if ($type != 'blob') {
                                                                   echo ' size="'.min($this->fdd[$k]['maxlen'],20).'"';
                                                                   echo ' maxlength="'.$this->fdd[$k]['maxlen'].'"';
                                                         }                                                          }
                                                           echo '/>';
                                                   } elseif ($this->col_is_number($k)) {
                                                           // it's a number
                                                           echo $this->htmlSelect($l.'_comp',$comp_ops,$$lc);
                                                           // it's treated as a string
                                                           echo '<input type="text" name="qf'.$k.'"'.
                                                                   ' value="'.$m.'"'.
                                                                   ' size="'.min($this->fdd[$k]['maxlen'],20).'"'.
                                                                   ' maxlength="'.$this->fdd[$k]['maxlen'].'"'.
                                                                   '/>';
                                                 } else {                                                  } else {
                                                         echo '&nbsp;';                                                          // type is 'unknown' or not set, it's treated as a string
                                                           echo '<input type="text" name="qf'.$k.'"';
                                                           echo ' value="'.stripslashes($m).'"';
                                                           if ($type != 'blob') {
                                                                   echo ' size="'.min($this->fdd[$k]['maxlen'],20).'"';
                                                                   echo ' maxlength="'.$this->fdd[$k]['maxlen'].'"';
                                                           }
                                                           echo '/>';
                                                 }                                                  }
                                                 */  
                                                 echo '</td>'."\n";  
                                         } else {                                          } else {
                                                 echo '<td>&nbsp;</td>'."\n";                                                  echo "&nbsp;";
                                         } // if elseif else                                          }
   
                                           // if it's int or real and if not password or hidden, display aggr options
                                           /* XXX Disabled until we have time to work on this
   
                                 } // end if bro1                                             if ((! $this->password($k) && ! $this->hidden($k))
                                              && (($this->col_is_number($k)) && (! isset($this->fdd[$k]['values'])))) {
   
                                              $var_to_total = 'qf'.$k.'_aggr';
                                              global $$var_to_total;
                                              $aggr_function = $$var_to_total;
                                              if (isset($$var_to_total)) {
                                              $vars_to_total[] = $this->fqn($k);
                                              $aggr_from_clause .=
                                              ' '.$aggr_function.'('.
                                              $this->fqn($k).
                                              ') as '.$var_to_total;
                                              }
                                              echo '<br>Aggr: ';
                                              echo $this->htmlSelect($var_to_total,$this->sql_aggrs,$$var_to_total);
                                              if ($$var_to_total != '') {
                                              $listall = true;
                                              }
                                              } else {
                                              echo '&nbsp;';
                                              }
                                            */
                                           echo '</td>'."\n";
                                   } else {
                                           echo '<td>&nbsp;</td>'."\n";
                                   } // if elseif else
                         } // for                          } // for
                         echo '</tr>'."\n";                          echo '</tr>'."\n";
                 } // if first and fl                  } // if first and fl
Line 1846  return true;
Line 1789  return true;
                  */                   */
                 $text_query = $this->make_text_where_from_query_opts();                  $text_query = $this->make_text_where_from_query_opts();
                 if ($text_query != '' && $this->display['query']) {                  if ($text_query != '' && $this->display['query']) {
                         echo '<tr><td colspan='.$sys_cols.' align="center">'.                          echo '<tr><td colspan='.$sys_cols.' align="center">'
                                 '<a class="pme_a_t" href="'.$PHP_SELF;                                  .'<a class="pme_a_t" href="'.$PHP_SELF;
                         if ($this->sfn) {                          if ($this->sfn) {
                                 echo "?sfn=".($this->sort_asc?'':'-').$this->sfn."&fl=".$this->fl."&fm=".$this->fm;                                  echo "?sfn=".($this->sort_asc?'':'-').$this->sfn."&fl=".$this->fl."&fm=".$this->fm;
                         }                          }
                         echo '">Clear</a>'.                          echo '">Clear</a></td>';
                                 '</td>';                          echo '<td colspan="'.$this->num_fields_displayed.'">Current Query: '
                         echo '<td colspan="'.$this->num_fields_displayed.'">Current Query: '.                                  .htmlspecialchars(stripslashes(stripslashes(stripslashes($text_query))))
                                 htmlspecialchars(stripslashes(stripslashes(stripslashes($text_query)))).                                  .'</td></tr>'."\n";
                                 "</td></tr>\n";  
                 }                  }
   
                 /*                  /*
                  * Each row of the HTML table is one record from the SQL Query                   * Each row of the HTML table is one record from the SQL Query
                    * Main list_table() query
                  */                   */
                 $res      = $this->myquery($this->query_make($qparts),__LINE__);                  $res      = $this->myquery($this->query_make($qparts), __LINE__);
                 $first    = true;                  $first    = true;
                 $rowCount = 0;                  $rowCount = 0;
   
Line 1870  return true;
Line 1813  return true;
                         $qstrparts = array();                          $qstrparts = array();
                         if (count($this->qo) > 0) {                          if (count($this->qo) > 0) {
                                 foreach ($this->qo as $key=>$val) {                                  foreach ($this->qo as $key=>$val) {
                                         if ($key != '' && $key != 'operation' && ! is_array($val) )                                          if ($key != '' && $key != 'operation' && ! is_array($val))
                                                 $qstrparts[] = "$key=$val";                                                  $qstrparts[] = "$key=$val";
                                 }                                  }
                         }                          }
                         if (count($this->get_opts) > 0) {                          if (count($this->get_opts) > 0) {
                                 foreach ($this->get_opts as $key=>$val) {                                  foreach ($this->get_opts as $key=>$val) {
                                         if ($key != '' && $key != 'operation' && ! is_array($val) )                                          if ($key != '' && $key != 'operation' && ! is_array($val))
                                                 $qstrparts[] = "$key=$val";                                                  $qstrparts[] = "$key=$val";
                                 }                                  }
                         }                          }
   
                         // preserve sort field number, filter row, and first record to display                          // preserve sort field number, filter row, and first record to display
                         if (isset($this->sfn))                          isset($this->sfn) && $qstrparts[] = 'sfn='.($this->sort_asc?'':'-').$this->sfn;
                                 $qstrparts[] = 'sfn='.($this->sort_asc?'':'-').$this->sfn;                          isset($this->fl)  && $qstrparts[] = 'fl='.$this->fl;
                         if (isset($this->fl))                          isset($this->fm)  && $qstrparts[] = 'fm='.$this->fm;
                                 $qstrparts[] = 'fl='.$this->fl;  
                         if (isset($this->fm))  
                                 $qstrparts[] = 'fm='.$this->fm;  
   
                         // do we need to preserve filter (filter query) and sw (filter display/hide button)?                          // do we need to preserve filter (filter query) and sw (filter display/hide button)?
   
                         $qpview      = $qstrparts;                          $qpview      = $qstrparts;
                         $qpview[]    = 'operation='.$this->labels['View'];                          $qpview[]    = 'operation='.$this->labels['View'];
                         $qpviewStr   = '?'.join('&',$qpview);                          $qpviewStr   = '?'.join('&',$qpview).$this->qfn;
   
                         $qpcopy      = $qstrparts;                          $qpcopy      = $qstrparts;
                         $qpcopy[]    = 'operation='.$this->labels['Copy'];                          $qpcopy[]    = 'operation='.$this->labels['Copy'];
                         $qpcopyStr   = '?'.join('&',$qpcopy);                          $qpcopyStr   = '?'.join('&',$qpcopy).$this->qfn;
   
                         $qpchange    = $qstrparts;                          $qpchange    = $qstrparts;
                         $qpchange[]  = 'operation='.$this->labels['Change'];                          $qpchange[]  = 'operation='.$this->labels['Change'];
                         $qpchangeStr = '?'.join('&',$qpchange);                          $qpchangeStr = '?'.join('&',$qpchange).$this->qfn;
   
                         $qpdelete    = $qstrparts;                          $qpdelete    = $qstrparts;
                         $qpdelete[]  = 'operation='.$this->labels['Delete'];                          $qpdelete[]  = 'operation='.$this->labels['Delete'];
                         $qpdeleteStr = '?'.join('&',$qpdelete);                          $qpdeleteStr = '?'.join('&',$qpdelete).$this->qfn;
                 }                  }
   
                 while ($row = @mysql_fetch_array($res, MYSQL_ASSOC)) {                  while ($row = @mysql_fetch_array($res, MYSQL_ASSOC)) {
                         if (0) { // TODO: delete me!  
                                 echo '<pre>';  
                                 var_dump($row);  
                                 echo '</pre>';  
                                 continue;  
                         }  
   
                         echo '<tr class="'.(($rowCount++%2)?'pme_tr_o':'pme_tr_e')."\">\n";                          echo '<tr class="'.(($rowCount++%2)?'pme_tr_o':'pme_tr_e')."\">\n";
                         if ($sys_cols) {                          if ($sys_cols) {
Line 1990  return true;
Line 1924  return true;
                         for ($k = 0; $k < $this->num_fds; $k++) {                          for ($k = 0; $k < $this->num_fds; $k++) {
                                 $fd = $this->fds[$k];                                  $fd = $this->fds[$k];
                                 if ($this->hidden($k) || $this->password($k)) {                                  if ($this->hidden($k) || $this->password($k)) {
                                         // XXX do nothing KLUDGE KLUDGE                                          continue;
                                 /*                                  } elseif (! $this->displayed[$k]) {
                                 } elseif (                                          continue;
                                         stristr($this->fdd[$fd]['options'],'L') ||                                  }
                                         ! isset($this->fdd[$fd]['options'])                                  // XXX: echo 'displayed: '.$k.'-'.$fd;
                                 ) {  
                                 */                                  /* TODO: what's this?!
                                 } elseif ($this->displayed[$k]) {  
                                         // XXX: echo 'displayed: '.$k.'-'.$fd;                                     if ((trim($row[$k]) == '') or ($row[$k] == 'NULL')) {
                                      echo '      <td>&nbsp;</td>'."\n";
                                         /* TODO: what's this?!                                     } else { */
   
                                            if ((trim($row[$k]) == '') or ($row[$k] == 'NULL')) {                                  // display the contents
                                                 echo '      <td>&nbsp;</td>'."\n";                                  $colattrs = $this->fdd[$fd]['colattrs'];
                                         } else { */                                  if ($colattrs != '')
                                           $colattrs = ' '.$colattrs;
                                         // display the contents                                  if ($this->fdd[$fd]['nowrap'])
                                         $colattrs = $this->fdd[$fd]['colattrs'];                                          $colattrs .= ' NOWRAP';
                                         if ($colattrs != '')                                  if (isset($this->fdd[$fd]['width'])) {
                                                 $colattrs = ' '.$colattrs;                                          $colattrs .= ' width="'.$this->fdd[$fd]['width'].'"';
                                         if ($this->fdd[$fd]['nowrap'])                                  }
                                                 $colattrs .= ' NOWRAP';                                  echo '      <td'.$colattrs.'>';
                                         if (isset($this->fdd[$fd]['width'])) {                                  if (! $this->hidden($k) && ! $this->password($k)) {
                                                 $colattrs .= ' width="'.$this->fdd[$fd]['width'].'"';                                          // displayable
                                         }                                          if (isset($this->fdd[$k]['URL'])
                                         echo '      <td'.$colattrs.'>';                                                          || isset($this->fdd[$k]['URLprefix'])
                                         if (! $this->hidden($k) && ! $this->password($k)) {                                                          || isset($this->fdd[$k]['URLpostfix'])) {
                                                 // displayable                                                  /* It's an URL
                                                 if (isset($this->fdd[$k]['URL'])                                                     Put some conveniences in the namespace for the user
                                                                 || isset($this->fdd[$k]['URLprefix'])                                                     to be able to use in the URL string. */
                                                                 || isset($this->fdd[$k]['URLpostfix'])) {                                                  $key     = $key_rec;
                                                         /* It's an URL                                                  $name    = $this->fds[$k];
                                                            Put some conveniences in the namespace for the user                                                  $value   = $row["qf$k"];
                                                            to be able to use in the URL string. */                                                  $page    = $this->page_name;
                                                         $key     = $key_rec;                                                  $urlstr  = $urlqueryproto.'&rec='.$key;
                                                         $name    = $this->fds[$k];                                                  $urllink = isset($this->fdd[$k]['URL'])
                                                         $value   = $row["qf$k"];                                                          ? eval('return "'.$this->fdd[$k]['URL'].'";')
                                                         $page    = $this->page_name;                                                          : $value;
                                                         $urlstr  = $urlqueryproto.'&rec='.$key;                                                  $urldisp = isset($this->fdd[$k]['URLdisp'])
                                                         $urllink = isset($this->fdd[$k]['URL'])                                                          ? eval('return "'.$this->fdd[$k]['URLdisp'].'";')
                                                                 ? eval('return "'.$this->fdd[$k]['URL'].'";')                                                          : $value;
                                                                 : $value;                                                  $target = isset($this->fdd[$k]['URLtarget'])
                                                         $urldisp = isset($this->fdd[$k]['URLdisp'])                                                          ? 'target="'.htmlspecialchars($this->fdd[$k]['URLtarget']).'" '
                                                                 ? eval('return "'.$this->fdd[$k]['URLdisp'].'";')                                                          : '';
                                                                 : $value;                                                  isset($this->fdd[$k]['URLprefix'])  && $urllink  = $this->fdd[$k]['URLprefix'].$urllink;
                                                         $target = isset($this->fdd[$k]['URLtarget'])                                                  isset($this->fdd[$k]['URLpostfix']) && $urllink .= $this->fdd[$k]['URLpostfix'];
                                                                 ? 'target="'.htmlspecialchars($this->fdd[$k]['URLtarget']).'" '                                                  $urllink = htmlspecialchars($urllink);
                                                                 : '';                                                  $urldisp = htmlspecialchars($urldisp);
                                                         isset($this->fdd[$k]['URLprefix'])  && $urllink  = $this->fdd[$k]['URLprefix'].$urllink;                                                  echo '<a '.$target.'class="pme_a_u" href="'.$urllink.'">'.$urldisp.'</a>';
                                                         isset($this->fdd[$k]['URLpostfix']) && $urllink .= $this->fdd[$k]['URLpostfix'];                                          } elseif (isset($this->fdd[$k]['datemask'])) {
                                                         $urllink = htmlspecialchars($urllink);                                                  // display date according to a mask if any
                                                         $urldisp = htmlspecialchars($urldisp);                                                  //echo $this->mdate_set($row[$k],$this->fdd[$k]['type'],$this->fdd[$k]['datemask']);
                                                         echo '<a '.$target.'class="pme_a_u" href="'.$urllink.'">'.$urldisp.'</a>';                                                  //echo
                                                 } elseif (isset($this->fdd[$k]['datemask'])) {                                                  //      $this->mdate_displayPlain(
                                                         // display date according to a mask if any                                                  //              $this->mdate_from_mysql(
                                                         //echo $this->mdate_set($row[$k],$this->fdd[$k]['type'],$this->fdd[$k]['datemask']);                                                  //                      $row[$k]),
                                                         //echo                                                  //                      (
                                                         //      $this->mdate_displayPlain(                                                  //                              $this->fdd[$k]['datemask']?
                                                         //              $this->mdate_from_mysql(                                                  //                                      $this->fdd[$k]['datemask']
                                                         //                      $row[$k]),                                                  //                              :
                                                         //                      (                                                  //                                      $this->mdate_masks[$this->fdd[$k]['type']]
                                                         //                              $this->fdd[$k]['datemask']?                                                  //                      )
                                                         //                                      $this->fdd[$k]['datemask']                                                  //              );
                                                         //                              :                                                  //echo $row[$k];
                                                         //                                      $this->mdate_masks[$this->fdd[$k]['type']]                                                  // it's a normal field
                                                         //                      )                                                  if (isset($this->fdd[$k]['trimlen'])
                                                         //              );                                                                  && strlen($row["qf$k"]) > $this->fdd[$k]['trimlen']) {
                                                         //echo $row[$k];                                                          $shortdisp = ereg_replace("[\r\n\t ]+", ' ', $row["qf$k"]);
                                                         // it's a normal field                                                          $shortdisp = substr($shortdisp,0,$this->fdd[$k]['trimlen']-3).'...';
                                                   } else {
                                                           $shortdisp = $row["qf$k"];
                                                   }
                                                   echo nl2br($this->htmlDisplay($this->fdd[$k], $shortdisp));
                                           } else {
                                                   // it's a normal field
                                                   if ($row["qf$k"] === null) {
                                                           $shortdisp  = $this->fdd[$k]['values2'][$row['qf'.$k.'_idx']];
                                                           //$shortdisp .= ' ('.$row['qf'.$k.'_idx'].')';
                                                           !isset($shortdisp) && $shortdisp = '';
                                                   } else {
                                                         if (isset($this->fdd[$k]['trimlen'])                                                          if (isset($this->fdd[$k]['trimlen'])
                                                                         && strlen($row["qf$k"]) > $this->fdd[$k]['trimlen']) {                                                                          && strlen($row["qf$k"]) > $this->fdd[$k]['trimlen']) {
                                                                 $shortdisp = ereg_replace("[\r\n\t ]+", ' ', $row["qf$k"]);                                                                  $shortdisp = ereg_replace("[\r\n\t ]+",' ',$row["qf$k"]);
                                                                 $shortdisp = substr($shortdisp,0,$this->fdd[$k]['trimlen']-3).'...';                                                                  $shortdisp = substr($shortdisp,0,$this->fdd[$k]['trimlen']-3).'...';
                                                         } else {                                                          } else {
                                                                 $shortdisp = $row["qf$k"];                                                                  $shortdisp = $row["qf$k"];
                                                         }                                                          }
                                                         echo nl2br($this->htmlDisplay($this->fdd[$k], $shortdisp));  
                                                 } else {  
                                                         // it's a normal field  
                                                         if ($row["qf$k"] === null) {  
                                                                 $shortdisp  = $this->fdd[$k]['values2'][$row['qf'.$k.'_idx']];  
                                                                 //$shortdisp .= ' ('.$row['qf'.$k.'_idx'].')';  
                                                                 !isset($shortdisp) && $shortdisp = '';  
                                                         } else {  
                                                                 if (isset($this->fdd[$k]['trimlen'])  
                                                                                 && strlen($row["qf$k"]) > $this->fdd[$k]['trimlen']) {  
                                                                         $shortdisp = ereg_replace("[\r\n\t ]+",' ',$row["qf$k"]);  
                                                                         $shortdisp = substr($shortdisp,0,$this->fdd[$k]['trimlen']-3).'...';  
                                                                 } else {  
                                                                         $shortdisp = $row["qf$k"];  
                                                                 }  
                                                         }  
                                                         echo nl2br($this->htmlDisplay($this->fdd[$k], $shortdisp));  
                                                 }                                                  }
                                         } else {                                                  echo nl2br($this->htmlDisplay($this->fdd[$k], $shortdisp));
                                                 // it's hidden or a password  
                                                 echo '<i>hidden</i>';  
                                         }                                          }
                                         echo '</td>'."\n";                                  } else {
                                         /* } // if else */                                          // it's hidden or a password
                                 } // if                                          echo '<i>hidden</i>';
                                   }
                                   echo '</td>'."\n";
                         } // for                          } // for
   
                         echo '    </tr>'."\n";                          echo '    </tr>'."\n";
                 } // while                          } // while
   
   
                 /*                  /*
Line 2183  return true;
Line 2111  return true;
                 }                  }
   
                 echo '<table width="100%" border="1" cellpadding="1" cellspacing="0" summary="'.$this->tb.'">'."\n";                  echo '<table width="100%" border="1" cellpadding="1" cellspacing="0" summary="'.$this->tb.'">'."\n";
                 echo '  <input type="hidden" name="rec" value="'.($this->copy_operation()?'':$this->rec).'" />'."\n";                  echo '<input type="hidden" name="rec" value="'.($this->copy_operation()?'':$this->rec).'" />'."\n";
                 echo '  <input type="hidden" name="fm" value="'.$this->fm.'" />'."\n";                  echo '<input type="hidden" name="fm" value="'.$this->fm.'" />'."\n";
                 echo '  <input type="hidden" name="sfn" value="'.$this->sfn.'" />'."\n";                  echo '<input type="hidden" name="sfn" value="'.$this->sfn.'" />'."\n";
                 echo '  <input type="hidden" name="fl" value="'.$this->fl.'" />'."\n";                  echo '<input type="hidden" name="fl" value="'.$this->fl.'" />'."\n";
                   echo $this->get_qf_hidden_fields();
                   echo '<input type="hidden" name="qfn" value="'.htmlspecialchars($this->qfn).'" />'."\n";
                 /*                  /*
                  * preserve the values of any filter fields qf0..qfn for Pass 3                  $this->qfn = '';
                  */  
                 for ($k = 0; $k < $this->num_fds; $k++) {                  for ($k = 0; $k < $this->num_fds; $k++) {
                         $l    = 'qf'.$k;                          $l    = 'qf'.$k;
                         $lc   = 'qf'.$k.'_comp';                          $lc   = 'qf'.$k.'_comp';
Line 2198  return true;
Line 2126  return true;
                         $$lc  = $this->get_cgi_var($lc);                          $$lc  = $this->get_cgi_var($lc);
                         $m    = $this->web2plain($$l);  // get the field name and value                          $m    = $this->web2plain($$l);  // get the field name and value
                         $mc   = $this->web2plain($$lc); // get the comparison operator for numeric/date types                          $mc   = $this->web2plain($$lc); // get the comparison operator for numeric/date types
                         if (isset($m)) {                          if (! isset($m)) {
                                 if (is_array($m)) { // multiple selection has been used                                  continue;
                                         if (!in_array('*',$m)) {        // one '*' in a multiple selection is all you need                          }
                                                 for ($n=0; $n<count($m); $n++) {                          if (is_array($m)) { // multiple selection has been used
                                                         if ($this->plain2web($m[$n]) != '') {                                  if (!in_array('*',$m)) {        // one '*' in a multiple selection is all you need
                                                                 echo '  <input type="hidden" name="qf'.$k.'['.$n.']" value="'                                          for ($n=0; $n<count($m); $n++) {
                                                                         .$this->plain2web($m[$n]).'">'."\n";                                                  if ($this->plain2web($m[$n]) != '') {
                                                         }                                                          $this->qfn = $this->qfn.'&qf'.$k.'['.$n.']='
                                                                   .$this->plain2web($m[$n]); }
                                                           echo '<input type="hidden" name="qf'.$k.'['.$n.']" value="'
                                                                   .$this->plain2web($m[$n]).'">'."\n";
                                                 }                                                  }
                                         }                                          }
                                 } else {                                  }
                                         if ($this->plain2web($m) != '') {                          } else {
                                                 $this->qfn = $this->qfn.'&qf'.$k.'='.$m;                                  if ($this->plain2web($m) != '') {
                                                 echo '  <input type="hidden" name="qf'.$k.'" value="'.$this->plain2web($m).'">'."\n";                                          $this->qfn = $this->qfn.'&qf'.$k.'='.$m;
                                         }                                          echo '<input type="hidden" name="qf'.$k.'" value="'.$this->plain2web($m).'">'."\n";
                                 }                                  }
                         }                          }
                 }                  }
                 echo '  <input type="hidden" name="qfn" value="'.$this->qfn.'" />'."\n";                  */
   
                 if ($this->add_operation()) {                  if ($this->add_operation()) {
                         $this->display_add_record();                          $this->display_add_record();
                 } else {                  } else {
                         $this->display_copy_change_delete_record();                          $this->display_copy_change_delete_record();
                 }                  }
   
                 echo '</table>'."\n";                  echo '</table>'."\n";
   
                 if ($this->nav_down()) {                  if ($this->nav_down()) {
                         //display buttons at bottom of page - sparky                          //display buttons at bottom of page - sparky
                         echo "  <hr />\n";                          echo "  <hr />\n";
                         $this->display_record_buttons();                          $this->display_record_buttons();
                 }                  }
   
                 echo '</form>'."\n";                  echo '</form>'."\n";
   
         } /* }}} */          } /* }}} */
   
         /*          /*
Line 2713  echo '<h5>'.mysql_affected_rows ().' '.$
Line 2640  echo '<h5>'.mysql_affected_rows ().' '.$
                         $this->page_name = $opts['page_name'];                          $this->page_name = $opts['page_name'];
   
                 // alternate row background colors                  // alternate row background colors
                 if (isset($opts['bgcolorOdd'])) {                  /* What's this?!
                         $this->bgcolorOdd = 'White';  
                 } else {                     if (isset($opts['bgcolorOdd'])) {
                         $this->bgcolorOdd = $opts['bgcolorOdd'];                     $this->bgcolorOdd = 'White';
                 }                     } else {
                 if (isset($opts['bgColorEven'])) {                     $this->bgcolorOdd = $opts['bgcolorOdd'];
                         $this->bgcolorEven = 'Silver';                     }
                 } else {                     if (isset($opts['bgColorEven'])) {
                         $this->bgcolorEven = $opts['bgcolorEven'];                     $this->bgcolorEven = 'Silver';
                 }                     } else {
                      $this->bgcolorEven = $opts['bgcolorEven'];
                      }
                    */
   
                 // e-mail notification                  // e-mail notification
                 if (isset($opts['notify'])) {                  if (isset($opts['notify'])) {
Line 2739  echo '<h5>'.mysql_affected_rows ().' '.$
Line 2669  echo '<h5>'.mysql_affected_rows ().' '.$
                 }                  }
   
                 /*                  /*
                  *              Find the URL to post forms                   * Find the URL to post forms
                  */                   */
   
                 $this->page_name = basename($HTTP_SERVER_VARS['PHP_SELF']);                  $this->page_name = basename($HTTP_SERVER_VARS['PHP_SELF']);
   
                 /*                  /*
                  *              form variables all around                   * Form variables all around
                  */                   */
   
                 $this->operation  = $this->get_cgi_var('operation');                  $this->operation  = $this->get_cgi_var('operation');
                 $this->apply      = $this->get_cgi_var('apply');                  $this->apply      = $this->get_cgi_var('apply');
                 $this->fl         = $this->get_cgi_var('fl');                  $this->fl         = intval($this->get_cgi_var('fl'));
                 $this->fm         = intval($this->get_cgi_var('fm'));                  $this->fm         = intval($this->get_cgi_var('fm'));
   
                 $this->sfn        = $this->get_cgi_var('sfn');                  $this->sfn        = $this->get_cgi_var('sfn');
                 $this->sort_asc   = $this->sfn[0] != '-';                  $this->sort_asc   = $this->sfn[0] != '-';
                 $this->sfn        = abs(intval($this->sfn));                  $this->sfn        = abs(intval($this->sfn));
   
                 //$this->qfn        = intval($this->get_cgi_var('qfn'));                  $this->qfn        = $this->get_cgi_var('qfn');
                 $this->qfn        = '';  
                 $this->sw         = $this->get_cgi_var('sw');                  $this->sw         = $this->get_cgi_var('sw');
                 $this->rec        = $this->get_cgi_var('rec', ''); // Fixed #523390 [7/8/2002] [2/2]                  $this->rec        = $this->get_cgi_var('rec', ''); // Fixed #523390 [7/8/2002] [2/2]
                 $this->prev       = $this->get_cgi_var('prev');                  $this->prev       = $this->get_cgi_var('prev');
Line 2769  echo '<h5>'.mysql_affected_rows ().' '.$
Line 2698  echo '<h5>'.mysql_affected_rows ().' '.$
                 $this->savedelete = $this->get_cgi_var('savedelete');                  $this->savedelete = $this->get_cgi_var('savedelete');
   
                 /*                  /*
                    * Filter setting
                    */
                   if (isset($this->sw)) {
                           $this->sw == $this->labels['Search'] && $this->fl = 1;
                           $this->sw == $this->labels['Hide']   && $this->fl = 0;
                   }
   
                   /*
                    * Specific $fdd modifications depending on performed action
                    */
   
                   $action_letter = 'L'; // list by default
                   $this->filter_operation() && $action_letter = 'F';
                   $this->view_operation()   && $action_letter = 'V';
                   $this->delete_operation() && $action_letter = 'D';
                   $this->add_operation()    && $action_letter = 'A';
                   $this->change_operation() && $action_letter = 'C';
                   $this->copy_operation()   && $action_letter = 'P';
                   //echo $action_letter.'<hr>';
   
                   foreach (array_keys($this->fdd) as $column) {
                           foreach (array_keys($this->fdd[$column]) as $col_option) {
                                   if (strchr($col_option, '|')) {
                                           $col_ar = explode('|', $col_option, 2);
                                           if (stristr($col_ar[1], $action_letter)) {
                                                   $this->fdd[$column][$col_ar[0]] = $this->fdd[$column][$col_option];
                                                   unset($this->fdd[$column][$col_option]);
                                                   //echo $column.': changing '.$col_option.' for '.$col_ar[0].'<br>';
                                           }
                                   }
                           }
                   }
   
                   /*
                  * Extract SQL Field Names and number of fields                   * Extract SQL Field Names and number of fields
                  */                   */
   
                 $this->guidance = false;                  $this->guidance = false;
                 $field_num = 0;                  $field_num = 0;
                 $num_fields_displayed = 0;                  $num_fields_displayed = 0;

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top