summaryrefslogtreecommitdiff
path: root/hugo/libraries/navigation/Navigation.class.php
blob: d140bbc33a18fbeb0aece930a98e7272a1292faf (plain)
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
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 * This class is responsible for instanciating
 * the various components of the navigation panel
 *
 * @package PhpMyAdmin-navigation
 */
if (! defined('PHPMYADMIN')) {
    exit;
}

require_once 'libraries/navigation/NodeFactory.class.php';
require_once 'libraries/navigation/NavigationHeader.class.php';
require_once 'libraries/navigation/NavigationTree.class.php';

/**
 * The navigation panel - displays server, db and table selection tree
 *
 * @package PhpMyAdmin-Navigation
 */
class PMA_Navigation
{
    /**
     * Initialises the class
     *
     * @return void
     */
    public function __construct()
    {
        if (empty($GLOBALS['token'])) {
            $GLOBALS['token'] = $_SESSION[' PMA_token '];
        }
    }

    /**
     * Renders the navigation tree, or part of it
     *
     * @return string The navigation tree
     */
    public function getDisplay()
    {
        /* Init */
        $retval = '';
        if (! PMA_Response::getInstance()->isAjax()) {
            $header = new PMA_NavigationHeader();
            $retval = $header->getDisplay();
        }
        $tree = new PMA_NavigationTree();
        if (! PMA_Response::getInstance()->isAjax()
            || ! empty($_REQUEST['full'])
            || ! empty($_REQUEST['reload'])
        ) {
            $treeRender = $tree->renderState();
        } else {
            $treeRender = $tree->renderPath();
        }

        if (! $treeRender) {
            $retval .= PMA_Message::error(
                __('An error has occured while loading the navigation tree')
            )->getDisplay();
        } else {
            $retval .= $treeRender;
        }

        if (! PMA_Response::getInstance()->isAjax()) {
            // closes the tags that were opened by the navigation header
            $retval .= '</div>';
            $retval .= '</div>';
            $retval .= '</div>';
        }

        return $retval;
    }
}
?>