From c92736229c2c5cc7f3bd6415d8b4f34f87d7d9ce Mon Sep 17 00:00:00 2001 From: james Date: Wed, 31 Oct 2007 19:09:50 +0000 Subject: [PATCH] Changes to tableeditor to make it backwards compatible with the "simple" (non class) abilities that it was originally intended for --- tableeditor.class.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/tableeditor.class.php b/tableeditor.class.php index a084490..52ea8a8 100644 --- a/tableeditor.class.php +++ b/tableeditor.class.php @@ -157,14 +157,14 @@ class TableEditor if($_GET['DEBUG']) $this->setDebug($_GET['DEBUG']); - //grab the table - $this->classname=$classname; - - if(is_callable(array($this->classname, 'tableEditorSetup'))) { + if(is_callable(array($classname, 'tableEditorSetup'))) { + //grab the table + $this->classname=$classname; call_user_func(array($this->classname, 'tableEditorSetup'), &$this); } else { //grab the list fields $this->listfields=$listfields; + $this->table=$classname; //grab the edit fields, if there arent any, then edit==list if($editfields) @@ -475,7 +475,7 @@ class TableEditor $query="UPDATE `{$this->table}` SET "; } - foreach($this->editfields AS $f=>$n) + foreach($editdata AS $f=>$n) { if($insert_mode) $field = ''; else $field = "`$f`="; @@ -510,7 +510,8 @@ class TableEditor if($_GET['TableEditorAction']=="delete" && $_GET['delete']) { - $data = new $this->classname($_GET['delete']); + if($this->classname) + $data = new $this->classname($_GET['delete']); if(method_exists($data, 'tableEditorDelete')) { $data->tableEditorDelete(); } else { @@ -527,11 +528,13 @@ class TableEditor || ($_POST['TableEditorAction']=="addsave") ) { if($_POST['TableEditorAction']=="addsave") { - $data = new $this->classname(); + if($this->classname) + $data = new $this->classname(); $insert_mode = 1; } else { // print("Insesrt mode=0\n"); - $data = new $this->classname($_POST['editsave']); + if($this->classname) + $data = new $this->classname($_POST['editsave']); $insert_mode = 0; } @@ -700,7 +703,8 @@ class TableEditor echo ""; echo ""; - $data = new $this->classname($_GET['edit']); + if($this->classname) + $data = new $this->classname($_GET['edit']); if(method_exists($data, 'tableEditorLoad')) { $editdata = $data->tableEditorLoad();