/openshift/adei

To get this branch, use:
bzr branch http://darksoft.org/webbzr/openshift/adei

« back to all changes in this revision

Viewing changes to services/srctree.php

  • Committer: Suren A. Chilingaryan
  • Date: 2008-10-29 03:02:24 UTC
  • Revision ID: csa@dside.dyndns.org-20081029030224-yc3wy2dti4htlfxf
New version of dhtmlxmenu and dhtmlxtree is added

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
require("../adei.php");
 
4
 
 
5
header("Content-type: text/xml");
 
6
header("Cache-Control: no-cache, must-revalidate");
 
7
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
 
8
 
 
9
 
 
10
$id = $_GET['id'];
 
11
$child = 1;
 
12
if (isset($id)) {
 
13
    $tmp = split($ADEI_ID_DELIMITER, $id, 3);
 
14
    $prefix = $id . $ADEI_ID_DELIMITER;
 
15
    $parent = $id;
 
16
    
 
17
    $props = array(
 
18
        "db_server" => $tmp[0]
 
19
    );
 
20
    
 
21
    if (isset($tmp[1])) {
 
22
        $props["db_name"] = $tmp[1];
 
23
        if (isset($tmp[2])) {
 
24
            $props["db_group"] = $tmp[2];
 
25
            $type = 3;
 
26
            $child = 0;
 
27
        } else {
 
28
            $type = 2;
 
29
        }
 
30
    } else {
 
31
        $type = 1;
 
32
    }
 
33
} else {
 
34
    $prefix = "";
 
35
    $props = array();
 
36
    $type = 0;
 
37
    $parent = "0";
 
38
}
 
39
 
 
40
 
 
41
$tree = "";
 
42
try {
 
43
    switch ($type) {
 
44
     case 0:
 
45
        $req = new REQUEST($props);
 
46
        $list = $req->GetServerList();
 
47
        break;
 
48
     case 1:
 
49
        $req = new SERVERRequest($props);
 
50
        $list = $req->GetDatabaseList();
 
51
        break;
 
52
     case 2:
 
53
        $req = new SOURCERequest($props);
 
54
        $list = $req->GetGroupList();
 
55
        break;
 
56
     case 3:
 
57
        $req = new GROUPRequest($props);
 
58
        $list = $req->GetItemList();
 
59
        break;
 
60
    }
 
61
} catch (ADEIException $ex) {
 
62
    $ex->logInfo(NULL, $req);
 
63
    $err = xml_escape($ex->getInfo());
 
64
}
 
65
 
 
66
 
 
67
if ($err) {
 
68
    echo "<?xml version='1.0' encoding='UTF-8'?>
 
69
<tree id=\"0\">
 
70
  <item id=\"1\" name=\"" . translate("Source tree generation is failed, error: %s", $err) . "\"/>
 
71
</tree>";
 
72
    return;
 
73
 
 
74
}
 
75
 
 
76
foreach ($list as $id => $info) {
 
77
    $tree.="<item id=\"{$prefix}{$id}\" text=\"" . xml_escape($info['name']) . "\" child=\"$child\" select=\"yes\"/>";
 
78
}
 
79
 
 
80
echo "<?xml version='1.0' encoding='UTF-8'?>
 
81
<tree id=\"$parent\">
 
82
 $tree
 
83
</tree>";
 
84
 
 
85
?>
 
86