summaryrefslogtreecommitdiffstats
path: root/codebase/Dhtmlx/Connector/MixedConnector.php
diff options
context:
space:
mode:
Diffstat (limited to 'codebase/Dhtmlx/Connector/MixedConnector.php')
-rw-r--r--codebase/Dhtmlx/Connector/MixedConnector.php31
1 files changed, 31 insertions, 0 deletions
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