Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Saturday, April 20, 2024

Diff for phpMyEdit/phpMyEdit.class.php between version 1.43 and 1.44

version 1.43, 2003/01/03 14:33:36 version 1.44, 2003/01/12 14:58:38
Line 19 
Line 19 
  * http://www.platon.sk/projects/phpMyEdit/   * http://www.platon.sk/projects/phpMyEdit/
  */   */
   
 /* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.42 2002/12/24 16:47:36 nepto Exp $ */  /* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.43 2003/01/03 14:33:36 nepto Exp $ */
   
 /*      phpMyEdit intro {{{ */  /*      phpMyEdit intro {{{ */
 /*  /*
Line 310  class phpMyEdit
Line 310  class phpMyEdit
                 $values2 = $this->fdd[$field_num]['values2'];                  $values2 = $this->fdd[$field_num]['values2'];
                 is_array($values2) && $values = $values2 + $values;                  is_array($values2) && $values = $values2 + $values;
                 is_array($prepend) && $values = $prepend + $values;                  is_array($prepend) && $values = $prepend + $values;
                 /* old wrong prepending -- REMOVE ME at December 2002  
                 if (is_array($prepend)) {  
                         $values[$prepend[0]] = $prepend[1];  
                 }  
                 */  
                 return $values;                  return $values;
         } /* }}} */          } /* }}} */
   
Line 756  class phpMyEdit
Line 751  class phpMyEdit
                 if ($this->add_operation() || $this->change_operation()) {                  if ($this->add_operation() || $this->change_operation()) {
                         $required_ar = array();                          $required_ar = array();
                         for ($k = 0; $k < $this->num_fds; $k++) {                          for ($k = 0; $k < $this->num_fds; $k++) {
                                 if ($this->displayed[$k]                                  if ($this->displayed[$k] && $this->fdd[$k]['required']) {
                                                 && $this->fdd[$k]['required']  
                                                 && ! $this->col_has_values($k)) {  
                                         $required_ar[] = $k;                                          $required_ar[] = $k;
                                         if (isset($this->fdd[$k]['regex']['js'])) {                                          if (isset($this->fdd[$k]['regex']['js'])) {
                                                 /* TODO: Use a javascript regex to validate it */                                                  /* TODO: Use a javascript regex to validate it */
Line 769  class phpMyEdit
Line 762  class phpMyEdit
                         if (count($required_ar) > 0) {                          if (count($required_ar) > 0) {
                                 echo '<script type="text/javascript"><!--'."\n";                                  echo '<script type="text/javascript"><!--'."\n";
                                 echo '                                  echo '
 function form_control(theForm)  function phpMyEdit_form_control(theForm)
 {'."\n";  {'."\n";
                                 foreach ($required_ar as $field_num) {                                  foreach ($required_ar as $field_num) {
                                         echo '                                          if ($this->col_has_values($field_num)) {
         if (theForm.'.$this->fds[$field_num].'.value.length == 0) {                                                  $condition = '.selectedIndex == -1';
                                                   $multiple  = $this->fdd[$field_num]['select'] == 'M'
                                                           || $this->col_is_set($field_num);
                                           } else {
                                                   $condition = '.value.length == 0';
                                                   $multiple  = false;
                                           }
   
                                           /* Multiple selects have their name like ``name[]''.
                                              It is not possible to work with it directly, because
                                              theForm.name[].something will result into JavaScript
                                              syntax error. Following search algorithm is provided
                                              as a workaround for this.
                                            */
   
                                           if ($multiple) {
                                                   echo '
           multiple_select = null;
           for (i = 0; i < theForm.length; i++) {
                   if (theForm.elements[i].name == "'.$this->fds[$field_num].'[]") {
                           multiple_select = theForm.elements[i];
                           break;
                   }
           }
           if (multiple_select != null && multiple_select'.$condition.') {
                   alert("'.$this->labels['Please enter'].' '.$this->fdd[$field_num]['name'].'.");
                   return false;
           }'."\n";
                                           } else {
                                                   echo '
           if (theForm.'.$this->fds[$field_num].$condition.') {
                 alert("'.$this->labels['Please enter'].' '.$this->fdd[$field_num]['name'].'.");                  alert("'.$this->labels['Please enter'].' '.$this->fdd[$field_num]['name'].'.");
                 theForm.'.$this->fds[$field_num].'.focus();                  theForm.'.$this->fds[$field_num].'.focus();
                 return false;                  return false;
         }'."\n";          }'."\n";
                                           }
                                 }                                  }
                                 echo '                                  echo '
         theForm.submit();          theForm.submit();
         return true;          return true;
 }'."\n\n";  }'."\n\n";
                                 echo '// --></script>' . "\n";                                  echo '// --></script>' . "\n";
                                 echo '<form action="'.$page_name.'" method="POST" onSubmit="return form_control(this);">'."\n";                                  echo '<form action="'.$page_name.'" method="POST" onSubmit="return phpMyEdit_form_control(this);">'."\n";
                                 return true;                                  return true;
                         }                          }
                 }                  }
Line 799  function form_control(theForm)
Line 823  function form_control(theForm)
   
         function display_add_record() /* {{{ */          function display_add_record() /* {{{ */
         {          {
                 if (0) { // XXX: WTF?  
                         echo '<tr>'."\n";  
                         echo '<th>Field</th>'."\n";  
                         echo '<th>Value</th>'."\n";  
                         if ($this->guidance)  
                                 echo '<th>Guidance</th>'."\n";  
                         echo '</tr>'."\n";  
                 }  
                 for ($k = 0; $k < $this->num_fds; $k++) {                  for ($k = 0; $k < $this->num_fds; $k++) {
                         if ($this->hidden($k)) {                          if ($this->hidden($k)) {
                                 echo $this->htmlHidden($this->fds[$k], $this->htmlDisplay($this->fdd[$k],                                  echo $this->htmlHidden($this->fds[$k], $this->htmlDisplay($this->fdd[$k],
Line 820  function form_control(theForm)
Line 836  function form_control(theForm)
                         echo '<td>'.$this->fdd[$k]['name'].'</td>'."\n";                          echo '<td>'.$this->fdd[$k]['name'].'</td>'."\n";
                         if ($this->col_has_values($k) && !$this->readonly($k)) {                          if ($this->col_has_values($k) && !$this->readonly($k)) {
                                 echo '<td>'."\n";                                  echo '<td>'."\n";
                                   $multiple = $this->fdd[$k]['select'] == 'M' || $this->col_is_set($k);
                                 $vals = isset($this->fdd[$k]['values']['table'])                                  $vals = isset($this->fdd[$k]['values']['table'])
                                         ? $this->set_values_from_table($k)                                          ? $this->set_values_from_table($k)
                                         : (array) $this->fdd[$k]['values2'] + (array) $this->fdd[$k]['values'];                                          : (array) $this->fdd[$k]['values2'] + (array) $this->fdd[$k]['values'];
                                 echo $this->htmlSelect($this->fds[$k], $vals, '', $this->col_is_set($k));                                  echo $this->htmlSelect($this->fds[$k], $vals, '', $multiple);
                                 echo '</td>'."\n";                                  echo '</td>'."\n";
                         } elseif (isset ($this->fdd[$k]['textarea']) && !$this->readonly($k)) {                          } elseif (isset ($this->fdd[$k]['textarea']) && !$this->readonly($k)) {
                                 echo '<td><textarea ';                                  echo '<td><textarea ';
Line 963  function form_control(theForm)
Line 980  function form_control(theForm)
                 echo '<td>'."\n";                  echo '<td>'."\n";
   
                 if ($this->col_has_values($k) && !$this->readonly($k)) {                  if ($this->col_has_values($k) && !$this->readonly($k)) {
                           $multiple = $this->fdd[$k]['select'] == 'M' || $this->col_is_set($k);
                         $vals = isset($this->fdd[$k]['values']['table'])                          $vals = isset($this->fdd[$k]['values']['table'])
                                 ? $this->set_values_from_table($k)                                  ? $this->set_values_from_table($k)
                                 : (array) $this->fdd[$k]['values2'] + (array) $this->fdd[$k]['values'];                                  : (array) $this->fdd[$k]['values2'] + (array) $this->fdd[$k]['values'];
                         echo $this->htmlSelect($this->fds[$k], $vals, $row["qf$k"], $this->col_is_set($k));                          echo $this->htmlSelect($this->fds[$k], $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 name="'.$this->fds[$k].'"';                          echo '<textarea name="'.$this->fds[$k].'"';
                         // rows attr                          // rows attr
Line 1097  function form_control(theForm)
Line 1115  function form_control(theForm)
                         $selected = $selected === null ? array() : array($selected);                          $selected = $selected === null ? array() : array($selected);
                 }                  }
   
                 //$keys = array_keys($kv_array);  
                 //debug_var('selected',$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).'"';
Line 1109  function form_control(theForm)
Line 1124  function form_control(theForm)
                                 $found = true;                                  $found = true;
                         }                          }
                         $ret .= '>'.htmlspecialchars(urldecode(strip_tags($value))).'</option>'."\n";                          $ret .= '>'.htmlspecialchars(urldecode(strip_tags($value))).'</option>'."\n";
                         //debug_var("array search $key",is_numeric(array_search($key,$selected)));  
                 }                  }
                 $ret .= '</select>';                  $ret .= '</select>';
                 return $ret;                  return $ret;
Line 1398  function form_control(theForm)
Line 1412  function form_control(theForm)
         } /* }}} */          } /* }}} */
   
         /*          /*
          * Display buttons at top and bottom of page - sparky           * Display buttons at top and bottom of page
          */           */
         function display_list_table_buttons($total_recs) /* {{{ */          function display_list_table_buttons($total_recs) /* {{{ */
         {          {
Line 1461  function form_control(theForm)
Line 1475  function form_control(theForm)
         } /* }}} */          } /* }}} */
   
         /*          /*
          * Display buttons at top and bottom of page - sparky           * Display buttons at top and bottom of page
          */           */
         function display_record_buttons() /* {{{ */          function display_record_buttons() /* {{{ */
         {          {
Line 1750  function form_control(theForm)
Line 1764  function form_control(theForm)
                                 }                                  }
                                 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 - default size is 2 and array required for values                                           * Multiple fields processing
                                            * Default size is 2 and array required for values.
                                          */                                           */
                                         $multiple = $this->fdd[$fd]['select'] == 'M';                                          $multiple = $this->fdd[$fd]['select'] == 'M';
                                         $selected = $m;                                          $selected = $m;

Legend:
Removed from v.1.43  
changed lines
  Added in v.1.44

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