blob: ad97be21b09925d45ad714fff18939ffa78cce03 (
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
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
95
96
97
98
99
100
101
102
103
104
105
|
<?php
/*
@author dhtmlx.com
@license GPL, see license.txt
*/
/*! DataItemUpdate class for realization Optimistic concurrency control
Wrapper for DataItem object
It's used during outputing updates instead of DataItem object
Create wrapper for every data item with update information.
*/
namespace DHTMLX\Connector\Data;
class DataItemUpdate extends DataItem {
/*! constructor
@param data
hash of data
@param config
DataConfig object
@param index
index of element
*/
public function __construct($data,$config,$index,$type){
$this->config=$config;
$this->data=$data;
$this->index=$index;
$this->skip=false;
$this->child = new $type($data, $config, $index);
}
/*! returns parent_id (for Tree and TreeGrid components)
*/
public function get_parent_id(){
if (method_exists($this->child, 'get_parent_id')) {
return $this->child->get_parent_id();
} else {
return '';
}
}
/*! generate XML on the data hash base
*/
public function to_xml(){
$str= "<update ";
$str .= 'status="'.$this->data['type'].'" ';
$str .= 'id="'.$this->data['dataId'].'" ';
$str .= 'parent="'.$this->get_parent_id().'"';
$str .= '>';
$str .= $this->child->to_xml();
$str .= '</update>';
return $str;
}
/*! return starting tag for XML string
*/
public function to_xml_start(){
$str="<update ";
$str .= 'status="'.$this->data['type'].'" ';
$str .= 'id="'.$this->data['dataId'].'" ';
$str .= 'parent="'.$this->get_parent_id().'"';
$str .= '>';
$str .= $this->child->to_xml_start();
return $str;
}
/*! return ending tag for XML string
*/
public function to_xml_end(){
$str = $this->child->to_xml_end();
$str .= '</update>';
return $str;
}
/*! returns false for outputing only current item without child items
*/
public function has_kids(){
return false;
}
/*! sets count of child items
@param value
count of child items
*/
public function set_kids($value){
if (method_exists($this->child, 'set_kids')) {
$this->child->set_kids($value);
}
}
/*! sets attribute for item
*/
public function set_attribute($name, $value){
if (method_exists($this->child, 'set_attribute')) {
LogMaster::log("setting attribute: \nname = {$name}\nvalue = {$value}");
$this->child->set_attribute($name, $value);
} else {
LogMaster::log("set_attribute method doesn't exists");
}
}
}
|