Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Streda, 14. október 2026

Rozdiely pre phpMyEdit/extensions/phpMyEdit-report.class.php medzi verziami 1.3 a 1.4

verzia 1.3, 2003/01/03 14:33:37 verzia 1.4, 2003/05/01 21:42:48
Riadok 17 
Riadok 17 
  * http://www.platon.sk/projects/phpMyEdit/   * http://www.platon.sk/projects/phpMyEdit/
  */   */
   
 /* $Platon: phpMyEdit/extensions/phpMyEdit-report.class.php,v 1.2 2002/12/02 23:11:36 nepto Exp $ */  /* $Platon: phpMyEdit/extensions/phpMyEdit-report.class.php,v 1.3 2003/01/03 14:33:37 nepto Exp $ */
   
 /* Extension TODO:  /* Extension TODO:
   
    - added labels to language files  
    - use button for "Select fields"  
    - allow user to enable/disable particular field in reporting (maybe 'X' flag     - allow user to enable/disable particular field in reporting (maybe 'X' flag
      for indicating that field is forbidden is good idea)       for indicating that field is forbidden is good idea)
    - make extension work with register globals turned off (if register_globals     - support for ['help'] in select fields screen
      are turned off, at selected fields preserving does not work; fix this ASAP)     - make extension's option for selecting "Select fields" link or button
    - use table name in cookie names (this will save preferences for various  
      report pages)  
  */   */
   
 require_once dirname(__FILE__).'/../phpMyEdit.class.php';  require_once dirname(__FILE__).'/../phpMyEdit.class.php';
   
 class phpMyEdit_report extends phpMyEdit  class phpMyEdit_report extends phpMyEdit
 {  {
         // Extension options array  
         // var $ext;  
   
         function phpMyEdit_report($opts) /* {{{ */          function phpMyEdit_report($opts) /* {{{ */
         {          {
                 $opts['options'] = 'L';                  $opts['options'] = 'L';
   
                 $execute = 1;                  $execute = 1;
                 isset($opts['execute']) && $execute = $opts['execute'];                  isset($opts['execute']) && $execute = $opts['execute'];
                 $opts['execute'] = 0;                  $opts['execute'] = 0;
                 parent::phpMyEdit($opts);                  parent::phpMyEdit($opts);
   
                 // $this->ext = $opts['ext'];  
   
                 $execute && $this->execute();                  $execute && $this->execute();
         } /* }}} */          } /* }}} */
   
Riadok 61  class phpMyEdit_report extends phpMyEdit
Riadok 51  class phpMyEdit_report extends phpMyEdit
                 return $ret;                  return $ret;
         } /* }}} */          } /* }}} */
   
         function display_report_selection_buttons() /* {{{ */          function get_cgi_cookie_var($name, $default_value = null) /* {{{ */
         {          {
                 // TODO: classify                  $ret = $this->get_cgi_var($name, null);
                 echo '<table border=0 cellpadding=0 cellspacing=0 width="100%" style="border:0;padding:0;">';                  if ($ret === null) {
                 echo '<tr><td align=left style="text-align:left;border:0;padding:0;" nowrap>' . "\n";                          global $HTTP_COOKIE_VARS;
                 echo '<input type=submit name=prepare_filter value="'.$this->labels['Make report'].'">'."\n";                          $ret = @$HTTP_COOKIE_VARS[$name.'_'.$this->tb.'_cookie'];
                 echo '</td></tr></table>'."\n";                          if (! isset($ret)) {
                                   $ret = $default_value;
                           }
                   }
                   return $ret;
           } /* }}} */
   
           function display_list_table_buttons($total_recs, $position) /* {{{ */
           {       /* This is mostly copy/paste from core class. */
                   $listall = $this->inc <= 0; // Are we doing a listall?
                   echo '<table class="',$this->getCSSclass('navigation', $position),'">',"\n";
                   echo '<tr class="',$this->getCSSclass('navigation', $position),'">',"\n";
                   echo '<td class="',$this->getCSSclass('buttons', $position),'">',"\n";
                   echo '<input class="',$this->getCSSclass('fields-select', $position);
                   echo '" type="submit" name="fields_select" value="',$this->labels['Select fields'],'">&nbsp;';
                   // Note that <input disabled isn't valid HTML, but most browsers support it
                   $disabled = ($this->fm > 0 && ! $listall) ? '' : ' disabled';
                   echo '<input',$disabled,' class="',$this->getCSSclass('prev', $position);
                   echo '" type="submit" name="',ltrim($disabled),'prev" value="',$this->labels['Prev'],'">&nbsp;';
                   $disabled = ($this->fm + $this->inc < $total_recs && ! $listall) ? '' : ' disabled';
                   echo '<input',$disabled,' class="',$this->getCSSclass('next', $position);
                   echo '" type="submit" name="',ltrim($disabled),'next" value="',$this->labels['Next'],'">';
                   // Message is now written here
                   echo '</td>',"\n";
                   if (strlen(@$this->message) > 0) {
                           echo '<td class="',$this->getCSSclass('message', $position),'">',$this->message,'</td>',"\n";
                   }
                   // Display page and records statistics
                   echo '<td class="',$this->getCSSclass('stats', $position),'">',"\n";
                   if ($listall) {
                           echo $this->labels['Page'],':&nbsp;1&nbsp;',$this->labels['of'],'&nbsp;1';
                   } else {
                           echo $this->labels['Page'],':&nbsp;',($this->fm / $this->inc) + 1;
                           echo '&nbsp;',$this->labels['of'],'&nbsp;',max(1, ceil($total_recs / abs($this->inc)));
                   }
                   echo '&nbsp; ',$this->labels['Records'],':&nbsp;',$total_recs;
                   echo '</td></tr></table>',"\n";
           } /* }}} */
   
           function display_report_selection_buttons($position) /* {{{ */
           {
                   echo '<table class="',$this->getCSSclass('navigation', $position),'">',"\n";
                   echo '<tr class="',$this->getCSSclass('navigation', $position),'">',"\n";
                   echo '<td class="',$this->getCSSclass('buttons', $position),'">',"\n";
                   echo '<input class="',$this->getCSSclass('make-report', $position);
                   echo '" type="submit" name="prepare_filter" value="',$this->labels['Make report'],'">',"\n";
                   echo '</td></tr></table>',"\n";
           } /* }}} */
   
           function get_select_fields_link() /* {{{ */
           {
                   $link = '<a href="'.htmlspecialchars($this->page_name).'?fields_select=1';
                   for ($i = 0; $i < count($table_cols); $i++) {
                           $varname = 'qf'.$i;
                           $value   = $this->get_cgi_cookie_var($varname);
                           if (! empty($value)) {
                                   $link .= htmlspecialchars(
                                                   '&'.rawurlencode($varname).
                                                   '='.rawurlencode($value));
                           }
                   }
                   $link .= htmlspecialchars($this->cgi['persist']);
                   $link .= '">'.$this->labels['Select fields'].'</a>';
                   return $link;
         } /* }}} */          } /* }}} */
   
         function execute() /* {{{ */          function execute() /* {{{ */
         {          {
                 global $HTTP_GET_VARS;                  global $HTTP_GET_VARS;
                 global $HTTP_POST_VARS;                  global $HTTP_POST_VARS;
                 global $HTTP_SERVER_VARS;  
                   /*
                    * Extracting field names
                    */
   
                 $table_cols     = array();                  $table_cols     = array();
                 $all_table_cols = array();                  $all_table_cols = array();
Riadok 82  class phpMyEdit_report extends phpMyEdit
Riadok 138  class phpMyEdit_report extends phpMyEdit
                 if ($this->connect() == false) {                  if ($this->connect() == false) {
                         return false;                          return false;
                 }                  }
   
                 $query_parts = array(                  $query_parts = array(
                                 'type'   => 'select',                                  'type'   => 'select',
                                 'select' => '*',                                  'select' => '*',
Riadok 90  class phpMyEdit_report extends phpMyEdit
Riadok 145  class phpMyEdit_report extends phpMyEdit
                                 'limit'  => '1');                                  'limit'  => '1');
                 $result = $this->myquery($this->query_make($query_parts), __LINE__);                  $result = $this->myquery($this->query_make($query_parts), __LINE__);
                 $all_table_cols = array_keys(@mysql_fetch_array($result, MYSQL_ASSOC));                  $all_table_cols = array_keys(@mysql_fetch_array($result, MYSQL_ASSOC));
   
                 if (count($all_table_cols) <= 0) {                  if (count($all_table_cols) <= 0) {
                         $this->error('database fetch error');                          $this->error('database fetch error');
                         return false;                          return false;
                 }                  }
   
                 foreach (array_keys($this->fdd) as $field_name) {                  foreach (array_keys($this->fdd) as $field_name) {
                         if (preg_match('/^\d*$/', $field_name))                          if (preg_match('/^\d*$/', $field_name))
                                 continue;                                  continue;
Riadok 103  class phpMyEdit_report extends phpMyEdit
Riadok 156  class phpMyEdit_report extends phpMyEdit
                                 $table_cols[$field_name] = mysql_field_len($result, $idx);                                  $table_cols[$field_name] = mysql_field_len($result, $idx);
                 }                  }
                 @mysql_free_result($result);                  @mysql_free_result($result);
                   unset($all_table_cols);
   
                 if (0) { // DEBUG                  /*
                         echo "<pre>";                   * Preparing variables
                         var_dump($table_cols);                   */
                         echo "</pre>";  
                         echo "<pre>";  
                         var_dump($all_table_cols);  
                         echo "</pre>";  
                 }  
   
                 unset($all_table_cols);                  $fields_select  = $this->get_cgi_var('fields_select');
                 $force_fields_select = false;                  $filter         = $this->get_cgi_var('filter');
                 $filter              = $this->get_cgi_var('filter');                  $prepare_filter = $this->get_cgi_var('prepare_filter');
                 $prepare_filter      = $this->get_cgi_var('prepare_filter');                  $this->inc      = intval($this->get_cgi_cookie_var('inc'));
                   $force_select   = true;
                 if (isset($filter) || isset($prepare_filter)) {                  $none_displayed = true;
                         $force_fields_select = true;                  $expire_time    = time() + (3600 * 24 * 30 * 12 * 5); // five years
                         foreach (array_merge(array('@inc'), array_keys($table_cols)) as $col) {                  $headers_sent   = @headers_sent();
                                 $var = ($col[0] == '@' ? substr($col, 1) : "have_$col");  
                                 global $$var;                  foreach (array_merge(array('@inc'), array_keys($table_cols)) as $col) {
                           $varname = ($col[0] == '@' ? substr($col, 1) : 'have_'.$col);
                                 if (isset($HTTP_POST_VARS[$var]) || isset($HTTP_GET_VARS[$var])) {                          if (isset($HTTP_POST_VARS[$varname]) || isset($HTTP_GET_VARS[$varname])) {
                                         $$var = $HTTP_POST_VARS[$var];                                  $value = $HTTP_POST_VARS[$varname];
                                   if (isset($HTTP_GET_VARS[$varname])) {
                                         if (isset($HTTP_GET_VARS[$var]))                                          $value = $HTTP_GET_VARS[$varname];
                                                 $$var = $HTTP_GET_VARS[$var];                                  }
                                   if ($varname != 'inc' && ! empty($value)) {
                                         session_register($var);                                          $force_select = false;
   
                                         if ($var != 'inc' && ! empty($$var))  
                                                 $force_fields_select = false;  
   
                                 } else {  
                                         if (session_is_registered($var))  
                                                 session_unregister($var);  
                                         unset($$var);  
                                 }                                  }
                                   $headers_sent || setcookie($varname.'_'.$this->tb.'_cookie', $value, $expire_time);
                                   $this->cgi['persist'] .= '&'.urlencode($varname);
                                   $this->cgi['persist'] .= '='.urlencode($value);
                           } else {
                                   $headers_sent || setcookie($varname.'_'.$this->tb.'_cookie', '', time() - 10000);
                         }                          }
                   }
   
                 } else {                  $i = -1;
                         session_start();                  foreach (array_keys($this->fdd) as $key) {
                           $i++;
                           if (preg_match('/^\d*$/', $key))
                                   continue;
                           $varname = 'have_'.$key;
                           $value   = @$this->get_cgi_cookie_var($varname, '');
                           $options = @$value ? 'LV' : '';
                           $this->fdd[$i]['options']   = $options;
                           $this->fdd[$key]['options'] = $options;
                           $this->displayed[$i] = @$value ? true : false;
                           $value && $none_displayed = false;
                 }                  }
   
                 /*                  /*
                  * Hackity hack with unregistering (unchecking) fields                   * Redirecting when neccessary
                    * (hackity hack with unregistering/unchecking fields)
                  */                   */
                 if ($prepare_filter) {  
                         $redirect_url = 'http://'.$HTTP_SERVER_VARS['HTTP_HOST'].$HTTP_SERVER_VARS['SCRIPT_NAME'];                  if ($prepare_filter && ! $headers_sent) {
                         $delim = '?';                          $this->execute_redirect();
                         foreach ($HTTP_POST_VARS + $HTTP_GET_VARS as $cgi_var_name => $cgi_var_value) {  
                                 if ($cgi_var_name == 'prepare_filter'){  
                                         $cgi_var_name = 'filter';  
                                 }  
                                 $redirect_url .= $delim;  
                                 $redirect_url .= rawurlencode($cgi_var_name).'='.rawurlencode($cgi_var_value);  
                                 if ($delim == '?')  
                                         $delim = '&';  
                         }  
                         header('Location: '.$redirect_url);  
                         exit;                          exit;
                 }                  }
   
                 $inc = $this->get_cgi_var('inc');                  /*
                 if (empty($inc)) {                   * Check if field selection report screen has to be displayed
                         global $HTTP_SESSION_VARS;                   */
                         $inc = $HTTP_SESSION_VARS['inc'];  
                 } else {  
                         session_register('inc');  
                 }  
   
                 $this->inc     = (intval($inc) <= 0 ? 0 : intval($inc));                  if (isset($fields_select) || $force_select || $none_displayed) {
                 $fields_select = $this->get_cgi_var('fields_select');  
                 if (isset($fields_select) || $force_fields_select) {  
                         $this->execute_report_screen($table_cols);                          $this->execute_report_screen($table_cols);
                 } else {                          return true;
                   }
                         $none_displayed = true;  
                         $i              = -1;  
                         foreach (array_keys($this->fdd) as $key) {  
                                 $i++;  
                                 if (preg_match('/^\d*$/', $key))  
                                         continue;  
                                 $have_var = "have_$key";  
                                 global $$have_var;  
                                 $have = isset($$have_var) ? $$have_var : $this->get_cgi_var($have_var);  
                                 $this->fdd[$i]['options'] = $this->fdd[$key]['options'] = $have ? 'LV' : '';  
                                 $this->displayed[$i] = $have ? true : false;  
                                 $have && $none_displayed = false;  
                         }  
   
                         if ($none_displayed) {                  if (0) {
                                 $this->execute_report_screen($table_cols);                          $this->message .= $this->get_select_fields_link();
                         } else {                  }
   
                                 /*                  // parent class call
                                  * Select fields link creation                  return parent::execute();
                                  */          } /* }}} */
                                 $this->message .= '<a href="'.htmlspecialchars($HTTP_SERVER_VARS['PHP_SELF']).'?fields_select=1';  
                                 for ($i = 0; $i < count($table_cols); $i++) {  
                                         $var    = "qf$i";  
                                         $varval = $this->get_cgi_var($var);  
                                         if (! empty($varval)) {  
                                                 $this->message .= htmlspecialchars(  
                                                                 '&'.rawurlencode($var)  
                                                                 .'='.rawurlencode($varval));  
                                         }  
                                 }  
                                 $this->message .= '">'.$this->labels['Select fields'].'</a>';  
   
                                 parent::execute();          function execute_redirect() /* {{{ */
                         }          {
                 }                  global $HTTP_SERVER_VARS;
                   global $HTTP_GET_VARS;
                   global $HTTP_POST_VARS;
                   $redirect_url = 'http://'.$HTTP_SERVER_VARS['HTTP_HOST'].$HTTP_SERVER_VARS['SCRIPT_NAME'];
                   $delim = '?';
                   foreach ($HTTP_POST_VARS + $HTTP_GET_VARS as $cgi_var_name => $cgi_var_value) {
                           $cgi_var_name == 'prepare_filter' && $cgi_var_name = 'filter';
                           $redirect_url .= $delim;
                           $redirect_url .= rawurlencode($cgi_var_name).'='.rawurlencode($cgi_var_value);
                           $delim == '?' && $delim = '&';
                   }
                   $redirect_url .= $this->cgi['persist'];
                   header('Location: '.$redirect_url);
                   exit;
         } /* }}} */          } /* }}} */
   
         function execute_report_screen($table_cols) /* {{{ */          function execute_report_screen($table_cols) /* {{{ */
         {          {
                 global $HTTP_SERVER_VARS;                  echo '<form method=post action="'.htmlspecialchars($this->page_name).'">'."\n";
                 echo '<form method=post action="'.htmlspecialchars($HTTP_SERVER_VARS['PHP_SELF']).'">'."\n";  
                 if ($this->nav_up()) {                  if ($this->nav_up()) {
                         $this->display_report_selection_buttons();                          $this->display_report_selection_buttons('up');
                         echo "<hr>\n";                          echo '<hr class="',$this->getCSSclass('hr', 'up'),'">',"\n";
                 }                  }
                 echo '<table border=0 cellpadding=0 cellspacing=0 width="100%">';                  echo '<table border=0 cellpadding=0 cellspacing=0 width="100%">',"\n";
   
                 $i = 0;                  $i = 0;
                 foreach ($table_cols as $key => $val) {                  foreach ($table_cols as $key => $val) {
                         echo '<tr>';                          echo '<tr>',"\n";
                         echo '<td nowrap>'.$this->fdd[$key]['name'].'</td>';                          echo '<td nowrap>',$this->fdd[$key]['name'],'</td>';
                         $var = "have_$key";                          $varname = 'have_'.$key;
                         global $$var;                          $value   = $this->get_cgi_cookie_var($varname);
                         $checked = $$var ? ' checked' : '';                          $checked = @$value ? ' checked' : '';
                         echo '<td width=1 align=center><input type=checkbox name="'.$var.'"'.$checked.'></td>';                          echo '<td width=1 align=center>';
                           echo '<input type=checkbox name="',htmlspecialchars($varname),'"',$checked,'>';
                           echo '</td>',"\n";
   
                         global ${"qf$i"};                          $varname = 'qf'.$i;
                           $value   = $this->get_cgi_cookie_var($varname);
                         echo '<td align=left>';                          echo '<td align=left>';
                         echo '<input type=text name="qf'.$i.'" value="'.${"qf$i"}.'"';                          echo '<input type=text name="',htmlspecialchars($varname),'" value="',htmlspecialchars($value);
                         echo ' size="' . min(40, $val) . '"';                          echo '" size="',min(40, $val),'" maxlength="',min(40, max(10, $val)),'">';
                         echo ' maxlength="'. min(40, max(10, $val)) .'"';                          echo '</td>',"\n",'</tr>',"\n";
                         echo '></td>';  
                         echo '</tr>';  
   
                         $i++;                          $i++;
                 }                  }
                 echo '<tr><td colspan=2>'.$this->labels['Records per screen'].'</td>';                  echo '<tr><td colspan=2>'.$this->labels['Records per screen'].'</td>';
                 echo '<td align=left><input type=text name=inc value="'.$this->inc.'"></td></tr>';                  echo '<td align=left><input type=text name=inc value="'.$this->inc.'"></td></tr>',"\n";
                 echo '</table>';                  echo '</table>',"\n";
                 if ($this->nav_down()) {                  if ($this->nav_down()) {
                         echo "<hr>\n";                          echo '<hr class="',$this->getCSSclass('hr', 'down'),'">',"\n";
                         $this->display_report_selection_buttons();                          $this->display_report_selection_buttons('down');
                 }                  }
                 echo '</form>';                  echo '</form>';
         } /* }}} */          } /* }}} */

Legend:
Odstranené z verzie1.3  
zmenené riadky
  Pridané vo verzii1.4

Platon Group <platon@platon.sk> http://platon.sk/
Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok