diff options
author | Egor <egor.26.93@gmail.com> | 2015-06-25 16:36:59 +0300 |
---|---|---|
committer | Egor <egor.26.93@gmail.com> | 2015-06-25 16:36:59 +0300 |
commit | 8255a94f15a0722c8789a9b363962ca943e51d6b (patch) | |
tree | 6b3c368c87eeb67a6497e65ad0ed4d8404fb7a18 | |
parent | a2246c9132f8e0da5c982ab60cc16e03c03c5d77 (diff) | |
download | connector-php-8255a94f15a0722c8789a9b363962ca943e51d6b.zip connector-php-8255a94f15a0722c8789a9b363962ca943e51d6b.tar.gz connector-php-8255a94f15a0722c8789a9b363962ca943e51d6b.tar.bz2 |
Added rendering data in xml for mixed connector.
-rw-r--r-- | codebase/Dhtmlx/Connector/MixedConnector.php | 31 |
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 |