| version 1.58, 2003/03/19 19:57:25 |
version 1.59, 2003/03/25 21:54:28 |
|
|
| * http://www.platon.sk/projects/phpMyEdit/ |
* http://www.platon.sk/projects/phpMyEdit/ |
| */ |
*/ |
| |
|
| /* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.57 2003/03/19 01:03:49 nepto Exp $ */ |
/* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.58 2003/03/19 19:57:25 nepto Exp $ */ |
| |
|
| /* phpMyEdit intro {{{ */ |
/* 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. |
| |
|
| This program works in three passes. Pass 1 (the last part of |
This program works in three passes. |
| the program) displays the selected MySQL table in a scrolling table |
* Pass 1 (the last part of the program) displays the selected MySQL |
| on the screen. Radio buttons are used to select a record for editing |
table in a scrolling table on the screen. Radio buttons are used to |
| or deletion. If the user chooses Add, Change, or Delete buttons, |
select a record for editing or deletion. If the user chooses Add, |
| Pass 2 starts, displaying the selected record. If the user chooses |
Change, Copy, View or Delete buttons. |
| the Save button from this screen, Pass 3 processes the update and |
* Pass 2 starts, displaying the selected record. If the user chooses |
| the display returns to the original table view (Pass 1). |
the Save button from this screen. |
| |
* Pass 3 processes the update and the display returns to the |
| version 3.5 - 06-May-01 |
original table view (Pass 1). |
| |
|
| important variables passed between calls to this program |
|
| |
|
| $fm first record to display |
|
| $inc no of records to display (SELECT ... LIMIT $fm,$inc) |
|
| $fl is the filter row displayed (boolean) |
|
| $rec unique id of record selected for editing |
|
| $qf0,.. value of filter for column 0 |
|
| $qfn value of all filters used during the last pass |
|
| $sfn sort field number (- = descending sort order) |
|
| $operation operation to do: Add, Change, Delete |
|
| $message informational message to print |
|
| $filter filter query |
|
| $sw filter display/hide button |
|
| |
|
| $prev, $next navigation buttons |
|
| $labels narrative for buttons, etc |
|
| |
|
| Conversion to PHP Classes by Pau Aliagas (pau@newtral.com) |
|
| |
|
| Aggregates: |
|
| nonworking code commented out in list_table() |
|
| doesn't work yet |
|
| |
|
| Query Building: |
|
| |
|
| Multi-Part Date Handling: |
|
| Finish converting date handling to internal date handling functions |
|
| Abstract date field gathering to get rid of _many_ redundant lines of code |
|
| There was some kludged fix for dateformat'ting where '%'s are removed |
|
| Better support for more date format macros |
|
| Better documentation for valid date format macros |
|
| |
|
| Multi-Language support: |
|
| Finish implementing language labels |
|
| Use browser-supplied language if available |
|
| Allow programmer override in setup.php generated .inc file |
|
| Add 'Search' and 'Go!' to labels array |
|
| |
|
| Data Validation: |
|
| Expand JS field validation to match JS regexes |
|
| Create PHP field validation to match PHP regexes |
|
| |
|
| Change Tracking/Notification: |
|
| Add change notification (via mail()) support |
|
| Don't die if mail() not available |
|
| |
|
| CSS: |
|
| Document & solicit feedback to standardize class names |
|
| |
|
| Even/Odd Coloring: |
|
| Move to CSS |
|
| Put values in setup.php generated file |
|
| |
|
| Timer Class: |
|
| Solicit user input whether to put timer class into this lib |
|
| */ |
*/ |
| /* }}} */ |
|
| |
|
| class phpMyEdit_timer /* {{{ */ |
class phpMyEdit_timer /* {{{ */ |
| { |
{ |
| Line 144 if (! function_exists('array_search')) { |
|
| Line 85 if (! function_exists('array_search')) { |
|
| class phpMyEdit |
class phpMyEdit |
| { |
{ |
| // Class variables {{{ |
// Class variables {{{ |
| var $hn; // hostname |
|
| var $un; // user name |
|
| var $pw; // password |
|
| var $db; // database |
|
| var $tb; // table |
|
| var $dbh; // database handle |
|
| |
|
| var $key; // Name of field which is the unique key |
|
| var $key_type; // Type of key field (int/real/string/date etc) |
|
| var $key_delim; |
|
| |
|
| var $inc; // no of records to display (SELECT ... LIMIT $fm, $inc) |
|
| var $fm; // first record to display |
|
| var $fl; // is the filter row displayed (boolean) |
|
| |
|
| var $options; // Options for users: A(dd) C(hange) D(elete) F(ilter) V(iew) co(P)y U(nsorted) |
|
| var $fdd; // field definitions |
|
| var $qfn; // value of all filters used during the last pass |
|
| var $sfn; // sort field number (- = descending sort order) |
|
| |
|
| var $rec; // no. of record selected for editing |
|
| var $prev; // navigation buttons |
|
| var $next; |
|
| var $sw; // filter display/hide button |
|
| var $labels; // labels for buttons, etc (multilingual) |
|
| var $cgi; // CGI variable features array |
|
| var $url; // URL array |
|
| var $operation; // operation to do: Add, Change, Delete |
|
| var $message; // informational message to print |
|
| |
|
| |
// Database handling |
| |
var $hn; // hostname |
| |
var $un; // user name |
| |
var $pw; // password |
| |
var $db; // database |
| |
var $tb; // table |
| |
var $dbh; // database handle |
| |
|
| |
// Record manipulation |
| |
var $key; // Name of field which is the unique key |
| |
var $key_type; // Type of key field (int/real/string/date etc.) |
| |
var $key_delim; // Character used for key value quoting |
| |
var $rec; // no. of record selected for editing |
| |
var $inc; // no of records to display |
| |
var $fm; // first record to display |
| |
var $fl; // is the filter row displayed (boolean) |
| |
var $fds; // sql field names |
| |
var $num_fds; // number of fields |
| |
var $options; // Options for users: ACDFVPI |
| |
var $fdd; // field definitions |
| |
var $qfn; // value of all filters used during the last pass |
| |
var $sfn; // sort field number (- = descending sort order) |
| |
|
| |
// Operation |
| |
var $prev; // "Prev" navigation button |
| |
var $next; // "Next" navigation button |
| |
var $sw; // filter display/hide/clear button |
| |
var $operation; // operation to do: Add, Change, Delete |
| var $saveadd; |
var $saveadd; |
| var $moreeadd; |
var $moreeadd; |
| var $savechange; |
var $savechange; |
| var $savedelete; |
var $savedelete; |
| |
|
| var $fds; // sql field names |
// Additional features |
| var $num_fds; // number of fields |
var $labels; // multilingual labels |
| |
var $cgi; // CGI variable features array |
| |
var $url; // URL array |
| |
var $message; // informational message to print |
| |
var $notify; // change notification e-mail adresses |
| |
var $logtable; // name of optional logtable |
| |
var $navigation; // navigation style |
| |
var $timer = null; // phpMyEdit_timer object |
| |
|
| var $notify; // change notification e-mail adresses |
|
| var $logtable; // name of optional logtable |
|
| var $navigation; // navigation style |
|
| var $timer = null; |
|
| // }}} |
// }}} |
| |
|
| |
/* |
| |
* type 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']); } |
| |
|
| |
/* |
| |
* functions for indicating whether navigation style is enabled |
| |
*/ |
| |
|
| |
function nav_buttons() { return stristr($this->navigation, 'B'); } |
| |
function nav_text_links() { return stristr($this->navigation, 'T'); } |
| |
function nav_graphic_links() { return stristr($this->navigation, 'G'); } |
| |
function nav_up() { return stristr($this->navigation, 'U'); } |
| |
function nav_down() { return stristr($this->navigation, 'D'); } |
| |
|
| |
/* |
| |
* functions for indicating whether operations are enabled |
| |
*/ |
| |
|
| |
function initial_sort_suppressed() { return (stristr ($this->options, 'I')); } |
| |
function add_enabled() { return stristr($this->options, 'A'); } |
| |
function change_enabled() { return stristr($this->options, 'C'); } |
| |
function delete_enabled() { return stristr($this->options, 'D'); } |
| |
function filter_enabled() { return stristr($this->options, 'F'); } |
| |
function view_enabled() { return stristr($this->options, 'V'); } |
| |
function copy_enabled() { return stristr($this->options, 'P') && $this->add_enabled(); } |
| |
function hidden($k) { return stristr($this->fdd[$k]['options'],'H'); } |
| |
function password($k) { return stristr($this->fdd[$k]['options'],'W'); } |
| |
function readonly($k) { return stristr($this->fdd[$k]['options'],'R') || $this->fdd[$k]['expression']; } |
| |
|
| |
function add_operation() { return $this->operation == $this->labels['Add'] && $this->add_enabled(); } |
| |
function change_operation() { return $this->operation == $this->labels['Change'] && $this->change_enabled(); } |
| |
function copy_operation() { return $this->operation == $this->labels['Copy'] && $this->copy_enabled(); } |
| |
function delete_operation() { return $this->operation == $this->labels['Delete'] && $this->delete_enabled(); } |
| |
function view_operation() { return $this->operation == $this->labels['View'] && $this->view_enabled(); } |
| |
function filter_operation() { return $this->fl && $this->filter_enabled(); } |
| |
function next_operation() { return $this->next == $this->labels['Next']; } |
| |
function prev_operation() { return $this->prev == $this->labels['Prev']; } |
| |
function clear_operation() { return $this->sw == $this->labels['Clear']; } |
| |
|
| |
function is_values2($k, $val = 'X') /* {{{ */ |
| |
{ |
| |
return $val === null || |
| |
(isset($this->fdd[$k]['values2']) && !isset($this->fdd[$k]['values']['table'])); |
| |
} /* }}} */ |
| |
|
| |
function processed($k) /* {{{ */ |
| |
{ |
| |
$options = @$this->fdd[$k]['options']; |
| |
if (! isset($options)) { |
| |
return true; |
| |
} |
| |
return |
| |
($this->saveadd == $this->labels['Save'] && stristr($options, 'A')) || |
| |
($this->moreadd == $this->labels['More'] && stristr($options, 'A')) || |
| |
($this->savechange == $this->labels['Save'] && stristr($options, 'C')) || |
| |
($this->morechange == $this->labels['Apply'] && stristr($options, 'C')) || |
| |
($this->savechange == $this->labels['Save'] && stristr($options, 'P')) || |
| |
($this->savedelete == $this->labels['Save'] && stristr($options, 'D')); |
| |
} /* }}} */ |
| |
|
| |
function displayed($k) /* {{{ */ |
| |
{ |
| |
if (is_numeric($k)) { |
| |
$k = $this->fds[$k]; |
| |
} |
| |
$options = @$this->fdd[$k]['options']; |
| |
if (! isset($options)) { |
| |
return true; |
| |
} |
| |
return |
| |
($this->add_operation() && stristr($options, 'A')) || |
| |
($this->view_operation() && stristr($options, 'V')) || |
| |
($this->change_operation() && stristr($options, 'C')) || |
| |
($this->copy_operation() && stristr($options, 'P')) || |
| |
($this->delete_operation() && stristr($options, 'D')) || |
| |
((stristr($options,'L') |
| |
|| ($this->filter_operation() && stristr($options, 'F'))) && |
| |
! $this->add_operation() && |
| |
! $this->view_operation() && |
| |
! $this->change_operation() && |
| |
! $this->copy_operation() && |
| |
! $this->delete_operation()); |
| |
} /* }}} */ |
| |
|
| function debug_var($name, $val) /* {{{ */ |
function debug_var($name, $val) /* {{{ */ |
| { |
{ |
|
|
| } /* }}} */ |
} /* }}} */ |
| |
|
| /* |
/* |
| * type 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']); } |
|
| |
|
| /* |
|
| * functions for indicating whether navigation style is enabled |
|
| */ |
|
| |
|
| function nav_buttons() { return stristr($this->navigation, 'B'); } |
|
| function nav_text_links() { return stristr($this->navigation, 'T'); } |
|
| function nav_graphic_links() { return stristr($this->navigation, 'G'); } |
|
| function nav_up() { return stristr($this->navigation, 'U'); } |
|
| function nav_down() { return stristr($this->navigation, 'D'); } |
|
| |
|
| /* |
|
| * functions for indicating whether operations are enabled |
|
| */ |
|
| |
|
| function initial_sort_suppressed() { return (stristr ($this->options, 'I')); } |
|
| function add_enabled() { return stristr($this->options, 'A'); } |
|
| function change_enabled() { return stristr($this->options, 'C'); } |
|
| function delete_enabled() { return stristr($this->options, 'D'); } |
|
| function filter_enabled() { return stristr($this->options, 'F'); } |
|
| function view_enabled() { return stristr($this->options, 'V'); } |
|
| function copy_enabled() { return stristr($this->options, 'P') && $this->add_enabled(); } |
|
| function hidden($k) { return stristr($this->fdd[$k]['options'],'H'); } |
|
| function password($k) { return stristr($this->fdd[$k]['options'],'W'); } |
|
| function readonly($k) { return stristr($this->fdd[$k]['options'],'R') || $this->fdd[$k]['expression']; } |
|
| |
|
| function add_operation() { return $this->operation == $this->labels['Add'] && $this->add_enabled(); } |
|
| function change_operation() { return $this->operation == $this->labels['Change'] && $this->change_enabled(); } |
|
| function copy_operation() { return $this->operation == $this->labels['Copy'] && $this->copy_enabled(); } |
|
| function delete_operation() { return $this->operation == $this->labels['Delete'] && $this->delete_enabled(); } |
|
| function view_operation() { return $this->operation == $this->labels['View'] && $this->view_enabled(); } |
|
| function filter_operation() { return $this->fl && $this->filter_enabled(); } |
|
| function next_operation() { return $this->next == $this->labels['Next']; } |
|
| function prev_operation() { return $this->prev == $this->labels['Prev']; } |
|
| function clear_operation() { return $this->sw == $this->labels['Clear']; } |
|
| |
|
| function is_values2($k, $val = 'X') /* {{{ */ |
|
| { |
|
| return $val === null || |
|
| (isset($this->fdd[$k]['values2']) && !isset($this->fdd[$k]['values']['table'])); |
|
| } /* }}} */ |
|
| |
|
| function processed($k) /* {{{ */ |
|
| { |
|
| $options = @$this->fdd[$k]['options']; |
|
| if (! isset($options)) |
|
| return true; |
|
| return /* empty($options) || */ |
|
| // XXX: woof woof woof hack, probably brokes BC, but here BC == BB (bad behaviour) |
|
| ($this->saveadd == $this->labels['Save'] && stristr($options, 'A')) || |
|
| ($this->moreadd == $this->labels['More'] && stristr($options, 'A')) || |
|
| ($this->savechange == $this->labels['Save'] && stristr($options, 'C')) || |
|
| ($this->morechange == $this->labels['Apply'] && stristr($options, 'C')) || |
|
| ($this->savechange == $this->labels['Save'] && stristr($options, 'P')) || |
|
| ($this->savedelete == $this->labels['Save'] && stristr($options, 'D')); |
|
| } /* }}} */ |
|
| |
|
| function displayed($k) /* {{{ */ |
|
| { |
|
| if (is_numeric($k)) { |
|
| $k = $this->fds[$k]; |
|
| } |
|
| $options = @$this->fdd[$k]['options']; |
|
| |
|
| if (! isset($options)) |
|
| return true; |
|
| |
|
| return |
|
| ($this->add_operation() && stristr($options, 'A')) || |
|
| ($this->view_operation() && stristr($options, 'V')) || |
|
| ($this->change_operation() && stristr($options, 'C')) || |
|
| ($this->copy_operation() && stristr($options, 'P')) || |
|
| ($this->delete_operation() && stristr($options, 'D')) || |
|
| ((stristr($options,'L') |
|
| || ($this->filter_operation() && stristr($options, 'F'))) && |
|
| ! $this->add_operation() && |
|
| ! $this->view_operation() && |
|
| ! $this->change_operation() && |
|
| ! $this->copy_operation() && |
|
| ! $this->delete_operation()); |
|
| } /* }}} */ |
|
| |
|
| /* |
|
| * Create JavaScripts |
* Create JavaScripts |
| */ |
*/ |
| |
|