Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Thursday, October 15, 2026

Diff for phpMyEdit/phpMyEdit.class.php between version 1.57 and 1.58

version 1.57, 2003/03/19 01:03:49 version 1.58, 2003/03/19 19:57:25
Line 19 
Line 19 
  * http://www.platon.sk/projects/phpMyEdit/   * http://www.platon.sk/projects/phpMyEdit/
  */   */
   
 /* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.56 2003/03/18 00:52:59 nepto Exp $ */  /* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.57 2003/03/19 01:03:49 nepto Exp $ */
   
 /*      phpMyEdit intro {{{ */  /*      phpMyEdit intro {{{ */
 /*  /*
Line 55 
Line 55 
   
         Conversion to PHP Classes by Pau Aliagas (pau@newtral.com)          Conversion to PHP Classes by Pau Aliagas (pau@newtral.com)
   
         ToDo:  
         'Copy' button  
   
         Aggregates:          Aggregates:
         nonworking code commented out in list_table()          nonworking code commented out in list_table()
         doesn't work yet          doesn't work yet
Line 271  class phpMyEdit
Line 268  class phpMyEdit
                 return $ret;                  return $ret;
         } /* }}} */          } /* }}} */
   
         function set_values_from_table($field_num, $prepend = '') /* {{{ */          function set_values($field_num, $prepend = null, $append = null, $strict = false) /* {{{ */
           {
                   return (array) $prepend + (array) $this->fdd[$field_num]['values2']
                           + (isset($this->fdd[$field_num]['values']['table']) || $strict
                                           ? $this->set_values_from_table($field_num, $strict)
                                           : array())
                           + (array) $append;
           } /* }}} */
   
           function set_values_from_table($field_num, $strict = false) /* {{{ */
         {          {
                 /*  
                    echo "$field_num, ";  
                    var_dump($prepend);  
                    echo '<pre>';  
                    var_dump($this->fdd);  
                    echo '</pre>';  
                  */  
                 if($this->fdd[$field_num]['values']['db']) {                  if($this->fdd[$field_num]['values']['db']) {
                         $db = $this->fdd[$field_num]['values']['db'];                          $db = $this->fdd[$field_num]['values']['db'];
                 } else {                  } else {
Line 331  class phpMyEdit
Line 330  class phpMyEdit
                 while ($row = @mysql_fetch_array($res, MYSQL_NUM)) {                  while ($row = @mysql_fetch_array($res, MYSQL_NUM)) {
                         $values[$row[0]] = $desc ? $row[1] : $row[0];                          $values[$row[0]] = $desc ? $row[1] : $row[0];
                 }                  }
                 $values2 = $this->fdd[$field_num]['values2'];  
                 is_array($values2) && $values = $values2 + $values;  
                 is_array($prepend) && $values = $prepend + $values;  
                 return $values;                  return $values;
         } /* }}} */          } /* }}} */
   
Line 521  class phpMyEdit
Line 517  class phpMyEdit
   
         function gather_query_opts() /* {{{ */          function gather_query_opts() /* {{{ */
         {          {
                   $this->query_opts = array();
                   $this->prev_qfn   = $this->qfn;
                   $this->qfn        = '';
                   if ($this->clear_operation()) {
                           return;
                   }
                 // gathers query options into an array, $this->query_opts                  // gathers query options into an array, $this->query_opts
                 $qo = array();                  $qo = array();
                 for ($k = 0; $k < $this->num_fds; $k++) {                  for ($k = 0; $k < $this->num_fds; $k++) {
Line 528  class phpMyEdit
Line 530  class phpMyEdit
                         $l    = 'qf'.$k;                          $l    = 'qf'.$k;
                         $lc   = 'qf'.$k.'_comp';                          $lc   = 'qf'.$k.'_comp';
                         $li   = 'qf'.$k.'_id';                          $li   = 'qf'.$k.'_id';
                         $m    = $this->get_cgi_var($l,  '');                          $m    = $this->get_cgi_var($l);
                         $mc   = $this->get_cgi_var($lc, '');                          $mc   = $this->get_cgi_var($lc);
                         $mi   = $this->get_cgi_var($li, '');                          $mi   = $this->get_cgi_var($li);
                         if ($m == '' && $mi == '') {                          if (! isset($m) && ! isset($mi)) {
                                 continue;                                  continue;
                         }                          }
                         if (is_array($m) || is_array($mi)) {                          if (is_array($m) || is_array($mi)) {
Line 556  class phpMyEdit
Line 558  class phpMyEdit
                                 $dont_cols = isset($this->fdd[$k]['values']['column']);                                  $dont_cols = isset($this->fdd[$k]['values']['column']);
                                 $qo[$this->fqn($k, false, $dont_desc, $dont_cols)] =                                  $qo[$this->fqn($k, false, $dont_desc, $dont_cols)] =
                                         array('oper'  => $qf_op, 'value' => "($qf_val)"); // )                                          array('oper'  => $qf_op, 'value' => "($qf_val)"); // )
                         } else if ($mi != '' /* && ($this->fdd[$k]['values']['description'] || $this->fdd[$k]['values']['column']) */) {                          } else if (isset($mi)) {
                                   if ($mi == '*') {
                                           continue;
                                   }
                                   if ($this->fdd[$k]['select'] != 'M' && $this->fdd[$k]['select'] != 'D' && $mi == '') {
                                           continue;
                                   }
                                 $afilter = addslashes($mi);                                  $afilter = addslashes($mi);
                                 if ($afilter != '*') {                                  $qo[$this->fqn($k, false, true, true)] = array('oper'  => '=', 'value' => "'$afilter'");
                                         $qo[$this->fqn($k, false, true, true)] = array('oper'  => '=', 'value' => "'$afilter'");                          } else if (isset($m)) {
                                   if ($m == '*') {
                                           continue;
                                 }                                  }
                         } else {                                  if ($this->fdd[$k]['select'] != 'M' && $this->fdd[$k]['select'] != 'D' && $m == '') {
                                 $afilter = addslashes($m);  
                                 if ($afilter == '*') {  
                                         continue;                                          continue;
                                 }                                  }
                                   $afilter = addslashes($m);
                                 if ($this->col_is_string($k)                                  if ($this->col_is_string($k)
                                                 || $this->fdd[$k]['values']['description']                                                  || $this->fdd[$k]['values']['description']
                                                 || $this->fdd[$k]['values']['column']) {                                                  || $this->fdd[$k]['values']['column']) {
Line 585  class phpMyEdit
Line 594  class phpMyEdit
                                                 }                                                  }
                                         }                                          }
                                         $qo[] = $ar;                                          $qo[] = $ar;
                                 } elseif ($this->col_is_number($k) && ($mc != '')) {                                  } elseif ($this->col_is_number($k) && isset($mc)) {
                                         if ($mc != '') {                                          if (isset($mc)) {
                                                 $qo[$this->fqn($k)] = array('oper'  => $mc, 'value' => "'$afilter'");                                                  $qo[$this->fqn($k)] = array('oper'  => $mc, 'value' => "'$afilter'");
                                         }                                          }
                                 } elseif ($this->col_is_date($k)) {                                  } elseif ($this->col_is_date($k)) {
Line 602  class phpMyEdit
Line 611  class phpMyEdit
                                         $qo[$this->fqn($k)] = array('oper'  => 'like', 'value' => "'$afilter'");                                          $qo[$this->fqn($k)] = array('oper'  => 'like', 'value' => "'$afilter'");
                                 }                                  }
                         }                          }
                 } // for                  }
                 $this->query_opts = $qo;                  $this->query_opts = $qo;
   
                   /* If the filter input boxes are not displayed, we need to preserve
                      the filter by its emulaion. */
                   for ($k = 0; $k < $this->num_fds; $k++) {
                           $l    = 'qf'.$k;
                           $lc   = 'qf'.$k.'_comp';
                           $li   = 'qf'.$k.'_id';
                           $m    = $this->get_cgi_var($l);
                           $mc   = $this->get_cgi_var($lc);
                           $mi   = $this->get_cgi_var($li);
                           if (! isset($m) && ! isset($mi)) {
                                   continue;
                           }
                           $stack = array();
                           foreach (array($l => $m, $lc => $mc, $li => $mi) as $name => $value) {
                                   if (is_array($value)) {
                                           foreach ($value as $key => $val) {
                                                   if ($key === '' && isset($value)) {
                                                           continue;
                                                   }
                                                   $this->qfn  .= '&'.$name.'['.rawurlencode($key).']='.rawurlencode($val);
                                                   $hidden_qfs .= '<input type="hidden" name="'.$name.'['.$key
                                                           .']" value="'.htmlspecialchars($val).'">'."\n";
                                           }
                                   } else {
                                           if (! isset($value) || $value == '*') {
                                                   continue;
                                           }
                                           // Sync with gather_query_opts()
                                           if ($this->fdd[$k]['select'] != 'M' && $this->fdd[$k]['select'] != 'D' && $value == '') {
                                                   continue;
                                           }
                                           /* Opertation CGI variables (=, <, >, ...) are added only
                                              if their numeric equivalent was already added as well. We
                                              are using $stack for remembering this. */
                                           if (preg_match('|^(qf\d+)_comp$|', $name, $matches)) {
                                                   if (! in_array($matches[1], $stack)) {
                                                           continue;
                                                   }
                                           }
                                           $stack[]    = $name;
                                           $this->qfn .= '&'.$name.'='.rawurlencode($value);
                                   }
                           }
                   }
         } /* }}} */          } /* }}} */
   
         /*          /*
Line 649  class phpMyEdit
Line 703  class phpMyEdit
         function filter_operation() { return $this->fl && $this->filter_enabled(); }          function filter_operation() { return $this->fl && $this->filter_enabled(); }
         function next_operation()       { return $this->next == $this->labels['Next']; }          function next_operation()       { return $this->next == $this->labels['Next']; }
         function prev_operation()       { return $this->prev == $this->labels['Prev']; }          function prev_operation()       { return $this->prev == $this->labels['Prev']; }
           function clear_operation()      { return $this->sw == $this->labels['Clear'];  }
   
         function is_values2($k, $val = 'X') /* {{{ */          function is_values2($k, $val = 'X') /* {{{ */
         {          {
Line 819  function phpMyEdit_form_control(theForm)
Line 874  function phpMyEdit_form_control(theForm)
                         echo '<td class="',$this->getCSSclass('value', '', true),'">'."\n";                          echo '<td class="',$this->getCSSclass('value', '', true),'">'."\n";
                         $css_class_name = $this->getCSSclass('input', '', true);                          $css_class_name = $this->getCSSclass('input', '', true);
                         if ($this->col_has_values($k) && !$this->readonly($k)) {                          if ($this->col_has_values($k) && !$this->readonly($k)) {
                                   $vals     = $this->set_values($k);
                                   $selected = @$this->fdd[$k]['default'];
                                 $multiple = ($this->fdd[$k]['select'] == 'M' || $this->col_is_set($k))                                  $multiple = ($this->fdd[$k]['select'] == 'M' || $this->col_is_set($k))
                                                 && ! $this->fdd[$k]['values']['table'];                                          && ! $this->fdd[$k]['values']['table'];
                                 $vals = isset($this->fdd[$k]['values']['table'])                                  echo $this->htmlSelect($this->fds[$k], $css_class_name, $vals, $selected, $multiple);
                                         ? $this->set_values_from_table($k)  
                                         : (array) $this->fdd[$k]['values2'] + (array) $this->fdd[$k]['values'];  
                                 echo $this->htmlSelect($this->fds[$k], $css_class_name, $vals, '', $multiple);  
                         } elseif (isset ($this->fdd[$k]['textarea']) && !$this->readonly($k)) {                          } elseif (isset ($this->fdd[$k]['textarea']) && !$this->readonly($k)) {
                                 echo '<textarea class="',$css_class_name,'" ';                                  echo '<textarea class="',$css_class_name,'" ';
                                 if (isset ($this->fdd[$k]['textarea']['rows'])) {                                  if (isset ($this->fdd[$k]['textarea']['rows'])) {
Line 957  function phpMyEdit_form_control(theForm)
Line 1011  function phpMyEdit_form_control(theForm)
                 echo '<td class="',$this->getCSSclass('value', '', true),'">',"\n";                  echo '<td class="',$this->getCSSclass('value', '', true),'">',"\n";
                 $css_class_name = $this->getCSSclass('input', '', true);                  $css_class_name = $this->getCSSclass('input', '', true);
                 if ($this->col_has_values($k) && !$this->readonly($k)) {                  if ($this->col_has_values($k) && !$this->readonly($k)) {
                           $vals     = $this->set_values($k);
                         $multiple = ($this->fdd[$k]['select'] == 'M' || $this->col_is_set($k))                          $multiple = ($this->fdd[$k]['select'] == 'M' || $this->col_is_set($k))
                                         && ! $this->fdd[$k]['values']['table'];                                          && ! $this->fdd[$k]['values']['table'];
                         $vals = isset($this->fdd[$k]['values']['table'])  
                                 ? $this->set_values_from_table($k)  
                                 : (array) $this->fdd[$k]['values2'] + (array) $this->fdd[$k]['values'];  
                         echo $this->htmlSelect($this->fds[$k], $css_class_name, $vals, $row["qf$k"], $multiple);                          echo $this->htmlSelect($this->fds[$k], $css_class_name, $vals, $row["qf$k"], $multiple);
                 } elseif (isset($this->fdd[$k]['textarea']) && !$this->readonly($k)) {                  } elseif (isset($this->fdd[$k]['textarea']) && !$this->readonly($k)) {
                         echo '<textarea class="',$css_class_name,'" name="'.$this->fds[$k].'"';                          echo '<textarea class="',$css_class_name,'" name="'.$this->fds[$k].'"';
Line 1107  function phpMyEdit_form_control(theForm)
Line 1159  function phpMyEdit_form_control(theForm)
                 $ret = '<select class="'.htmlspecialchars($class).'" name="'.htmlspecialchars($name);                  $ret = '<select class="'.htmlspecialchars($class).'" name="'.htmlspecialchars($name);
                 if ($multiple) {                  if ($multiple) {
                         $ret  .= '[]" multiple size="'.$this->multiple;                          $ret  .= '[]" multiple size="'.$this->multiple;
                         !is_array($selected) && $selected = explode(',', $selected);                          if (! is_array($selected) && $selected !== null) {
                                   $selected = explode(',', $selected);
                           }
                 }                  }
                 $ret .= '">'."\n";                  $ret .= '">'."\n";
   
                 if ($nat_sort) {                  if ($nat_sort) {
                         uasort($kv_array,'strnatcasecmp');                          uasort($kv_array,'strnatcasecmp');
                 }                  }
                 if (! is_array($selected)) {                  if (! is_array($selected)) {
                         $selected = $selected === null ? array() : array($selected);                          $selected = $selected === null ? array() : array($selected);
                 }                  }
   
                 $found = false;                  $found = false;
                 foreach ($kv_array as $key => $value) {                  foreach ($kv_array as $key => $value) {
                         $ret .= '<option value="'.htmlspecialchars($key).'"';                          $ret .= '<option value="'.htmlspecialchars($key).'"';
                         if ((! $found || $multiple) && is_numeric(array_search($key, $selected))                          if ((! $found || $multiple) && in_array((string) $key, $selected, 1)
                                         || (count($selected) == 0 && ! $found)) {                                          || (count($selected) == 0 && ! $found && ! $multiple)) {
                                 $ret  .= ' selected';                                  $ret  .= ' selected';
                                 $found = true;                                  $found = true;
                         }                          }
Line 1245  function phpMyEdit_form_control(theForm)
Line 1297  function phpMyEdit_form_control(theForm)
                 return $ret;                  return $ret;
         } /* }}} */          } /* }}} */
   
         function get_qf_hidden_fields() /* {{{ */  
         {  
                 /* If the filter input boxes are not displayed, we need to preserve  
                    the filter by its emulaion. */  
                 $this->qfn  = '';  
                 $hidden_qfs = '';  
                 for ($k = 0; $k < $this->num_fds; $k++) {  
                         $l    = 'qf'.$k;  
                         $lc   = 'qf'.$k.'_comp';  
                         $li   = 'qf'.$k.'_id';  
                         $m    = $this->get_cgi_var($l,  '');  
                         $mc   = $this->get_cgi_var($lc, '');  
                         $mi   = $this->get_cgi_var($li, '');  
                         if ($m == '' && $mi == '') {  
                                 continue;  
                         }  
                         foreach (array($l => $m, $lc => $mc, $li => $mi) as $name => $value) {  
                                 if (is_array($value)) {  
                                         foreach ($value as $key => $val) {  
                                                 if ($key === '' || $val === '') {  
                                                         continue;  
                                                 }  
                                                 $this->qfn  .= '&'.$name.'['.rawurlencode($key).']='.rawurlencode($val);  
                                                 $hidden_qfs .= '<input type="hidden" name="'.$name.'['.$key  
                                                         .']" value="'.htmlspecialchars($val).'">'."\n";  
                                         }  
                                 } else {  
                                         if ($value != '') {  
                                                 $this->qfn  .= '&'.$name.'='.rawurlencode($value);  
                                                 $hidden_qfs .= '<input type="hidden" name="'.$name.'" value="'.htmlspecialchars($value).'">'."\n";  
                                         }  
                                 }  
                         }  
                 }  
                 return $hidden_qfs;  
         } /* }}} */  
   
         function get_cgi_var($name, $default_value = null) /* {{{ */          function get_cgi_var($name, $default_value = null) /* {{{ */
         {          {
                 if (isset($this) && isset($this->cgi['overwrite'][$name])) {                  if (isset($this) && isset($this->cgi['overwrite'][$name])) {
Line 1303  function phpMyEdit_form_control(theForm)
Line 1318  function phpMyEdit_form_control(theForm)
                                 $var = stripslashes($var);                                  $var = stripslashes($var);
                         }                          }
                 } else {                  } else {
                         $var = @$default_value;                          $var = $default_value;
                 }                  }
   
                 if (isset($this) && $var === null && isset($this->cgi['append'][$name])) {                  if (isset($this) && $var === null && isset($this->cgi['append'][$name])) {
Line 1544  function phpMyEdit_form_control(theForm)
Line 1559  function phpMyEdit_form_control(theForm)
                 if ($this->next_operation()) {                  if ($this->next_operation()) {
                         $this->fm += $this->inc;                          $this->fm += $this->inc;
                 }                  }
                   // If sort sequence has changed, restart listing
                   $this->qfn != $this->prev_qfn && $this->fm = 0;
                   if (0) { // TODO: delete me!
                           echo 'qfn vs. prev_qfn comparsion ';
                           echo '[<b>'.htmlspecialchars($this->qfn).'</b>]';
                           echo '[<b>'.htmlspecialchars($this->prev_qfn).'</b>]<br>';
                           echo 'comparsion <u>'.($this->qfn == $this->prev_qfn ? 'proved' : 'failed').'</u>';
                           echo '<hr>';
                   }
                 /*                  /*
                  * 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
Line 1556  function phpMyEdit_form_control(theForm)
Line 1579  function phpMyEdit_form_control(theForm)
                 /*                  /*
                  * Display the MySQL table in an HTML table                   * Display the MySQL table in an HTML table
                  */                   */
                 $comp_ops = array(                  $comp_ops = array('<'=>'<','<='=>'<=',
                                 ''=>'','<'=>'<','<='=>'<=',  
                                 '='=>'=','>='=>'>=','>'=>'>');                                  '='=>'=','>='=>'>=','>'=>'>');
                 echo '<form class="',$this->getCSSclass('form'),'" action="';                  echo '<form class="',$this->getCSSclass('form'),'" action="';
                 echo htmlspecialchars($this->page_name),'" method="POST">',"\n";                  echo htmlspecialchars($this->page_name),'" method="POST">',"\n";
                 echo $this->get_origvars_html($this->get_sfn_cgi_vars());                  echo $this->get_origvars_html($this->get_sfn_cgi_vars());
                 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 and/or bottom of page.                  // Display buttons at top and/or bottom of page.
                 // Setup query to get num_rows. (sparky)                  // Setup query to get num_rows. (sparky)
                 $total_recs  = 0;                  $total_recs  = 0;
Line 1592  function phpMyEdit_form_control(theForm)
Line 1603  function phpMyEdit_form_control(theForm)
                 if ($this->cgi['persist'] != '') {                  if ($this->cgi['persist'] != '') {
                         echo $this->get_origvars_html($this->cgi['persist']);                          echo $this->get_origvars_html($this->cgi['persist']);
                 }                  }
                 if (!$this->fl) {                  if (! $this->fl) {
                         echo($hidden_qfs);                          echo $this->get_origvars_html($this->qfn);
                 }                  }
                 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";                  echo '<input type=hidden name=fm value="',htmlspecialchars($this->fm),'">',"\n";
Line 1642  function phpMyEdit_form_control(theForm)
Line 1653  function phpMyEdit_form_control(theForm)
                                         array_unshift($new_sfn, in_array("$k", $new_sfn, 1) ? "-$k" : $k);                                          array_unshift($new_sfn, in_array("$k", $new_sfn, 1) ? "-$k" : $k);
                                         echo '<th',$w,' class="',$this->getCSSclass('header'),'">';                                          echo '<th',$w,' class="',$this->getCSSclass('header'),'">';
                                         echo '<a class="',$this->getCSSclass('header'),'" href="';                                          echo '<a class="',$this->getCSSclass('header'),'" href="';
                                         echo htmlspecialchars($this->page_name.'?fm=0&fl='.$this->fl.'&'                                          echo htmlspecialchars($this->page_name.'?fm=0&fl='.$this->fl
                                                         .$this->get_sfn_cgi_vars($new_sfn).$this->cgi['persist'].$this->qfn);                                                          .'&qfn='.rawurlencode($this->qfn).$this->qfn
                                                           .'&'.$this->get_sfn_cgi_vars($new_sfn).$this->cgi['persist']);
                                         echo '">',$fdn,'</a></th>',"\n";                                          echo '">',$fdn,'</a></th>',"\n";
                                 }                                  }
                         }                          }
Line 1752  function phpMyEdit_form_control(theForm)
Line 1764  function phpMyEdit_form_control(theForm)
                                         $this->field_name = $this->fds[$k];                                          $this->field_name = $this->fds[$k];
                                         $fd               = $this->field_name;                                          $fd               = $this->field_name;
                                         $this->field      = $this->fdd[$fd];                                          $this->field      = $this->fdd[$fd];
                                           $css_class_name   = $this->getCSSclass('filter');
                                         $l  = 'qf'.$k;                                          $l  = 'qf'.$k;
                                         $lc = 'qf'.$k.'_comp';                                          $lc = 'qf'.$k.'_comp';
                                         $li = 'qf'.$k.'_id';                                          $li = 'qf'.$k.'_id';
                                         $m  = $this->get_cgi_var($l,  '');                                          if ($this->clear_operation()) {
                                         $mc = $this->get_cgi_var($lc, '');                                                  $m  = null;
                                         $mi = $this->get_cgi_var($li, '');                                                  $mc = null;
                                         $css_class_name = $this->getCSSclass('filter');                                                  $mi = null;
                                           } else {
                                                   $m  = $this->get_cgi_var($l);
                                                   $mc = $this->get_cgi_var($lc);
                                                   $mi = $this->get_cgi_var($li);
                                           }
                                         if (isset($this->fdd[$fd]['width'])) {                                          if (isset($this->fdd[$fd]['width'])) {
                                                 $widthStyle = ' STYLE=\'width: "'.(6*$this->fdd[$fd]['width']).'px"\'';                                                  $widthStyle = ' STYLE=\'width: "'.(6*$this->fdd[$fd]['width']).'px"\'';
                                         }                                          }
Line 1772  function phpMyEdit_form_control(theForm)
Line 1789  function phpMyEdit_form_control(theForm)
                                         if ($this->col_has_values($k)) {                                          if ($this->col_has_values($k)) {
                                                 $type = 'string';                                                  $type = 'string';
                                         }                                          }
                                         /* if ( stristr($this->fdd[$fd]['options'],'L') or  
                                            !isset ($this->fdd[$fd]['options'])) */  
                                         if (! $this->displayed[$k]) {                                          if (! $this->displayed[$k]) {
                                                 continue;                                                  continue;
                                         }                                          }
                                         if ($this->fdd[$fd]['select'] == 'D' or $this->fdd[$fd]['select'] == 'M') {                                          if ($this->fdd[$fd]['select'] == 'D' or $this->fdd[$fd]['select'] == 'M') {
                                                 // Multiple fields processing                                                  // Multiple fields processing
                                                 // Default size is 2 and array required for values.                                                  // Default size is 2 and array required for values.
                                                 $multiple = $this->fdd[$fd]['select'] == 'M';                                                  $vals     = $this->set_values($k, array('*' => '*'), null, true);
                                                 $selected = $mi;                                                  $selected = $mi;
                                                 $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('*' => '*'))                                                  echo $this->htmlSelect($l.'_id', $css_class_name, $vals, $selected, $multiple);
                                                         : array('*' => '*') + (array) $this->fdd[$k]['values2'] + (array) $this->fdd[$k]['values'];  
                                                 echo $this->htmlSelect($l.'_id', $css_class_name, $x, $selected, $multiple);  
                                         } elseif ($this->fdd[$fd]['select'] == 'T') {                                          } elseif ($this->fdd[$fd]['select'] == 'T') {
                                                 // This is where we put the comparison selects                                                  // This is where we put the comparison selects
                                                 if (! $this->password($k) && ! $this->hidden($k)) {                                                  if (! $this->password($k) && ! $this->hidden($k)) {
Line 1800  function phpMyEdit_form_control(theForm)
Line 1813  function phpMyEdit_form_control(theForm)
                                                         if ($this->col_is_string($k)) {                                                          if ($this->col_is_string($k)) {
                                                                 // it's treated as a string                                                                  // it's treated as a string
                                                                 echo '<input class="',$css_class_name,'" value="';                                                                  echo '<input class="',$css_class_name,'" value="';
                                                                 echo htmlspecialchars($m),'" type="text" name="qf',$k,'"',$size_ml_props,'>';                                                                  echo htmlspecialchars(@$m),'" type="text" name="qf',$k,'"',$size_ml_props,'>';
                                                         } elseif ($this->col_is_date($k)) {                                                          } elseif ($this->col_is_date($k)) {
                                                                 // it's a date                                                                  // it's a date
                                                                 // it's treated as a string                                                                  // it's treated as a string
                                                                 echo '<input class="',$css_class_name,'" value="';                                                                  echo '<input class="',$css_class_name,'" value="';
                                                                 echo htmlspecialchars($m),'" type="text" name="qf',$k,'"',$size_ml_props,'>';                                                                  echo htmlspecialchars(@$m),'" type="text" name="qf',$k,'"',$size_ml_props,'>';
                                                         } elseif ($this->col_is_number($k)) {                                                          } elseif ($this->col_is_number($k)) {
                                                                 // it's a number                                                                  // it's a number
                                                                   $mc = in_array($mc, $comp_ops) ? $mc : '=';
                                                                 echo $this->htmlSelect($l.'_comp', $css_class_name, $comp_ops, $mc);                                                                  echo $this->htmlSelect($l.'_comp', $css_class_name, $comp_ops, $mc);
                                                                 // it's treated as a string                                                                  // it's treated as a string
                                                                 echo '<input class="',$css_class_name,'" value="';                                                                  echo '<input class="',$css_class_name,'" value="';
                                                                 echo htmlspecialchars($m),'" type="text" name="qf',$k,'"',$size_ml_props,'>';                                                                  echo htmlspecialchars(@$m),'" type="text" name="qf',$k,'"',$size_ml_props,'>';
                                                         } else {                                                          } else {
                                                                 // type is 'unknown' or not set, it's treated as a string                                                                  // type is 'unknown' or not set, it's treated as a string
                                                                 echo '<input class="',$css_class_name,'" value="';                                                                  echo '<input class="',$css_class_name,'" value="';
                                                                 echo htmlspecialchars($m),'" type="text" name="qf',$k,'"',$size_ml_props,'>';                                                                  echo htmlspecialchars(@$m),'" type="text" name="qf',$k,'"',$size_ml_props,'>';
                                                         }                                                          }
                                                 } else {                                                  } else {
                                                         echo '&nbsp;';                                                          echo '&nbsp;';
Line 1838  function phpMyEdit_form_control(theForm)
Line 1852  function phpMyEdit_form_control(theForm)
                         echo '<td class="',$css_class_name,'" colspan="',$sys_cols,'">';                          echo '<td class="',$css_class_name,'" colspan="',$sys_cols,'">';
                         echo '<a class="',$css_class_name,'" href="';                          echo '<a class="',$css_class_name,'" href="';
                         echo htmlspecialchars($this->get_server_var('PHP_SELF').'?fl='.$this->fl.'&fm='.$this->fm                          echo htmlspecialchars($this->get_server_var('PHP_SELF').'?fl='.$this->fl.'&fm='.$this->fm
                                         .$this->qfn.$this->cgi['persist']);                                          .'&qfn='.rawurlencode($this->qfn).$this->qfn.$this->cgi['persist']);
                         echo '">',$this->labels['Clear'],'</a></td>',"\n";                          echo '">',$this->labels['Clear'],'</a></td>',"\n";
                         echo '<td class="',$css_class_name,'" colspan="',$this->num_fields_displayed,'">';                          echo '<td class="',$css_class_name,'" colspan="',$this->num_fields_displayed,'">';
                         echo $this->labels['Sorted By'],': ',join(', ', $sort_fields_w),'</td></tr>',"\n";                          echo $this->labels['Sorted By'],': ',join(', ', $sort_fields_w),'</td></tr>',"\n";
Line 1854  function phpMyEdit_form_control(theForm)
Line 1868  function phpMyEdit_form_control(theForm)
                         echo '<td class="',$css_class_name,'" colspan="',$sys_cols,'">';                          echo '<td class="',$css_class_name,'" colspan="',$sys_cols,'">';
                         echo '<a class="',$css_class_name,'" href="';                          echo '<a class="',$css_class_name,'" href="';
                         echo htmlspecialchars($this->get_server_var('PHP_SELF').'?fl='.$this->fl.'&fm='.$this->fm                          echo htmlspecialchars($this->get_server_var('PHP_SELF').'?fl='.$this->fl.'&fm='.$this->fm
                                         .'&'.$this->get_sfn_cgi_vars().$this->cgi['persist']);                                          .'&qfn='.rawurlencode($this->qfn).'&'.$this->get_sfn_cgi_vars().$this->cgi['persist']);
                         echo '">',$this->labels['Clear'],'</a></td>',"\n";                          echo '">',$this->labels['Clear'],'</a></td>',"\n";
                         echo '<td class="',$css_class_name,'" colspan="',$this->num_fields_displayed,'">';                          echo '<td class="',$css_class_name,'" colspan="',$this->num_fields_displayed,'">';
                         echo $this->labels['Current Query'],': ',htmlspecialchars($text_query),'</td></tr>',"\n";                          echo $this->labels['Current Query'],': ',htmlspecialchars($text_query),'</td></tr>',"\n";
Line 2138  function phpMyEdit_form_control(theForm)
Line 2152  function phpMyEdit_form_control(theForm)
                         echo $this->get_origvars_html($this->cgi['persist']);                          echo $this->get_origvars_html($this->cgi['persist']);
                 }                  }
                 echo $this->get_origvars_html($this->get_sfn_cgi_vars());                  echo $this->get_origvars_html($this->get_sfn_cgi_vars());
                 echo $this->get_qf_hidden_fields();                  echo $this->get_origvars_html($this->qfn);
                 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="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="fl" value="'.$this->fl.'">'."\n";                  echo '<input type="hidden" name="fl" value="',$this->fl,'">',"\n";
                 if ($this->nav_up()) {                  if ($this->nav_up()) {
                         $this->display_record_buttons();                          $this->display_record_buttons();
                         echo '<hr class="',$this->getCSSclass('hr', 'up'),'">',"\n";                          echo '<hr class="',$this->getCSSclass('hr', 'up'),'">',"\n";
Line 2418  function phpMyEdit_form_control(theForm)
Line 2432  function phpMyEdit_form_control(theForm)
                 }                  }
                 $body    .= "\n--\r\n"; // \r is needed for signature separating                  $body    .= "\n--\r\n"; // \r is needed for signature separating
                 $body    .= "phpMyEdit\ninstant MySQL table editor and code generator\n";                  $body    .= "phpMyEdit\ninstant MySQL table editor and code generator\n";
                 $body    .= "http://www.platon.sk/projects/phpMyEdit/\n";                  $body    .= "http://www.platon.sk/projects/phpMyEdit/\n\n";
                 $subject  = @$this->notify['prefix'].$subject.' '.$this->db.'.'.$this->tb;                  $subject  = @$this->notify['prefix'].$subject.' '.$this->db.'.'.$this->tb;
                 $subject  = trim($subject); // just for sure                  $subject  = trim($subject); // just for sure
                 $wrap_w   = intval(@$this->notify['wrap']);                  $wrap_w   = intval(@$this->notify['wrap']);
Line 2486  function phpMyEdit_form_control(theForm)
Line 2500  function phpMyEdit_form_control(theForm)
                 $this->fds            = array();                  $this->fds            = array();
                 $this->displayed      = array();                  $this->displayed      = array();
                 $this->guidance       = false;                  $this->guidance       = false;
                 foreach ($this->fdd as $akey => $aval) {                  foreach (array_keys($this->fdd) as $key) {
                         if (preg_match('/^\d*$/', $akey)) { // skipping numeric keys                          if (preg_match('/^\d*$/', $key)) { // skipping numeric keys
                                 continue;                                  continue;
                         }                          }
                         $this->fds[$field_num] = $akey;                          $this->fds[$field_num] = $key;
                         /* We must use here displayed() function, because displayed[] array                          /* We must use here displayed() function, because displayed[] array
                            is not created yet. We will simultaneously create that array as well. */                             is not created yet. We will simultaneously create that array as well. */
                         if ($this->displayed[$field_num] = $this->displayed($field_num)) {                          if ($this->displayed[$field_num] = $this->displayed($field_num)) {
                                 $num_fields_displayed++;                                  $num_fields_displayed++;
                         }                          }
                         if (is_array(@$aval['values']) && (! @$aval['values']['table'])) {                          if (is_array(@$this->fdd[$key]['values']) && ! isset($this->fdd[$key]['values']['table'])) {
                                 $values = array();                                  foreach ($this->fdd[$key]['values'] as $val) {
                                 foreach ($aval['values'] as $val) {                                          $this->fdd[$key]['values2'][$val] = $val;
                                         $values[$val] = $val;  
                                 }                                  }
                                 $aval['values'] = $values;                                  unset($this->fdd[$key]['values']);
                         }                          }
                         $this->fdd[$field_num] = $aval;                          isset($this->fdd[$key]['help']) && $this->guidance = true;
                         @$aval['help'] && $this->guidance = true;                          $this->fdd[$field_num] = $this->fdd[$key];
                         $field_num++;                          $field_num++;
                 }                  }
                 if (0) {  
                         echo '<b>Displayed array:</b><pre>';  
                         var_dump($this->displayed);  
                         echo '</pre><hr>';  
                 }  
                 $this->num_fds              = $field_num;                  $this->num_fds              = $field_num;
                 $this->num_fields_displayed = $num_fields_displayed;                  $this->num_fields_displayed = $num_fields_displayed;
                 $this->key_num              = array_search($this->key, $this->fds);                  $this->key_num              = array_search($this->key, $this->fds);
Line 2783  function phpMyEdit_form_control(theForm)
Line 2791  function phpMyEdit_form_control(theForm)
                 if (isset($this->sw)) {                  if (isset($this->sw)) {
                         $this->sw == $this->labels['Search'] && $this->fl = 1;                          $this->sw == $this->labels['Search'] && $this->fl = 1;
                         $this->sw == $this->labels['Hide']   && $this->fl = 0;                          $this->sw == $this->labels['Hide']   && $this->fl = 0;
                         $this->sw == $this->labels['Clear']  && $this->fl = 0;                          //$this->sw == $this->labels['Clear']  && $this->fl = 0;
                 }                  }
                 // Specific $fdd modifications depending on performed action                  // Specific $fdd modifications depending on performed action
                 $this->recreate_fdd();                  $this->recreate_fdd();
                 // Extract SQL Field Names and number of fields                  // Extract SQL Field Names and number of fields
                 $this->recreate_displayed();                  $this->recreate_displayed();
                 // Clear action  
                 if ($this->sw == $this->labels['Clear']) {  
                         for ($k = 0; $k < $this->num_fds; $k++) {  
                                 $this->cgi['overwrite']["qf$k"]         = '';  
                                 $this->cgi['overwrite']["qf$k".'_comp'] = '';  
                                 $this->cgi['overwrite']["qf$k".'_id']   = '';  
                         }  
                 }  
                 // Constants                  // Constants
                 $this->sql_aggrs = array(                  $this->sql_aggrs = array(
                                 ''      => '',                                  ''      => '',
Line 2864  function phpMyEdit_form_control(theForm)
Line 2864  function phpMyEdit_form_control(theForm)
                 $opts['execute'] && $this->execute();                  $opts['execute'] && $this->execute();
         } /* }}} */          } /* }}} */
   
 } // end of phpMyEdit class  }
   
 /* Modeline for ViM {{{  /* Modeline for ViM {{{
  * vim:set ts=4:   * vim:set ts=4:

Legend:
Removed from v.1.57  
changed lines
  Added in v.1.58

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