File: datatree.php

package info (click to toggle)
horde3 3.0.4-4sarge7
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 15,980 kB
  • ctags: 16,295
  • sloc: php: 68,726; xml: 2,382; sql: 498; makefile: 74; sh: 63; pascal: 6
file content (76 lines) | stat: -rw-r--r-- 2,514 bytes parent folder | download
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
<?php
/**
 * $Horde: horde/admin/datatree.php,v 1.7.2.1 2005/01/03 12:25:29 jan Exp $
 *
 * Copyright 2004-2005 Jan Schneider <jan@horde.org>
 *
 * See the enclosed file COPYING for license information (LGPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 */

function addTree($parent, $parent_id, $indent = 1)
{
    global $datatree, $tree;

    $nodes = $datatree->getById(DATATREE_FORMAT_FLAT, $parent_id, true, $parent, 1);
    $expanded = $tree->isExpanded($parent);
    $url = Horde::url('datatree.php');
    foreach ($nodes as $id => $node) {
        if ($id == $parent_id) {
            continue;
        }
        $tree->addNode($parent . ':' . $id, $parent, $datatree->getShortName($node), $indent, false, array('url' => Util::addParameter($url, 'show', $datatree->getParam('group') . ':' . $id) . '#show'));
        if ($expanded) {
            addTree($parent . ':' . $id, $id, $indent + 1);
        }
    }
}

@define('HORDE_BASE', dirname(__FILE__) . '/..');
require_once HORDE_BASE . '/lib/base.php';
require_once 'Horde/Menu.php';
require_once 'Horde/Help.php';
require_once 'Horde/Tree.php';
require_once 'Horde/DataTree.php';

if (!Auth::isAdmin()) {
    Horde::authenticationFailureRedirect();
}

$tree = &Horde_Tree::factory('datatree', 'html');
$tree->setOption('alternate', true);

$driver = $conf['datatree']['driver'];
$config = Horde::getDriverConfig('datatree', $conf['datatree']['driver']);
$datatree = &DataTree::singleton($conf['datatree']['driver']);
$roots = $datatree->getGroups();

if (is_a($roots, 'PEAR_Error')) {
    $notification->push($roots);
} else {
    foreach ($roots as $root) {
        $tree->addNode($root, null, $root, 0, false);
        $datatree = &DataTree::singleton($driver, array_merge($config, array('group' => $root)));
        addTree($root, DATATREE_ROOT);
    }
}

if ($show = Util::getFormData('show')) {
    list($root, $id) = explode(':', $show);
    $datatree = &DataTree::singleton($driver, array_merge($config, array('group' => $root)));
    $data = $datatree->getData($id);
    $attributes = $datatree->getAttributes($id);
}

$title = _("DataTree Browser");
require HORDE_TEMPLATES . '/common-header.inc';
require HORDE_TEMPLATES . '/admin/common-header.inc';
$notification->notify();
$tree->renderTree();
if ($show) {
    echo '<br /><div class="text" style="white-space:pre"><a name="show"></a>';
    print_r($data);
    print_r($attributes);
    echo '</div>';
}
require HORDE_TEMPLATES . '/common-footer.inc';