summaryrefslogtreecommitdiffstats
path: root/codebase/Output/JSONTreeRenderStrategy.php
diff options
context:
space:
mode:
authorKirylka <kirylanoshko@gmail.com>2015-03-31 17:56:47 +0300
committerKirylka <kirylanoshko@gmail.com>2015-03-31 17:56:47 +0300
commitf5f99c335707d9b11d40f1eb0f6ddb5a993fd31a (patch)
treed9c0d3532ec9f0f2fb68e31d2611282ae0642181 /codebase/Output/JSONTreeRenderStrategy.php
parent458f0aead573842f1df00ce2ae00334c27f66585 (diff)
downloadconnector-php-f5f99c335707d9b11d40f1eb0f6ddb5a993fd31a.zip
connector-php-f5f99c335707d9b11d40f1eb0f6ddb5a993fd31a.tar.gz
connector-php-f5f99c335707d9b11d40f1eb0f6ddb5a993fd31a.tar.bz2
Creating a new connector for yii2.
Diffstat (limited to 'codebase/Output/JSONTreeRenderStrategy.php')
-rw-r--r--codebase/Output/JSONTreeRenderStrategy.php39
1 files changed, 39 insertions, 0 deletions
diff --git a/codebase/Output/JSONTreeRenderStrategy.php b/codebase/Output/JSONTreeRenderStrategy.php
new file mode 100644
index 0000000..04a8672
--- /dev/null
+++ b/codebase/Output/JSONTreeRenderStrategy.php
@@ -0,0 +1,39 @@
+<?php
+namespace DHTMLX\Connector\Output;
+
+class JSONTreeRenderStrategy extends TreeRenderStrategy {
+
+ public function render_set($res, $name, $dload, $sep, $config,$mix){
+ $output=array();
+ $index=0;
+ $conn = $this->conn;
+ $config_copy = new DataConfig($config);
+ $this->mix($config, $mix);
+ while ($data=$conn->sql->get_next($res)){
+ $data = $this->complex_mix($mix, $data);
+ $data = new $name($data,$config,$index);
+ $conn->event->trigger("beforeRender",$data);
+ //there is no info about child elements,
+ //if we are using dyn. loading - assume that it has,
+ //in normal mode just exec sub-render routine
+ if ($data->has_kids()===-1 && $dload)
+ $data->set_kids(true);
+ $record = $data->to_xml_start();
+ if ($data->has_kids()===-1 || ( $data->has_kids()==true && !$dload)){
+ $sub_request = new DataRequestConfig($conn->get_request());
+ //$sub_request->set_fieldset(implode(",",$config_copy->db_names_list($conn->sql)));
+ $sub_request->set_relation($data->get_id());
+ //$sub_request->set_filters(array());
+ $temp = $this->render_set($conn->sql->select($sub_request), $name, $dload, $sep, $config_copy, $mix);
+ if (sizeof($temp))
+ $record["data"] = $temp;
+ }
+ if ($record !== false)
+ $output[] = $record;
+ $index++;
+ }
+ $this->unmix($config, $mix);
+ return $output;
+ }
+
+} \ No newline at end of file