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.22 and 1.23

version 1.22, 2002/10/29 16:54:47 version 1.23, 2002/10/30 11:49:56
Line 19 
Line 19 
  * http://www.platon.sk/projects/phpMyEdit/   * http://www.platon.sk/projects/phpMyEdit/
  */   */
   
 /* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.21 2002/10/29 16:17:57 nepto Exp $ */  /* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.22 2002/10/29 16:54:47 nepto Exp $ */
   
 /*      phpMyEdit intro {{{ */  /*      phpMyEdit intro {{{ */
 /*  /*
Line 1349  return true;
Line 1349  return true;
                 // TODO: classify this table and cells                  // TODO: classify this table and cells
                 echo '<table border=0 cellpadding=0 cellspacing=0 width="100%" style="border:0;padding:0;">';                  echo '<table border=0 cellpadding=0 cellspacing=0 width="100%" style="border:0;padding:0;">';
                 echo '<tr><td align=left style="text-align:left;border:0;padding:0;" nowrap>' . "\n";                  echo '<tr><td align=left style="text-align:left;border:0;padding:0;" nowrap>' . "\n";
                 if ($this->fm > 0 && ! $listall) {                  $disabled = ($this->fm > 0 && ! $listall) ? '' : ' disabled';
                         echo '<input type="submit" name="prev" value="'.$this->labels['Prev'].'">&nbsp;';                  echo '<input'.$disabled.' type="submit" name="'.ltrim($disabled).'prev" value="'
                 } else {                          .$this->labels['Prev'].'">&nbsp;';
                         echo '<input disabled type="submit" name="dprev" value="'.$this->labels['Prev'].'">&nbsp;';  
                 }  
                 if ($this->add_enabled ()) {                  if ($this->add_enabled ()) {
                         echo '<input type="submit" name="operation" value="'.$this->labels['Add'].'">&nbsp;';                          echo '<input type="submit" name="operation" value="'.$this->labels['Add'].'">&nbsp;';
                 }                  }
Line 1381  return true;
Line 1379  return true;
                         } // if else                          } // if else
                 }                  }
   
                   $disabled = ($this->fm + $this->inc < $total_recs && ! $listall) ? '' : ' disabled';
                 if ($this->fm + $this->inc < $total_recs && ! $listall) {                  echo '<input'.$disabled.' type="submit" name="'.ltrim($disabled).'next" value="'
                         echo '<input type="submit" name="next" value="'.$this->labels['Next'].'">';                          .$this->labels['Next'].'">';
                 } else {  
                         echo '<input disabled type="submit" name="dnext" value="'.$this->labels['Next'].'">';  
                 }  
   
                 // Message is now written here                  // Message is now written here
                 echo '</td><td align=center style="text-align:center;border:0;padding:0;" nowrap><b>'.$this->message.'</b></td>';                  echo '</td><td align=center style="text-align:center;border:0;padding:0;" nowrap><b>'.$this->message.'</b></td>';
Line 2573  echo '<h5>'.mysql_affected_rows ().' '.$
Line 2568  echo '<h5>'.mysql_affected_rows ().' '.$
         } /* }}} */          } /* }}} */
   
         /*          /*
          * The workhorse           * Recreate functions
          */           */
         function execute() /* {{{ */          function recreate_fdd() /* {{{ */
         {          {
                 set_magic_quotes_runtime(0); // let's do explicit quoting ... it's safer                  // TODO: one level deeper browsing
   
                 // XXX fix this to use col_is_[type]                  $action_letter = 'L'; // list by default
                 if (in_array($this->key_type,                  $this->filter_operation() && $action_letter = 'F';
                                         array('string','blob','date','time','datetime','timestamp','year'))) {                  $this->view_operation()   && $action_letter = 'V';
                         $this->key_delim = '"';                  $this->delete_operation() && $action_letter = 'D';
                 } else {                  $this->add_operation()    && $action_letter = 'A';
                         $this->key_delim = '';                  $this->change_operation() && $action_letter = 'C';
                         $this->rec = intval($this->rec); // Fixed #523390 [7/8/2002] [1/2]                  $this->copy_operation()   && $action_letter = 'P';
   
                   // Restore backups (if exists)
                   foreach (array_keys($this->fdd) as $column) {
                           foreach (array_keys($this->fdd[$column]) as $col_option) {
                                   if ($col_option[strlen($col_option) - 1] != '~')
                                           continue;
   
                                   $this->fdd[$column][substr($col_option, 0, strlen($col_option) - 1)]
                                           = $this->fdd[$column][$col_option];
                                   unset($this->fdd[$column][$col_option]);
                           }
                 }                  }
   
                 $this->gather_query_opts();                  foreach (array_keys($this->fdd) as $column) {
                 $this->gather_get_vars();                          foreach (array_keys($this->fdd[$column]) as $col_option) {
                 $this->gather_post_vars();                                  if (! strchr($col_option, '|'))
                 $this->unify_opts();                                          continue;
                                   $col_ar = explode('|', $col_option, 2);
                                   if (! stristr($col_ar[1], $action_letter))
                                           continue;
   
                 //  DEBUG -  uncomment to enable                                  // Make field backups
                 /*                                  $this->fdd[$column][$col_ar[0] .'~'] = $this->fdd[$column][$col_ar[0]];
                 //phpinfo();                                  $this->fdd[$column][$col_option.'~'] = $this->fdd[$column][$col_option];
                 $this->print_get_vars();                                  // Set particular field
                 $this->print_post_vars();                                  $this->fdd[$column][$col_ar[0]] = $this->fdd[$column][$col_option];
                 $this->print_vars();                                  unset($this->fdd[$column][$col_option]);
                 echo "<pre>query opts:\n";                          }
                 echo print_r($this->query_opts);                  }
                 echo "</pre>\n";          } /* }}} */
                 echo "<pre>get vars:\n";  
                 echo print_r($this->get_opts);          function recreate_displayed($sort_field = '') /* {{{ */
                 echo "</pre>\n";          {
                  */                  $field_num            = 0;
                   $num_fields_displayed = 0;
                   $this->fds            = array();
                   $this->displayed      = array();
                   $this->guidance       = false;
   
                   foreach ($this->fdd as $akey => $aval) {
                           if (preg_match('/^\d*$/', $akey)) /* skipping numeric keys */
                                   continue;
   
                           $this->fds[$field_num] = $akey;
                           if ($sfn == '' && $akey == $sort_field) {
                                   $this->sfn = $field_num;
                           }
                           /* We must use here displayed() function, because displayed[] array
                              is not created yet. We will simultaneously create that array as well. */
                           if ($this->displayed[$field_num] = $this->displayed($field_num)) {
                                   $num_fields_displayed++;
                           }
                           /* I *really* want to know what does this foreach() do!
                              -- Nepto [17/10/2002] */
                           if (is_array($aval['values']) && (! $aval['values']['table'])) {
                                   $values = array();
                                   foreach ($aval['values'] as $val) {
                                           $values[$val] = $val;
                                   }
                                   $aval['values'] = $values;
                           }
                           $this->fdd[$field_num] = $aval;
                           $aval['help'] && $this->guidance = true;
                           $field_num++;
                   }
                   if (0) {
                           echo '<b>Displayed array:</b><pre>';
                           var_dump($this->displayed);
                           echo '</pre><hr>';
                   }
   
                   $this->num_fds              = $field_num;
                   $this->num_fields_displayed = $num_fields_displayed;
                   $this->key_num              = array_search($this->key, $this->fds);
           } /* }}} */
   
           /*
            * Database connection function
            */
           function connect() /* {{{ */
           {
                 if (!isset($this->db)) {                  if (!isset($this->db)) {
                         echo '<h1>phpMyEdit: no database defined</h1>'."\n";                          echo '<h1>phpMyEdit: no database defined</h1>'."\n";
                         return;                          return;
Line 2621  echo '<h5>'.mysql_affected_rows ().' '.$
Line 2676  echo '<h5>'.mysql_affected_rows ().' '.$
                         echo '<h1>phpMyEdit: could not connect to MySQL</h1>'."\n";                          echo '<h1>phpMyEdit: could not connect to MySQL</h1>'."\n";
                         return;                          return;
                 }                  }
           } /* }}} */
   
           /*
            * The workhorse
            */
           function execute() /* {{{ */
           {
                   //  DEBUG -  uncomment to enable
                   /*
                   //phpinfo();
                   $this->print_get_vars();
                   $this->print_post_vars();
                   $this->print_vars();
                   echo "<pre>query opts:\n";
                   echo print_r($this->query_opts);
                   echo "</pre>\n";
                   echo "<pre>get vars:\n";
                   echo print_r($this->get_opts);
                   echo "</pre>\n";
                    */
   
                   /* Database connection*/
                   $this->connect();
   
                 /*                  /*
                  * ======================================================================                   * ======================================================================
Line 2793  echo '<h5>'.mysql_affected_rows ().' '.$
Line 2871  echo '<h5>'.mysql_affected_rows ().' '.$
                  * Specific $fdd modifications depending on performed action                   * Specific $fdd modifications depending on performed action
                  */                   */
   
                 $action_letter = 'L'; // list by default                  $this->recreate_displayed();
                 $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->recreate_displayed();
                 $field_num = 0;  
                 $num_fields_displayed = 0;  
                 $this->fds = array();  
                 foreach ($this->fdd as $akey => $aval) {  
                         $this->fds[] = $akey;  
                         if ($sfn == '' && $akey == $sort_field) {  
                                 $this->sfn = $field_num;  
                         }  
                         /* We must use here displayed() function, because displayed[] array  
                            is not created yet. We will simultaneously create that array as well. */  
                         if ($this->displayed[$field_num] = $this->displayed($field_num)) {  
                                 $num_fields_displayed++;  
                         }  
                         /* I *really* want to know what does this foreach() do!  
                            -- Nepto [17/10/2002] */  
                         if (is_array($aval['values']) && (! $aval['values']['table'])) {  
                                 $values = array();  
                                 foreach ($aval['values'] as $val) {  
                                         $values[$val] = $val;  
                                 }  
                                 $aval['values'] = $values;  
                         }  
                         $this->fdd[$field_num] = $aval;  
                         $aval['help'] && $this->guidance = true;  
                         $field_num++;  
                 }  
                 if (0) {  
                         echo '<b>Displayed array:</b><pre>';  
                         var_dump($this->displayed);  
                         echo '</pre><hr>';  
                 }  
   
                 $this->num_fds = $field_num;  
                 $this->num_fields_displayed = $num_fields_displayed;  
                 $this->key_num = array_search($this->key, $this->fds);  
   
                 /*                  /*
                  * Clear action                   * Clear action
Line 2871  echo '<h5>'.mysql_affected_rows ().' '.$
Line 2894  echo '<h5>'.mysql_affected_rows ().' '.$
                  */                   */
   
                 // code to use this is commented out                  // code to use this is commented out
                 $this->sql_aggrs = array(''=>'','sum'=>'Total','avg'=>'Average','min'=>'Minimum','max'=>'Maximum','count'=>'Count');                  $this->sql_aggrs = array(
                                   ''      => '',
                                   'sum'   => 'Total',
                                   'avg'   => 'Average',
                                   'min'   => 'Minimum',
                                   'max'   => 'Maximum',
                                   'count' => 'Count');
   
                 // to support quick type checking                  // to support quick type checking
                 $this->stringTypes = array('string','blob','set','enum');                  $this->stringTypes = array('string','blob','set','enum');
Line 2908  echo '<h5>'.mysql_affected_rows ().' '.$
Line 2937  echo '<h5>'.mysql_affected_rows ().' '.$
                    Also note, that this is currently unused. */                     Also note, that this is currently unused. */
                 $this->development = 0;                  $this->development = 0;
   
                   /*
                    * Preparing some others values
                    * (this was moved from execute() method)
                    */
                   set_magic_quotes_runtime(0); // let's do explicit quoting ... it's safer
   
                   // XXX fix this to use col_is_[type]
                   if (in_array($this->key_type,
                                           array('string','blob','date','time','datetime','timestamp','year'))) {
                           $this->key_delim = '"';
                   } else {
                           $this->key_delim = '';
                           $this->rec = intval($this->rec); // Fixed #523390 [7/8/2002] [1/2]
                   }
   
                   $this->gather_query_opts();
                   $this->gather_get_vars();
                   $this->gather_post_vars();
                   $this->unify_opts();
   
                 // Call to Action                  // Call to Action
                 // Moved this from the setup.php generated file to here                  // Moved this from the setup.php generated file to here
                 !isset($opts['execute']) && $opts['execute'] = 1;                  !isset($opts['execute']) && $opts['execute'] = 1;

Legend:
Removed from v.1.22  
changed lines
  Added in v.1.23

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