blob: 7f737c1a73cae098f7f84efb0ea0de18c58a6c16 (
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
|
<?php
/**
* PHPPgAdmin v6.0.0-RC6
*/
namespace PHPPgAdmin\Controller;
use PHPPgAdmin\Decorators\Decorator;
/**
* Base controller class.
*
* @package PHPPgAdmin
*/
class BrowserController extends BaseController
{
protected $no_db_connection = true;
/**
* Default method to render the controller according to the action parameter.
*
* @param null|mixed $action
*/
public function render($action = null)
{
if ($action === null) {
$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->misc->icon('Refresh'),
'Servers' => $this->misc->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 \PHPPgAdmin\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');
}
}
|