version 1.60, 2003/03/26 18:40:01 |
version 1.61, 2003/03/29 01:34:04 |
|
|
* http://www.platon.sk/projects/phpMyEdit/ |
* http://www.platon.sk/projects/phpMyEdit/ |
*/ |
*/ |
|
|
/* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.59 2003/03/25 21:54:28 nepto Exp $ */ |
/* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.60 2003/03/26 18:40:01 nepto Exp $ */ |
|
|
/* This is a generic table editing program. The table and fields to be |
/* This is a generic table editing program. The table and fields to be |
edited are defined in the calling program. |
edited are defined in the calling program. |
|
|
var $dbh; // database handle |
var $dbh; // database handle |
|
|
// Record manipulation |
// Record manipulation |
var $key; // Name of field which is the unique key |
var $key; // name of field which is the unique key |
var $key_type; // Type of key field (int/real/string/date etc.) |
var $key_num; // number of field which is the unique key |
var $key_delim; // Character used for key value quoting |
var $key_type; // type of key field (int/real/string/date etc.) |
var $rec; // no. of record selected for editing |
var $key_delim; // character used for key value quoting |
var $inc; // no of records to display |
var $rec; // number of record selected for editing |
|
var $inc; // number of records to display |
var $fm; // first record to display |
var $fm; // first record to display |
var $fl; // is the filter row displayed (boolean) |
var $fl; // is the filter row displayed (boolean) |
var $fds; // sql field names |
var $fds; // sql field names |
var $num_fds; // number of fields |
var $num_fds; // number of fields |
var $options; // Options for users: ACDFVPI |
var $options; // options for users: ACDFVPI |
var $fdd; // field definitions |
var $fdd; // field definitions |
var $qfn; // value of all filters used during the last pass |
var $qfn; // value of all filters used during the last pass |
var $sfn; // sort field number (- = descending sort order) |
var $sfn; // sort field number (- = descending sort order) |
|
|
var $navigation; // navigation style |
var $navigation; // navigation style |
var $timer = null; // phpMyEdit_timer object |
var $timer = null; // phpMyEdit_timer object |
|
|
|
// Predefined variables |
|
var $comp_ops = array('<'=>'<','<='=>'<=','='=>'=','>='=>'>=','>'=>'>'); |
|
var $sql_aggrs = array( |
|
'sum' => 'Total', |
|
'avg' => 'Average', |
|
'min' => 'Minimum', |
|
'max' => 'Maximum', |
|
'count' => 'Count'); |
// }}} |
// }}} |
|
|
/* |
/* |
* type functions |
* column specific functions |
*/ |
*/ |
|
|
function col_is_date($k) { return in_array($this->fdd[$k]['type'], $this->dateTypes ); } |
|
function col_is_number($k) { return in_array($this->fdd[$k]['type'], $this->numberTypes); } |
|
function col_is_string($k) { return in_array($this->fdd[$k]['type'], $this->stringTypes); } |
|
function col_is_set($k) { return $this->fdd[$k]['type'] == 'set'; } |
|
function col_has_values($k) { return isset($this->fdd[$k]['values']) || isset($this->fdd[$k]['values2']); } |
function col_has_values($k) { return isset($this->fdd[$k]['values']) || isset($this->fdd[$k]['values2']); } |
|
|
/* |
/* |
|
|
$table = $this->fdd[$field_num]['values']['table']; |
$table = $this->fdd[$field_num]['values']['table']; |
$key = $this->fdd[$field_num]['values']['column']; |
$key = $this->fdd[$field_num]['values']['column']; |
$desc = $this->fdd[$field_num]['values']['description']; |
$desc = $this->fdd[$field_num]['values']['description']; |
$qparts['type'] = 'select'; |
$qparts['type'] = 'select'; |
if ($table) { |
if ($table) { |
$qparts['select'] = 'DISTINCT '.$key; |
$qparts['select'] = 'DISTINCT '.$key; |
if ($desc) { |
if ($desc) { |
|
|
{ |
{ |
$fields = array(); |
$fields = array(); |
for ($k = 0; $k < $this->num_fds; $k++) { |
for ($k = 0; $k < $this->num_fds; $k++) { |
if (! $this->displayed[$k] && $k != $this->key_num) |
if (! $this->displayed[$k] && $k != $this->key_num) { |
continue; |
continue; |
if ($this->col_is_date($k)) { |
} |
//$fields[] = 'UNIX_TIMESTAMP('.$this->fqn($k).') AS qf'.$k; |
$fields[] = $this->fqn($k).' AS qf'.$k; |
//$fields[] = 'DATE_FORMAT('.$this->fqn($k).',"%Y%m%d%H%i%s") AS qf'.$k; |
if ($this->col_has_values($k)) { |
$fields[] = $this->fqn($k).' AS qf'.$k; |
$fields[] = $this->fqn($k, false, true, true).' AS qf'.$k.'_idx'; |
} else { |
|
$fields[] = $this->fqn($k).' AS qf'.$k; |
|
if ($this->col_has_values($k)) { |
|
$fields[] = $this->fqn($k, false, true, true).' AS qf'.$k.'_idx'; |
|
} |
|
//echo '[['.$this->fqn($k).' AS qf'.$k.']]<br>'; |
|
} |
} |
} |
} |
return join(',',$fields); |
return join(',', $fields); |
} /* }}} */ |
} /* }}} */ |
|
|
function query_make($parts) /* {{{ */ |
function query_make($parts) /* {{{ */ |
|
|
foreach ($parts as $k => $v) { |
foreach ($parts as $k => $v) { |
$parts[$k] = trim($parts[$k]); |
$parts[$k] = trim($parts[$k]); |
} |
} |
|
|
switch ($parts['type']) { |
switch ($parts['type']) { |
case 'select': |
case 'select': |
$ret = 'SELECT '; |
$ret = 'SELECT '; |
|
|
// gathers query options into an array, $this->query_opts |
// gathers query options into an array, $this->query_opts |
$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'; |
$li = 'qf'.$k.'_id'; |
$li = 'qf'.$k.'_id'; |
|
|
continue; |
continue; |
} |
} |
if (is_array($m) || is_array($mi)) { |
if (is_array($m) || is_array($mi)) { |
is_array($mi) && $m = $mi; |
if (is_array($mi)) { |
|
$m = $mi; |
|
$l = $li; |
|
} |
if (in_array('*', $m)) { |
if (in_array('*', $m)) { |
continue; |
continue; |
} |
} |
|
|
$afilter = $afilter.',"'.addslashes($m[$key]).'"'; |
$afilter = $afilter.',"'.addslashes($m[$key]).'"'; |
$qf_val .= ',"'.addslashes($m[$key]).'"'; |
$qf_val .= ',"'.addslashes($m[$key]).'"'; |
} |
} |
|
$this->qfn .= '&'.$l.'['.rawurlencode($key).']='.rawurlencode($m[$key]); |
} |
} |
$afilter = $afilter.')'; |
$afilter = $afilter.')'; |
// XXX: $dont_desc and $dont_cols hack |
// XXX: $dont_desc and $dont_cols hack |
|
|
} |
} |
$afilter = addslashes($mi); |
$afilter = addslashes($mi); |
$qo[$this->fqn($k, false, true, true)] = array('oper' => '=', 'value' => "'$afilter'"); |
$qo[$this->fqn($k, false, true, true)] = array('oper' => '=', 'value' => "'$afilter'"); |
|
$this->qfn .= '&'.$li.'='.rawurlencode($mi); |
} else if (isset($m)) { |
} else if (isset($m)) { |
if ($m == '*') { |
if ($m == '*') { |
continue; |
continue; |
|
|
continue; |
continue; |
} |
} |
$afilter = addslashes($m); |
$afilter = addslashes($m); |
if ($this->col_is_string($k) |
if ($this->fdd[$k]['select'] == 'N') { |
|| $this->fdd[$k]['values']['description'] |
$mc = in_array($mc, $this->comp_ops) ? $mc : '='; |
|| $this->fdd[$k]['values']['column']) { |
$qo[$this->fqn($k)] = array('oper' => $mc, 'value' => "'$afilter'"); |
|
$this->qfn .= '&'.$l .'='.rawurlencode($m); |
|
$this->qfn .= '&'.$lc.'='.rawurlencode($mc); |
|
} else { |
$afilter = '%'.str_replace('*', '%', $afilter).'%'; |
$afilter = '%'.str_replace('*', '%', $afilter).'%'; |
$ids = array(); |
$ids = array(); |
$ar = array(); |
$ar = array(); |
$ar[$this->fqn($k)] = array('oper' => 'LIKE', 'value' => "'$afilter'"); |
$ar[$this->fqn($k)] = array('oper' => 'LIKE', 'value' => "'$afilter'"); |
if (is_array($this->fdd[$k]['values2'])) { |
if (is_array($this->fdd[$k]['values2'])) { |
foreach ($this->fdd[$k]['values2'] as $key => $val) { |
foreach ($this->fdd[$k]['values2'] as $key => $val) { |
if (stristr($val, $m)) { |
if (strlen($m) > 0 && stristr($val, $m)) { |
$ids[] = '"'.addslashes($key).'"'; |
$ids[] = '"'.addslashes($key).'"'; |
} |
} |
} |
} |
|
|
} |
} |
} |
} |
$qo[] = $ar; |
$qo[] = $ar; |
} elseif ($this->col_is_number($k) && isset($mc)) { |
$this->qfn .= '&'.$l.'='.rawurlencode($m); |
if (isset($mc)) { |
|
$qo[$this->fqn($k)] = array('oper' => $mc, '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)) { |
|
//debug_var('col_is_string',$this->fdd[$k]['name'].'::'.$this->fdd[$k]['type']); |
|
$qo[$this->fqn($k)] = array( 'oper' => '=', 'value' => "'$afilter'"); |
|
} else { |
|
// unknown (to mysql/php interface) field type |
|
// message the filter for a string comparison |
|
$afilter = '%'.str_replace ('*', '%', $afilter).'%'; |
|
$qo[$this->fqn($k)] = array('oper' => 'like', 'value' => "'$afilter'"); |
|
} |
} |
} |
} |
} |
} |
$this->query_opts = $qo; |
$this->query_opts = $qo; |
|
|
/* If the filter input boxes are not displayed, we need to preserve |
# TODO: DELETE ME!! |
the filter by its emulaion. */ |
|
for ($k = 0; $k < $this->num_fds; $k++) { |
# /* If the filter input boxes are not displayed, we need to preserve |
$l = 'qf'.$k; |
# the filter by its emulaion. */ |
$lc = 'qf'.$k.'_comp'; |
# for ($k = 0; $k < $this->num_fds; $k++) { |
$li = 'qf'.$k.'_id'; |
# $l = 'qf'.$k; |
$m = $this->get_cgi_var($l); |
# $lc = 'qf'.$k.'_comp'; |
$mc = $this->get_cgi_var($lc); |
# $li = 'qf'.$k.'_id'; |
$mi = $this->get_cgi_var($li); |
# $m = $this->get_cgi_var($l); |
if (! isset($m) && ! isset($mi)) { |
# $mc = $this->get_cgi_var($lc); |
continue; |
# $mi = $this->get_cgi_var($li); |
} |
# if (! isset($m) && ! isset($mi)) { |
$stack = array(); |
# continue; |
foreach (array($l => $m, $lc => $mc, $li => $mi) as $name => $value) { |
# } |
if (is_array($value)) { |
# $stack = array(); |
foreach ($value as $key => $val) { |
# foreach (array($l => $m, $lc => $mc, $li => $mi) as $name => $value) { |
if ($key === '' && isset($value)) { |
# if (is_array($value)) { |
continue; |
# foreach ($value as $key => $val) { |
} |
# if ($key === '' && isset($value)) { |
$this->qfn .= '&'.$name.'['.rawurlencode($key).']='.rawurlencode($val); |
# continue; |
$hidden_qfs .= '<input type="hidden" name="'.$name.'['.$key |
# } |
.']" value="'.htmlspecialchars($val).'">'."\n"; |
# $this->qfn_old .= '&'.$name.'['.rawurlencode($key).']='.rawurlencode($val); |
} |
# } |
} else { |
# } else { |
if (! isset($value) || $value == '*') { |
# if (! isset($value) || $value == '*') { |
continue; |
# continue; |
} |
# } |
// Sync with gather_query_opts() |
# // Sync with gather_query_opts() |
if ($this->fdd[$k]['select'] != 'M' && $this->fdd[$k]['select'] != 'D' && $value == '') { |
# if ($this->fdd[$k]['select'] != 'M' && $this->fdd[$k]['select'] != 'D' && $value == '') { |
continue; |
# continue; |
} |
# } |
/* Opertation CGI variables (=, <, >, ...) are added only |
# /* Opertation CGI variables (=, <, >, ...) are added only |
if their numeric equivalent was already added as well. We |
# if their numeric equivalent was already added as well. We |
are using $stack for remembering this. */ |
# are using $stack for remembering this. */ |
if (preg_match('|^(qf\d+)_comp$|', $name, $matches)) { |
# if (preg_match('|^(qf\d+)_comp$|', $name, $matches)) { |
if (! in_array($matches[1], $stack)) { |
# if (! in_array($matches[1], $stack)) { |
continue; |
# continue; |
} |
# } |
} |
# } |
$stack[] = $name; |
# $stack[] = $name; |
$this->qfn .= '&'.$name.'='.rawurlencode($value); |
# $this->qfn_old .= '&'.$name.'='.rawurlencode($value); |
} |
# } |
} |
# } |
} |
# } |
|
# echo htmlspecialchars('['.$this->qfn_old.']'); |
|
# echo '<br>'; |
|
# echo htmlspecialchars('['.$this->qfn.']'); |
} /* }}} */ |
} /* }}} */ |
|
|
/* |
/* |
Line 744 function phpMyEdit_form_control(theForm) |
|
Line 738 function phpMyEdit_form_control(theForm) |
|
foreach ($required_ar as $field_num) { |
foreach ($required_ar as $field_num) { |
if ($this->col_has_values($field_num)) { |
if ($this->col_has_values($field_num)) { |
$condition = 'theForm.%s.selectedIndex == -1'; |
$condition = 'theForm.%s.selectedIndex == -1'; |
$multiple = ($this->fdd[$field_num]['select'] == 'M' |
$multiple = $this->fdd[$field_num]['select'] == 'M' |
|| $this->col_is_set($field_num)) |
|
&& ! $this->fdd[$k]['values']['table']; |
&& ! $this->fdd[$k]['values']['table']; |
} else { |
} else { |
$condition = 'phpMyEdit_trim(theForm.%s.value) == ""'; |
$condition = 'phpMyEdit_trim(theForm.%s.value) == ""'; |
Line 818 function phpMyEdit_form_control(theForm) |
|
Line 811 function phpMyEdit_form_control(theForm) |
|
if ($this->col_has_values($k) && !$this->readonly($k)) { |
if ($this->col_has_values($k) && !$this->readonly($k)) { |
$vals = $this->set_values($k); |
$vals = $this->set_values($k); |
$selected = @$this->fdd[$k]['default']; |
$selected = @$this->fdd[$k]['default']; |
$multiple = ($this->fdd[$k]['select'] == 'M' || $this->col_is_set($k)) |
$multiple = $this->fdd[$k]['select'] == 'M' && ! $this->fdd[$k]['values']['table']; |
&& ! $this->fdd[$k]['values']['table']; |
|
echo $this->htmlSelect($this->fds[$k], $css_class_name, $vals, $selected, $multiple); |
echo $this->htmlSelect($this->fds[$k], $css_class_name, $vals, $selected, $multiple); |
} elseif (isset ($this->fdd[$k]['textarea']) && !$this->readonly($k)) { |
} elseif (isset ($this->fdd[$k]['textarea']) && !$this->readonly($k)) { |
echo '<textarea class="',$css_class_name,'" '; |
echo '<textarea class="',$css_class_name,'" '; |
Line 837 function phpMyEdit_form_control(theForm) |
|
Line 829 function phpMyEdit_form_control(theForm) |
|
} else { |
} else { |
// Simple edit box required |
// Simple edit box required |
$size_ml_props = ''; |
$size_ml_props = ''; |
if ($this->fdd[$k]['type'] != 'blob') { |
$maxlen = intval($this->fdd[$k]['maxlen']); |
$maxlen = intval($this->fdd[$k]['maxlen']); |
//$maxlen > 0 || $maxlen = 300; |
$maxlen > 0 || $maxlen = 300; |
$size = min($maxlen, 60); |
$size = min($maxlen, 60); |
$size && $size_ml_props .= ' size="'.$size.'"'; |
$size && $size_ml_props .= ' size="'.$size.'"'; |
$maxlen && $size_ml_props .= ' maxlength="'.$maxlen.'"'; |
$maxlen && $size_ml_props .= ' maxlength="'.$maxlen.'"'; |
echo '<input class="',$css_class_name,'" type="text" '; |
} |
echo ($this->readonly($k) ? 'disabled ' : ''),' name="',$this->fds[$k],'"'; |
if ($this->col_is_string($k) || $this->col_is_number($k)) { |
echo $size_ml_props,' value="'; |
// string type |
echo $this->htmlDisplay($this->fdd[$k],$this->fdd[$k]['default'],false,false,false),'">'; |
echo '<input class="',$css_class_name,'" type="text" '; |
|
echo ($this->readonly($k) ? 'disabled ' : ''),' name="',$this->fds[$k],'"'; |
|
echo $size_ml_props,' value="'; |
|
echo $this->htmlDisplay($this->fdd[$k],$this->fdd[$k]['default'],false,false,false),'">'; |
|
} elseif ($this->col_is_date($k)) { |
|
// date type, get date components |
|
//if ($this->fdd[$k]['default']) |
|
// $value = $this->mdate_set($this->fdd[$k]['default'],$this->fdd[$k]['type']); |
|
//$value = time(); |
|
//echo $this->mdate_disperse($k,$value,true); |
|
// string type |
|
echo '<input class="',$css_class_name,'" type="text" '; |
|
echo ($this->readonly($k) ? 'disabled ' : ''),' name="',$this->fds[$k],'"'; |
|
echo $size_ml_props,' value="'; |
|
echo $this->htmlDisplay($this->fdd[$k],$this->fdd[$k]['default'],false,false,false),'">'; |
|
} else { |
|
// unknown type |
|
echo '<input class="',$css_class_name,'" type="text" '; |
|
echo ($this->readonly($k) ? 'disabled ' : ''),' name="',$this->fds[$k],'"'; |
|
echo $size_ml_props,' value="'; |
|
echo $this->htmlDisplay($this->fdd[$k],$this->fdd[$k]['default'],false,false,false),'">'; |
|
} |
|
} |
} |
echo '</td>',"\n"; |
echo '</td>',"\n"; |
if ($this->guidance) { |
if ($this->guidance) { |
Line 954 function phpMyEdit_form_control(theForm) |
|
Line 924 function phpMyEdit_form_control(theForm) |
|
$css_class_name = $this->getCSSclass('input', '', true); |
$css_class_name = $this->getCSSclass('input', '', true); |
if ($this->col_has_values($k) && !$this->readonly($k)) { |
if ($this->col_has_values($k) && !$this->readonly($k)) { |
$vals = $this->set_values($k); |
$vals = $this->set_values($k); |
$multiple = ($this->fdd[$k]['select'] == 'M' || $this->col_is_set($k)) |
$multiple = $this->fdd[$k]['select'] == 'M' && ! $this->fdd[$k]['values']['table']; |
&& ! $this->fdd[$k]['values']['table']; |
|
echo $this->htmlSelect($this->fds[$k], $css_class_name, $vals, $row["qf$k"], $multiple); |
echo $this->htmlSelect($this->fds[$k], $css_class_name, $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 class="',$css_class_name,'" name="'.$this->fds[$k].'"'; |
echo '<textarea class="',$css_class_name,'" name="'.$this->fds[$k].'"'; |
Line 977 function phpMyEdit_form_control(theForm) |
|
Line 946 function phpMyEdit_form_control(theForm) |
|
echo $row[$this->fds[$k]],'</textarea>',"\n"; |
echo $row[$this->fds[$k]],'</textarea>',"\n"; |
} else { |
} else { |
$size_ml_props = ''; |
$size_ml_props = ''; |
if ($this->fdd[$k]['type'] != 'blob') { |
$maxlen = intval($this->fdd[$k]['maxlen']); |
$maxlen = intval($this->fdd[$k]['maxlen']); |
//$maxlen > 0 || $maxlen = 300; |
$maxlen > 0 || $maxlen = 300; |
$size = min($maxlen, 60); |
$size = min($maxlen, 60); |
$size && $size_ml_props .= ' size="'.$size.'"'; |
$size && $size_ml_props .= ' size="'.$size.'"'; |
$maxlen && $size_ml_props .= ' maxlength="'.$maxlen.'"'; |
$maxlen && $size_ml_props .= ' maxlength="'.$maxlen.'"'; |
echo '<input class="',$css_class_name,'" type="text" '; |
} |
echo ($this->readonly($k) ? 'disabled ' : ''),'name="',$this->fds[$k],'" value="'; |
if ($this->col_is_string($k) || $this->col_is_number($k)) { |
echo $this->htmlDisplay($this->fdd[$k], $row["qf$k"], false, true, false); |
// string type |
echo '" ',$size_ml_props,'>',"\n"; |
echo '<input class="',$css_class_name,'" type="text" '; |
|
echo ($this->readonly($k) ? 'disabled ' : ''),'name="',$this->fds[$k],'" value="'; |
|
echo $this->htmlDisplay($this->fdd[$k], $row["qf$k"], false, true, false); |
|
echo '" ',$size_ml_props,'>'; |
|
} elseif ($this->col_is_date($k)) { |
|
echo '<input class="',$css_class_name,'" type="text" '; |
|
echo ($this->readonly($k) ? 'disabled ' : ''),'name="',$this->fds[$k],'" value="'; |
|
echo $this->htmlDisplay($this->fdd[$k], $row["qf$k"], false, true, false); |
|
echo '" ',$size_ml_props,'>'; |
|
} else { |
|
// unknown type |
|
echo '<input class="',$css_class_name,'" type="text" '; |
|
echo ($this->readonly($k) ? 'disabled ' : ''),'name="',$this->fds[$k],'" value="'; |
|
echo $this->htmlDisplay($this->fdd[$k], $row["qf$k"], false, true, false); |
|
echo '" ',$size_ml_props,'>'; |
|
} |
|
echo "\n"; |
|
} |
} |
echo '</td>',"\n"; |
echo '</td>',"\n"; |
} /* }}} */ |
} /* }}} */ |
Line 1011 function phpMyEdit_form_control(theForm) |
|
Line 963 function phpMyEdit_form_control(theForm) |
|
{ |
{ |
echo '<td class="',$this->getCSSclass('value', '', true),'">',"\n"; |
echo '<td class="',$this->getCSSclass('value', '', true),'">',"\n"; |
$size_ml_props = ''; |
$size_ml_props = ''; |
if ($this->fdd[$k]['type'] != 'blob') { |
$maxlen = intval($this->fdd[$k]['maxlen']); |
$maxlen = intval($this->fdd[$k]['maxlen']); |
//$maxlen > 0 || $maxlen = 300; |
$maxlen > 0 || $maxlen = 300; |
$size = min($maxlen, 60); |
$size = min($maxlen, 60); |
$size && $size_ml_props .= ' size="'.$size.'"'; |
$size && $size_ml_props .= ' size="'.$size.'"'; |
$maxlen && $size_ml_props .= ' maxlength="'.$maxlen.'"'; |
$maxlen && $size_ml_props .= ' maxlength="'.$maxlen.'"'; |
|
} |
|
echo '<input class="',$this->getCSSclass('value', '', true),'" type="password" '; |
echo '<input class="',$this->getCSSclass('value', '', true),'" type="password" '; |
echo ($this->readonly($k) ? 'disabled ' : ''),'name="',$this->fds[$k],'" value="'; |
echo ($this->readonly($k) ? 'disabled ' : ''),'name="',$this->fds[$k],'" value="'; |
echo $this->htmlDisplay($this->fdd[$k], $row["qf$k"], false, true, false); |
echo $this->htmlDisplay($this->fdd[$k], $row["qf$k"], false, true, false); |
echo '" ',$size_ml_props,'>'; |
echo '" ',$size_ml_props,'>',"\n"; |
echo '</td>',"\n"; |
echo '</td>',"\n"; |
} /* }}} */ |
} /* }}} */ |
|
|
Line 1525 function phpMyEdit_form_control(theForm) |
|
Line 1475 function phpMyEdit_form_control(theForm) |
|
/* |
/* |
* Display the MySQL table in an HTML table |
* Display the MySQL table in an HTML table |
*/ |
*/ |
$comp_ops = array('<'=>'<','<='=>'<=', |
|
'='=>'=','>='=>'>=','>'=>'>'); |
|
echo '<form class="',$this->getCSSclass('form'),'" action="'; |
echo '<form class="',$this->getCSSclass('form'),'" action="'; |
echo htmlspecialchars($this->page_name),'" method="POST">',"\n"; |
echo htmlspecialchars($this->page_name),'" method="POST">',"\n"; |
echo $this->get_origvars_html($this->get_sfn_cgi_vars()); |
echo $this->get_origvars_html($this->get_sfn_cgi_vars()); |
Line 1702 function phpMyEdit_form_control(theForm) |
|
Line 1650 function phpMyEdit_form_control(theForm) |
|
$fields = array_flip(array_keys($filter_row)); |
$fields = array_flip(array_keys($filter_row)); |
} |
} |
if ($fields != false) { |
if ($fields != false) { |
echo '<tr class="',$this->getCSSclass('filter'),'">'; |
echo '<tr class="',$this->getCSSclass('filter'),'">',"\n"; |
echo '<td class="',$this->getCSSclass('filter'),'" colspan="',$sys_cols,'">'; |
echo '<td class="',$this->getCSSclass('filter'),'" colspan="',$sys_cols,'">'; |
echo '<input class="',$this->getCSSclass('filter'),'" type="submit" name="filter" value="'; |
echo '<input class="',$this->getCSSclass('filter'),'" type="submit" name="filter" value="'; |
echo $this->labels['Query'],'"></td>',"\n"; |
echo $this->labels['Query'],'"></td>',"\n"; |
for ($k = 0; $k < $this->num_fds; $k++) { |
for ($k = 0; $k < $this->num_fds; $k++) { |
|
if (! $this->displayed[$k]) { |
|
continue; |
|
} |
$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]; |
Line 1723 function phpMyEdit_form_control(theForm) |
|
Line 1674 function phpMyEdit_form_control(theForm) |
|
$mc = $this->get_cgi_var($lc); |
$mc = $this->get_cgi_var($lc); |
$mi = $this->get_cgi_var($li); |
$mi = $this->get_cgi_var($li); |
} |
} |
if (isset($this->fdd[$fd]['width'])) { |
$widthStyle = isset($this->fdd[$fd]['width']) |
$widthStyle = ' STYLE=\'width: "'.(6*$this->fdd[$fd]['width']).'px"\''; |
? ' STYLE=\'width: "'.(6*$this->fdd[$fd]['width']).'px"\'' : ''; |
} |
echo '<td',$widthStyle,' class="',$css_class_name,'">'; |
$opened = false; |
if ($this->password($k) || $this->hidden($k)) { |
if ($this->displayed[$k]) { |
echo ' '; |
echo '<td',$widthStyle,' class="',$css_class_name,'">'; |
} else if ($this->fdd[$fd]['select'] == 'D' || $this->fdd[$fd]['select'] == 'M') { |
$opened = true; |
|
} |
|
$type = $this->fdd[$fd]['type']; |
|
if ($this->col_has_values($k)) { |
|
$type = 'string'; |
|
} |
|
if (! $this->displayed[$k]) { |
|
continue; |
|
} |
|
if ($this->fdd[$fd]['select'] == 'D' or $this->fdd[$fd]['select'] == 'M') { |
|
// Multiple fields processing |
// Multiple fields processing |
// Default size is 2 and array required for values. |
// Default size is 2 and array required for values. |
$vals = $this->set_values($k, array('*' => '*'), null, true); |
$vals = $this->set_values($k, array('*' => '*'), null, true); |
$selected = $mi; |
$selected = $mi; |
$multiple = $this->fdd[$fd]['select'] == 'M'; |
$multiple = $this->fdd[$fd]['select'] == 'M'; |
echo $this->htmlSelect($l.'_id', $css_class_name, $vals, $selected, $multiple); |
echo $this->htmlSelect($l.'_id', $css_class_name, $vals, $selected, $multiple); |
} elseif ($this->fdd[$fd]['select'] == 'T') { |
} elseif ($this->fdd[$fd]['select'] == 'N' || $this->fdd[$fd]['select'] == 'T') { |
// This is where we put the comparison selects |
$size_ml_props = ''; |
if (! $this->password($k) && ! $this->hidden($k)) { |
$maxlen = intval($this->fdd[$k]['maxlen']); |
$size_ml_props = ''; |
$maxlen > 0 || $maxlen = intval(@mysql_field_len($res, $fields["qf$k"])); |
if ($type != 'blob') { |
$size = $maxlen < 30 ? min($maxlen, 8) : 12; |
$maxlen = intval($this->fdd[$k]['maxlen']); |
$size && $size_ml_props .= ' size="'.$size.'"'; |
$maxlen > 0 || $maxlen = intval(@mysql_field_len($res, $fields["qf$k"])); |
$maxlen && $size_ml_props .= ' maxlength="'.$maxlen.'"'; |
$size = $maxlen < 30 ? min($maxlen, 8) : 12; |
if ($this->fdd[$fd]['select'] == 'N') { |
$size && $size_ml_props .= ' size="'.$size.'"'; |
$mc = in_array($mc, $this->comp_ops) ? $mc : '='; |
$maxlen && $size_ml_props .= ' maxlength="'.$maxlen.'"'; |
echo $this->htmlSelect($l.'_comp', $css_class_name, $this->comp_ops, $mc); |
} |
|
if ($this->col_is_string($k)) { |
|
// it's treated as a string |
|
echo '<input class="',$css_class_name,'" value="'; |
|
echo htmlspecialchars(@$m),'" type="text" name="qf',$k,'"',$size_ml_props,'>'; |
|
} elseif ($this->col_is_date($k)) { |
|
// it's a date |
|
// it's treated as a string |
|
echo '<input class="',$css_class_name,'" value="'; |
|
echo htmlspecialchars(@$m),'" type="text" name="qf',$k,'"',$size_ml_props,'>'; |
|
} elseif ($this->col_is_number($k)) { |
|
// it's a number |
|
$mc = in_array($mc, $comp_ops) ? $mc : '='; |
|
echo $this->htmlSelect($l.'_comp', $css_class_name, $comp_ops, $mc); |
|
// it's treated as a string |
|
echo '<input class="',$css_class_name,'" value="'; |
|
echo htmlspecialchars(@$m),'" type="text" name="qf',$k,'"',$size_ml_props,'>'; |
|
} else { |
|
// type is 'unknown' or not set, it's treated as a string |
|
echo '<input class="',$css_class_name,'" value="'; |
|
echo htmlspecialchars(@$m),'" type="text" name="qf',$k,'"',$size_ml_props,'>'; |
|
} |
|
} else { |
|
echo ' '; |
|
} |
} |
echo '</td>',"\n"; |
echo '<input class="',$css_class_name,'" value="'; |
|
echo htmlspecialchars(@$m),'" type="text" name="qf',$k,'"',$size_ml_props,'>'; |
} else { |
} else { |
echo '<td class="',$css_class_name,'"> </td>',"\n"; |
echo ' '; |
} |
} |
|
echo '</td>',"\n"; |
} |
} |
echo '</tr>',"\n"; |
echo '</tr>',"\n"; |
} |
} |
Line 2649 function phpMyEdit_form_control(theForm) |
|
Line 2568 function phpMyEdit_form_control(theForm) |
|
{ |
{ |
// Instance class variables |
// Instance class variables |
$this->hn = $opts['hn']; |
$this->hn = $opts['hn']; |
$this->hn = $opts['hn']; |
|
$this->un = $opts['un']; |
$this->un = $opts['un']; |
$this->pw = $opts['pw']; |
$this->pw = $opts['pw']; |
$this->db = $opts['db']; |
$this->db = $opts['db']; |
Line 2739 function phpMyEdit_form_control(theForm) |
|
Line 2657 function phpMyEdit_form_control(theForm) |
|
$this->sw == $this->labels['Hide'] && $this->fl = 0; |
$this->sw == $this->labels['Hide'] && $this->fl = 0; |
//$this->sw == $this->labels['Clear'] && $this->fl = 0; |
//$this->sw == $this->labels['Clear'] && $this->fl = 0; |
} |
} |
// Specific $fdd modifications depending on performed action |
|
$this->recreate_fdd(); |
|
// Extract SQL Field Names and number of fields |
|
$this->recreate_displayed(); |
|
// Constants |
|
$this->sql_aggrs = array( |
|
'' => '', |
|
'sum' => 'Total', |
|
'avg' => 'Average', |
|
'min' => 'Minimum', |
|
'max' => 'Maximum', |
|
'count' => 'Count'); |
|
// To support quick type checking |
|
$this->stringTypes = array('string','blob','set','enum'); |
|
$this->numberTypes = array('int','real'); |
|
$this->dateTypes = array('date','datetime','timestamp','time','year'); |
|
// MDdate constants |
|
$this->mdate_masks = array( |
|
'date'=>'%Y-%m-%d', |
|
'datetime'=>'%Y-%m-%d %H:%i:%s', |
|
'timestamp'=>'%Y%m%d%H%i%s', |
|
'time'=>'%H:%i:%s', |
|
'year'=>'%Y'); |
|
$this->mdate_daterange = range(date('Y')-10,date('Y')+10); |
|
$this->months_short = array( |
|
'~~PME~~'=>0, |
|
'Jan'=>1, 'Feb'=>2, 'Mar'=>3, 'Apr'=>4, |
|
'May'=>5, 'Jun'=>6, 'Jul'=>7, 'Aug'=>8, |
|
'Sep'=>9, 'Oct'=>10, 'Nov'=>11, 'Dec'=>12); |
|
$this->months_long = array( |
|
'~~PME~~'=>0, |
|
'January'=>1,'February'=>2,'March'=>3, |
|
'April'=>4,'May'=>5,'June'=>6, |
|
'July'=>7,'August'=>8,'September'=>9, |
|
'October'=>10,'November'=>11,'December'=>12); |
|
$this->months_long_keys = array_keys($this->months_long); |
|
/* If you are phpMyEdit developer, set this to 1. |
|
You can also hide some new unfinished and/or untested features under |
|
if ($this->development) { new_feature(); } statement. |
|
|
|
Also note, that this is currently unused. */ |
|
$this->development = 0; |
|
|
|
/* |
|
* Preparing some others values |
|
* (this was moved from execute() method) |
|
*/ |
|
// Setting key_delim according to key_type |
// Setting key_delim according to key_type |
if ($this->key_type == 'real') { |
if ($this->key_type == 'real') { |
/* If 'real' key_type does not work, |
/* If 'real' key_type does not work, |
Line 2796 function phpMyEdit_form_control(theForm) |
|
Line 2667 function phpMyEdit_form_control(theForm) |
|
$this->rec = intval($this->rec); |
$this->rec = intval($this->rec); |
$this->key_delim = ''; |
$this->key_delim = ''; |
} else { |
} else { |
// XXX fix this to use col_is_[type] |
|
// if (in_array($this->key_type, |
|
// array('string','blob','date','time','datetime','timestamp','year'))) |
|
$this->key_delim = '"'; |
$this->key_delim = '"'; |
// $this->rec remains unmodified |
// $this->rec remains unmodified |
} |
} |
|
// Specific $fdd modifications depending on performed action |
|
$this->recreate_fdd(); |
|
// Extract SQL Field Names and number of fields |
|
$this->recreate_displayed(); |
// Gathering query options |
// Gathering query options |
$this->gather_query_opts(); |
$this->gather_query_opts(); |
// Call to Action |
// Call to action |
// Moved this from the setup.php generated file to here |
|
!isset($opts['execute']) && $opts['execute'] = 1; |
!isset($opts['execute']) && $opts['execute'] = 1; |
$opts['execute'] && $this->execute(); |
$opts['execute'] && $this->execute(); |
} /* }}} */ |
} /* }}} */ |