version 1.78, 2003/04/28 22:18:36 |
version 1.79, 2003/05/01 21:44:44 |
|
|
* http://www.platon.sk/projects/phpMyEdit/ |
* http://www.platon.sk/projects/phpMyEdit/ |
*/ |
*/ |
|
|
/* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.77 2003/04/26 22:13:31 nepto Exp $ */ |
/* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.78 2003/04/28 22:18:36 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. |
|
|
echo htmlspecialchars($content); |
echo htmlspecialchars($content); |
echo "</pre>\n"; |
echo "</pre>\n"; |
} else { |
} else { |
echo 'debug_var()::<i>'.htmlspecialchars($name).'</i>::<b>' |
echo 'debug_var()::<i>',htmlspecialchars($name),'</i>'; |
.htmlspecialchars($val).'</b>::'."<br>\n"; |
echo '::<b>',htmlspecialchars($val),'</b>::',"<br>\n"; |
} |
} |
} /* }}} */ |
} /* }}} */ |
|
|
|
|
} |
} |
|
|
if (count($required_ar) > 0) { |
if (count($required_ar) > 0) { |
echo '<script type="text/javascript"><!--'."\n"; |
echo '<script type="text/javascript"><!--',"\n"; |
echo ' |
echo ' |
function phpMyEdit_trim(str) |
function phpMyEdit_trim(str) |
{ |
{ |
Line 707 function phpMyEdit_trim(str) |
|
Line 707 function phpMyEdit_trim(str) |
|
} |
} |
|
|
function phpMyEdit_form_control(theForm) |
function phpMyEdit_form_control(theForm) |
{'."\n"; |
{',"\n"; |
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'; |
Line 728 function phpMyEdit_form_control(theForm) |
|
Line 728 function phpMyEdit_form_control(theForm) |
|
echo ' |
echo ' |
multiple_select = null; |
multiple_select = null; |
for (i = 0; i < theForm.length; i++) { |
for (i = 0; i < theForm.length; i++) { |
if (theForm.elements[i].name == "'.$this->fds[$field_num].'[]") { |
if (theForm.elements[i].name == "',$this->fds[$field_num],'[]") { |
multiple_select = theForm.elements[i]; |
multiple_select = theForm.elements[i]; |
break; |
break; |
} |
} |
} |
} |
if (multiple_select != null && multiple_select.selectedIndex == -1) { |
if (multiple_select != null && multiple_select.selectedIndex == -1) { |
alert("'.$this->labels['Please enter'].' '.$this->fdd[$field_num]['name'].'."); |
alert("',$this->labels['Please enter'],' ',$this->fdd[$field_num]['name'],'."); |
return false; |
return false; |
}'."\n"; |
}',"\n"; |
} else { |
} else { |
echo ' |
echo ' |
if ('.sprintf($condition, $this->fds[$field_num]).') { |
if (',sprintf($condition, $this->fds[$field_num]),') { |
alert("'.$this->labels['Please enter'].' '.$this->fdd[$field_num]['name'].'."); |
alert("',$this->labels['Please enter'],' ',$this->fdd[$field_num]['name'],'."); |
theForm.'.$this->fds[$field_num].'.focus(); |
theForm.',$this->fds[$field_num],'.focus(); |
return false; |
return false; |
}'."\n"; |
}',"\n"; |
} |
} |
} |
} |
echo ' |
echo ' |
return true; |
return true; |
}'."\n\n"; |
}',"\n\n"; |
echo '// --></script>', "\n"; |
echo '// --></script>', "\n"; |
echo '<form class="',$this->getCSSclass('form'); |
echo '<form class="',$this->getCSSclass('form'); |
echo '" action="',$page_name,'" method="POST"'; |
echo '" action="',$page_name,'" method="POST"'; |
Line 779 function phpMyEdit_form_control(theForm) |
|
Line 779 function phpMyEdit_form_control(theForm) |
|
$css_class_name = $this->getCSSclass('input', null, 'next', $css_postfix); |
$css_class_name = $this->getCSSclass('input', null, 'next', $css_postfix); |
echo '<tr class="',$this->getCSSclass('row', null, true, $css_postfix),'">',"\n"; |
echo '<tr class="',$this->getCSSclass('row', null, true, $css_postfix),'">',"\n"; |
echo '<td class="',$this->getCSSclass('key', null, true, $css_postfix),'">',$this->fdd[$k]['name'],'</td>',"\n"; |
echo '<td class="',$this->getCSSclass('key', null, true, $css_postfix),'">',$this->fdd[$k]['name'],'</td>',"\n"; |
echo '<td class="',$this->getCSSclass('value', null, true, $css_postfix),'">'."\n"; |
echo '<td class="',$this->getCSSclass('value', null, true, $css_postfix),'">',"\n"; |
if ($this->col_has_values($k)) { |
if ($this->col_has_values($k)) { |
$vals = $this->set_values($k); |
$vals = $this->set_values($k); |
$selected = @$this->fdd[$k]['default']; |
$selected = @$this->fdd[$k]['default']; |
Line 790 function phpMyEdit_form_control(theForm) |
|
Line 790 function phpMyEdit_form_control(theForm) |
|
echo $this->htmlSelect($this->fds[$k], $css_class_name, $vals, $selected, |
echo $this->htmlSelect($this->fds[$k], $css_class_name, $vals, $selected, |
$multiple, $readonly, $strip_tags, $escape); |
$multiple, $readonly, $strip_tags, $escape); |
} elseif (isset ($this->fdd[$k]['textarea'])) { |
} elseif (isset ($this->fdd[$k]['textarea'])) { |
echo '<textarea class="',$css_class_name,'" name="'.$this->fds[$k].'"'; |
echo '<textarea class="',$css_class_name,'" name="',$this->fds[$k],'"'; |
echo ($this->readonly($k) ? ' disabled' : ''); |
echo ($this->readonly($k) ? ' disabled' : ''); |
if (intval($this->fdd[$k]['textarea']['rows']) > 0) { |
if (intval($this->fdd[$k]['textarea']['rows']) > 0) { |
echo ' rows="',$this->fdd[$k]['textarea']['rows'],'"'; |
echo ' rows="',$this->fdd[$k]['textarea']['rows'],'"'; |
Line 855 function phpMyEdit_form_control(theForm) |
|
Line 855 function phpMyEdit_form_control(theForm) |
|
continue; |
continue; |
} |
} |
$css_postfix = @$this->fdd[$k]['css']['postfix']; |
$css_postfix = @$this->fdd[$k]['css']['postfix']; |
echo '<tr class="',$this->getCSSclass('row', null, 'next', $css_postfix),'">'."\n"; |
echo '<tr class="',$this->getCSSclass('row', null, 'next', $css_postfix),'">',"\n"; |
echo '<td class="',$this->getCSSclass('key', null, true, $css_postfix),'">',$this->fdd[$k]['name'],'</td>',"\n"; |
echo '<td class="',$this->getCSSclass('key', null, true, $css_postfix),'">',$this->fdd[$k]['name'],'</td>',"\n"; |
/* There are two possibilities of readonly fields handling: |
/* There are two possibilities of readonly fields handling: |
1. Display plain text |
1. Display plain text |
Line 873 function phpMyEdit_form_control(theForm) |
|
Line 873 function phpMyEdit_form_control(theForm) |
|
$cell_value = $this->fdd[$k]['help'] ? $this->fdd[$k]['help'] : ' '; |
$cell_value = $this->fdd[$k]['help'] ? $this->fdd[$k]['help'] : ' '; |
echo '<td class="',$css_class_name,'">',$cell_value,'</td>',"\n"; |
echo '<td class="',$css_class_name,'">',$cell_value,'</td>',"\n"; |
} |
} |
echo '</tr>'."\n"; |
echo '</tr>',"\n"; |
} elseif ($this->delete_operation() || $this->view_operation()) { |
} elseif ($this->delete_operation() || $this->view_operation()) { |
if (! $this->displayed[$k]) { |
if (! $this->displayed[$k]) { |
continue; |
continue; |
} |
} |
$css_postfix = @$this->fdd[$k]['css']['postfix']; |
$css_postfix = @$this->fdd[$k]['css']['postfix']; |
echo '<tr class="',$this->getCSSclass('row', null, 'next', $css_postfix),'">'."\n"; |
echo '<tr class="',$this->getCSSclass('row', null, 'next', $css_postfix),'">',"\n"; |
echo '<td class="',$this->getCSSclass('key', null, true, $css_postfix),'">',$this->fdd[$k]['name'].'</td>'."\n"; |
echo '<td class="',$this->getCSSclass('key', null, true, $css_postfix),'">',$this->fdd[$k]['name'],'</td>',"\n"; |
if ($this->password($k)) { |
if ($this->password($k)) { |
echo '<td class="',$this->getCSSclass('value', null, true, $css_postfix),'">'; |
echo '<td class="',$this->getCSSclass('value', null, true, $css_postfix),'">'; |
echo $this->labels['hidden'],'</td>'; |
echo $this->labels['hidden'],'</td>'; |
Line 911 function phpMyEdit_form_control(theForm) |
|
Line 911 function phpMyEdit_form_control(theForm) |
|
echo $this->htmlSelect($this->fds[$k], $css_class_name, $vals, $row["qf$k"], |
echo $this->htmlSelect($this->fds[$k], $css_class_name, $vals, $row["qf$k"], |
$multiple, $readonly, $strip_tags, $escape); |
$multiple, $readonly, $strip_tags, $escape); |
} elseif (isset($this->fdd[$k]['textarea'])) { |
} elseif (isset($this->fdd[$k]['textarea'])) { |
echo '<textarea class="',$css_class_name,'" name="'.$this->fds[$k].'"'; |
echo '<textarea class="',$css_class_name,'" name="',$this->fds[$k],'"'; |
echo ($this->readonly($k) ? ' disabled' : ''); |
echo ($this->readonly($k) ? ' disabled' : ''); |
if (intval($this->fdd[$k]['textarea']['rows']) > 0) { |
if (intval($this->fdd[$k]['textarea']['rows']) > 0) { |
echo ' rows="',$this->fdd[$k]['textarea']['rows'],'"'; |
echo ' rows="',$this->fdd[$k]['textarea']['rows'],'"'; |
Line 1349 function phpMyEdit_form_control(theForm) |
|
Line 1349 function phpMyEdit_form_control(theForm) |
|
function print_vars ($miss = 'Current instance variables') // debug only /* {{{ */ |
function print_vars ($miss = 'Current instance variables') // debug only /* {{{ */ |
{ |
{ |
echo "$miss "; |
echo "$miss "; |
echo 'page_name='.$this->page_name.' '; |
echo 'page_name=',$this->page_name,' '; |
echo 'hn='.$this->hn.' '; |
echo 'hn=',$this->hn,' '; |
echo 'un='.$this->un.' '; |
echo 'un=',$this->un,' '; |
echo 'pw='.$this->pw.' '; |
echo 'pw=',$this->pw,' '; |
echo 'db='.$this->db.' '; |
echo 'db=',$this->db,' '; |
echo 'tb='.$this->tb.' '; |
echo 'tb=',$this->tb,' '; |
echo 'key='.$this->key.' '; |
echo 'key=',$this->key,' '; |
echo 'key_type='.$this->key_type.' '; |
echo 'key_type=',$this->key_type,' '; |
echo 'inc='.$this->inc.' '; |
echo 'inc=',$this->inc,' '; |
echo 'options='.$this->options.' '; |
echo 'options=',$this->options,' '; |
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='.htmlspecialchars($this->get_sfn_cgi_vars()).' '; |
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,' '; |
echo 'prev='.$this->prev.' '; |
echo 'prev=',$this->prev,' '; |
echo 'next='.$this->next.' '; |
echo 'next=',$this->next,' '; |
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 'morechange=',$this->morechange,' '; |
echo 'savedelete='.$this->savedelete.' '; |
echo 'savedelete=',$this->savedelete,' '; |
echo 'operation='.$this->operation.' '; |
echo 'operation=',$this->operation,' '; |
echo "\n"; |
echo "\n"; |
} /* }}} */ |
} /* }}} */ |
|
|
Line 1485 function phpMyEdit_form_control(theForm) |
|
Line 1485 function phpMyEdit_form_control(theForm) |
|
if (strlen(@$this->message) > 0) { |
if (strlen(@$this->message) > 0) { |
echo '<td class="',$this->getCSSclass('message', $position),'">',$this->message,'</td>',"\n"; |
echo '<td class="',$this->getCSSclass('message', $position),'">',$this->message,'</td>',"\n"; |
} |
} |
echo '</tr></table>'."\n"; |
echo '</tr></table>',"\n"; |
} /* }}} */ |
} /* }}} */ |
|
|
|
|
Line 1510 function phpMyEdit_form_control(theForm) |
|
Line 1510 function phpMyEdit_form_control(theForm) |
|
$this->qfn != $this->prev_qfn && $this->fm = 0; |
$this->qfn != $this->prev_qfn && $this->fm = 0; |
if (0) { // DEBUG |
if (0) { // DEBUG |
echo 'qfn vs. prev_qfn comparsion '; |
echo 'qfn vs. prev_qfn comparsion '; |
echo '[<b>'.htmlspecialchars($this->qfn).'</b>]'; |
echo '[<b>',htmlspecialchars($this->qfn),'</b>]'; |
echo '[<b>'.htmlspecialchars($this->prev_qfn).'</b>]<br>'; |
echo '[<b>',htmlspecialchars($this->prev_qfn),'</b>]<br>'; |
echo 'comparsion <u>'.($this->qfn == $this->prev_qfn ? 'proved' : 'failed').'</u>'; |
echo 'comparsion <u>',($this->qfn == $this->prev_qfn ? 'proved' : 'failed'),'</u>'; |
echo '<hr>'; |
echo '<hr>'; |
} |
} |
/* |
/* |
Line 1529 function phpMyEdit_form_control(theForm) |
|
Line 1529 function phpMyEdit_form_control(theForm) |
|
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()); |
echo '<input type="hidden" name="fl" value="'.$this->fl.'">'."\n"; |
echo '<input type="hidden" name="fl" value="',$this->fl,'">',"\n"; |
// Display buttons at top and/or bottom of page. |
// Display buttons at top and/or bottom of page. |
// Setup query to get num_rows. (sparky) |
// Setup query to get num_rows. (sparky) |
$total_recs = 0; |
$total_recs = 0; |
Line 1553 function phpMyEdit_form_control(theForm) |
|
Line 1553 function phpMyEdit_form_control(theForm) |
|
} |
} |
echo '<input type="hidden" name="qfn" value="',htmlspecialchars($this->qfn),'">',"\n"; |
echo '<input type="hidden" name="qfn" value="',htmlspecialchars($this->qfn),'">',"\n"; |
echo '<input type="hidden" name="fm" value="',htmlspecialchars($this->fm),'">',"\n"; |
echo '<input type="hidden" name="fm" value="',htmlspecialchars($this->fm),'">',"\n"; |
echo '<table class="'.$this->getCSSclass('main').'" summary="',$this->tb,'">',"\n"; |
echo '<table class="',$this->getCSSclass('main'),'" summary="',$this->tb,'">',"\n"; |
echo '<tr class="',$this->getCSSclass('header'),'">',"\n"; |
echo '<tr class="',$this->getCSSclass('header'),'">',"\n"; |
/* |
/* |
* System (navigation, selection) columns counting |
* System (navigation, selection) columns counting |
Line 1583 function phpMyEdit_form_control(theForm) |
|
Line 1583 function phpMyEdit_form_control(theForm) |
|
} else { |
} else { |
echo ' '; |
echo ' '; |
} |
} |
echo '</th>'."\n"; |
echo '</th>',"\n"; |
} |
} |
for ($k = 0; $k < $this->num_fds; $k++) { |
for ($k = 0; $k < $this->num_fds; $k++) { |
$fd = $this->fds[$k]; |
$fd = $this->fds[$k]; |
Line 1910 function phpMyEdit_form_control(theForm) |
|
Line 1910 function phpMyEdit_form_control(theForm) |
|
} |
} |
} |
} |
if (! $this->nav_buttons() || $sys_cols > 1) { |
if (! $this->nav_buttons() || $sys_cols > 1) { |
echo '</td>'."\n"; |
echo '</td>',"\n"; |
} |
} |
if ($this->nav_buttons()) { |
if ($this->nav_buttons()) { |
echo '<td class="',$css_class_name,'"><input class="',$css_class_name; |
echo '<td class="',$css_class_name,'"><input class="',$css_class_name; |
Line 1947 function phpMyEdit_form_control(theForm) |
|
Line 1947 function phpMyEdit_form_control(theForm) |
|
} |
} |
echo '<td class="',$css_class_name,'"',$colattrs,'>'; |
echo '<td class="',$css_class_name,'"',$colattrs,'>'; |
echo $this->cellDisplay($k, $row, $css_class_name); |
echo $this->cellDisplay($k, $row, $css_class_name); |
echo '</td>'."\n"; |
echo '</td>',"\n"; |
} /* }}} */ |
} /* }}} */ |
echo '</tr>'."\n"; |
echo '</tr>',"\n"; |
} |
} |
|
|
/* |
/* |
Line 1970 function phpMyEdit_form_control(theForm) |
|
Line 1970 function phpMyEdit_form_control(theForm) |
|
$tot_row = @mysql_fetch_array($totals_result, MYSQL_ASSOC); |
$tot_row = @mysql_fetch_array($totals_result, MYSQL_ASSOC); |
//} |
//} |
$qp_aggr = $qp; |
$qp_aggr = $qp; |
echo "\n".'<tr class="TODO-class">'."\n".'<td class="TODO-class"> </td>'."\n"; |
echo "\n",'<tr class="TODO-class">',"\n",'<td class="TODO-class"> </td>',"\n"; |
/* |
/* |
echo '<td>'; |
echo '<td>'; |
echo printarray($qp_aggr); |
echo printarray($qp_aggr); |
Line 1986 function phpMyEdit_form_control(theForm) |
|
Line 1986 function phpMyEdit_form_control(theForm) |
|
$aggr_var = 'qf'.$k.'_aggr'; |
$aggr_var = 'qf'.$k.'_aggr'; |
$$aggr_var = $this->get_cgi_var($aggr_var); |
$$aggr_var = $this->get_cgi_var($aggr_var); |
if ($$aggr_var) { |
if ($$aggr_var) { |
echo $this->sql_aggrs[$$aggr_var].': '.$tot_row[$aggr_var]; |
echo $this->sql_aggrs[$$aggr_var],': ',$tot_row[$aggr_var]; |
} else { |
} else { |
echo ' '; |
echo ' '; |
} |
} |
echo '</td>'."\n"; |
echo '</td>',"\n"; |
} |
} |
} |
} |
echo '</tr>'."\n"; |
echo '</tr>',"\n"; |
} |
} |
echo '</table>'."\n"; // end of table rows listing |
echo '</table>',"\n"; // end of table rows listing |
if ($this->nav_down()) { |
if ($this->nav_down()) { |
echo '<hr class="',$this->getCSSclass('hr', 'down'),'">',"\n"; |
echo '<hr class="',$this->getCSSclass('hr', 'down'),'">',"\n"; |
$this->display_list_table_buttons($total_recs, 'down'); |
$this->display_list_table_buttons($total_recs, 'down'); |
} |
} |
echo '</form>'."\n"; |
echo '</form>',"\n"; |
} /* }}} */ |
} /* }}} */ |
|
|
function display_record() /* {{{ */ |
function display_record() /* {{{ */ |
Line 2030 function phpMyEdit_form_control(theForm) |
|
Line 2030 function phpMyEdit_form_control(theForm) |
|
echo '<hr class="',$this->getCSSclass('hr', 'down'),'">',"\n"; |
echo '<hr class="',$this->getCSSclass('hr', 'down'),'">',"\n"; |
$this->display_record_buttons(); |
$this->display_record_buttons(); |
} |
} |
echo '</form>'."\n"; |
echo '</form>',"\n"; |
} /* }}} */ |
} /* }}} */ |
|
|
/* |
/* |
Line 2436 function phpMyEdit_form_control(theForm) |
|
Line 2436 function phpMyEdit_form_control(theForm) |
|
*/ |
*/ |
function error($message, $additional_info = '') /* {{{ */ |
function error($message, $additional_info = '') /* {{{ */ |
{ |
{ |
echo '<h1>phpMyEdit error: '.htmlspecialchars($message).'</h1>'."\n"; |
echo '<h1>phpMyEdit error: ',htmlspecialchars($message),'</h1>',"\n"; |
if ($additional_info != '') { |
if ($additional_info != '') { |
echo '<hr>'.htmlspecialchars($additional_info); |
echo '<hr>',htmlspecialchars($additional_info); |
} |
} |
return false; |
return false; |
} /* }}} */ |
} /* }}} */ |
Line 2556 function phpMyEdit_form_control(theForm) |
|
Line 2556 function phpMyEdit_form_control(theForm) |
|
|
|
$this->disconnect(); |
$this->disconnect(); |
if ($this->display['time'] && $this->timer != null) { |
if ($this->display['time'] && $this->timer != null) { |
echo $this->timer->end() . ' miliseconds'; |
echo $this->timer->end(),' miliseconds'; |
} |
} |
} /* }}} */ |
} /* }}} */ |
|
|