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
90
91
92
93
94
|
<?php
/*
@author dhtmlx.com
@license GPL, see license.txt
*/
require_once("treegrid_connector.php");
class TreeGridGroupConnector extends TreeGridConnector{
private $id_postfix = '__{group_param}';
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);
$this->event->attach("beforeProcessing", Array($this, 'check_id'));
}
public function get_id_postfix() {
return $this->id_postfix;
}
public function render(){
if (isset($_GET['id'])) {
$_GET['id'] = str_replace($this->id_postfix, "", $_GET['id']);
}
$this->parse_request();
if (!isset($_GET['id'])) {
$this->request->set_relation(false);
}
if (isset($_GET["editing"]))
$this->editing=true;
else if (isset($_POST["ids"])){
$this->editing=true;
} else {
$this->editing = false;
}
if ($this->editing){
$dp = new $this->names["data_class"]($this,$this->config,$this->request);
$dp->process($this->config,$this->request);
}
else {
$wrap = new SortInterface($this->request);
$this->event->trigger("beforeSort",$wrap);
$wrap->store();
$wrap = new FilterInterface($this->request);
$this->event->trigger("beforeFilter",$wrap);
$wrap->store();
if (isset($_GET['id'])) {
$this->output_as_xml( $this->sql->select($this->request) );
} else {
$relation_id = $this->config->relation_id['name'];
$this->output_as_xml( $this->sql->get_variants($this->config->relation_id['name'], $this->request));
}
}
$this->end_run();
}
/*! renders self as xml, starting part
*/
protected function xml_start(){
if (isset($_GET['id'])) {
return "<rows parent='".$_GET['id'].$this->id_postfix."'>";
} else {
return "<rows parent='0'>";
}
}
public function check_id($action) {
if (isset($_GET['editing'])) {
$id = $action->get_id();
$pid = $action->get_value($this->config->relation_id['name']);
$pid = str_replace($this->id_postfix, "", $pid);
$action->set_value($this->config->relation_id['name'], $pid);
if (strpos($id, $this->id_postfix) == false) {
return $action;
} else {
$action->error();
$action->set_response_text("This record can't be updated!");
return $action;
}
} else {
return $action;
}
}
}
?>
|