diff options
Diffstat (limited to 'codebase/Dhtmlx')
17 files changed, 334 insertions, 91 deletions
diff --git a/codebase/Dhtmlx/Connector/Connector.php b/codebase/Dhtmlx/Connector/Connector.php index ec8ae9a..6f45153 100755 --- a/codebase/Dhtmlx/Connector/Connector.php +++ b/codebase/Dhtmlx/Connector/Connector.php @@ -17,30 +17,19 @@ use Dhtmlx\Connector\Event\FilterInterface; use Dhtmlx\Connector\DataStorage\ArrayQueryWrapper; class Connector { + private $id_seed=0; //!< default value, used to generate auto-IDs + private $db; //!< db connection resource + protected $config;//DataConfig instance protected $request;//DataRequestConfig instance protected $names;//!< hash of names for used classes protected $encoding="utf-8";//!< assigned encoding (UTF-8 by default) protected $editing=false;//!< flag of edit mode ( response for dataprocessor ) - - public static $filter_var="dhx_filter"; - public static $sort_var="dhx_sort"; - public static $kids_var="dhx_kids"; - - public $model=false; - - private $updating=false;//!< flag of update mode ( response for data-update ) - private $db; //!< db connection resource + protected $updating=false;//!< flag of update mode ( response for data-update ) protected $dload;//!< flag of dyn. loading mode - public $access; //!< AccessMaster instance protected $data_separator = "\n"; - - public $sql; //DataWrapper instance - public $event; //EventMaster instance - public $limit=false; - - private $id_seed=0; //!< default value, used to generate auto-IDs protected $live_update = false; // actions table name for autoupdating + protected $live_update_data_type = "DataUpdate"; protected $extra_output="";//!< extra info which need to be sent to client side protected $options=array();//!< hash of OptionsConnector protected $as_string = false; // render() returns string, don't send result in response @@ -50,6 +39,16 @@ class Connector { protected $mix; protected $order = false; + public static $filter_var="dhx_filter"; + public static $sort_var="dhx_sort"; + public static $kids_var="dhx_kids"; + + public $model=false; + public $access; //!< AccessMaster instance + public $sql; //DataWrapper instance + public $event; //EventMaster instance + public $limit=false; + /*! constructor Here initilization of all Masters occurs, execution timer initialized @@ -71,7 +70,7 @@ class Connector { if (class_exists($dsnamespace.$type."DBDataWrapper",true)) $type.="DBDataWrapper"; if (!$item_type) $item_type="Dhtmlx\\Connector\\Data\\DataItem"; - if (!$data_type) $data_type="Dhtmlx\\Connector\\Data\\DataProcessor"; + if (!$data_type) $data_type="Dhtmlx\\Connector\\DataProcessor\\DataProcessor"; if (!$render_type) $render_type="Dhtmlx\\Connector\\Output\\RenderStrategy"; $this->names=array( @@ -551,6 +550,10 @@ class Connector { $this->options[$name]=$options; } + public function get_options() { + return $this->options; + } + public function insert($data) { $action = new DataAction('inserted', false, $data); @@ -592,7 +595,7 @@ class Connector { url used for update notifications */ public function enable_live_update($table, $url=false){ - $this->live_update = new DataUpdate($this->sql, $this->config, $this->request, $table,$url); + $this->live_update = new $this->live_update_data_type($this->sql, $this->config, $this->request, $table,$url, array("connector" => $this)); $this->live_update->set_event($this->event,$this->names["item_class"]); $this->event->attach("beforeOutput", Array($this->live_update, "version_output")); $this->event->attach("beforeFiltering", Array($this->live_update, "get_updates")); diff --git a/codebase/Dhtmlx/Connector/Data/DataItemUpdate.php b/codebase/Dhtmlx/Connector/Data/DataItemUpdate.php index c77451c..3dcee14 100644 --- a/codebase/Dhtmlx/Connector/Data/DataItemUpdate.php +++ b/codebase/Dhtmlx/Connector/Data/DataItemUpdate.php @@ -47,7 +47,7 @@ class DataItemUpdate extends DataItem { */ public function to_xml(){ $str= "<update "; - $str .= 'status="'.$this->data['type'].'" '; + $str .= 'status="'.$this->data['action_table_type'].'" '; $str .= 'id="'.$this->data['dataId'].'" '; $str .= 'parent="'.$this->get_parent_id().'"'; $str .= '>'; @@ -60,7 +60,7 @@ class DataItemUpdate extends DataItem { */ public function to_xml_start(){ $str="<update "; - $str .= 'status="'.$this->data['type'].'" '; + $str .= 'status="'.$this->data['action_table_type'].'" '; $str .= 'id="'.$this->data['dataId'].'" '; $str .= 'parent="'.$this->get_parent_id().'"'; $str .= '>'; diff --git a/codebase/Dhtmlx/Connector/Data/DataRequestConfig.php b/codebase/Dhtmlx/Connector/Data/DataRequestConfig.php index e2b709c..91752fe 100644 --- a/codebase/Dhtmlx/Connector/Data/DataRequestConfig.php +++ b/codebase/Dhtmlx/Connector/Data/DataRequestConfig.php @@ -5,6 +5,8 @@ use \Exception; /*! manager of data request **/ class DataRequestConfig { + + private $action_mode = ""; private $filters; //!< array of filtering rules private $relation=false; //!< ID or other element used for linking hierarchy private $sort_by; //!< sorting field @@ -49,6 +51,7 @@ class DataRequestConfig { $this->relation =$proto->get_relation(); $this->user = $proto->user; $this->version = $proto->version; + $this->action_mode = $proto->action_mode; } /*! convert self to string ( for logs ) @@ -66,6 +69,15 @@ class DataRequestConfig { return $str; } + public function set_action_mode($action_mode) { + $this->action_mode = $action_mode; + return $this; + } + + public function get_action_mode() { + return $this->action_mode; + } + /*! returns set of filtering rules @return set of filtering rules diff --git a/codebase/Dhtmlx/Connector/Data/DataUpdate.php b/codebase/Dhtmlx/Connector/Data/DataUpdate.php index 7db2261..7c00297 100644 --- a/codebase/Dhtmlx/Connector/Data/DataUpdate.php +++ b/codebase/Dhtmlx/Connector/Data/DataUpdate.php @@ -24,13 +24,14 @@ class DataUpdate { @param request DataRequestConfig object */ - function __construct($sql, $config, $request, $table, $url){ + function __construct($sql, $config, $request, $table, $url, $options){ $this->config= $config; $this->request= $request; $this->sql = $sql; $this->table=$table; $this->url=$url; $this->demu = false; + $this->options = $options; } public function set_demultiplexor($path){ @@ -42,15 +43,15 @@ class DataUpdate { $this->item_class = $name; } - private function select_update($actions_table, $join_table, $id_field_name, $version, $user) { - $sql = "SELECT * FROM {$actions_table}"; + protected function select_update($actions_table, $join_table, $id_field_name, $version, $user) { + $sql = "SELECT $join_table.*, {$actions_table}.id, {$actions_table}.dataId, {$actions_table}.type as action_table_type, {$actions_table}.user FROM {$actions_table}"; $sql .= " LEFT OUTER JOIN {$join_table} ON "; $sql .= "{$actions_table}.DATAID = {$join_table}.{$id_field_name} "; $sql .= "WHERE {$actions_table}.ID > '{$version}' AND {$actions_table}.USER <> '{$user}'"; return $sql; } - private function get_update_max_version() { + protected function get_update_max_version() { $sql = "SELECT MAX(id) as VERSION FROM {$this->table}"; $res = $this->sql->query($sql); $data = $this->sql->get_next($res); @@ -68,6 +69,9 @@ class DataUpdate { file_get_contents($this->demu); } + public function get_table() { + return $this->table; + } @@ -80,6 +84,10 @@ class DataUpdate { $dataId = $this->sql->escape($action->get_new_id()); $user = $this->sql->escape($this->request->get_user()); if ($type!="error" && $type!="invalid" && $type !="collision") { + $action_mode = $this->request->get_action_mode(); + if(!empty($action_mode)) + $type .= "#".$action_mode; + $this->log_update_action($this->table, $dataId, $type, $user); } } diff --git a/codebase/Dhtmlx/Connector/Data/GanttLinkDataItem.php b/codebase/Dhtmlx/Connector/Data/GanttLinkDataItem.php new file mode 100644 index 0000000..0b53cf6 --- /dev/null +++ b/codebase/Dhtmlx/Connector/Data/GanttLinkDataItem.php @@ -0,0 +1,22 @@ +<?php +namespace Dhtmlx\Connector\Data; + +class GanttLinkDataItem extends DataItem { + + public function to_xml_start(){ + $str="<item id='".$this->xmlentities($this->get_id())."'"; + for ($i=0; $i < sizeof($this->config->data); $i++){ + $name=$this->config->data[$i]["name"]; + $db_name=$this->config->data[$i]["db_name"]; + $str.=" ".$name."='".$this->xmlentities($this->data[$name])."'"; + } + //output custom data + if ($this->userdata !== false) + foreach ($this->userdata as $key => $value){ + $str.=" ".$key."='".$this->xmlentities($value)."'"; + } + + return $str.">"; + } + +}
\ No newline at end of file diff --git a/codebase/Dhtmlx/Connector/Data/JSONDataItemUpdate.php b/codebase/Dhtmlx/Connector/Data/JSONDataItemUpdate.php new file mode 100644 index 0000000..bb6ec47 --- /dev/null +++ b/codebase/Dhtmlx/Connector/Data/JSONDataItemUpdate.php @@ -0,0 +1,15 @@ +<?php +namespace Dhtmlx\Connector\Data; + +class JSONDataItemUpdate extends DataItemUpdate { + + public function to_xml() { + return array( + "status" => $this->data["action_table_type"], + "id" => $this->data["dataId"], + "parent" => $this->get_parent_id(), + "data" => $this->child->to_xml() + ); + } + +}
\ No newline at end of file diff --git a/codebase/Dhtmlx/Connector/Data/JSONDataUpdate.php b/codebase/Dhtmlx/Connector/Data/JSONDataUpdate.php new file mode 100644 index 0000000..ea84e8d --- /dev/null +++ b/codebase/Dhtmlx/Connector/Data/JSONDataUpdate.php @@ -0,0 +1,62 @@ +<?php +namespace Dhtmlx\Connector\Data; + +class JSONDataUpdate extends DataUpdate { + + /*! adds action version in output XML as userdata +*/ + public function version_output($conn, $out) { + $outJson = json_decode($out->__toString(), true); + if(!isset($outJson["userdata"])) + $outJson["userdata"] = array(); + + $outJson["userdata"] = array_merge($outJson["userdata"], $this->get_version()); + $out->reset(); + $out->add(json_encode($outJson)); + } + + /*! return action version in XMl format + */ + public function get_version() { + $version = array("version" => $this->get_update_max_version()); + return $version; + } + + public function get_updates() { + $sub_request = new DataRequestConfig($this->request); + $version = $this->request->get_version(); + $user = $this->request->get_user(); + + $sub_request->parse_sql($this->select_update($this->table, $this->request->get_source(), $this->config->id['db_name'], $version, $user)); + $sub_request->set_relation(false); + + $output = $this->render_set($this->sql->select($sub_request), $this->item_class); + + if(!isset($output["userdata"])) + $output["userdata"] = array(); + + $output["userdata"] = array_merge($output["userdata"], $this->get_version()); + $this->output(json_encode($output)); + } + + protected function render_set($res, $name){ + $output = array(); + $index = 0; + while($data = $this->sql->get_next($res)) { + $data = new JSONDataItemUpdate($data, $this->config, $index, $name); + $this->event->trigger("beforeRender", $data); + array_push($output, $data->to_xml()); + $index++; + } + + return array("updates" => $output); + } + + protected function output($res){ + $out = new OutputWriter($res, ""); + $out->set_type("json"); + $this->event->trigger("beforeOutput", $this, $out); + $out->output("", true, $this->encoding); + } + +}
\ No newline at end of file diff --git a/codebase/Dhtmlx/Connector/Data/JSONGanttDataUpdate.php b/codebase/Dhtmlx/Connector/Data/JSONGanttDataUpdate.php new file mode 100644 index 0000000..eba380f --- /dev/null +++ b/codebase/Dhtmlx/Connector/Data/JSONGanttDataUpdate.php @@ -0,0 +1,58 @@ +<?php +namespace Dhtmlx\Connector\Data; + +class JSONGanttDataUpdate extends JSONDataUpdate { + + public function get_updates() { + $updates = $this->get_data_updates(); + //ToDo: Add rendering for data. + } + + + private function get_data_updates() { + $actions_table = $this->table; + $version = $this->request->get_version(); + $user = $this->request->get_user(); + + $select_actions = "SELECT DATAID, TYPE, USER FROM {$actions_table}"; + $select_actions .= " WHERE {$actions_table}.ID > '{$version}' AND {$actions_table}.USER <> '{$user}'"; + + + $output = array(); + $index = 0; + $actions_query = $this->sql->query($select_actions); + while($action_data=$this->sql->get_next($actions_query)){ + $action_type = $action_data["TYPE"]; + $type_parts = explode("#", $action_type); + $action_mode = $type_parts[1]; + if($action_mode == "links") { + $data = $this->select_links_for_action($action_data["DATAID"]); + $data = new DataItemUpdate($data, $this->config, $index, $this->item_class); + } + else { + $data = $this->select_task_for_action($action_data["DATAID"]); + $data = new DataItemUpdate($data, $this->config, $index, $this->item_class); + } + + array_push($output, $data); + $index++; + } + + return $output; + } + + protected function select_task_for_action($taskId) { + $tasks_table = $this->request->get_source(); + $field_task_id = $this->config->id['db_name']; + $select_actions_tasks = "SELECT * FROM {$tasks_table} WHERE {$taskId} = {$tasks_table}.{$field_task_id}"; + return $this->sql->get_next($this->sql->query($select_actions_tasks)); + } + + protected function select_links_for_action($taskId) { + $links_connector_options = $this->options["connector"]->get_options(); + $links_table = $links_connector_options["links"]->get_request()->get_source(); + $field_task_id = $this->config->id['db_name']; + $select_actions_tasks = "SELECT * FROM {$links_table} WHERE {$taskId} = {$links_table}.{$field_task_id}"; + return $this->sql->get_next($this->sql->query($select_actions_tasks)); + } +}
\ No newline at end of file diff --git a/codebase/Dhtmlx/Connector/DataStorage/PDODBDataWrapper.php b/codebase/Dhtmlx/Connector/DataStorage/PDODBDataWrapper.php index 8eebe0c..07dda9a 100644 --- a/codebase/Dhtmlx/Connector/DataStorage/PDODBDataWrapper.php +++ b/codebase/Dhtmlx/Connector/DataStorage/PDODBDataWrapper.php @@ -31,7 +31,7 @@ class PDODBDataWrapper extends DBDataWrapper { if ($where) $sql.=" WHERE ".$where; if ($sort) $sql.=" ORDER BY ".$sort; if ($start || $count) { - if ($this->connection->getAttribute(PDO::ATTR_DRIVER_NAME)=="pgsql") + if ($this->connection->getAttribute(\PDO::ATTR_DRIVER_NAME)=="pgsql") $sql.=" OFFSET ".$start." LIMIT ".$count; else $sql.=" LIMIT ".$start.",".$count; diff --git a/codebase/Dhtmlx/Connector/DataStorage/ResultHandler/PDOResultHandler.php b/codebase/Dhtmlx/Connector/DataStorage/ResultHandler/PDOResultHandler.php index d2b13ec..9aa2776 100644 --- a/codebase/Dhtmlx/Connector/DataStorage/ResultHandler/PDOResultHandler.php +++ b/codebase/Dhtmlx/Connector/DataStorage/ResultHandler/PDOResultHandler.php @@ -7,7 +7,7 @@ class PDOResultHandler { $this->res = $res; } public function next(){ - $data = $this->res->fetch(PDO::FETCH_ASSOC); + $data = $this->res->fetch(\PDO::FETCH_ASSOC); if (!$data){ $this->res->closeCursor(); return null; diff --git a/codebase/Dhtmlx/Connector/GanttConnector.php b/codebase/Dhtmlx/Connector/GanttConnector.php index 84246cd..e581386 100755 --- a/codebase/Dhtmlx/Connector/GanttConnector.php +++ b/codebase/Dhtmlx/Connector/GanttConnector.php @@ -1,10 +1,20 @@ <?php namespace Dhtmlx\Connector; +use Dhtmlx\Connector\Tools\LogMaster; +use Dhtmlx\Connector\Tools\EventMaster; +use Dhtmlx\Connector\Event\SortInterface; +use Dhtmlx\Connector\Event\FilterInterface; +use Dhtmlx\Connector\DataStorage\ArrayDBDataWrapper; +use Dhtmlx\Connector\DataStorage\ArrayQueryWrapper; + /*! Connector class for dhtmlxGantt **/ class GanttConnector extends Connector { + private $action_mode = ""; + public $links_table = ""; + protected $live_update_data_type = "Dhtmlx\\Connector\\Data\\GanttDataUpdate"; protected $extra_output="";//!< extra info which need to be sent to client side protected $options=array();//!< hash of OptionsConnector protected $links_mode = false; @@ -56,8 +66,14 @@ class GanttConnector extends Connector { function parse_request(){ parent::parse_request(); - if (isset($_GET["gantt_mode"]) && $_GET["gantt_mode"] == "links") - $this->links_mode = true; + $action_links = "links"; + if(isset($_GET["gantt_mode"]) && $_GET["gantt_mode"] == $action_links) { + $this->action_mode = $action_links; + $this->request->set_action_mode($action_links); + $this->options[$action_links]->request->set_action_mode($action_links); + $this->options[$action_links]->request->set_user($this->request->get_user()); + } + if (count($this->config->text)){ if (isset($_GET["to"])) @@ -88,9 +104,68 @@ class GanttConnector extends Connector { } } - public function render_links($table,$id="",$fields=false,$extra=false,$relation_id=false) { + public function render_links($table,$id="",$fields=false,$extra=false) { $links = new GanttLinksConnector($this->get_connection(),$this->names["db_class"]); + + if($this->live_update) + $links->enable_live_update($this->live_update->get_table()); + $links->render_table($table,$id,$fields,$extra); $this->set_options("links", $links); + $this->links_table = $table; } + + /*! 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->action_mode == "links") && 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(); + } + + }
\ No newline at end of file diff --git a/codebase/Dhtmlx/Connector/GanttLinksConnector.php b/codebase/Dhtmlx/Connector/GanttLinksConnector.php index 6dcf607..bdf2047 100644 --- a/codebase/Dhtmlx/Connector/GanttLinksConnector.php +++ b/codebase/Dhtmlx/Connector/GanttLinksConnector.php @@ -2,6 +2,13 @@ namespace Dhtmlx\Connector; class GanttLinksConnector extends OptionsConnector { + protected $live_update_data_type = "Dhtmlx\\Connector\\Data\\GanttDataUpdate"; + + public function __construct($res,$type=false,$item_type=false,$data_type=false,$render_type=false){ + if (!$item_type) $item_type="Dhtmlx\\Connector\\Data\\GanttLinkDataItem"; + parent::__construct($res,$type,$item_type,$data_type,$render_type); + } + public function render(){ if (!$this->init_flag){ $this->init_flag=true; diff --git a/codebase/Dhtmlx/Connector/JSONDataConnector.php b/codebase/Dhtmlx/Connector/JSONDataConnector.php index 2b4b3ca..4d0d929 100644..100755 --- a/codebase/Dhtmlx/Connector/JSONDataConnector.php +++ b/codebase/Dhtmlx/Connector/JSONDataConnector.php @@ -6,7 +6,7 @@ class JSONDataConnector extends DataConnector { public function __construct($res,$type=false,$item_type=false,$data_type=false,$render_type=false){ if (!$item_type) $item_type="Dhtmlx\\Connector\\Data\\JSONCommonDataItem"; - if (!$data_type) $data_type="Dhtmlx\\Connector\\Data\\CommonDataProcessor"; + if (!$data_type) $data_type="Dhtmlx\\Connector\\DataProcessor\\CommonDataProcessor"; if (!$render_type) $render_type="Dhtmlx\\Connector\\Output\\JSONRenderStrategy"; $this->data_separator = ",\n"; parent::__construct($res,$type,$item_type,$data_type,$render_type); diff --git a/codebase/Dhtmlx/Connector/JSONGanttConnector.php b/codebase/Dhtmlx/Connector/JSONGanttConnector.php index 18bdc16..3198d25 100644..100755 --- a/codebase/Dhtmlx/Connector/JSONGanttConnector.php +++ b/codebase/Dhtmlx/Connector/JSONGanttConnector.php @@ -1,16 +1,11 @@ <?php namespace Dhtmlx\Connector; -use Dhtmlx\Connector\Tools\LogMaster; -use Dhtmlx\Connector\Tools\EventMaster; use Dhtmlx\Connector\Output\OutputWriter; -use Dhtmlx\Connector\Event\SortInterface; -use Dhtmlx\Connector\Event\FilterInterface; -use Dhtmlx\Connector\DataStorage\ArrayDBDataWrapper; -use Dhtmlx\Connector\DataStorage\ArrayQueryWrapper; class JSONGanttConnector extends GanttConnector { protected $data_separator = ","; + protected $live_update_data_type = "Dhtmlx\\Connector\\Data\\JSONGanttDataUpdate"; /*! constructor @@ -25,9 +20,9 @@ class JSONGanttConnector extends GanttConnector { name of class which will be used for dataprocessor calls handling, optional, DataProcessor class will be used by default. */ public function __construct($res,$type=false,$item_type=false,$data_type=false,$render_type=false){ - if (!$item_type) $item_type="JSONGanttDataItem"; - if (!$data_type) $data_type="GanttDataProcessor"; - if (!$render_type) $render_type="JSONRenderStrategy"; + if (!$item_type) $item_type="Dhtmlx\\Connector\\Data\\JSONGanttDataItem"; + if (!$data_type) $data_type="Dhtmlx\\Connector\\DataProcessor\\GanttDataProcessor"; + if (!$render_type) $render_type="Dhtmlx\\Connector\\Output\\JSONRenderStrategy"; parent::__construct($res,$type,$item_type,$data_type,$render_type); } @@ -104,60 +99,12 @@ 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"]); + + if($this->live_update) + $links->enable_live_update($this->live_update->get_table()); + $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(); - } }
\ No newline at end of file diff --git a/codebase/Dhtmlx/Connector/JSONGanttLinksConnector.php b/codebase/Dhtmlx/Connector/JSONGanttLinksConnector.php index c08b451..899fd11 100644 --- a/codebase/Dhtmlx/Connector/JSONGanttLinksConnector.php +++ b/codebase/Dhtmlx/Connector/JSONGanttLinksConnector.php @@ -2,6 +2,8 @@ namespace Dhtmlx\Connector; class JSONGanttLinksConnector extends JSONOptionsConnector { + protected $live_update_data_type = "Dhtmlx\\Connector\\Data\\JSONGanttDataUpdate"; + public function render(){ if (!$this->init_flag){ $this->init_flag=true; diff --git a/codebase/Dhtmlx/Connector/JSONSchedulerConnector.php b/codebase/Dhtmlx/Connector/JSONSchedulerConnector.php index a84bf68..443dbcc 100755 --- a/codebase/Dhtmlx/Connector/JSONSchedulerConnector.php +++ b/codebase/Dhtmlx/Connector/JSONSchedulerConnector.php @@ -5,6 +5,7 @@ use Dhtmlx\Connector\Output\OutputWriter; class JSONSchedulerConnector extends SchedulerConnector { protected $data_separator = ","; + protected $live_update_data_type = "JSONDataUpdate"; /*! constructor diff --git a/codebase/Dhtmlx/Connector/MixedConnector.php b/codebase/Dhtmlx/Connector/MixedConnector.php index 1d2c9ff..ae2c297 100644 --- a/codebase/Dhtmlx/Connector/MixedConnector.php +++ b/codebase/Dhtmlx/Connector/MixedConnector.php @@ -3,13 +3,28 @@ namespace Dhtmlx\Connector; class MixedConnector extends Connector { + private $_data_type = null; + + function __construct($dataType = "json") { + $this->_data_type = $dataType; + } + + protected $attributes = array(); protected $connectors = array(); public function add($name, $conn) { $this->connectors[$name] = $conn; + $conn->simple = true; } public function render() { + if($this->_data_type == "json") + $this->render_json(); + else + $this->render_xml(); + } + + private function render_json() { $result = "{"; $parts = array(); foreach($this->connectors as $name => $conn) { @@ -19,4 +34,20 @@ class MixedConnector extends Connector { $result .= implode(",\n", $parts)."}"; echo $result; } + + private function render_xml() { + $result = ""; + $parts = array(); + + foreach($this->connectors as $name => $conn) { + $conn->asString(true); + $parts[] = "<".$name.">".($conn->render())."</".$name.">\n"; + } + $result .= implode("", $parts); + $this->output_as_xml($result); + } + + protected function output_as_xml($res) { + echo "<?xml version='1.0' encoding='".$this->encoding."' ?>".$this->xml_start().$res.$this->xml_end(); + } }
\ No newline at end of file |