[go: up one dir, main page]

Menu

[r3]: / doc / app / tree.inc.php  Maximize  Restore  History

Download this file

268 lines (179 with data), 7.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
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
<?
//just show a single level of collections
function expandSingleCol($conn,$curValue) {
//somehow, this is faster than the two table query method
if (bitset_compare(BITSET,ADMIN,null)) {
$sql = "SELECT DISTINCT id,name,parent_id,
(SELECT count(id) FROM
(SELECT id,parent_id FROM dm_view_collections) AS mytable
WHERE parent_id=dm_view_collections.id) AS child_count
FROM dm_view_collections WHERE parent_id='$curValue' ORDER BY name
";
}
else {
$permStr = permString();
//a little fancy query footwork
$sql = "SELECT DISTINCT id,name,parent_id,
(SELECT count(id) FROM
(SELECT id,parent_id FROM dm_view_collections WHERE ".$permStr.") AS mytable
WHERE parent_id=dm_view_collections.id) AS child_count
FROM dm_view_collections WHERE parent_id='$curValue' AND ".$permStr." ORDER BY name
";
}
$list = list_result($conn,$sql);
$str = null;
for ($i=0;$i<$list["count"];$i++) {
//first, get the info for this file
$str .= "<collection>\n";
$str .= xmlEntry("id",$list[$i]["id"]);
$str .= xmlEntry("name",$list[$i]["name"]);
$str .= xmlEntry("parent_id",$list[$i]["parent_id"]);
$str .= xmlEntry("child_count",$list[$i]["child_count"]);
$str .= "</collection>\n";
}
return $str;
}
function expandValueCol($conn,$curValue) {
//get all collections that need to be displayed
$sql = "SELECT DISTINCT id,name,parent_id FROM dm_view_collections";
if (!bitset_compare(BITSET,ADMIN,null)) $sql .= " WHERE ".permString($conn);
$sql .= " ORDER BY name ";
$catInfo = total_result($conn,$sql);
$arr = array();
if ($curValue) {
if (!is_array($curValue)) $curValue = array($curValue);
$num = count($curValue);
for ($i=0;$i<$num;$i++)
$arr = array_merge($arr,returnCatOwner($catInfo,$curValue[$i],null));
$arr = array_values(array_unique($arr));
}
//get the parent of the current, then pass it on to return info for all files
//which are on the same level. we also pass our value array so we can
//decent to the next level at a hit
if ($catInfo["count"] > 0) {
$keys = array_keys($catInfo["parent_id"],"0");
$xml = showColXml($catInfo,$keys,$arr);
}
else $xml = null;
return $xml;
}
function showColXml($catInfo,$keys,$arr) {
if (!$keys) return false;
foreach ($keys AS $childKey) {
//first, get the infor for this file
$str .= "<collection>\n";
$str .= xmlEntry("id",$catInfo["id"][$childKey]);
$str .= xmlEntry("name",$catInfo["name"][$childKey]);
$str .= xmlEntry("parent_id",$catInfo["parent_id"][$childKey]);
//now show the children
$keys = array_keys($catInfo["parent_id"],$catInfo["id"][$childKey]);
//show the children count
$str .= xmlEntry("child_count",count($keys));
//if in the expansion array show the children
if (@in_array($catInfo["id"][$childKey],$arr)) {
$str .= "<children>\n";
$str .= showColXml($catInfo,$keys,$arr);
$str .= "</children>\n";
}
$str .= "</collection>\n";
}
return $str;
}
//just show a single level of collections
function expandSingleObj($conn,$curValue) {
//somehow, this is faster than the two table query method
if (bitset_compare(BITSET,ADMIN,null)) {
$sql = "SELECT DISTINCT id,name,object_type,parent_id,
(SELECT count(id) FROM
(SELECT id,parent_id FROM dm_view_objects) AS mytable
WHERE parent_id=dm_view_objects.id) AS child_count
FROM dm_view_objects WHERE parent_id='$curValue' ORDER BY name
";
}
else {
$permStr = permString();
//a little fancy query footwork
$sql = "SELECT DISTINCT id,name,object_type,parent_id,
(SELECT count(id) FROM
(SELECT id,parent_id FROM dm_view_objects WHERE ".$permStr.") AS mytable
WHERE parent_id=dm_view_objects.id) AS child_count
FROM dm_view_objects WHERE parent_id='$curValue' AND ".$permStr." ORDER BY name
";
}
$list = list_result($conn,$sql);
$str = null;
for ($i=0;$i<$list["count"];$i++) {
//first, get the info for this file
$str .= "<object>\n";
$str .= xmlEntry("id",$list[$i]["id"]);
$str .= xmlEntry("name",$list[$i]["name"]);
$str .= xmlEntry("icon",returnObjIcon($list[$i]["name"],$list[$i]["object_type"]));
$str .= xmlEntry("parent_id",$list[$i]["parent_id"]);
$str .= xmlEntry("child_count",$list[$i]["child_count"]);
$str .= "</object>\n";
}
return $str;
}
function expandValueObj($conn,$curValue) {
//get all objects that need to be displayed
$sql = "SELECT DISTINCT id,name,object_type,parent_id FROM dm_view_objects";
if (!bitset_compare(BITSET,ADMIN,null)) $sql .= " WHERE ".permString($conn);
$sql .= " ORDER BY name ";
$objInfo = total_result($conn,$sql);
$arr = array();
if ($curValue) {
if (!is_array($curValue)) $curValue = array($curValue);
$num = count($curValue);
for ($i=0;$i<$num;$i++)
$arr = array_merge($arr,returnCatOwner($objInfo,$curValue[$i],null));
$arr = array_values(array_unique($arr));
}
//get the parent of the current, then pass it on to return info for all files
//which are on the same level. we also pass our value array so we can
//decent to the next level at a hit
if ($objInfo["count"] > 0) {
$keys = array_keys($objInfo["parent_id"],"0");
$xml = showObjXml($objInfo,$keys,$arr);
}
else $xml = null;
return $xml;
}
function showObjXml($objInfo,$keys,$arr) {
if (!$keys) return false;
foreach ($keys AS $childKey) {
//first, get the infor for this file
$str .= "<object>\n";
$str .= xmlEntry("id",$objInfo["id"][$childKey]);
$str .= xmlEntry("name",$objInfo["name"][$childKey]);
$str .= xmlEntry("parent_id",$objInfo["parent_id"][$childKey]);
//now show the children
$keys = array_keys($objInfo["parent_id"],$objInfo["id"][$childKey]);
$str .= xmlEntry("icon",returnObjIcon($objInfo["name"][$childKey],$objInfo["object_type"][$childKey]));
//show the children count
$str .= xmlEntry("child_count",count($keys));
//if in the expansion array show the children
if (@in_array($objInfo["id"][$childKey],$arr)) {
$str .= "<children>\n";
$str .= showObjXml($objInfo,$keys,$arr);
$str .= "</children>\n";
}
$str .= "</object>\n";
}
return $str;
}
function returnObjIcon($name,$objType) {
//list the icon that will be used for this object
if ($objType=="file") {
//use the file's type icon if it exists
$type = return_file_type($name);
if (file_exists(THEME_PATH."/images/fileicons/".$type.".png"))
$img = THEME_PATH."/images/fileicons/".$type.".png";
else
$img = THEME_PATH."/images/fileicons/file.png";
} else {
//use the icon for the type if it exists, otherwise use the standard file icon
$img = THEME_PATH."/images/fileicons/".$objType.".png";
if (!file_exists($img)) THEME_PATH."/images/fileicons/file.png";
}
return $img;
}