| version 1.27, 2002/11/12 21:41:43 |
version 1.28, 2002/11/14 23:29:58 |
|
|
| * http://www.platon.sk/projects/phpMyEdit/ |
* http://www.platon.sk/projects/phpMyEdit/ |
| */ |
*/ |
| |
|
| /* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.26 2002/11/03 15:29:10 nepto Exp $ */ |
/* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.27 2002/11/12 21:41:43 nepto Exp $ */ |
| |
|
| /* phpMyEdit intro {{{ */ |
/* phpMyEdit intro {{{ */ |
| /* |
/* |
|
|
| $file = $this->dir['lang'].'PME.lang.EN.inc'; |
$file = $this->dir['lang'].'PME.lang.EN.inc'; |
| } |
} |
| $ret = @include($file); |
$ret = @include($file); |
| |
// XXX: temporary "Apply" keyword hack -- add it into lang files |
| |
!isset($ret['Apply']) && $ret['Apply'] = 'Apply'; |
| !isset($ret['of']) && $ret['of'] = '/'; |
!isset($ret['of']) && $ret['of'] = '/'; |
| $small = array( |
$small = array( |
| 'Search' => 'v', |
'Search' => 'v', |
|
|
| function fqn($field, $use_qfx = false, $dont_desc = false, $dont_cols = false) /* {{{ */ |
function fqn($field, $use_qfx = false, $dont_desc = false, $dont_cols = false) /* {{{ */ |
| { |
{ |
| if (is_string($field)) { |
if (is_string($field)) { |
| $field = array_search($field,$this->fds); |
$field = array_search($field, $this->fds); |
| } |
} |
| |
|
| // on copy/change always use simple key retrieving |
// on copy/change always use simple key retrieving |
| Line 1134 function form_control(theForm) |
|
| Line 1136 function form_control(theForm) |
|
| return $str; |
return $str; |
| } /* }}} */ |
} /* }}} */ |
| |
|
| |
/* Function extracted from phpPlatonLib |
| |
http://www.platon.sk/projects/phpPlatonLib/ */ |
| |
function write_origvars_html($origvars, $default_value = null) /* {{{ */ |
| |
{ |
| |
foreach (explode('&', $origvars) as $param) { |
| |
|
| |
$parts = explode('=', $param, 2); |
| |
if (! isset($parts[1]) && isset($default_value)) |
| |
$parts[1] = $default_value; |
| |
|
| |
if (strlen($parts[0]) <= 0) |
| |
continue; |
| |
|
| |
echo '<input type="hidden" name="' . $parts[0] . '"'; |
| |
if (isset($parts[1])) |
| |
echo ' value="' . $parts[1] . '"'; |
| |
echo ">\n"; |
| |
} |
| |
|
| |
return true; |
| |
} /* }}} */ |
| |
|
| |
function get_sfn_cgi_vars($alternative_sfn = null) /* {{{ */ |
| |
{ |
| |
if ($alternative_sfn == null) { // FAST! (cached return value) |
| |
static $ret = null; |
| |
$ret == null && $ret = $this->get_sfn_cgi_vars($this->sfn); |
| |
return $ret; |
| |
} |
| |
$ret = ''; |
| |
$i = 0; |
| |
foreach ($alternative_sfn as $val) { |
| |
$ret != '' && $ret .= '&'; |
| |
$ret .= "sfn[$i]=$val"; |
| |
$i++; |
| |
} |
| |
return $ret; |
| |
} /* }}} */ |
| |
|
| function get_qf_hidden_fields() /* {{{ */ |
function get_qf_hidden_fields() /* {{{ */ |
| { |
{ |
| /* If the filter input boxes are not displayed, we need to preserve |
/* If the filter input boxes are not displayed, we need to preserve |
| Line 1238 function form_control(theForm) |
|
| Line 1279 function form_control(theForm) |
|
| return $var; |
return $var; |
| } /* }}} */ |
} /* }}} */ |
| |
|
| function get_http_get_var_by_name($name) /* {{{ */ |
|
| { |
|
| return phpMyEdit::get_cgi_var($name); |
|
| /* |
|
| global $HTTP_GET_VARS; |
|
| |
|
| if (is_array($HTTP_GET_VARS)) |
|
| $v = $HTTP_GET_VARS[$name]; |
|
| // $v could be an array if we allowed bidimensional form fields |
|
| return $v; |
|
| */ |
|
| } /* }}} */ |
|
| |
|
| function get_http_post_var_by_name ($name) /* {{{ */ |
|
| { |
|
| return phpMyEdit::get_cgi_var($name); |
|
| /* |
|
| global $HTTP_POST_VARS; |
|
| |
|
| if (is_array($HTTP_POST_VARS)) |
|
| $v = $HTTP_POST_VARS[$name]; |
|
| // $v could be an array if we allowed bidimensional form fields |
|
| return $v; |
|
| */ |
|
| } /* }}} */ |
|
| |
|
| /* |
/* |
| * Debug functions |
* Debug functions |
| */ |
*/ |
| Line 1339 function form_control(theForm) |
|
| Line 1354 function form_control(theForm) |
|
| echo 'fdd='.$this->fdd.' '; |
echo 'fdd='.$this->fdd.' '; |
| echo 'fl='.$this->fl.' '; |
echo 'fl='.$this->fl.' '; |
| echo 'fm='.$this->fm.' '; |
echo 'fm='.$this->fm.' '; |
| echo 'sfn='.$this->sfn.' '; |
echo 'sfn='.htmlspecialchars($this->get_sfn_cgi_vars()).' '; |
| echo 'qfn='.$this->qfn.' '; |
echo 'qfn='.$this->qfn.' '; |
| echo 'sw='.$this->sw.' '; |
echo 'sw='.$this->sw.' '; |
| echo 'rec='.$this->rec.' '; |
echo 'rec='.$this->rec.' '; |
| Line 1348 function form_control(theForm) |
|
| Line 1363 function form_control(theForm) |
|
| echo 'saveadd='.$this->saveadd.' '; |
echo 'saveadd='.$this->saveadd.' '; |
| echo 'moreadd='.$this->moreadd.' '; |
echo 'moreadd='.$this->moreadd.' '; |
| echo 'savechange='.$this->savechange.' '; |
echo 'savechange='.$this->savechange.' '; |
| |
echo 'morechange='.$this->morechange.' '; |
| echo 'savedelete='.$this->savedelete.' '; |
echo 'savedelete='.$this->savedelete.' '; |
| echo 'operation='.$this->operation.' '; |
echo 'operation='.$this->operation.' '; |
| echo "\n"; |
echo "\n"; |
| Line 1426 function form_control(theForm) |
|
| Line 1442 function form_control(theForm) |
|
| echo '<tr><td align="left" style="text-align:left;border:0;">' . "\n"; |
echo '<tr><td align="left" style="text-align:left;border:0;">' . "\n"; |
| if ($this->change_operation()) { |
if ($this->change_operation()) { |
| echo '<input type="submit" name="savechange" value="'.$this->labels['Save'].'" />'."\n"; |
echo '<input type="submit" name="savechange" value="'.$this->labels['Save'].'" />'."\n"; |
| |
echo '<input type="submit" name="morechange" value="'.$this->labels['Apply'].'" />'."\n"; |
| echo '<input type="button" name="cancel" value="'.$this->labels['Cancel'].'" onClick="form.submit();" />'."\n"; |
echo '<input type="button" name="cancel" value="'.$this->labels['Cancel'].'" onClick="form.submit();" />'."\n"; |
| } elseif ($this->add_operation()) { |
} elseif ($this->add_operation()) { |
| echo '<input type="submit" name="saveadd" value="'.$this->labels['Save'].'" />'."\n"; |
echo '<input type="submit" name="saveadd" value="'.$this->labels['Save'].'" />'."\n"; |
| Line 1443 function form_control(theForm) |
|
| Line 1460 function form_control(theForm) |
|
| } |
} |
| echo '<input type="submit" name="cancel" value="'.$this->labels['Cancel'].'" />'."\n"; |
echo '<input type="submit" name="cancel" value="'.$this->labels['Cancel'].'" />'."\n"; |
| } |
} |
| |
// Message is now written here |
| |
echo '</td><td align="center" style="text-align:center;border:0;" ><b>'.$this->message.'</b></td>'; |
| echo '</td></tr></table>'."\n"; |
echo '</td></tr></table>'."\n"; |
| } /* }}} */ |
} /* }}} */ |
| |
|
| Line 1478 function form_control(theForm) |
|
| Line 1497 function form_control(theForm) |
|
| $select_recs = $this->key != '' && |
$select_recs = $this->key != '' && |
| ($this->change_enabled() || $this->delete_enabled() || $this->view_enabled()); |
($this->change_enabled() || $this->delete_enabled() || $this->view_enabled()); |
| |
|
| //echo "sfn::".$this->sfn."::<br>\n"; |
|
| |
|
| // Default is to sort on first displayed field |
|
| if (! is_numeric($this->sfn) && ! $this->initial_sort_suppressed() |
|
| && ! isset($this->default_sort_columns)) { |
|
| for ($k = 0; ! $this->displayed[$k]; $k++); |
|
| $this->sfn = $k; |
|
| } |
|
| |
|
| // Are we doing a listall? |
// Are we doing a listall? |
| $listall = $this->inc <= 0; |
$listall = $this->inc <= 0; |
| |
|
| Line 1498 function form_control(theForm) |
|
| Line 1508 function form_control(theForm) |
|
| ''=>'','%3C'=>'%3C','%3C%3D'=>'%3C%3D', |
''=>'','%3C'=>'%3C','%3C%3D'=>'%3C%3D', |
| '%3D'=>'%3D','%3E%3D'=>'%3E%3D','%3E'=>'%3E'); |
'%3D'=>'%3D','%3E%3D'=>'%3E%3D','%3E'=>'%3E'); |
| echo '<form action="'.$this->page_name.'" method="POST">'."\n"; |
echo '<form action="'.$this->page_name.'" method="POST">'."\n"; |
| echo '<input type="hidden" name="sfn" value="'; |
$this->write_origvars_html($this->get_sfn_cgi_vars()); |
| echo ($this->sort_asc?'':'-').$this->sfn.'" />'."\n"; |
|
| echo '<input type="hidden" name="fl" value="'.$this->fl.'" />'."\n"; |
echo '<input type="hidden" name="fl" value="'.$this->fl.'" />'."\n"; |
| |
|
| $prev_qfn = $this->qfn; |
$prev_qfn = $this->qfn; |
| Line 1587 function form_control(theForm) |
|
| Line 1596 function form_control(theForm) |
|
| $w = ''; |
$w = ''; |
| } |
} |
| if ($this->fdd[$fd]['sort']) { |
if ($this->fdd[$fd]['sort']) { |
| // clicking on the current sort field reverses the sort order |
// Clicking on the current sort field reverses the sort order |
| echo '<th'.$w.'><a href="'.$this->page_name.'?fm=0&fl='.$this->fl.'&sfn='; |
$new_sfn = $this->sfn; |
| if ($this->sfn == $k) { |
array_unshift($new_sfn, in_array("$k", $new_sfn, 1) ? "-$k" : $k); |
| // reverse the sort order sign |
echo '<th'.$w.'><a href="'.$this->page_name.'?fm=0&fl='.$this->fl; |
| echo ($this->sort_asc?'-':''); |
echo '&'.$this->get_sfn_cgi_vars($new_sfn); |
| } |
echo $this->qfn.'">'.$fdn.'</a></th>'."\n"; |
| echo $k.$this->qfn.'">'.$fdn.'</a></th>'."\n"; |
|
| } else { |
} else { |
| echo '<th'.$w.'>'.$fdn.'</th>'."\n"; |
echo '<th'.$w.'>'.$fdn.'</th>'."\n"; |
| } |
} |
| } // if |
} |
| |
|
| // if we have any aggregates going on, then we have to list all results |
// if we have any aggregates going on, then we have to list all results |
| $var_to_total = 'qf'.$k.'_aggr'; |
$var_to_total = 'qf'.$k.'_aggr'; |
| Line 1624 function form_control(theForm) |
|
| Line 1632 function form_control(theForm) |
|
| $qparts['from'] = $this->create_join_clause(); |
$qparts['from'] = $this->create_join_clause(); |
| $qparts['where'] = $this->make_where_from_query_opts(); |
$qparts['where'] = $this->make_where_from_query_opts(); |
| // build up the ORDER BY clause |
// build up the ORDER BY clause |
| if (is_numeric($this->sfn) || isset($this->default_sort_columns)) { |
if (isset($this->sfn)) { |
| $raw_sort_fields = array(); |
// WTF $raw_sort_fields? |
| |
//$raw_sort_fields = array(); |
| $sort_fields = array(); |
$sort_fields = array(); |
| $sort_fields_w = array(); |
$sort_fields_w = array(); |
| //if ($this->sfn != '') |
|
| if (is_numeric($this->sfn)) { |
foreach ($this->sfn as $field) { |
| if (isset($this->fdd[$this->sfn]['expression'])) { |
if ($field[0] == '-') { |
| $raw_sort_field = 'qf'.$this->sfn; |
$field = substr($field, 1); |
| $sort_field = 'qf'.$this->sfn; |
$desc = true; |
| $sort_field_w = $this->sfn.'(expression)'; |
|
| } else { |
} else { |
| $raw_sort_field = $this->fqn($this->sfn); |
$field = $field; |
| $sort_field = $this->fqn($this->sfn); |
$desc = false; |
| $sort_field_w = $this->fdd[$this->sfn]['name']; |
|
| } |
} |
| if (! $this->sort_asc) { |
//$raw_sort_field = 'qf'.$field; |
| |
$sort_field = 'qf'.$field; |
| |
$sort_field_w = $this->fdd[$field]['name']; |
| |
$this->fdd[$field]['expression'] && $sort_field_w .= ' (expression)'; |
| |
if ($desc) { |
| $sort_field .= ' DESC'; |
$sort_field .= ' DESC'; |
| $sort_field_w .= ' descending'; |
$sort_field_w .= ' descending'; |
| } |
} |
| $raw_sort_fields[] = $raw_sort_field; |
//$raw_sort_fields[] = $raw_sort_field; |
| $sort_fields[] = $sort_field; |
$sort_fields[] = $sort_field; |
| $sort_fields_w[] = $sort_field_w; |
$sort_fields_w[] = $sort_field_w; |
| } |
} |
| if (isset($this->default_sort_columns)) { |
|
| foreach ($this->default_sort_columns as $dsc) { |
|
| if ($dsc[0] == '-') { |
|
| $field = substr($dsc, 1); |
|
| $desc = true; |
|
| } else { |
|
| $field = $dsc; |
|
| $desc = false; |
|
| } |
|
| $raw_candidate = $this->fqn($field); |
|
| $candidate = $this->fqn($field,true); |
|
| $sort_field_w = $this->fdd[$field]['name']; |
|
| if ($desc) { |
|
| $candidate .= ' DESC'; |
|
| $sort_field_w .= ' descending'; |
|
| } |
|
| if (! in_array($raw_candidate,$raw_sort_fields)) { |
|
| $sort_fields[] = $candidate; |
|
| $sort_fields_w[] = $sort_field_w; |
|
| } |
|
| } |
|
| } |
|
| if (count($sort_fields) > 0) { |
if (count($sort_fields) > 0) { |
| $qparts['orderby'] = join(',',$sort_fields); |
$qparts['orderby'] = join(',', $sort_fields); |
| } |
} |
| } |
} |
| $to = $this->fm + $this->inc; |
$to = $this->fm + $this->inc; |
| Line 1683 function form_control(theForm) |
|
| Line 1672 function form_control(theForm) |
|
| if ($qparts['orderby'] && $this->display['sort']) { |
if ($qparts['orderby'] && $this->display['sort']) { |
| // XXX this doesn't preserve filters |
// XXX this doesn't preserve filters |
| echo '<tr>'; |
echo '<tr>'; |
| if ($this->sfn != 0) { |
if (isset($this->sfn)) { |
| echo '<td align="center">'. |
echo '<td align="center">'. |
| '<a class="pme_a_t" href="'.$PHP_SELF.'">'.$this->labels['Clear'].'</a>'. |
'<a class="pme_a_t" href="'.$PHP_SELF.'">'.$this->labels['Clear'].'</a>'. |
| '</td>'; |
'</td>'; |
| Line 1851 function form_control(theForm) |
|
| Line 1840 function form_control(theForm) |
|
| if ($text_query != '' && $this->display['query']) { |
if ($text_query != '' && $this->display['query']) { |
| echo '<tr><td colspan='.$sys_cols.' align="center">' |
echo '<tr><td colspan='.$sys_cols.' align="center">' |
| .'<a class="pme_a_t" href="'.$PHP_SELF; |
.'<a class="pme_a_t" href="'.$PHP_SELF; |
| if ($this->sfn) { |
echo '?sfn='.$this->get_sfn_cgi_vars().'&fl='.$this->fl.'&fm='.$this->fm; |
| echo "?sfn=".($this->sort_asc?'':'-').$this->sfn."&fl=".$this->fl."&fm=".$this->fm; |
|
| } |
|
| echo '">'.$this->labels['Clear'].'</a></td>'; |
echo '">'.$this->labels['Clear'].'</a></td>'; |
| echo '<td colspan="'.$this->num_fields_displayed.'">Current Query: ' |
echo '<td colspan="'.$this->num_fields_displayed.'">Current Query: ' |
| .htmlspecialchars(stripslashes(stripslashes(stripslashes($text_query)))) |
.htmlspecialchars(stripslashes(stripslashes(stripslashes($text_query)))) |
| Line 1885 function form_control(theForm) |
|
| Line 1872 function form_control(theForm) |
|
| } |
} |
| |
|
| // preserve sort field number, filter row, and first record to display |
// preserve sort field number, filter row, and first record to display |
| isset($this->sfn) && $qstrparts[] = 'sfn='.($this->sort_asc?'':'-').$this->sfn; |
isset($this->sfn) && $qstrparts[] = $this->get_sfn_cgi_vars(); |
| isset($this->fl) && $qstrparts[] = 'fl='.$this->fl; |
isset($this->fl) && $qstrparts[] = 'fl='.$this->fl; |
| isset($this->fm) && $qstrparts[] = 'fm='.$this->fm; |
isset($this->fm) && $qstrparts[] = 'fm='.$this->fm; |
| |
|
| Line 2005 function form_control(theForm) |
|
| Line 1992 function form_control(theForm) |
|
| } |
} |
| } |
} |
| |
|
| // calculate the url query string for optional URL support |
// Calculate the url query string for optional URL support |
| $urlqueryproto = 'fm='.$this->fm.'&sfn='.($this->sort_asc?'':'-') |
$urlqueryproto = 'fm='.$this->fm |
| .$this->sfn.'&'.'fl='.$this->fl.'&qfn='.$this->qfn; |
.'&sfn='.$this->get_sfn_cgi_vars() |
| |
.'&fl='.$this->fl |
| |
.'&qfn='.$this->qfn; |
| for ($k = 0; $k < $this->num_fds; $k++) { |
for ($k = 0; $k < $this->num_fds; $k++) { |
| $fd = $this->fds[$k]; |
$fd = $this->fds[$k]; |
| if ($this->hidden($k) || $this->password($k)) { |
if ($this->hidden($k) || $this->password($k)) { |
| Line 2209 function form_control(theForm) |
|
| Line 2198 function form_control(theForm) |
|
| echo '<table width="100%" border="1" cellpadding="1" cellspacing="0" summary="'.$this->tb.'">'."\n"; |
echo '<table width="100%" border="1" cellpadding="1" cellspacing="0" summary="'.$this->tb.'">'."\n"; |
| echo '<input type="hidden" name="rec" value="'.($this->copy_operation()?'':$this->rec).'">'."\n"; |
echo '<input type="hidden" name="rec" value="'.($this->copy_operation()?'':$this->rec).'">'."\n"; |
| echo '<input type="hidden" name="fm" value="'.$this->fm.'">'."\n"; |
echo '<input type="hidden" name="fm" value="'.$this->fm.'">'."\n"; |
| echo '<input type="hidden" name="sfn" value="'.($this->sort_asc?'':'-').$this->sfn.'">'."\n"; |
$this->write_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"; |
| echo $this->get_qf_hidden_fields(); |
echo $this->get_qf_hidden_fields(); |
| echo '<input type="hidden" name="qfn" value="'.htmlspecialchars($this->qfn).'">'."\n"; |
echo '<input type="hidden" name="qfn" value="'.htmlspecialchars($this->qfn).'">'."\n"; |
| Line 2297 function form_control(theForm) |
|
| Line 2286 function form_control(theForm) |
|
| $type = $this->fdd[$k]['type']; |
$type = $this->fdd[$k]['type']; |
| if ($this->processed($k)) { |
if ($this->processed($k)) { |
| $fd = $this->fds[$k]; |
$fd = $this->fds[$k]; |
| $fn = $this->get_http_post_var_by_name($fd); |
// XXX: REMOVE ME! |
| |
// $fn = $this->get_http_post_var_by_name($fd); |
| |
$fn = $this->get_cgi_var($fd); |
| /* |
/* |
| if ($this->col_is_date($k)) |
if ($this->col_is_date($k)) |
| { |
{ |
| Line 2387 function form_control(theForm) |
|
| Line 2378 function form_control(theForm) |
|
| if ($this->processed($k) && ! $this->readonly($k)) { |
if ($this->processed($k) && ! $this->readonly($k)) { |
| $fd = $this->fds[$k]; |
$fd = $this->fds[$k]; |
| if ($fd == $this->key) { |
if ($fd == $this->key) { |
| $key_col_val = addslashes($this->get_http_post_var_by_name($fd)); |
// XXX: remove me! |
| } |
//$key_col_val = addslashes($this->get_http_post_var_by_name($fd)); |
| $fn = $this->get_http_post_var_by_name($fd); |
$key_col_val = addslashes($this->get_cgi_var($fd)); |
| |
} |
| |
// XXX: detto |
| |
//$fn = $this->get_http_post_var_by_name($fd); |
| |
$fn = $this->get_cgi_var($fd); |
| /* |
/* |
| if ($this->col_is_date($k)) |
if ($this->col_is_date($k)) |
| { |
{ |
| Line 2629 echo '<h5>'.mysql_affected_rows ().' '.$ |
|
| Line 2624 echo '<h5>'.mysql_affected_rows ().' '.$ |
|
| } |
} |
| } /* }}} */ |
} /* }}} */ |
| |
|
| function recreate_displayed($sort_field = '') /* {{{ */ |
function recreate_displayed() /* {{{ */ |
| { |
{ |
| /* $sort_field initialization here is currently not used |
|
| it may be useful in future if we will want to initialize initial |
|
| sort also by column name, not only by column number */ |
|
| |
|
| $field_num = 0; |
$field_num = 0; |
| $num_fields_displayed = 0; |
$num_fields_displayed = 0; |
| $this->fds = array(); |
$this->fds = array(); |
| Line 2646 echo '<h5>'.mysql_affected_rows ().' '.$ |
|
| Line 2637 echo '<h5>'.mysql_affected_rows ().' '.$ |
|
| continue; |
continue; |
| |
|
| $this->fds[$field_num] = $akey; |
$this->fds[$field_num] = $akey; |
| if ($sfn == '' && $akey == $sort_field) { |
|
| $this->sfn = $field_num; |
|
| } |
|
| /* 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)) { |
| Line 2676 echo '<h5>'.mysql_affected_rows ().' '.$ |
|
| Line 2665 echo '<h5>'.mysql_affected_rows ().' '.$ |
|
| $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); |
| |
|
| |
/* Adds first displayed column into sorting fields by replacing last |
| |
array entry. Also remove duplicite values and change column names to |
| |
their particular field numbers. |
| |
|
| |
Note that entries like [0]=>'9' [1]=>'-9' are correct and they will |
| |
have desirable sorting behaviour. So there is no need to remove them. |
| |
*/ |
| |
for ($k = 0; ! $this->displayed[$k]; $k++); |
| |
$this->sfn[count($this->sfn) - 1] = "$k"; // important quotes |
| |
$this->sfn = array_unique($this->sfn); |
| |
$check_ar = array(); |
| |
foreach ($this->sfn as $key => $val) { |
| |
if (preg_match('/^[-]?\d*$/', $val)) { // skipping numeric keys |
| |
$val = abs($val); |
| |
if (in_array($val, $check_ar)) { |
| |
unset($this->sfn[$key]); |
| |
} else { |
| |
$check_ar[] = $val; |
| |
} |
| |
continue; |
| |
} |
| |
if ($val[0] == '-') { |
| |
$val = substr($val, 1); |
| |
$minus = '-'; |
| |
} else { |
| |
$minus = ''; |
| |
} |
| |
if (($val = array_search($val, $this->fds)) === false) { |
| |
unset($this->sfn[$key]); |
| |
} else { |
| |
$val = intval($val); |
| |
if (in_array($val, $check_ar)) { |
| |
unset($this->sfn[$key]); |
| |
} else { |
| |
$this->sfn[$key] = $minus.$val; |
| |
$check_ar[] = $val; |
| |
} |
| |
} |
| |
} |
| |
$this->sfn = array_unique($this->sfn); |
| |
return true; |
| } /* }}} */ |
} /* }}} */ |
| |
|
| /* |
/* |
| Line 2745 echo '<h5>'.mysql_affected_rows ().' '.$ |
|
| Line 2776 echo '<h5>'.mysql_affected_rows ().' '.$ |
|
| if ($this->moreadd == $this->labels['More']) { |
if ($this->moreadd == $this->labels['More']) { |
| $this->do_add_record(); |
$this->do_add_record(); |
| $this->operation = $this->labels['Add']; // to force add operation |
$this->operation = $this->labels['Add']; // to force add operation |
| |
$this->recreate_fdd(); |
| |
$this->recreate_displayed(); |
| } |
} |
| if ($this->savechange == $this->labels['Save']) { |
if ($this->savechange == $this->labels['Save']) { |
| $this->do_change_record(); |
$this->do_change_record(); |
| } |
} |
| |
if ($this->morechange == $this->labels['Apply']) { |
| |
$this->do_change_record(); |
| |
$this->operation = $this->labels['Change']; // to force change operation |
| |
$this->recreate_fdd(); |
| |
$this->recreate_displayed(); |
| |
} |
| if ($this->savedelete == $this->labels['Delete']) { |
if ($this->savedelete == $this->labels['Delete']) { |
| $this->do_delete_record(); |
$this->do_delete_record(); |
| } |
} |
| Line 2823 echo '<h5>'.mysql_affected_rows ().' '.$ |
|
| Line 2862 echo '<h5>'.mysql_affected_rows ().' '.$ |
|
| $this->logtable = $opts['logtable']; |
$this->logtable = $opts['logtable']; |
| $this->page_name = $this->tb; |
$this->page_name = $this->tb; |
| $opts['page_name'] && $this->page_name = $opts['page_name']; |
$opts['page_name'] && $this->page_name = $opts['page_name']; |
| $this->default_sort_columns = $opts['default_sort_columns']; |
// REMOVE ME! |
| |
//$this->default_sort_columns = $opts['default_sort_columns']; |
| |
|
| // alternate row background colors |
// alternate row background colors |
| /* What's this?! |
/* What's this?! |
| Line 2869 echo '<h5>'.mysql_affected_rows ().' '.$ |
|
| Line 2909 echo '<h5>'.mysql_affected_rows ().' '.$ |
|
| $this->page_name = basename($HTTP_SERVER_VARS['PHP_SELF']); |
$this->page_name = basename($HTTP_SERVER_VARS['PHP_SELF']); |
| |
|
| /* |
/* |
| |
* Sorting variables |
| |
*/ |
| |
$this->sfn = $this->get_cgi_var('sfn'); |
| |
isset($this->sfn) || $this->sfn = array(); |
| |
is_array($this->sfn) || $this->sfn = array($this->sfn); |
| |
isset($opts['sort_field']) || $opts['sort_field'] = array(); |
| |
is_array($opts['sort_field']) || $opts['sort_field'] = array($opts['sort_field']); |
| |
$this->sfn = array_merge($this->sfn, $opts['sort_field']); |
| |
$this->sfn[] = '0'; // this last entry will be replaced in recreate_displayed() |
| |
|
| |
/* |
| * Form variables all around |
* Form variables all around |
| */ |
*/ |
| |
|
| Line 2877 echo '<h5>'.mysql_affected_rows ().' '.$ |
|
| Line 2928 echo '<h5>'.mysql_affected_rows ().' '.$ |
|
| $this->fl = intval($this->get_cgi_var('fl')); |
$this->fl = intval($this->get_cgi_var('fl')); |
| $this->fm = intval($this->get_cgi_var('fm')); |
$this->fm = intval($this->get_cgi_var('fm')); |
| |
|
| $this->sfn = $this->get_cgi_var('sfn', $opts['sort_field']); |
|
| $this->sort_asc = $this->sfn[0] != '-'; |
|
| $this->sfn = abs(intval($this->sfn)); |
|
| |
|
| $this->qfn = $this->get_cgi_var('qfn'); |
$this->qfn = $this->get_cgi_var('qfn'); |
| $this->sw = $this->get_cgi_var('sw'); |
$this->sw = $this->get_cgi_var('sw'); |
| $this->rec = $this->get_cgi_var('rec', ''); // Fixed #523390 [7/8/2002] [2/2] |
$this->rec = $this->get_cgi_var('rec', ''); // Fixed #523390 [7/8/2002] [2/2] |
| Line 2889 echo '<h5>'.mysql_affected_rows ().' '.$ |
|
| Line 2936 echo '<h5>'.mysql_affected_rows ().' '.$ |
|
| $this->saveadd = $this->get_cgi_var('saveadd'); |
$this->saveadd = $this->get_cgi_var('saveadd'); |
| $this->moreadd = $this->get_cgi_var('moreadd'); |
$this->moreadd = $this->get_cgi_var('moreadd'); |
| $this->savechange = $this->get_cgi_var('savechange'); |
$this->savechange = $this->get_cgi_var('savechange'); |
| |
$this->morechange = $this->get_cgi_var('morechange'); |
| $this->savedelete = $this->get_cgi_var('savedelete'); |
$this->savedelete = $this->get_cgi_var('savedelete'); |
| |
|
| /* |
/* |