|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* PHPPgAdmin v6.0.0-beta.33 |
|
5
|
|
|
*/ |
|
6
|
|
|
|
|
7
|
|
|
namespace PHPPgAdmin\Controller; |
|
8
|
|
|
|
|
9
|
|
|
use PHPPgAdmin\Decorators\Decorator; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Base controller class. |
|
13
|
|
|
* |
|
14
|
|
|
* @package PHPPgAdmin |
|
15
|
|
|
*/ |
|
16
|
|
|
class BrowserController extends BaseController |
|
17
|
|
|
{ |
|
18
|
|
|
public $controller_name = 'BrowserController'; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Default method to render the controller according to the action parameter. |
|
22
|
|
|
*/ |
|
23
|
|
|
public function render($action = null) |
|
24
|
|
|
{ |
|
25
|
|
|
if ($action === null) { |
|
26
|
|
|
$action = $this->action; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
switch ($action) { |
|
30
|
|
|
case 'tree': |
|
31
|
|
|
return $this->doTree(); |
|
32
|
|
|
|
|
33
|
|
|
break; |
|
|
|
|
|
|
34
|
|
|
case 'jstree': |
|
35
|
|
|
return $this->jsTree(); |
|
36
|
|
|
break; |
|
37
|
|
|
|
|
38
|
|
|
default: |
|
39
|
|
|
return $this->doDefault(); |
|
40
|
|
|
break; |
|
41
|
|
|
} |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Default method to render the controller according to the action parameter. |
|
46
|
|
|
*/ |
|
47
|
|
|
public function doDefault() |
|
48
|
|
|
{ |
|
49
|
|
|
$this->misc->setNoDBConnection(true); |
|
50
|
|
|
|
|
51
|
|
|
$this->setNoBottomLink(true); |
|
52
|
|
|
|
|
53
|
|
|
$viewVars = ['icon' => [ |
|
54
|
|
|
'blank' => $this->misc->icon('blank'), |
|
55
|
|
|
'I' => $this->misc->icon('I'), |
|
56
|
|
|
'L' => $this->misc->icon('L'), |
|
57
|
|
|
'Lminus' => $this->misc->icon('Lminus'), |
|
58
|
|
|
'Loading' => $this->misc->icon('Loading'), |
|
59
|
|
|
'Lplus' => $this->misc->icon('Lplus'), |
|
60
|
|
|
'ObjectNotFound' => $this->misc->icon('ObjectNotFound'), |
|
61
|
|
|
'Refresh' => $this->misc->icon('Refresh'), |
|
62
|
|
|
'Servers' => $this->misc->icon('Servers'), |
|
63
|
|
|
'T' => $this->misc->icon('T'), |
|
64
|
|
|
'Tminus' => $this->misc->icon('Tminus'), |
|
65
|
|
|
'Tplus' => $this->misc->icon('Tplus'), |
|
66
|
|
|
]]; |
|
67
|
|
|
|
|
68
|
|
|
return $this->view->fetch('browser.twig', $viewVars); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Default method to render the controller according to the action parameter. |
|
73
|
|
|
*/ |
|
74
|
|
|
public function jsTree() |
|
75
|
|
|
{ |
|
76
|
|
|
$this->misc->setNoDBConnection(true); |
|
77
|
|
|
|
|
78
|
|
|
$this->setNoBottomLink(true); |
|
79
|
|
|
|
|
80
|
|
|
$viewVars = ['icon' => [ |
|
81
|
|
|
'blank' => $this->misc->icon('blank'), |
|
82
|
|
|
'I' => $this->misc->icon('I'), |
|
83
|
|
|
'L' => $this->misc->icon('L'), |
|
84
|
|
|
'Lminus' => $this->misc->icon('Lminus'), |
|
85
|
|
|
'Loading' => $this->misc->icon('Loading'), |
|
86
|
|
|
'Lplus' => $this->misc->icon('Lplus'), |
|
87
|
|
|
'ObjectNotFound' => $this->misc->icon('ObjectNotFound'), |
|
88
|
|
|
'Refresh' => $this->misc->icon('Refresh'), |
|
89
|
|
|
'Servers' => $this->misc->icon('Servers'), |
|
90
|
|
|
'T' => $this->misc->icon('T'), |
|
91
|
|
|
'Tminus' => $this->misc->icon('Tminus'), |
|
92
|
|
|
'Tplus' => $this->misc->icon('Tplus'), |
|
93
|
|
|
]]; |
|
94
|
|
|
|
|
95
|
|
|
return $this->view->fetch('jstree.twig', $viewVars); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
public function doTree() |
|
99
|
|
|
{ |
|
100
|
|
|
$treedata = new \PHPPgAdmin\ArrayRecordSet([]); |
|
101
|
|
|
$reqvars = []; |
|
102
|
|
|
|
|
103
|
|
|
$attrs = [ |
|
104
|
|
|
'text' => 'Servers', |
|
105
|
|
|
'icon' => 'Servers', |
|
106
|
|
|
'is_root' => 'true', |
|
107
|
|
|
'action' => Decorator::url('/src/views/servers'), |
|
108
|
|
|
'branch' => Decorator::url('/src/views/servers', $reqvars, ['action' => 'tree']), |
|
109
|
|
|
]; |
|
110
|
|
|
|
|
111
|
|
|
return $this->printTree($treedata, $attrs, 'server'); |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
} |
|
115
|
|
|
|
The
breakstatement is not necessary if it is preceded for example by areturnstatement:If you would like to keep this construct to be consistent with other
casestatements, you can safely mark this issue as a false-positive.