applicationId = func_get_arg(0); $this->elementId = func_get_arg(1); $this->name = func_get_arg(2); $this->success = false; $this->load(); } catch (Exception $e) { throw new Exception ("Could not initialize element var, because: " . $e); } } } /** * @return String the name of this element var */ public function __toString () { return (string) $this->name; } /* * @return Assoc Array containing the fields to send to the user */ public function getFields() { $result = array( ); return $result; } public function create() { } /* * @param $changes JSON keys and their values of what to change in the object */ public function change($changes) { } public function commit() { } public function remove() { } public function toSql () { $insert .= "INSERT INTO gui_element_vars(fkey_gui_id, fkey_e_id, var_name, var_value, context, var_type"; $insert .= ") VALUES ("; $insert .= "'" . $this->applicationId . "',"; $insert .= "'" . $this->elementId . "',"; $insert .= "'" . $this->name . "',"; $insert .= "'" . db_escape_string($this->value) . "',"; $insert .= "'" . db_escape_string($this->context) . "',"; $insert .= "'" . $this->type . "'"; $insert.=");\n"; return $insert; } public function load() { $sql = "SELECT * from gui_element_vars WHERE fkey_gui_id = $1 AND fkey_e_id = $2 AND var_name = $3; "; $v = array($this->applicationId, $this->elementId, $this->name); $t = array("s", "s", "s"); $res = db_prep_query($sql, $v, $t); try { $row = db_fetch_array($res); if ($row !== false) { $this->value = $row["var_value"]; $this->context = $row["context"]; $this->type = $row["var_type"]; $this->success = true; } else { $this->success = false; } } catch (Exception $e) { throw new Exception ("no such element var"); } } public static function getList($filter) { return array(); } public static function byName($name) { return null; } public function isValid () { return true; } } ?>