\n";
echo " ".i18n("T-Shirt Size")." | ";
diff --git a/tableeditor.class.php b/tableeditor.class.php
index 2e2e2288..97c6557e 100644
--- a/tableeditor.class.php
+++ b/tableeditor.class.php
@@ -27,6 +27,17 @@
// - Fix INSERTING with a hidden field with value of NOW()
+interface TableEditorInterface {
+ function tableEditorSetup($editor);
+ function tableEditorLoad();
+ function tableEditorSave($data);
+ function tableEditorDelete();
+ function tableEditorGetList($editor);
+};
+
+
+
+
//ironforge
//$icon_path="/phpscripts/icons/16";
//lightbox
@@ -95,6 +106,7 @@ class TableEditor
var $fieldFilterList=array();
var $actionButtons=array();
var $additionalListTables=array();
+ var $options=array();
/**#@-*/
/**#@+
@@ -316,6 +328,29 @@ class TableEditor
$this->DEBUG=$d;
}
+ function createOption($o)
+ {
+ $this->options[$o] = null;
+ }
+
+ function setOption($o, $v)
+ {
+ if(array_key_exists($o, $this->options)) {
+ $this->options[$o] = $v;
+ return;
+ }
+ echo "Attempt to setOption($o, $v): option doesn't exist (create it with createOption)";
+ exit;
+ }
+ function getOption($o)
+ {
+ if(array_key_exists($o, $this->options)) {
+ return $this->options[$o];
+ }
+ echo "Attempt to getOption($o): option doesn't exist (create it with createOption)";
+ exit;
+ }
+
function getFieldType($f)
{
$inputtype = '';
@@ -875,33 +910,50 @@ class TableEditor
}
+ function defaultGetList()
+ {
+ $sel = array();
+ $from = array();
+ $where = array();
+
+ foreach($this->listfields AS $f=>$n)
+ $sel[] = "`$f`";
+
+ $from[] = "`{$this->table}`";
+ if(count($this->additionalListTables)) {
+ foreach($this->additionalListTables as $t) {
+ $from[] = "$t ";
+ }
+ }
+
+ if(count($this->fieldFilterList)) {
+ foreach($this->fieldFilterList AS $k=>$v) {
+ $where = ($v == false) ? $k : "`$k`='$v'";
+ }
+ }
+ return array($sel, $from, $where);
+ }
+
function displayTable()
{
global $icon_path;
global $icon_extension;
$query="SELECT SQL_CALC_FOUND_ROWS {$this->primaryKey}";
- foreach($this->listfields AS $f=>$n)
- $query.=", `$f`";
- $query.=" FROM `{$this->table}`";
- if(count($this->additionalListTables)) {
- foreach($this->additionalListTables as $t) {
- $query .= "$t ";
- }
+ if(is_callable($this->classname, 'tableEditorGetList')) {
+ list($sel, $from, $where) = call_user_func(array($this->classname, 'tableEditorGetList'), &$this);
+ } else {
+ echo "Calling default func\n";
+ list($sel, $from, $where) = $this->defaultGetList();
}
- if(count($this->fieldFilterList))
- {
- $query.=" WHERE 1 ";
- foreach($this->fieldFilterList AS $k=>$v)
- {
- if($v == false)
- $query .= "AND $k ";
- else
- $query.=" AND `$k`='$v' ";
- }
- }
+ foreach($sel as $s) $query .= ",$s";
+ $query .= " FROM ";
+ foreach($from as $f) $query .= "$f ";
+ $query .= " WHERE 1 ";
+ foreach($where as $w) $query .= "AND $w ";
+
if($this->sortField())
$query.=" ORDER BY ".$this->sortField()."";
@@ -921,6 +973,8 @@ class TableEditor
echo "".i18n("Add new %1",array($this->recordType))."
";
}
if($this->DEBUG) echo $query;
+
+// print("query[$query]");
$q=mysql_query($query);
//put in some paganation stuff here.
|