summaryrefslogtreecommitdiffstats
path: root/codebase/data_connector.php
diff options
context:
space:
mode:
authorStanislau Wolski <stanislau.wolski@gmail.com>2014-04-18 13:29:59 +0300
committerStanislau Wolski <stanislau.wolski@gmail.com>2014-04-18 13:29:59 +0300
commit1eb0d049180342db92bed2c1acaa9f6d7a76cca9 (patch)
tree08669004cfebc5d7431362253de099dbb7cc3fd5 /codebase/data_connector.php
parenta98ac5261f2e8dbf70bcc2af3543279841637c80 (diff)
downloadconnector-php-1eb0d049180342db92bed2c1acaa9f6d7a76cca9.zip
connector-php-1eb0d049180342db92bed2c1acaa9f6d7a76cca9.tar.gz
connector-php-1eb0d049180342db92bed2c1acaa9f6d7a76cca9.tar.bz2
[add] $rootId for tree connectors
Diffstat (limited to 'codebase/data_connector.php')
-rw-r--r--codebase/data_connector.php10
1 files changed, 8 insertions, 2 deletions
diff --git a/codebase/data_connector.php b/codebase/data_connector.php
index 7c9251d..99ec843 100644
--- a/codebase/data_connector.php
+++ b/codebase/data_connector.php
@@ -366,6 +366,7 @@ class TreeCommonDataItem extends CommonDataItem{
class TreeDataConnector extends DataConnector{
protected $parent_name = 'parent';
+ public $rootId = "0";
/*! constructor
@@ -403,7 +404,10 @@ class TreeDataConnector extends DataConnector{
/*! renders self as xml, starting part
*/
protected function xml_start(){
- $attributes = " parent='".$this->request->get_relation()."' ";
+ $attributes = " ";
+ if (!$this->rootId || $this->rootId != $this->request->get_relation())
+ $attributes = " parent='".$this->request->get_relation()."' ";
+
foreach($this->attributes as $k=>$v)
$attributes .= " ".$k."='".$v."'";
@@ -426,7 +430,9 @@ class JSONTreeDataConnector extends TreeDataConnector{
if ($this->simple) return $result;
$data = array();
- $data["parent"] = $this->request->get_relation();
+ if (!$this->rootId || $this->rootId != $this->request->get_relation())
+ $data["parent"] = $this->request->get_relation();
+
$data["data"] = $result;
$this->fill_collections();