Changes to tableeditor to make it backwards compatible with the "simple" (non class) abilities that it was originally intended for

This commit is contained in:
james 2007-10-31 19:09:50 +00:00
parent 1de8f94516
commit c92736229c

View File

@ -157,14 +157,14 @@ class TableEditor
if($_GET['DEBUG']) $this->setDebug($_GET['DEBUG']); if($_GET['DEBUG']) $this->setDebug($_GET['DEBUG']);
if(is_callable(array($classname, 'tableEditorSetup'))) {
//grab the table //grab the table
$this->classname=$classname; $this->classname=$classname;
if(is_callable(array($this->classname, 'tableEditorSetup'))) {
call_user_func(array($this->classname, 'tableEditorSetup'), &$this); call_user_func(array($this->classname, 'tableEditorSetup'), &$this);
} else { } else {
//grab the list fields //grab the list fields
$this->listfields=$listfields; $this->listfields=$listfields;
$this->table=$classname;
//grab the edit fields, if there arent any, then edit==list //grab the edit fields, if there arent any, then edit==list
if($editfields) if($editfields)
@ -475,7 +475,7 @@ class TableEditor
$query="UPDATE `{$this->table}` SET "; $query="UPDATE `{$this->table}` SET ";
} }
foreach($this->editfields AS $f=>$n) foreach($editdata AS $f=>$n)
{ {
if($insert_mode) $field = ''; if($insert_mode) $field = '';
else $field = "`$f`="; else $field = "`$f`=";
@ -510,6 +510,7 @@ class TableEditor
if($_GET['TableEditorAction']=="delete" && $_GET['delete']) if($_GET['TableEditorAction']=="delete" && $_GET['delete'])
{ {
if($this->classname)
$data = new $this->classname($_GET['delete']); $data = new $this->classname($_GET['delete']);
if(method_exists($data, 'tableEditorDelete')) { if(method_exists($data, 'tableEditorDelete')) {
$data->tableEditorDelete(); $data->tableEditorDelete();
@ -527,10 +528,12 @@ class TableEditor
|| ($_POST['TableEditorAction']=="addsave") ) || ($_POST['TableEditorAction']=="addsave") )
{ {
if($_POST['TableEditorAction']=="addsave") { if($_POST['TableEditorAction']=="addsave") {
if($this->classname)
$data = new $this->classname(); $data = new $this->classname();
$insert_mode = 1; $insert_mode = 1;
} else { } else {
// print("Insesrt mode=0\n"); // print("Insesrt mode=0\n");
if($this->classname)
$data = new $this->classname($_POST['editsave']); $data = new $this->classname($_POST['editsave']);
$insert_mode = 0; $insert_mode = 0;
} }
@ -700,6 +703,7 @@ class TableEditor
echo "<input type=\"hidden\" name=\"TableEditorAction\" value=\"editsave\">"; echo "<input type=\"hidden\" name=\"TableEditorAction\" value=\"editsave\">";
echo "<input type=\"hidden\" name=\"editsave\" value=\"{$_GET['edit']}\">"; echo "<input type=\"hidden\" name=\"editsave\" value=\"{$_GET['edit']}\">";
if($this->classname)
$data = new $this->classname($_GET['edit']); $data = new $this->classname($_GET['edit']);
if(method_exists($data, 'tableEditorLoad')) { if(method_exists($data, 'tableEditorLoad')) {