Welcome to mirror list, hosted at ThFree Co, Russian Federation.

BrowserController.php « Controller « src - github.com/HuasoFoundries/phpPgAdmin6.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e98933c642c9cde749153443d0ece6e34b7b5b8f (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
78
79
80
81
82
83
84
85
86
<?php

/**
 * PHPPgAdmin6
 */

namespace PHPPgAdmin\Controller;

use PHPPgAdmin\Core\ArrayRecordset;
use PHPPgAdmin\Decorators\Decorator;

/**
 * Base controller class.
 */
class BrowserController extends BaseController
{
    protected $no_db_connection = true;

    /**
     * Default method to render the controller according to the action parameter.
     *
     * @param null|mixed $action
     *
     * @return string
     */
    public function render($action = null)
    {
        if (null === $action) {
            $action = $this->action;
        }

        switch ($action) {
            case 'tree':
                return $this->doTree();

                break;

            default:
                return $this->doDefault();

                break;
        }
    }

    /**
     * Default method to render the browser iframe using jstree.
     *
     * @return string rendered html of the jstree template
     */
    public function doDefault()
    {
        $this->misc->setNoDBConnection(true);

        $this->setNoBottomLink(true);

        $viewVars = ['icon' => [
            'Refresh' => $this->view->icon('Refresh'),
            'Servers' => $this->view->icon('Servers'),
        ]];

        return $this->view->fetch('browser.twig', $viewVars);
    }

    /**
     * Renders the root element of the jstree.
     *
     * @return string json representation of the root element of the jstree
     */
    public function doTree()
    {
        $treedata = new ArrayRecordset([]);
        $reqvars = [];
        $action = Decorator::url('/src/views/servers');
        $branch = Decorator::url('/src/views/servers', $reqvars, ['action' => 'tree']);
        // $this->dump($branch);
        $attrs = [
            'text' => 'Servers',
            'icon' => 'Servers',
            'is_root' => 'true',
            'action' => $action,
            'branch' => $branch,
        ];

        return $this->printTree($treedata, $attrs, 'server');
    }
}