-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathtreedatagroup_connector.php
More file actions
89 lines (69 loc) · 2.2 KB
/
treedatagroup_connector.php
File metadata and controls
89 lines (69 loc) · 2.2 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
/*
@author dhtmlx.com
@license GPL, see license.txt
*/
require_once("data_connector.php");
class TreeDataGroupConnector extends TreeDataConnector{
public function __construct($res,$type=false,$item_type=false,$data_type=false,$render_type=false){
if (!$render_type) $render_type="GroupRenderStrategy";
parent::__construct($res,$type,$item_type,$data_type,$render_type);
}
/*! if not isset $_GET[id] then it's top level
*/
protected function set_relation() {
if (!isset($_GET[$this->parent_name])) $this->request->set_relation(false);
}
/*! if it's first level then distinct level
* else select by parent
*/
protected function get_resource() {
$resource = null;
if (isset($_GET[$this->parent_name]))
$resource = $this->sql->select($this->request);
else
$resource = $this->sql->get_variants($this->config->relation_id['name'], $this->request);
return $resource;
}
/*! renders self as xml, starting part
*/
public function xml_start(){
if (isset($_GET[$this->parent_name])) {
return "<data parent='".$_GET[$this->parent_name].$this->render->get_postfix()."'>";
} else {
return "<data parent='0'>";
}
}
}
class JSONTreeDataGroupConnector extends JSONTreeDataConnector{
public function __construct($res,$type=false,$item_type=false,$data_type=false,$render_type=false){
if (!$render_type) $render_type="JSONGroupRenderStrategy";
parent::__construct($res,$type,$item_type,$data_type,$render_type);
}
/*! if not isset $_GET[id] then it's top level
*/
protected function set_relation() {
if (!isset($_GET[$this->parent_name])) $this->request->set_relation(false);
}
/*! if it's first level then distinct level
* else select by parent
*/
protected function get_resource() {
$resource = null;
if (isset($_GET[$this->parent_name]))
$resource = $this->sql->select($this->request);
else
$resource = $this->sql->get_variants($this->config->relation_id['name'], $this->request);
return $resource;
}
/*! renders self as xml, starting part
*/
public function xml_start(){
if (isset($_GET[$this->parent_name])) {
return "<data parent='".$_GET[$this->parent_name].$this->render->get_postfix()."'>";
} else {
return "<data parent='0'>";
}
}
}
?>