/adei/ui

To get this branch, use:
bzr branch http://darksoft.org/webbzr/adei/ui
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
<?php

require("../adei.php");

header("Content-type: text/xml");
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");


$id = $_GET['id'];
$child = 1;
if (isset($id)) {
    $tmp = split($ADEI_ID_DELIMITER, $id, 3);
    $prefix = $id . $ADEI_ID_DELIMITER;
    $parent = $id;
    
    $props = array(
	"db_server" => $tmp[0]
    );
    
    if (isset($tmp[1])) {
	$props["db_name"] = $tmp[1];
	if (isset($tmp[2])) {
	    $props["db_group"] = $tmp[2];
	    $type = 3;
	    $child = 0;
	} else {
	    $type = 2;
	}
    } else {
	$type = 1;
    }
} else {
    $prefix = "";
    $props = array();
    $type = 0;
    $parent = "0";
}


$tree = "";
try {
    switch ($type) {
     case 0:
	$req = new REQUEST($props);
	$list = $req->GetServerList();
	break;
     case 1:
	$req = new SERVERRequest($props);
	$list = $req->GetDatabaseList();
	break;
     case 2:
	$req = new SOURCERequest($props);
	$list = $req->GetGroupList();
	break;
     case 3:
	$req = new GROUPRequest($props);
	$list = $req->GetItemList();
	break;
    }
} catch (ADEIException $ex) {
    $ex->logInfo(NULL, $req);
    $err = xml_escape($ex->getInfo());
}


if ($err) {
    echo "<?xml version='1.0' encoding='UTF-8'?>
<tree id=\"$parent\">
  <item id=\"{$prefix}___error\" text=\"" . translate("Source tree generation is failed, error: %s", $err) . "\"/>
</tree>";
    return;

}

foreach ($list as $id => $info) {
    $tree.="<item id=\"{$prefix}{$id}\" text=\"" . xml_escape($info['name']) . "\" child=\"$child\" select=\"yes\"/>";
}

echo "<?xml version='1.0' encoding='UTF-8'?>
<tree id=\"$parent\">
 $tree
</tree>";

?>