Subversion Repositories oidplus

Rev

Rev 104 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 104 Rev 106
Line 38... Line 38...
38
        public function gui($id, &$out, &$handled) {
38
        public function gui($id, &$out, &$handled) {
39
                if ($id === 'oidplus:system') {
39
                if ($id === 'oidplus:system') {
40
                        $handled = true;
40
                        $handled = true;
41
 
41
 
42
                        $out['title'] = OIDplus::config()->systemTitle(); // 'Object Database of ' . $_SERVER['SERVER_NAME'];
42
                        $out['title'] = OIDplus::config()->systemTitle(); // 'Object Database of ' . $_SERVER['SERVER_NAME'];
43
                        $out['icon'] = 'img/system_big.png';
43
                        $out['icon'] = 'plugins/publicPages/'.basename(__DIR__).'/system_big.png';
44
                        $out['text'] = file_get_contents('welcome.html');
44
                        $out['text'] = file_get_contents('welcome.html');
45
 
45
 
46
                        if (strpos($out['text'], '%%OBJECT_TYPE_LIST%%') !== false) {
46
                        if (strpos($out['text'], '%%OBJECT_TYPE_LIST%%') !== false) {
47
                                $tmp = '<ul>';
47
                                $tmp = '<ul>';
48
                                foreach (OIDplus::getRegisteredObjectTypes() as $ot) {
48
                                foreach (OIDplus::getRegisteredObjectTypes() as $ot) {
Line 54... Line 54...
54
 
54
 
55
                        return $out;
55
                        return $out;
56
                }
56
                }
57
        }
57
        }
58
 
58
 
59
        public function tree(&$json, $ra_email=null, $nonjs=false) {
59
        public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
60
                $json = array();
-
 
61
 
-
 
62
                if ($nonjs) {
60
                if ($nonjs) {
63
                        $static_node_id = isset($_REQUEST['goto']) ? $_REQUEST['goto'] : 'oidplus:system';
-
 
64
 
-
 
65
                        $json[] = array('id' => 'oidplus:system', 'icon' => 'img/system.png', 'text' => 'System');
61
                        $json[] = array('id' => 'oidplus:system', 'icon' => 'plugins/publicPages/'.basename(__DIR__).'/system.png', 'text' => 'System');
66
 
62
 
67
                        $parent = '';
63
                        $parent = '';
68
                        $res = OIDplus::db()->query("select parent from ".OIDPLUS_TABLENAME_PREFIX."objects where id = '".OIDplus::db()->real_escape_string($static_node_id)."'");
64
                        $res = OIDplus::db()->query("select parent from ".OIDPLUS_TABLENAME_PREFIX."objects where id = '".OIDplus::db()->real_escape_string($req_goto)."'");
69
                        while ($row = OIDplus::db()->fetch_object($res)) {
65
                        while ($row = OIDplus::db()->fetch_object($res)) {
70
                                $parent = $row->parent;
66
                                $parent = $row->parent;
71
                        }
67
                        }
72
 
68
 
73
                        $objTypesChildren = array();
69
                        $objTypesChildren = array();
74
                        foreach (OIDplus::getRegisteredObjectTypes() as $ot) {
70
                        foreach (OIDplus::getRegisteredObjectTypes() as $ot) {
75
                                $icon = 'plugins/objectTypes/'.$ot::ns().'/img/treeicon_root.png';
71
                                $icon = 'plugins/objectTypes/'.$ot::ns().'/img/treeicon_root.png';
76
                                $json[] = array('id' => $ot::root(), 'icon' => $icon, 'text' => $ot::objectTypeTitle());
72
                                $json[] = array('id' => $ot::root(), 'icon' => $icon, 'text' => $ot::objectTypeTitle());
77
 
73
 
78
                                try {
74
                                try {
79
                                        $tmp = OIDplusObject::parse($static_node_id);
75
                                        $tmp = OIDplusObject::parse($req_goto);
80
                                } catch (Exception $e) {
76
                                } catch (Exception $e) {
81
                                        $tmp = null;
77
                                        $tmp = null;
82
                                }
78
                                }
83
                                if (!is_null($tmp) && ($ot == get_class($tmp))) {
79
                                if (!is_null($tmp) && ($ot == get_class($tmp))) {
84
                                        // TODO: Instead of just having 3 levels (parent, this and children), it would be better if we'd had a full tree of all parents
80
                                        // TODO: Instead of just having 3 levels (parent, this and children), it would be better if we'd had a full tree of all parents
85
                                        //       on the other hand, for giving search engines content, this is good enough
81
                                        //       on the other hand, for giving search engines content, this is good enough
86
                                        $res = OIDplus::db()->query("select * from ".OIDPLUS_TABLENAME_PREFIX."objects where " .
82
                                        $res = OIDplus::db()->query("select * from ".OIDPLUS_TABLENAME_PREFIX."objects where " .
87
                                                           "parent = '".OIDplus::db()->real_escape_string($static_node_id)."' or " .
83
                                                           "parent = '".OIDplus::db()->real_escape_string($req_goto)."' or " .
88
                                                           "id = '".OIDplus::db()->real_escape_string($static_node_id)."' " .
84
                                                           "id = '".OIDplus::db()->real_escape_string($req_goto)."' " .
89
                                                           ((!empty($parent)) ? " or id = '".OIDplus::db()->real_escape_string($parent)."' " : "") .
85
                                                           ((!empty($parent)) ? " or id = '".OIDplus::db()->real_escape_string($parent)."' " : "") .
90
                                                           "order by ".OIDplus::db()->natOrder('id'));
86
                                                           "order by ".OIDplus::db()->natOrder('id'));
91
                                        $z_used = 0;
87
                                        $z_used = 0;
92
                                        $y_used = 0;
88
                                        $y_used = 0;
93
                                        $x_used = 0;
89
                                        $x_used = 0;
Line 99... Line 95...
99
                                                if (is_null($obj)) continue; // might happen if the objectType is not available/loaded
95
                                                if (is_null($obj)) continue; // might happen if the objectType is not available/loaded
100
                                                if (!$obj->userHasReadRights()) continue;
96
                                                if (!$obj->userHasReadRights()) continue;
101
                                                $txt = $row->title == '' ? '' : ' -- '.htmlentities($row->title);
97
                                                $txt = $row->title == '' ? '' : ' -- '.htmlentities($row->title);
102
 
98
 
103
                                                if ($row->id == $parent) { $stufe=0; $z_used++; }
99
                                                if ($row->id == $parent) { $stufe=0; $z_used++; }
104
                                                if ($row->id == $static_node_id) { $stufe=1; $y_used++; }
100
                                                if ($row->id == $req_goto) { $stufe=1; $y_used++; }
105
                                                if ($row->parent == $static_node_id) { $stufe=2; $x_used++; }
101
                                                if ($row->parent == $req_goto) { $stufe=2; $x_used++; }
106
 
102
 
107
                                                $menu_entry = array('id' => $row->id, 'icon' => '', 'text' => $txt, 'indent' => 0);
103
                                                $menu_entry = array('id' => $row->id, 'icon' => '', 'text' => $txt, 'indent' => 0);
108
                                                $menu_entries[] = $menu_entry;
104
                                                $menu_entries[] = $menu_entry;
109
                                                $stufen[] = $stufe;
105
                                                $stufen[] = $stufe;
110
                                        }
106
                                        }
Line 151... Line 147...
151
                                'text' => "Objects",
147
                                'text' => "Objects",
152
                                'state' => array(
148
                                'state' => array(
153
                                        "opened" => true,
149
                                        "opened" => true,
154
                                        // "selected" => true)  // "selected" ist buggy: 1) Das select-Event wird beim Laden nicht gefeuert 2) Die direkt untergeordneten Knoten lassen sich nicht öffnen (laden für ewig)
150
                                        // "selected" => true)  // "selected" ist buggy: 1) Das select-Event wird beim Laden nicht gefeuert 2) Die direkt untergeordneten Knoten lassen sich nicht öffnen (laden für ewig)
155
                                ),
151
                                ),
156
                                'icon' => 'img/system.png',
152
                                'icon' => 'plugins/publicPages/'.basename(__DIR__).'/system.png',
157
                                'children' => $objTypesChildren
153
                                'children' => $objTypesChildren
158
                        );
154
                        );
159
 
155
 
160
                        return true;
156
                        return true;
161
                }
157
                }