| version 1.82, 2003/05/31 21:14:14 |
version 1.83, 2003/06/21 11:44:42 |
|
|
| * http://www.platon.sk/projects/phpMyEdit/ |
* http://www.platon.sk/projects/phpMyEdit/ |
| */ |
*/ |
| |
|
| /* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.81 2003/05/12 22:30:22 nepto Exp $ */ |
/* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.82 2003/05/31 21:14:14 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 $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 $tabs; // TAB names |
| var $timer = null; // phpMyEdit_timer object |
var $timer = null; // phpMyEdit_timer object |
| |
|
| // Predefined variables |
// Predefined variables |
|
|
| function filter_enabled() { return stristr($this->options, 'F'); } |
function filter_enabled() { return stristr($this->options, 'F'); } |
| function view_enabled() { return stristr($this->options, 'V'); } |
function view_enabled() { return stristr($this->options, 'V'); } |
| function copy_enabled() { return stristr($this->options, 'P') && $this->add_enabled(); } |
function copy_enabled() { return stristr($this->options, 'P') && $this->add_enabled(); } |
| |
function tabs_enabled() { return count($this->tabs) > 0; } |
| function hidden($k) { return stristr($this->fdd[$k]['options'],'H'); } |
function hidden($k) { return stristr($this->fdd[$k]['options'],'H'); } |
| function password($k) { return stristr($this->fdd[$k]['options'],'W'); } |
function password($k) { return stristr($this->fdd[$k]['options'],'W'); } |
| function readonly($k) { return stristr($this->fdd[$k]['options'],'R'); } |
function readonly($k) { return stristr($this->fdd[$k]['options'],'R'); } |
|
|
| */ |
*/ |
| $page_name = htmlspecialchars($this->page_name); |
$page_name = htmlspecialchars($this->page_name); |
| |
|
| |
if ($this->add_operation() || $this->change_operation() || $this->copy_operation() |
| |
|| $this->view_operation() || $this->delete_operation()) { |
| |
$field_to_tab = ''; |
| |
for ($tab = 0, $k = 0; $k < $this->num_fds; $k++) { |
| |
if (isset($this->fdd[$k]['tab'])) { |
| |
if ($tab == 0 && $k > 0) { |
| |
$this->tabs[0] = 'Initial TAB'; |
| |
$tab++; |
| |
} |
| |
$this->tabs[$tab] = @$this->fdd[$k]['tab']; |
| |
$tab++; |
| |
} |
| |
$field_to_tab .= ($tab - 1).', '; |
| |
} |
| |
if ($this->tabs_enabled()) { |
| |
// initial TAB styles |
| |
echo '<style type="text/css" media="screen">',"\n"; |
| |
echo ' #phpMyEdit_tab0 { display: block; }',"\n"; |
| |
for ($i = 1; $i < count($this->tabs); $i++) { |
| |
echo ' #phpMyEdit_tab',$i,' { display: none; }',"\n"; |
| |
} |
| |
echo '</style>',"\n"; |
| |
// TAB javascripts |
| |
echo '<script type="text/javascript"><!--',"\n\n"; |
| |
echo 'var phpMyEdit_field_to_tab = [',$field_to_tab,'-1];',"\n"; |
| |
echo 'var phpMyEdit_current_tab = "phpMyEdit_tab0"; |
| |
|
| |
function phpMyEdit_show_tab(tab_name) |
| |
{ |
| |
document.getElementById(phpMyEdit_current_tab).style.display = "none"; |
| |
document.getElementById(phpMyEdit_current_tab+"_label").style.background = "inherit"; |
| |
document.getElementById(tab_name).style.display = "block"; |
| |
document.getElementById(tab_name+"_label").style.background = "#FFFFFF"; |
| |
phpMyEdit_current_tab = tab_name; |
| |
}',"\n\n"; |
| |
echo '// --></script>', "\n"; |
| |
} |
| |
} |
| |
|
| if ($this->add_operation() || $this->change_operation() || $this->copy_operation()) { |
if ($this->add_operation() || $this->change_operation() || $this->copy_operation()) { |
| $required_ar = array(); |
$required_ar = array(); |
| for ($k = 0; $k < $this->num_fds; $k++) { |
for ($k = 0; $k < $this->num_fds; $k++) { |
| Line 723 function phpMyEdit_form_control(theForm) |
|
| Line 764 function phpMyEdit_form_control(theForm) |
|
| syntax error. Following search algorithm is provided |
syntax error. Following search algorithm is provided |
| as a workaround for this. |
as a workaround for this. |
| */ |
*/ |
| |
|
| if ($multiple) { |
if ($multiple) { |
| echo ' |
echo ' |
| multiple_select = null; |
multiple_select = null; |
| Line 734 function phpMyEdit_form_control(theForm) |
|
| Line 774 function phpMyEdit_form_control(theForm) |
|
| } |
} |
| } |
} |
| 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'],'.");'; |
| |
if ($this->tabs_enabled()) { |
| |
echo ' |
| |
phpMyEdit_show_tab("phpMyEdit_tab"+phpMyEdit_field_to_tab['.$field_num.']);'; |
| |
} |
| |
echo ' |
| 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'],'.");'; |
| |
if ($this->tabs_enabled()) { |
| |
echo ' |
| |
phpMyEdit_show_tab("phpMyEdit_tab"+phpMyEdit_field_to_tab['.$field_num.']);'; |
| |
} |
| |
echo ' |
| theForm.',$this->fds[$field_num],'.focus(); |
theForm.',$this->fds[$field_num],'.focus(); |
| return false; |
return false; |
| }',"\n"; |
}',"\n"; |
| Line 761 function phpMyEdit_form_control(theForm) |
|
| Line 811 function phpMyEdit_form_control(theForm) |
|
| return true; |
return true; |
| } /* }}} */ |
} /* }}} */ |
| |
|
| |
function display_tab_labels() /* {{{ */ |
| |
{ |
| |
if (! is_array($this->tabs)) { |
| |
return false; |
| |
} |
| |
echo "<table>\n"; |
| |
echo '<tr>',"\n"; |
| |
for ($i = 0; $i < count($this->tabs); $i++) { |
| |
echo '<td id="phpMyEdit_tab',$i,'_label">'; |
| |
echo '<a href="javascript:phpMyEdit_show_tab(\'phpMyEdit_tab',$i,'\')">'; |
| |
echo $this->tabs[$i],'</a></td>',"\n"; |
| |
} |
| |
echo '<td width="100%"> </td>'; |
| |
echo '</tr>',"\n"; |
| |
echo '</table>',"\n"; |
| |
} /* }}} */ |
| |
|
| |
|
| |
|
| |
|
| /* |
/* |
| * Display functions |
* Display functions |
| */ |
*/ |
| |
|
| function display_add_record() /* {{{ */ |
function display_add_record() /* {{{ */ |
| { |
{ |
| for ($k = 0; $k < $this->num_fds; $k++) { |
for ($tab = 0, $k = 0; $k < $this->num_fds; $k++) { |
| |
if (isset($this->fdd[$k]['tab']) && $this->tabs_enabled() && $k > 0) { |
| |
$tab++; |
| |
echo '</table>',"\n"; |
| |
echo '</div>',"\n"; |
| |
echo '<div id="phpMyEdit_tab',$tab,'">',"\n"; |
| |
echo '<table class="',$this->getCSSclass('main'),'" summary="',$this->tb,'">',"\n"; |
| |
} |
| if ($this->hidden($k)) { |
if ($this->hidden($k)) { |
| echo $this->htmlHidden($this->fds[$k], $row["qf$k"]); |
echo $this->htmlHidden($this->fds[$k], $row["qf$k"]); |
| continue; |
continue; |
| Line 844 function phpMyEdit_form_control(theForm) |
|
| Line 921 function phpMyEdit_form_control(theForm) |
|
| if (! ($row = @mysql_fetch_array($res, MYSQL_ASSOC))) { |
if (! ($row = @mysql_fetch_array($res, MYSQL_ASSOC))) { |
| return false; |
return false; |
| } |
} |
| for ($k = 0; $k < $this->num_fds; $k++) { |
for ($tab = 0, $k = 0; $k < $this->num_fds; $k++) { |
| |
if (isset($this->fdd[$k]['tab']) && $this->tabs_enabled() && $k > 0) { |
| |
$tab++; |
| |
echo '</table>',"\n"; |
| |
echo '</div>',"\n"; |
| |
echo '<div id="phpMyEdit_tab',$tab,'">',"\n"; |
| |
echo '<table class="',$this->getCSSclass('main'),'" summary="',$this->tb,'">',"\n"; |
| |
} |
| if ($this->copy_operation() || $this->change_operation()) { |
if ($this->copy_operation() || $this->change_operation()) { |
| if ($this->hidden($k)) { |
if ($this->hidden($k)) { |
| if ($k != $this->key_num) { |
if ($k != $this->key_num) { |
| Line 2031 function phpMyEdit_form_control(theForm) |
|
| Line 2115 function phpMyEdit_form_control(theForm) |
|
| if ($this->nav_up()) { |
if ($this->nav_up()) { |
| $this->display_record_buttons(); |
$this->display_record_buttons(); |
| echo '<hr class="',$this->getCSSclass('hr', 'up'),'">',"\n"; |
echo '<hr class="',$this->getCSSclass('hr', 'up'),'">',"\n"; |
| |
if ($this->tabs_enabled()) { |
| |
$this->display_tab_labels(); |
| |
} |
| |
} |
| |
if ($this->tabs_enabled()) { |
| |
echo '<div id="phpMyEdit_tab0">',"\n"; |
| } |
} |
| echo '<table class="',$this->getCSSclass('main'),'" summary="',$this->tb,'">',"\n"; |
echo '<table class="',$this->getCSSclass('main'),'" summary="',$this->tb,'">',"\n"; |
| if ($this->add_operation()) { |
if ($this->add_operation()) { |
| Line 2039 function phpMyEdit_form_control(theForm) |
|
| Line 2129 function phpMyEdit_form_control(theForm) |
|
| $this->display_copy_change_delete_record(); |
$this->display_copy_change_delete_record(); |
| } |
} |
| echo '</table>',"\n"; |
echo '</table>',"\n"; |
| |
echo '</div>',"\n"; |
| if ($this->nav_down()) { |
if ($this->nav_down()) { |
| |
if ($this->tabs_enabled()) { |
| |
$this->display_tab_labels(); |
| |
} |
| echo '<hr class="',$this->getCSSclass('hr', 'down'),'">',"\n"; |
echo '<hr class="',$this->getCSSclass('hr', 'down'),'">',"\n"; |
| $this->display_record_buttons(); |
$this->display_record_buttons(); |
| } |
} |
| Line 2671 function phpMyEdit_form_control(theForm) |
|
| Line 2765 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; |
| } |
} |
| |
// TAB names |
| |
$this->tabs = array(); |
| // 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, |