summaryrefslogtreecommitdiffstats
path: root/codebase/Dhtmlx/Connector/JSONTreeDataMultitableConnector.php
blob: a826b8ec991ce9a1fb9eae6f99cda534e4270435 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
namespace Dhtmlx\Connector;
use Dhtmlx\Connector\Output\OutputWriter;

class JSONTreeDataMultitableConnector extends TreeDataMultitableConnector {

    public function __construct($res,$type=false,$item_type=false,$data_type=false,$render_type=false){
        if (!$item_type) $item_type="JSONTreeCommonDataItem";
        if (!$data_type) $data_type="CommonDataProcessor";
        if (!$render_type) $render_type="JSONMultitableTreeRenderStrategy";
        parent::__construct($res,$type,$item_type,$data_type,$render_type);
    }

    protected function output_as_xml($res){
        $result = $this->render_set($res);
        if ($this->simple) return $result;

        $data = array();
        if (isset($_GET['parent']))
            $data["parent"] = $this->render->level_id($_GET[$this->parent_name], $this->render->get_level() - 1);
        else
            $data["parent"] = "0";
        $data["data"] = $result;

        $result = json_encode($data);
        if ($this->as_string) return $result;

        $out = new OutputWriter($result, "");
        $out->set_type("json");
        $this->event->trigger("beforeOutput", $this, $out);
        $out->output("", true, $this->encoding);
    }

    public function xml_start(){
        return '';
    }
}