| version 1.48, 2003/02/12 00:08:48 |
version 1.49, 2003/02/15 11:23:57 |
|
|
| * http://www.platon.sk/projects/phpMyEdit/ |
* http://www.platon.sk/projects/phpMyEdit/ |
| */ |
*/ |
| |
|
| /* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.47 2003/01/28 04:07:44 nepto Exp $ */ |
/* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.48 2003/02/12 00:08:48 nepto Exp $ */ |
| |
|
| /* phpMyEdit intro {{{ */ |
/* phpMyEdit intro {{{ */ |
| /* |
/* |
|
|
| */ |
*/ |
| /* }}} */ |
/* }}} */ |
| |
|
| if (@include_once dirname(__FILE__).'/timer.class') { |
class phpMyEdit_timer /* {{{ */ |
| $phpMyEdit_timer = new timerClass(); |
{ |
| } |
var $startTime; |
| |
var $started; |
| |
|
| |
function phpMyEdit_timer($start = true) |
| |
{ |
| |
$this->started = false; |
| |
if ($start) { |
| |
$this->start(); |
| |
} |
| |
} |
| |
|
| |
function start() |
| |
{ |
| |
$startMtime = explode(' ', microtime()); |
| |
$this->startTime = (double) $startMtime[0] + (double) $startMtime[1]; |
| |
$this->started = true; |
| |
} |
| |
|
| |
function end($iterations = 1) |
| |
{ |
| |
// get the time, check whether the timer was started later |
| |
$endMtime = explode(' ', microtime()); |
| |
if ($this->started) { |
| |
$endTime = (double)($endMtime[0])+(double)($endMtime[1]); |
| |
$dur = $endTime - $this->startTime; |
| |
$avg = 1000 * $dur / $iterations; |
| |
$avg = round(1000 * $avg) / 1000; |
| |
return $avg; |
| |
} else { |
| |
return 'phpMyEdit_timer ERROR: timer not started'; |
| |
} |
| |
} |
| |
} /* }}} */ |
| |
|
| if (! function_exists('array_search')) { /* {{{ */ |
if (! function_exists('array_search')) { /* {{{ */ |
| function array_search($needle, $haystack) |
function array_search($needle, $haystack) |
|
|
| var $notify; // change notification e-mail adresses |
var $notify; // change notification e-mail adresses |
| var $logtable; // name of optional logtable |
var $logtable; // name of optional logtable |
| var $navigation; // navigation style |
var $navigation; // navigation style |
| |
var $timer = null; |
| // }}} |
// }}} |
| |
|
| function debug_var($name, $val) /* {{{ */ |
function debug_var($name, $val) /* {{{ */ |
|
|
| return $join; |
return $join; |
| } /* }}} */ |
} /* }}} */ |
| |
|
| function make_where_from_query_opts($qp='') /* {{{ */ |
function make_where_from_query_opts($qp = null, $text = 0) /* {{{ */ |
| { |
{ |
| if ($qp == '') |
if ($qp == null) { |
| $qp = $this->query_opts; |
$qp = $this->query_opts; |
| |
} |
| $where = array(); |
$where = array(); |
| foreach ($qp as $field => $ov) { |
foreach ($qp as $field => $ov) { |
| $where[] = sprintf('%s %s %s', $field, $ov['oper'], $ov['value']); |
if (is_numeric($field)) { |
| |
$tmp_where = array(); |
| |
foreach ($ov as $field2 => $ov2) { |
| |
$tmp_where[] = sprintf('%s %s %s', $field2, $ov2['oper'], $ov2['value']); |
| |
} |
| |
$where[] = '('.join(' OR ', $tmp_where).')'; |
| |
} else { |
| |
$where[] = sprintf('%s %s %s', $field, $ov['oper'], $ov['value']); |
| |
} |
| } |
} |
| |
|
| // Add any coder specified filters |
// Add any coder specified filters |
| if ($this->filters) |
if (! $text && $this->filters) { |
| $where[] = '('.$this->filters.')'; |
$where[] = '('.$this->filters.')'; |
| if (count($where) > 0) |
|
| return join(' AND ',$where); |
|
| |
|
| return false; |
|
| } /* }}} */ |
|
| |
|
| function make_text_where_from_query_opts($qp='') /* {{{ */ |
|
| { |
|
| if ($qp == '') |
|
| $qp = $this->query_opts; |
|
| $where = array(); |
|
| foreach ($qp as $field => $ov) { |
|
| $where[] = sprintf('%s %s %s', $field, $ov['oper'], $ov['value']); |
|
| } |
} |
| |
if (count($where) > 0) { |
| if (count($where) > 0) |
if ($text) { |
| return str_replace('%', '*', join(' AND ',$where)); |
return str_replace('%', '*', join(' AND ',$where)); |
| |
} else { |
| |
return join(' AND ',$where); |
| |
} |
| |
} |
| return false; |
return false; |
| } /* }}} */ |
} /* }}} */ |
| |
|
|
|
| function gather_query_opts() /* {{{ */ |
function gather_query_opts() /* {{{ */ |
| { |
{ |
| // gathers query options into an array, $this->query_opts |
// gathers query options into an array, $this->query_opts |
| |
|
| $query_opts = array(); |
$query_opts = array(); |
| $qo = array(); |
$qo = array(); |
| |
|
| for ($k = 0; $k < $this->num_fds; $k++) { |
for ($k = 0; $k < $this->num_fds; $k++) { |
| |
$type = $this->fdd[$k]['type']; |
| $l = 'qf'.$k; |
$l = 'qf'.$k; |
| $lc = 'qf'.$k.'_comp'; |
$lc = 'qf'.$k.'_comp'; |
| $$l = $this->get_cgi_var($l); |
$li = 'qf'.$k.'_id'; |
| $$lc = $this->get_cgi_var($lc); |
$m = $this->get_cgi_var($l, ''); |
| $m = $this->web2plain($$l); // get the field name and value |
$mc = $this->get_cgi_var($lc, ''); |
| $mc = $this->web2plain($$lc); // get the comparison operator for numeric/date types |
$mi = $this->get_cgi_var($li, ''); |
| $type = $this->fdd[$k]['type']; |
if ($m == '' && $mi == '') { |
| |
|
| if ($m == '') { |
|
| continue; |
continue; |
| } |
} |
| if (is_array($m)) { // multiple selection has been used |
if ($mi != '' /* && ($this->fdd[$k]['values']['description'] || $this->fdd[$k]['values']['column']) */) { |
| if (!in_array('*',$m)) { // one '*' in a multiple selection is all you need |
$afilter = addslashes($mi); |
| |
if ($afilter != '*') { |
| |
$qo[$this->fqn($k, false, true, true)] = array('oper' => '=', 'value' => "'$afilter'"); |
| |
} |
| |
} else if (is_array($m)) { |
| |
// TODO: is_array($mi) |
| |
if (!in_array('*',$m)){ |
| $qf_op = ''; |
$qf_op = ''; |
| foreach (array_keys($m) as $key) { |
foreach (array_keys($m) as $key) { |
| if ($qf_op == '') { |
if ($qf_op == '') { |
| $qf_op = 'IN'; |
$qf_op = 'IN'; |
| $qf_val = "'".addslashes($m[$key])."'"; |
$qf_val = '"'.addslashes($m[$key]).'"'; |
| $afilter =" IN ('".addslashes($m[$key])."'"; |
$afilter = ' IN ("'.addslashes($m[$key]).'"'; |
| } else { |
} else { |
| $afilter = $afilter.",'".addslashes($m[$key])."'"; |
$afilter = $afilter.',"'.addslashes($m[$key]).'"'; |
| $qf_val .= ",'".addslashes($m[$key])."'"; |
$qf_val .= ',"'.addslashes($m[$key]).'"'; |
| } |
} |
| } |
} |
| $afilter = $afilter.')'; |
$afilter = $afilter.')'; |
|
|
| $dont_desc = isset($this->fdd[$k]['values']['description']); |
$dont_desc = isset($this->fdd[$k]['values']['description']); |
| $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 { |
} else { |
| $afilter = addslashes($m); |
$afilter = addslashes($m); |
| if ($afilter != '*') { |
if ($afilter != '*') { |
| /* XXX: This is ugly fqn() hack. We must pass third |
if ($this->col_is_string($k) |
| $dont_desc parameter to fqn() method, as far as we |
|| $this->fdd[$k]['values']['description'] |
| want to return not description column, but ID one. */ |
|| $this->fdd[$k]['values']['column']) { |
| if ($this->fdd[$k]['values']['description']) { |
$afilter = '%'.str_replace('*', '%', $afilter).'%'; |
| // DEBUG |
$ids = array(); |
| // echo htmlspecialchars(' k = '.$k.' | fqn($k) = '.$this->fqn($k, false, true)); |
$ar = array(); |
| $qo[$this->fqn($k, false, true, true)] = |
$ar[$this->fqn($k)] = array('oper' => 'LIKE', 'value' => "'$afilter'"); |
| array('oper' => '=', 'value' => "'".$afilter."'"); |
if (is_array($this->fdd[$k]['values2'])) { |
| } elseif ($this->fdd[$k]['values']['column']) { |
foreach ($this->fdd[$k]['values2'] as $key => $val) { |
| $qo[$this->fqn($k, false, true, true)] = |
if (stristr($val, $m)) { |
| array('oper' => '=', 'value' => "'".$afilter."'"); |
$ids[] = '"'.addslashes($key).'"'; |
| } elseif ($this->col_is_string($k)) { |
} |
| // massage the filter for a string comparison |
} |
| if (($afilter != '') AND ($afilter != '*')) { |
if (count($ids) > 0) { |
| $afilter = '%'.str_replace('*', '%', $afilter).'%'; |
$ar[$this->fqn($k, false, true, true)] |
| $qo[$this->fqn($k)] = |
= array('oper' => 'IN', 'value' => '('.join(',', $ids).')'); |
| array('oper' => 'like', 'value' => "'".$afilter."'"); |
} |
| } |
|
| } elseif ($this->col_is_number($k) && ($$lc != '')) { |
|
| if ($$lc != '') { |
|
| $qo[$this->fqn($k)] = |
|
| array('oper' => $mc, 'value' => $afilter); |
|
| } |
} |
| } elseif ($this->col_is_date($k)) { |
$qo[] = $ar; |
| #if ($$lc != '') { |
} elseif ($this->col_is_number($k) && ($mc != '')) { |
| # $val = $this->gather_date_fields_into_type($$l,$type); |
if ($mc != '') { |
| # $val = $this->mdate_set(date($this->mdate_masks[$type],$this->mdate_getFromPost($k)),$type); |
$qo[$this->fqn($k)] = array('oper' => $mc, 'value' => "'$afilter'"); |
| # $val = $this->mdate_getFromPost($k); |
|
| # if ($val != '') { |
|
| # $qo[$this->fqn($k)] = |
|
| # array( 'oper' => $mc, 'value' => '"'.$val.'"'); |
|
| # } |
|
| #} |
|
| # massage the filter for a string comparison |
|
| if (($afilter != '') AND ($afilter != '*')) { |
|
| $afilter = '%'.str_replace ('*', '%', $afilter).'%'; |
|
| $qo[$this->fqn($k)] = |
|
| array('oper' => 'like', 'value' => "'".$afilter."'"); |
|
| } |
} |
| |
} elseif ($this->col_is_date($k)) { |
| |
$afilter = '%'.str_replace ('*', '%', $afilter).'%'; |
| |
$qo[$this->fqn($k)] = array('oper' => 'like', 'value' => "'$afilter'"); |
| } elseif($this->col_has_values($k)) { |
} elseif($this->col_has_values($k)) { |
| //debug_var('col_is_string',$this->fdd[$k]['name'].'::'.$this->fdd[$k]['type']); |
//debug_var('col_is_string',$this->fdd[$k]['name'].'::'.$this->fdd[$k]['type']); |
| $qo[$this->fqn($k)] = |
$qo[$this->fqn($k)] = array( 'oper' => '=', 'value' => "'$afilter'"); |
| array( 'oper' => '=', 'value' => "'".$afilter."'"); |
|
| } else { |
} else { |
| // unknown (to mysql/php interface) field type |
// unknown (to mysql/php interface) field type |
| // message the filter for a string comparison |
// message the filter for a string comparison |
| $afilter = '%'.str_replace ('*', '%', $afilter).'%'; |
$afilter = '%'.str_replace ('*', '%', $afilter).'%'; |
| $qo[$this->fqn($k)] = |
$qo[$this->fqn($k)] = array('oper' => 'like', 'value' => "'$afilter'"); |
| array('oper' => 'like', 'value' => "'".$afilter."'"); |
|
| } |
} |
| } |
} |
| } |
} |
| } // for |
} // for |
| |
|
| $this->query_opts = $qo; |
$this->query_opts = $qo; |
| } // gather_query_opts /* }}} */ |
} // gather_query_opts /* }}} */ |
| |
|
| Line 1139 function phpMyEdit_form_control(theForm) |
|
| Line 1157 function phpMyEdit_form_control(theForm) |
|
| $ret .= ' selected'; |
$ret .= ' selected'; |
| $found = true; |
$found = true; |
| } |
} |
| $ret .= '>'.htmlspecialchars(urldecode(strip_tags($value))).'</option>'."\n"; |
$ret .= '>'.htmlspecialchars($value).'</option>'."\n"; |
| } |
} |
| $ret .= '</select>'; |
$ret .= '</select>'; |
| return $ret; |
return $ret; |
| Line 1178 function phpMyEdit_form_control(theForm) |
|
| Line 1196 function phpMyEdit_form_control(theForm) |
|
| return $str; |
return $str; |
| } /* }}} */ |
} /* }}} */ |
| |
|
| /* Function extracted from phpPlatonLib |
/** |
| http://www.platon.sk/projects/phpPlatonLib/ */ |
* Returns original variables HTML code for use in forms or links. |
| function write_origvars_html($origvars, $default_value = null) /* {{{ */ |
* |
| { |
* @param mixed $origvars string or array of original varaibles |
| foreach (explode('&', $origvars) as $param) { |
* @param string $method type of method ("POST" or "GET") |
| |
* @param mixed $default_value default value of variables |
| $parts = explode('=', $param, 2); |
* if null, empty values will be skipped |
| if (! isset($parts[1]) && isset($default_value)) |
* @return get HTML code of original varaibles |
| $parts[1] = $default_value; |
*/ |
| |
function get_origvars_html($origvars, $method = 'POST', $default_value = '') /* {{{ */ |
| if (strlen($parts[0]) <= 0) |
{ |
| continue; |
$ret = ''; |
| |
$method = strtoupper($method); |
| echo '<input type="hidden" name="' . $parts[0] . '"'; |
if ($method == 'POST') { |
| if (isset($parts[1])) |
if (! is_array($origvars)) { |
| echo ' value="' . $parts[1] . '"'; |
$new_origvars = array(); |
| echo ">\n"; |
foreach (explode('&', $origvars) as $param) { |
| } |
$parts = explode('=', $param, 2); |
| |
if (! isset($parts[1])) { |
| return true; |
$parts[1] = $default_value; |
| } /* }}} */ |
} |
| |
if (strlen($parts[0]) <= 0) { |
| |
continue; |
| |
} |
| |
$new_origvars[$parts[0]] = $parts[1]; |
| |
} |
| |
$origvars =& $new_origvars; |
| |
} |
| |
foreach ($origvars as $key => $val) { |
| |
if (strlen($val) <= 0 && $default_value === null) { |
| |
continue; |
| |
} |
| |
$key = rawurldecode($key); |
| |
$val = rawurldecode($val); |
| |
$ret .= '<input type="hidden" name="'; |
| |
$ret .= htmlspecialchars($key).'"'; |
| |
$ret .= ' value="'.htmlspecialchars($val).'"'; |
| |
$ret .= " />\n"; |
| |
} |
| |
} else if (! strncmp('GET', $method, 3)) { |
| |
if (! is_array($origvars)) { |
| |
$ret .= $origvars; |
| |
} else { |
| |
foreach ($origvars as $key => $val) { |
| |
if (strlen($val) <= 0 && $default_value === null) { |
| |
continue; |
| |
} |
| |
$ret == '' || $ret .= '&'; |
| |
$ret .= htmlspecialchars(rawurlencode($key)); |
| |
$ret .= '='; |
| |
$ret .= htmlspecialchars(rawurlencode($val)); |
| |
} |
| |
} |
| |
if ($method[strlen($method) - 1] == '+') { |
| |
$ret = "?$ret"; |
| |
} |
| |
} else { |
| |
trigger_error('Unsupported Platon::get_origvars_html() method: ' |
| |
.$method, E_USER_ERROR); |
| |
} |
| |
return $ret; |
| |
} /* }}} */ |
| |
|
| function get_sfn_cgi_vars($alternative_sfn = null) /* {{{ */ |
function get_sfn_cgi_vars($alternative_sfn = null) /* {{{ */ |
| { |
{ |
| Line 1211 function phpMyEdit_form_control(theForm) |
|
| Line 1270 function phpMyEdit_form_control(theForm) |
|
| $i = 0; |
$i = 0; |
| foreach ($alternative_sfn as $val) { |
foreach ($alternative_sfn as $val) { |
| $ret != '' && $ret .= '&'; |
$ret != '' && $ret .= '&'; |
| $ret .= "sfn[$i]=$val"; |
$ret .= "sfn[$i]=".rawurlencode($val); |
| $i++; |
$i++; |
| } |
} |
| return $ret; |
return $ret; |
| Line 1224 function phpMyEdit_form_control(theForm) |
|
| Line 1283 function phpMyEdit_form_control(theForm) |
|
| $this->qfn = ''; |
$this->qfn = ''; |
| $hidden_qfs = ''; |
$hidden_qfs = ''; |
| for ($k = 0; $k < $this->num_fds; $k++) { |
for ($k = 0; $k < $this->num_fds; $k++) { |
| $l = 'qf'.$k; |
$l = 'qf'.$k; |
| $lc = 'qf'.$k.'_comp'; |
$lc = 'qf'.$k.'_comp'; |
| $$l = $this->get_cgi_var($l); |
$li = 'qf'.$k.'_id'; |
| $$lc = $this->get_cgi_var($lc); |
$m = $this->get_cgi_var($l, ''); |
| $m = $this->web2plain($$l); // get the field name and value |
$mc = $this->get_cgi_var($lc, ''); |
| $mc = $this->web2plain($$lc); // get the comparison operator for numeric/date types |
$mi = $this->get_cgi_var($li, ''); |
| |
if ($m == '' && $mi == '') { |
| if (!isset($m)) { |
|
| continue; |
continue; |
| } |
} |
| if (is_array($m)) { // multiple selection has been used |
foreach (array($l => $m, $lc => $mc, $li => $mi) as $name => $value) { |
| if (!in_array('*',$m)) {// one '*' in a multiple selection is all you need |
if (is_array($value)) { |
| for ($n=0; $n<count($m); $n++) { |
foreach ($value as $key => $val) { |
| if ($this->plain2web($m[$n]) != '') { |
if ($key == '' || $val == '') { |
| $this->qfn = $this->qfn.'&qf'.$k.'['.$n.']=' |
continue; |
| .$this->plain2web($m[$n]); } |
} |
| $hidden_qfs .= '<input type="hidden" name="qf'.$k.'['.$n |
$this->qfn = $this->qfn.'&'.$name.'['.$key.']='.rawurlencode($val); |
| .']" value="'.$this->plain2web($m[$n]).'">'."\n"; |
$hidden_qfs .= '<input type="hidden" name="'.$name.'['.$key |
| |
.']" value="'.htmlspecialchars($val).'">'."\n"; |
| |
} |
| |
} else { |
| |
if ($value != '') { |
| |
$this->qfn = $this->qfn.'&'.$name.'='.rawurlencode($value); |
| |
$hidden_qfs .= '<input type="hidden" name="'.$name.'" value="'.htmlspecialchars($value).'">'."\n"; |
| } |
} |
| } |
|
| } else { |
|
| // query field comparison operator (if any) |
|
| if ($this->plain2web($mc) != '') { |
|
| $this->qfn = $this->qfn.'&qf'.$k.'_comp='.$this->plain2web($mc); |
|
| $hidden_qfs .= '<input type="hidden" name="'.$lc.'" value="'.$mc.'">'."\n"; |
|
| } |
|
| // preserve query field & value |
|
| if ($this->plain2web($m) != '') { |
|
| $this->qfn = $this->qfn.'&qf'.$k.'='.$this->plain2web($m); |
|
| $hidden_qfs .= '<input type="hidden" name="'.$l.'" value="'.$m.'">'."\n"; |
|
| } |
} |
| } |
} |
| } |
} |
| return $hidden_qfs; |
return $hidden_qfs; |
| } /* }}} */ |
} /* }}} */ |
| |
|
| function web2plain($x) /* {{{ */ |
|
| { |
|
| if (isset($x)) { |
|
| if (is_array($x)) { |
|
| foreach (array_keys($x) as $key) { |
|
| $x[$key] = rawurldecode($x[$key]); |
|
| } |
|
| } else { |
|
| $x = rawurldecode($x); |
|
| } |
|
| } |
|
| return $x; |
|
| } /* }}} */ |
|
| |
|
| function plain2web($x) /* {{{ */ |
function plain2web($x) /* {{{ */ |
| { |
{ |
| Line 1327 function phpMyEdit_form_control(theForm) |
|
| Line 1366 function phpMyEdit_form_control(theForm) |
|
| if (isset($HTTP_SERVER_VARS[$name])) { |
if (isset($HTTP_SERVER_VARS[$name])) { |
| return $HTTP_SERVER_VARS[$name]; |
return $HTTP_SERVER_VARS[$name]; |
| } |
} |
| global $name; |
global $$name; |
| if (isset($$name)) { |
if (isset($$name)) { |
| return $$name; |
return $$name; |
| } |
} |
| Line 1554 function phpMyEdit_form_control(theForm) |
|
| Line 1593 function phpMyEdit_form_control(theForm) |
|
| * Display the MySQL table in an HTML table |
* Display the MySQL table in an HTML table |
| */ |
*/ |
| |
|
| |
//$comp_ops = array( |
| |
// ''=>'','%3C'=>'%3C','%3C%3D'=>'%3C%3D', |
| |
// '%3D'=>'%3D','%3E%3D'=>'%3E%3D','%3E'=>'%3E'); |
| $comp_ops = array( |
$comp_ops = array( |
| ''=>'','%3C'=>'%3C','%3C%3D'=>'%3C%3D', |
''=>'','<'=>'<','<='=>'<=', |
| '%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"; |
| $this->write_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; |
$prev_qfn = $this->qfn; |
| Line 1592 function phpMyEdit_form_control(theForm) |
|
| Line 1634 function phpMyEdit_form_control(theForm) |
|
| } |
} |
| |
|
| if ($this->cgi['persist'] != '') { |
if ($this->cgi['persist'] != '') { |
| $this->write_origvars_html($this->cgi['persist']); |
echo $this->get_origvars_html($this->cgi['persist']); |
| } |
} |
| if (!$this->fl) { |
if (!$this->fl) { |
| echo($hidden_qfs); |
echo($hidden_qfs); |
| Line 1643 function phpMyEdit_form_control(theForm) |
|
| Line 1685 function phpMyEdit_form_control(theForm) |
|
| // Clicking on the current sort field reverses the sort order |
// Clicking on the current sort field reverses the sort order |
| $new_sfn = $this->sfn; |
$new_sfn = $this->sfn; |
| 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.'><a href="'.$this->page_name.'?fm=0&fl='.$this->fl; |
echo '<th'.$w.'><a href="'; |
| echo '&'.$this->get_sfn_cgi_vars($new_sfn).$this->cgi['persist']; |
echo htmlspecialchars($this->page_name.'?fm=0&fl='.$this->fl.'&' |
| echo $this->qfn.'">'.$fdn.'</a></th>'."\n"; |
.$this->get_sfn_cgi_vars($new_sfn).$this->cgi['persist'].$this->qfn); |
| |
echo '">'.htmlspecialchars($fdn).'</a></th>'."\n"; |
| } |
} |
| } |
} |
| |
|
| Line 1750 function phpMyEdit_form_control(theForm) |
|
| Line 1793 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]; |
| $l = 'qf'.$k; |
$l = 'qf'.$k; |
| $lc = 'qf'.$k.'_comp'; |
$lc = 'qf'.$k.'_comp'; |
| $$l = $this->get_cgi_var($l); |
$li = 'qf'.$k.'_id'; |
| $$lc = $this->get_cgi_var($lc); |
$m = $this->get_cgi_var($l, ''); |
| $m = $this->web2plain($$l); // get the field name and value |
$mc = $this->get_cgi_var($lc, ''); |
| $mc = $this->web2plain($$lc); // get the comparison operator for numeric/date types |
$mi = $this->get_cgi_var($li, ''); |
| |
|
| $widthStyle = ''; |
$widthStyle = ''; |
| if (isset($this->fdd[$fd]['width'])) { |
if (isset($this->fdd[$fd]['width'])) { |
| Line 1781 function phpMyEdit_form_control(theForm) |
|
| Line 1824 function phpMyEdit_form_control(theForm) |
|
| * Default size is 2 and array required for values. |
* Default size is 2 and array required for values. |
| */ |
*/ |
| $multiple = $this->fdd[$fd]['select'] == 'M'; |
$multiple = $this->fdd[$fd]['select'] == 'M'; |
| $selected = $m; |
$selected = $mi; |
| $x = isset($this->fdd[$k]['values']['table']) || !$this->col_has_values($k) |
$x = isset($this->fdd[$k]['values']['table']) || !$this->col_has_values($k) |
| ? $this->set_values_from_table($k, array('*' => '*')) |
? $this->set_values_from_table($k, array('*' => '*')) |
| : array('*' => '*') + (array) $this->fdd[$k]['values2'] + (array) $this->fdd[$k]['values']; |
: array('*' => '*') + (array) $this->fdd[$k]['values2'] + (array) $this->fdd[$k]['values']; |
| echo $this->htmlSelect($l, $x, $selected, $multiple); |
echo $this->htmlSelect($l.'_id', $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 1808 function phpMyEdit_form_control(theForm) |
|
| Line 1851 function phpMyEdit_form_control(theForm) |
|
| echo ' value="'.htmlspecialchars($m).'"'.$size_ml_props.'>'; |
echo ' value="'.htmlspecialchars($m).'"'.$size_ml_props.'>'; |
| } elseif ($this->col_is_date($k)) { |
} elseif ($this->col_is_date($k)) { |
| // it's a date |
// it's a date |
| //echo $this->htmlSelect($l.'_comp',$comp_ops,$$lc); |
|
| // first get any date elements that were passed in |
|
| //$filter_val = $this->gather_search_date_fields_into_mysql_timestamp('qf'.$k); |
|
| // display the search formlet |
|
| //if ($mc) { |
|
| // //echo $this->display_search_field_date($type,'qf'.$k,$filter_val,$this->fdd[$k]['datemask']); |
|
| // //echo $this->mdate_displayForm($filter_val,$type,'qf'.$k,$this->fdd[$k]['datemask'],true); |
|
| // echo $this->mdate_disperse($k,true,$filter_val); |
|
| //} |
|
| //else { |
|
| // //echo $this->display_search_field_date( $type,'qf'.$k,'',$this->fdd[$k]['datemask']); |
|
| // echo $this->mdate_displayForm('',$type,'qf'.$k,$this->fdd[$k]['datemask'],true); |
|
| //} |
|
| // it's treated as a string |
// it's treated as a string |
| echo '<input type="text" name="qf'.$k.'"'; |
echo '<input type="text" name="qf'.$k.'"'; |
| echo ' value="'.htmlspecialchars($m).'"'.$size_ml_props.'>'; |
echo ' value="'.htmlspecialchars($m).'"'.$size_ml_props.'>'; |
| } elseif ($this->col_is_number($k)) { |
} elseif ($this->col_is_number($k)) { |
| // it's a number |
// it's a number |
| echo $this->htmlSelect($l.'_comp',$comp_ops,$$lc); |
echo $this->htmlSelect($l.'_comp',$comp_ops,$mc); |
| // it's treated as a string |
// it's treated as a string |
| echo '<input type="text" name="qf'.$k.'"' |
echo '<input type="text" name="qf'.$k.'"' |
| .' value="'.htmlspecialchars($m).'"'.$size_ml_props.'>'; |
.' value="'.htmlspecialchars($m).'"'.$size_ml_props.'>'; |
| Line 1891 function phpMyEdit_form_control(theForm) |
|
| Line 1921 function phpMyEdit_form_control(theForm) |
|
| * Display the current query |
* Display the current query |
| */ |
*/ |
| |
|
| $text_query = $this->make_text_where_from_query_opts(); |
$text_query = $this->make_where_from_query_opts(null, true); |
| 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="'.$this->get_server_var('PHP_SELF') |
.'<a class="pme_a_t" href="'.$this->get_server_var('PHP_SELF') |
| .'?sfn='.$this->get_sfn_cgi_vars().'&fl='.$this->fl.'&fm='.$this->fm |
.'?'.$this->get_sfn_cgi_vars().'&fl='.$this->fl.'&fm='.$this->fm |
| .$this->cgi['persist'].'">'.$this->labels['Clear'].'</a></td>'; |
.$this->cgi['persist'].'">'.$this->labels['Clear'].'</a></td>'; |
| echo '<td colspan="'.$this->num_fields_displayed.'">' |
echo '<td colspan="'.$this->num_fields_displayed.'">' |
| .$this->labels['Current Query'].': <i>' |
.$this->labels['Current Query'].': <i>' |
| Line 1928 function phpMyEdit_form_control(theForm) |
|
| Line 1958 function phpMyEdit_form_control(theForm) |
|
| $qpview = $qstrparts; |
$qpview = $qstrparts; |
| $qpview[] = 'operation='.$this->labels['View']; |
$qpview[] = 'operation='.$this->labels['View']; |
| $qpviewStr = '?'.join('&',$qpview).$this->qfn; |
$qpviewStr = '?'.join('&',$qpview).$this->qfn; |
| |
|
| $qpcopy = $qstrparts; |
$qpcopy = $qstrparts; |
| $qpcopy[] = 'operation='.$this->labels['Copy']; |
$qpcopy[] = 'operation='.$this->labels['Copy']; |
| $qpcopyStr = '?'.join('&',$qpcopy).$this->qfn; |
$qpcopyStr = '?'.join('&',$qpcopy).$this->qfn; |
| |
|
| $qpchange = $qstrparts; |
$qpchange = $qstrparts; |
| $qpchange[] = 'operation='.$this->labels['Change']; |
$qpchange[] = 'operation='.$this->labels['Change']; |
| $qpchangeStr = '?'.join('&',$qpchange).$this->qfn; |
$qpchangeStr = '?'.join('&',$qpchange).$this->qfn; |
| |
|
| $qpdelete = $qstrparts; |
$qpdelete = $qstrparts; |
| $qpdelete[] = 'operation='.$this->labels['Delete']; |
$qpdelete[] = 'operation='.$this->labels['Delete']; |
| $qpdeleteStr = '?'.join('&',$qpdelete).$this->qfn; |
$qpdeleteStr = '?'.join('&',$qpdelete).$this->qfn; |
| Line 2239 function phpMyEdit_form_control(theForm) |
|
| Line 2266 function phpMyEdit_form_control(theForm) |
|
| $this->create_javascripts(); |
$this->create_javascripts(); |
| |
|
| if ($this->cgi['persist'] != '') { |
if ($this->cgi['persist'] != '') { |
| $this->write_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_qf_hidden_fields(); |
| |
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"; |
| $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 '<input type="hidden" name="qfn" value="'.htmlspecialchars($this->qfn).'">'."\n"; |
|
| |
|
| if ($this->nav_up()) { |
if ($this->nav_up()) { |
| $this->display_record_buttons(); |
$this->display_record_buttons(); |
| Line 2798 function phpMyEdit_form_control(theForm) |
|
| Line 2825 function phpMyEdit_form_control(theForm) |
|
| |
|
| $this->disconnect(); |
$this->disconnect(); |
| |
|
| global $phpMyEdit_timer; |
if ($this->display['time'] && $this->timer != null) { |
| if ($this->display['time'] && $phpMyEdit_timer) { |
echo $this->timer->end() . ' miliseconds'; |
| echo $phpMyEdit_timer->end(); |
|
| } |
} |
| } /* }}} */ |
} /* }}} */ |
| |
|
| Line 2810 function phpMyEdit_form_control(theForm) |
|
| Line 2836 function phpMyEdit_form_control(theForm) |
|
| function phpMyEdit($opts) /* {{{ */ |
function phpMyEdit($opts) /* {{{ */ |
| { |
{ |
| /* |
/* |
| * Creating directory variables |
|
| */ |
|
| $this->dir['root'] = dirname(__FILE__) |
|
| . (strlen(dirname(__FILE__)) > 0 ? '/' : ''); |
|
| $this->dir['lang'] = $this->dir['root'].'lang/'; |
|
| |
|
| /* |
|
| * Creting URL variables |
|
| */ |
|
| $this->url['images'] = 'images/'; |
|
| isset($opts['url']['images']) && $this->url['images'] = $opts['url']['images']; |
|
| |
|
| /* |
|
| * Instance class variables |
* Instance class variables |
| */ |
*/ |
| $this->hn = $opts['hn']; |
$this->hn = $opts['hn']; |
| Line 2838 function phpMyEdit_form_control(theForm) |
|
| Line 2851 function phpMyEdit_form_control(theForm) |
|
| $this->fdd = $opts['fdd']; |
$this->fdd = $opts['fdd']; |
| $this->multiple = intval($opts['multiple']); |
$this->multiple = intval($opts['multiple']); |
| $this->multiple <= 0 && $this->multiple = 2; |
$this->multiple <= 0 && $this->multiple = 2; |
| $this->display = @$opts['display']; |
|
| $this->filters = @$opts['filters']; |
$this->filters = @$opts['filters']; |
| $this->triggers = @$opts['triggers']; |
$this->triggers = @$opts['triggers']; |
| $this->notify = @$opts['notify']; |
$this->notify = @$opts['notify']; |
| $this->logtable = @$opts['logtable']; |
$this->logtable = @$opts['logtable']; |
| $this->page_name = $this->tb; |
$this->page_name = $this->tb; |
| isset($opts['page_name']) && $this->page_name = $opts['page_name']; |
isset($opts['page_name']) && $this->page_name = $opts['page_name']; |
| |
$this->display['query'] = @$opts['display']['query']; |
| |
$this->display['sort'] = @$opts['display']['sort']; |
| |
$this->display['time'] = @$opts['display']['time']; |
| |
if ($this->display['time']) { |
| |
$this->timer = new phpMyEdit_timer(); |
| |
} |
| |
|
| |
/* |
| |
* Creating directory variables |
| |
*/ |
| |
$this->dir['root'] = dirname(__FILE__) |
| |
. (strlen(dirname(__FILE__)) > 0 ? '/' : ''); |
| |
$this->dir['lang'] = $this->dir['root'].'lang/'; |
| |
|
| |
/* |
| |
* Creting URL variables |
| |
*/ |
| |
$this->url['images'] = 'images/'; |
| |
isset($opts['url']['images']) && $this->url['images'] = $opts['url']['images']; |
| |
|
| |
|
| // alternate row background colors |
// alternate row background colors |
| /* What's this?! |
/* What's this?! |
| Line 2909 function phpMyEdit_form_control(theForm) |
|
| Line 2941 function phpMyEdit_form_control(theForm) |
|
| $this->apply = $this->get_cgi_var('apply'); |
$this->apply = $this->get_cgi_var('apply'); |
| $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->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 2947 function phpMyEdit_form_control(theForm) |
|
| Line 2978 function phpMyEdit_form_control(theForm) |
|
| */ |
*/ |
| if ($this->sw == $this->labels['Clear']) { |
if ($this->sw == $this->labels['Clear']) { |
| for ($k = 0; $k < $this->num_fds; $k++) { |
for ($k = 0; $k < $this->num_fds; $k++) { |
| $this->cgi['overwrite']["qf$k"] = ''; |
$this->cgi['overwrite']["qf$k"] = ''; |
| $this->cgi['overwrite']["qf$k".'_comp'] = ''; |
$this->cgi['overwrite']["qf$k".'_comp'] = ''; |
| |
$this->cgi['overwrite']["qf$k".'_id'] = ''; |
| } |
} |
| } |
} |
| |
|