/adei/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/adei/trunk
79 by Suren A. Chilingaryan
New version of dhtmlxmenu and dhtmlxtree is added
1
<?php
119 by Suren A. Chilingaryan
New way of service handling (mod_rewrite), Various fixups, katrin stuff moved to SETUP directory
2
global $ADEI_ID_DELIMITER;
239 by Suren A. Chilingaryan
Basic implementation of TANGOReader
3
global $ADEI_SRCTREE_EXTRA;
79 by Suren A. Chilingaryan
New version of dhtmlxmenu and dhtmlxtree is added
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)) {
212 by Suren A. Chilingaryan
Integration of work of students with fixes
13
    $tmp = explode($ADEI_ID_DELIMITER, $id, 3);
79 by Suren A. Chilingaryan
New version of dhtmlxmenu and dhtmlxtree is added
14
    $prefix = $id . $ADEI_ID_DELIMITER;
15
    $parent = $id;
239 by Suren A. Chilingaryan
Basic implementation of TANGOReader
16
17
    if ($tmp[0] == "virtual") {
18
        $props = array();
19
        $extra_mod = $tmp[1];
20
        $prefix = $tmp[2];
21
        $type = 4;
79 by Suren A. Chilingaryan
New version of dhtmlxmenu and dhtmlxtree is added
22
    } else {
239 by Suren A. Chilingaryan
Basic implementation of TANGOReader
23
        $props = array(
24
	    "db_server" => $tmp[0]
25
        );
26
    
27
        if (isset($tmp[1])) {
28
	    $props["db_name"] = $tmp[1];
29
	    if (isset($tmp[2])) {
30
	        $props["db_group"] = $tmp[2];
31
	        $type = 3;
32
	        $child = 0;
33
	    } else {
34
	        $type = 2;
35
	    }
36
        } else {
37
	    $type = 1;
38
        }
79 by Suren A. Chilingaryan
New version of dhtmlxmenu and dhtmlxtree is added
39
    }
40
} else {
41
    $prefix = "";
42
    $props = array();
43
    $type = 0;
44
    $parent = "0";
239 by Suren A. Chilingaryan
Basic implementation of TANGOReader
45
    unset($extra_mod);
79 by Suren A. Chilingaryan
New version of dhtmlxmenu and dhtmlxtree is added
46
}
47
48
49
$tree = "";
50
try {
51
    switch ($type) {
52
     case 0:
53
	$req = new REQUEST($props);
54
	$list = $req->GetServerList();
55
	break;
56
     case 1:
57
	$req = new SERVERRequest($props);
151 by Suren A. Chilingaryan
New TOSKA configuration
58
	$list = $req->GetDatabaseList(REQUEST::LIST_WILDCARDED);
79 by Suren A. Chilingaryan
New version of dhtmlxmenu and dhtmlxtree is added
59
	break;
60
     case 2:
61
	$req = new SOURCERequest($props);
62
	$list = $req->GetGroupList();
63
	break;
64
     case 3:
65
	$req = new GROUPRequest($props);
66
	$list = $req->GetItemList();
67
	break;
239 by Suren A. Chilingaryan
Basic implementation of TANGOReader
68
     default:
69
	$req = new REQUEST($props);
70
    }
71
72
    $branches = array();
73
    
74
    if (($type == 0)||($type == 4)) {
75
        if ($ADEI_SRCTREE_EXTRA) {
76
	    foreach ($ADEI_SRCTREE_EXTRA as $extra => $cfg) {
77
	        if (isset($extra_mode)&&($extra != $extra_mod)) continue;
78
	        
79
	        ADEI::RequireClass("srctree/{$cfg['class']}");
80
	        $cl = new $extra($req, $cfg['options']);
81
	        $res = $cl->GetBranches($prefix);
82
	        $extra_prefix = "virtual__" . strtolower($extra) . "__";
83
	        foreach ($res as $id => $info) {
84
	            $branches[$extra_prefix . $id ] = $info;
85
	        }
86
    	    }
87
        }
88
    }
89
90
    if ($list) {
91
        foreach ($list as $id => $info) {
92
            $branches["{$prefix}{$id}"] = array_merge($info, array("child" => $child));
93
        }
79 by Suren A. Chilingaryan
New version of dhtmlxmenu and dhtmlxtree is added
94
    }
95
} catch (ADEIException $ex) {
96
    $ex->logInfo(NULL, $req);
97
    $err = xml_escape($ex->getInfo());
98
}
99
239 by Suren A. Chilingaryan
Basic implementation of TANGOReader
100
79 by Suren A. Chilingaryan
New version of dhtmlxmenu and dhtmlxtree is added
101
if ($err) {
102
    echo "<?xml version='1.0' encoding='UTF-8'?>
80 by Suren A. Chilingaryan
Few steps on source tree integration in javascript frontend
103
<tree id=\"$parent\">
104
  <item id=\"{$prefix}___error\" text=\"" . translate("Source tree generation is failed, error: %s", $err) . "\"/>
79 by Suren A. Chilingaryan
New version of dhtmlxmenu and dhtmlxtree is added
105
</tree>";
198 by Suren A. Chilingaryan
Update of setups
106
    exit(0);
79 by Suren A. Chilingaryan
New version of dhtmlxmenu and dhtmlxtree is added
107
108
}
109
239 by Suren A. Chilingaryan
Basic implementation of TANGOReader
110
/*
79 by Suren A. Chilingaryan
New version of dhtmlxmenu and dhtmlxtree is added
111
foreach ($list as $id => $info) {
112
    $tree.="<item id=\"{$prefix}{$id}\" text=\"" . xml_escape($info['name']) . "\" child=\"$child\" select=\"yes\"/>";
113
}
239 by Suren A. Chilingaryan
Basic implementation of TANGOReader
114
*/
115
116
foreach ($branches as $id => $info) {
117
    $tree.="<item id=\"{$id}\" text=\"" . xml_escape($info['name']) . "\" child=\"" . ($info['child']?1:0) . "\" select=\"yes\"/>";
118
}
119
79 by Suren A. Chilingaryan
New version of dhtmlxmenu and dhtmlxtree is added
120
121
echo "<?xml version='1.0' encoding='UTF-8'?>
122
<tree id=\"$parent\">
123
 $tree
124
</tree>";
125
126
?>
127