summaryrefslogtreecommitdiffstats
path: root/codebase
diff options
context:
space:
mode:
authorStanislau Wolski <stanislau.wolski@gmail.com>2013-10-03 19:21:34 +0300
committerStanislau Wolski <stanislau.wolski@gmail.com>2013-10-03 19:21:34 +0300
commitfcb32da12351b71c2d9b2d317744e2c6a850c332 (patch)
tree75015c87e88a1c7a38b2355ebf199f4f0ef4065e /codebase
parent394f114ab531f4a89555a3bd347a8cd3591364e6 (diff)
downloadconnector-php-fcb32da12351b71c2d9b2d317744e2c6a850c332.zip
connector-php-fcb32da12351b71c2d9b2d317744e2c6a850c332.tar.gz
connector-php-fcb32da12351b71c2d9b2d317744e2c6a850c332.tar.bz2
[update] better support of GanttConnector
Diffstat (limited to 'codebase')
-rw-r--r--codebase/base_connector.php10
-rw-r--r--codebase/data_connector.php4
-rw-r--r--codebase/gantt_connector.php113
-rw-r--r--codebase/strategy.php2
4 files changed, 31 insertions, 98 deletions
diff --git a/codebase/base_connector.php b/codebase/base_connector.php
index 39ac6eb..3a30eb2 100644
--- a/codebase/base_connector.php
+++ b/codebase/base_connector.php
@@ -600,10 +600,11 @@ class Connector {
$this->request->set_sort($this->resolve_parameter($k),$v);
}
- if (isset($_GET[Connector::$sort_var]))
+ if (isset($_GET[Connector::$filter_var]))
foreach($_GET[Connector::$filter_var] as $k => $v){
$k = $this->safe_field_name($k);
- $this->request->set_filter($this->resolve_parameter($k),$v);
+ if ($v !== "")
+ $this->request->set_filter($this->resolve_parameter($k),$v);
}
$this->check_csrf();
@@ -923,6 +924,11 @@ class OptionsConnector extends Connector{
$res = $this->sql->select($this->request);
return $this->render_set($res);
}
+
+ public function render_save(){
+ $this->config->remove_field($this->config->id["name"]);
+ parent::render();
+ }
}
diff --git a/codebase/data_connector.php b/codebase/data_connector.php
index fe8cc82..d3e5492 100644
--- a/codebase/data_connector.php
+++ b/codebase/data_connector.php
@@ -310,6 +310,10 @@ class JSONOptionsConnector extends JSONDataConnector{
$res = $this->sql->select($this->request);
return $this->render_set($res);
}
+
+ public function render_save(){
+ parent::render();
+ }
}
diff --git a/codebase/gantt_connector.php b/codebase/gantt_connector.php
index 74b8636..3f20062 100644
--- a/codebase/gantt_connector.php
+++ b/codebase/gantt_connector.php
@@ -38,7 +38,6 @@ class GanttConnector extends Connector{
protected $extra_output="";//!< extra info which need to be sent to client side
protected $options=array();//!< hash of OptionsConnector
- protected $links_mode = false;
/*! assign options collection to the column
@@ -87,9 +86,6 @@ class GanttConnector extends Connector{
function parse_request(){
parent::parse_request();
- if (isset($_GET["gantt_mode"]) && $_GET["gantt_mode"] == "links")
- $this->links_mode = true;
-
if (count($this->config->text)){
if (isset($_GET["to"]))
$this->request->set_filter($this->config->text[0]["name"],$_GET["to"],"<");
@@ -111,7 +107,7 @@ class GanttConnector extends Connector{
function delete_related_links($action){
if (isset($this->options["links"])){
$links = $this->options["links"];
- $value = $this->sql->escape($action->get_new_id());
+ $value = $this->sql->escape($action->get_id());
$table = $links->get_request()->get_source();
$this->sql->query("DELETE FROM $table WHERE source = '$value'");
@@ -119,9 +115,22 @@ class GanttConnector extends Connector{
}
}
+ /*! render self
+ process commands, output requested data as XML
+ */
+ public function render(){
+ if (!$this->as_string){
+ if (isset($_GET["gantt_mode"]) && $_GET["gantt_mode"] == "links")
+ if (isset($this->options["links"]))
+ return $this->options["links"]->render_save();
+ }
+
+ return parent::render();
+ }
+
public function render_links($table,$id="",$fields=false,$extra=false,$relation_id=false) {
- $links = new GanttLinksConnector($this->get_connection(),$this->names["db_class"]);
- $links->render_table($table,$id,$fields,$extra);
+ $links = new OptionsConnector($this->get_connection(),$this->names["db_class"]);
+ $links->render_table($table,$id,$id.",".$fields,$extra);
$this->set_options("links", $links);
}
}
@@ -266,99 +275,13 @@ class JSONGanttConnector extends GanttConnector {
}
public function render_links($table,$id="",$fields=false,$extra=false,$relation_id=false) {
- $links = new JSONGanttLinksConnector($this->get_connection(),$this->names["db_class"]);
+ $links = new JSONOptionsConnector($this->get_connection(),$this->names["db_class"]);
+ $links->enable_log("some.txt");
$links->render_table($table,$id,$fields,$extra);
$this->set_options("links", $links);
}
-
-
- /*! render self
- process commands, output requested data as XML
- */
- public function render(){
- $this->event->trigger("onInit", $this);
- EventMaster::trigger_static("connectorInit",$this);
-
- if (!$this->as_string)
- $this->parse_request();
- $this->set_relation();
-
- if ($this->live_update !== false && $this->updating!==false) {
- $this->live_update->get_updates();
- } else {
- if ($this->editing){
- if ($this->links_mode && isset($this->options["links"])) {
- $this->options["links"]->save();
- } else {
- $dp = new $this->names["data_class"]($this,$this->config,$this->request);
- $dp->process($this->config,$this->request);
- }
- } else {
- if (!$this->access->check("read")){
- LogMaster::log("Access control: read operation blocked");
- echo "Access denied";
- die();
- }
- $wrap = new SortInterface($this->request);
- $this->apply_sorts($wrap);
- $this->event->trigger("beforeSort",$wrap);
- $wrap->store();
-
- $wrap = new FilterInterface($this->request);
- $this->apply_filters($wrap);
- $this->event->trigger("beforeFilter",$wrap);
- $wrap->store();
-
- if ($this->model && method_exists($this->model, "get")){
- $this->sql = new ArrayDBDataWrapper();
- $result = new ArrayQueryWrapper(call_user_func(array($this->model, "get"), $this->request));
- $out = $this->output_as_xml($result);
- } else {
- $out = $this->output_as_xml($this->get_resource());
-
- if ($out !== null) return $out;
- }
-
- }
- }
- $this->end_run();
- }
}
-class GanttLinksConnector extends OptionsConnector {
- public function render(){
- if (!$this->init_flag){
- $this->init_flag=true;
- return "";
- }
-
- $res = $this->sql->select($this->request);
- return $this->render_set($res);
- }
-
- public function save() {
- $dp = new $this->names["data_class"]($this,$this->config,$this->request);
- $dp->process($this->config,$this->request);
- }
-}
-
-
-class JSONGanttLinksConnector extends JSONOptionsConnector {
- public function render(){
- if (!$this->init_flag){
- $this->init_flag=true;
- return "";
- }
-
- $res = $this->sql->select($this->request);
- return $this->render_set($res);
- }
-
- public function save() {
- $dp = new $this->names["data_class"]($this,$this->config,$this->request);
- $dp->process($this->config,$this->request);
- }
-}
?> \ No newline at end of file
diff --git a/codebase/strategy.php b/codebase/strategy.php
index 92deadc..c011297 100644
--- a/codebase/strategy.php
+++ b/codebase/strategy.php
@@ -46,7 +46,7 @@ class RenderStrategy {
protected function simple_mix($mix, $data) {
// get mix details
for ($i = 0; $i < count($mix); $i++)
- $data[$mix[$i]["name"]] = is_string($mix[$i]["value"]) ? $mix[$i]["value"] : "";
+ $data[$mix[$i]["name"]] = is_object($mix[$i]["value"]) ? "" : $mix[$i]["value"];
return $data;
}