1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* PHPPgAdmin 6.1.3 |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
namespace PHPPgAdmin\Traits; |
8
|
|
|
|
9
|
|
|
use PHPPgAdmin\ContainerUtils; |
10
|
|
|
use PHPPgAdmin\Decorators\Decorator; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @file |
14
|
|
|
* A trait to deal with nav tabs |
15
|
|
|
*/ |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* A trait to deal with nav tabs. |
19
|
|
|
*/ |
20
|
|
|
trait MiscTrait |
21
|
|
|
{ |
22
|
|
|
public function getSubjectParams($subject) |
23
|
|
|
{ |
24
|
|
|
$vars = []; |
25
|
|
|
$common_params = []; |
26
|
|
|
|
27
|
|
|
if (\array_key_exists('server', $_REQUEST)) { |
28
|
|
|
$common_params['server'] = $_REQUEST['server']; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
if (\array_key_exists('database', $_REQUEST)) { |
32
|
|
|
$common_params['database'] = $_REQUEST['database']; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
if (\array_key_exists('schema', $_REQUEST)) { |
36
|
|
|
$common_params['schema'] = $_REQUEST['schema']; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
switch ($subject) { |
40
|
|
|
case 'root': |
41
|
|
|
$vars = [ |
42
|
|
|
'params' => [ |
43
|
|
|
'subject' => 'root', |
44
|
|
|
], |
45
|
|
|
]; |
46
|
|
|
|
47
|
|
|
break; |
48
|
|
|
case 'server': |
49
|
|
|
$vars = ['params' => [ |
50
|
|
|
'subject' => 'server', |
51
|
|
|
'server' => $_REQUEST['server'], |
52
|
|
|
]]; |
53
|
|
|
|
54
|
|
|
break; |
55
|
|
|
case 'role': |
56
|
|
|
$vars = ['params' => [ |
57
|
|
|
'subject' => 'role', |
58
|
|
|
'server' => $_REQUEST['server'], |
59
|
|
|
'action' => 'properties', |
60
|
|
|
'rolename' => $_REQUEST['rolename'], |
61
|
|
|
]]; |
62
|
|
|
|
63
|
|
|
break; |
64
|
|
|
case 'database': |
65
|
|
|
$vars = ['params' => \array_merge($common_params, [ |
66
|
|
|
'subject' => 'database', |
67
|
|
|
])]; |
68
|
|
|
|
69
|
|
|
break; |
70
|
|
|
case 'schema': |
71
|
|
|
$vars = ['params' => \array_merge($common_params, [ |
72
|
|
|
'subject' => 'schema', |
73
|
|
|
])]; |
74
|
|
|
|
75
|
|
|
break; |
76
|
|
|
case 'table': |
77
|
|
|
$vars = ['params' => \array_merge($common_params, [ |
78
|
|
|
'subject' => 'table', |
79
|
|
|
|
80
|
|
|
'table' => $_REQUEST['table'], |
81
|
|
|
])]; |
82
|
|
|
|
83
|
|
|
break; |
84
|
|
|
case 'selectrows': |
85
|
|
|
$vars = [ |
86
|
|
|
'url' => 'tables', |
87
|
|
|
'params' => \array_merge($common_params, [ |
88
|
|
|
'subject' => 'table', |
89
|
|
|
'table' => $_REQUEST['table'], |
90
|
|
|
'action' => 'confselectrows', |
91
|
|
|
]), ]; |
92
|
|
|
|
93
|
|
|
break; |
94
|
|
|
case 'view': |
95
|
|
|
$vars = ['params' => \array_merge($common_params, [ |
96
|
|
|
'subject' => 'view', |
97
|
|
|
'view' => $_REQUEST['view'], |
98
|
|
|
])]; |
99
|
|
|
|
100
|
|
|
break; |
101
|
|
|
case 'matview': |
102
|
|
|
$vars = ['params' => \array_merge($common_params, [ |
103
|
|
|
'subject' => 'matview', |
104
|
|
|
'matview' => $_REQUEST['matview'], |
105
|
|
|
])]; |
106
|
|
|
|
107
|
|
|
break; |
108
|
|
|
case 'fulltext': |
109
|
|
|
case 'ftscfg': |
110
|
|
|
$vars = ['params' => \array_merge($common_params, [ |
111
|
|
|
'subject' => 'fulltext', |
112
|
|
|
'action' => 'viewconfig', |
113
|
|
|
'ftscfg' => $_REQUEST['ftscfg'], |
114
|
|
|
])]; |
115
|
|
|
|
116
|
|
|
break; |
117
|
|
|
case 'function': |
118
|
|
|
$vars = ['params' => \array_merge($common_params, [ |
119
|
|
|
'subject' => 'function', |
120
|
|
|
'function' => $_REQUEST['function'], |
121
|
|
|
'function_oid' => $_REQUEST['function_oid'], |
122
|
|
|
])]; |
123
|
|
|
|
124
|
|
|
break; |
125
|
|
|
case 'aggregate': |
126
|
|
|
$vars = ['params' => \array_merge($common_params, [ |
127
|
|
|
'subject' => 'aggregate', |
128
|
|
|
'action' => 'properties', |
129
|
|
|
'aggrname' => $_REQUEST['aggrname'], |
130
|
|
|
'aggrtype' => $_REQUEST['aggrtype'], |
131
|
|
|
])]; |
132
|
|
|
|
133
|
|
|
break; |
134
|
|
|
case 'column': |
135
|
|
|
if (isset($_REQUEST['table'])) { |
136
|
|
|
$vars = ['params' => \array_merge($common_params, [ |
137
|
|
|
'subject' => 'column', |
138
|
|
|
|
139
|
|
|
'table' => $_REQUEST['table'], |
140
|
|
|
'column' => $_REQUEST['column'], |
141
|
|
|
])]; |
142
|
|
|
} elseif (isset($_REQUEST['view'])) { |
143
|
|
|
$vars = ['params' => \array_merge($common_params, [ |
144
|
|
|
'subject' => 'column', |
145
|
|
|
|
146
|
|
|
'view' => $_REQUEST['view'], |
147
|
|
|
'column' => $_REQUEST['column'], |
148
|
|
|
])]; |
149
|
|
|
} elseif (isset($_REQUEST['matview'])) { |
150
|
|
|
$vars = ['params' => \array_merge($common_params, [ |
151
|
|
|
'subject' => 'column', |
152
|
|
|
|
153
|
|
|
'matview' => $_REQUEST['matview'], |
154
|
|
|
'column' => $_REQUEST['column'], |
155
|
|
|
])]; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
break; |
159
|
|
|
|
160
|
|
|
default: |
161
|
|
|
return false; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
if (!isset($vars['url'])) { |
165
|
|
|
$vars['url'] = \containerInstance()->subFolder . '/redirect'; |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
if (containerInstance()->subFolder . '/redirect' === $vars['url'] && isset($vars['params']['subject'])) { |
169
|
|
|
$vars['url'] = \containerInstance()->subFolder . '/redirect/' . $vars['params']['subject']; |
170
|
|
|
unset($vars['params']['subject']); |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
return $vars; |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
public function maybeClipStr($str, $params) |
177
|
|
|
{ |
178
|
|
|
if (isset($params['map'], $params['map'][$str])) { |
179
|
|
|
$str = $params['map'][$str]; |
180
|
|
|
} |
181
|
|
|
// Clip the value if the 'clip' parameter is true. |
182
|
|
|
if (!isset($params['clip']) || true !== $params['clip']) { |
183
|
|
|
return $str; |
184
|
|
|
} |
185
|
|
|
$maxlen = isset($params['cliplen']) && \is_int($params['cliplen']) ? $params['cliplen'] : $this->conf['max_chars']; |
186
|
|
|
$ellipsis = $params['ellipsis'] ?? $this->lang['strellipsis']; |
187
|
|
|
|
188
|
|
|
if (\mb_strlen($str) > $maxlen) { |
189
|
|
|
$str = \mb_substr($str, 0, $maxlen - 1) . $ellipsis; |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
return $str; |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
public function printBoolean($type, &$str, $params) |
196
|
|
|
{ |
197
|
|
|
$lang = $this->lang; |
198
|
|
|
|
199
|
|
|
if ('yesno' === $type) { |
200
|
|
|
$this->coalesceArr($params, 'true', $lang['stryes']); |
201
|
|
|
$this->coalesceArr($params, 'false', $lang['strno']); |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
if (\is_bool($str)) { |
205
|
|
|
$str = $str ? 't' : 'f'; |
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
switch ($str) { |
209
|
|
|
case 't': |
210
|
|
|
$out = ($params['true'] ?? $lang['strtrue']); |
211
|
|
|
$align = 'center'; |
212
|
|
|
|
213
|
|
|
break; |
214
|
|
|
case 'f': |
215
|
|
|
$out = ($params['false'] ?? $lang['strfalse']); |
216
|
|
|
$align = 'center'; |
217
|
|
|
|
218
|
|
|
break; |
219
|
|
|
|
220
|
|
|
default: |
221
|
|
|
$align = null; |
222
|
|
|
$out = \htmlspecialchars($str); |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
return [$str, $align, $out]; |
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
/** |
229
|
|
|
* Render a value into HTML using formatting rules specified |
230
|
|
|
* by a type name and parameters. |
231
|
|
|
* |
232
|
|
|
* @param null|string $str The string to change |
233
|
|
|
* @param string $type Field type (optional), this may be an internal PostgreSQL type, or: |
234
|
|
|
* yesno - same as bool, but renders as 'Yes' or 'No'. |
235
|
|
|
* pre - render in a <pre> block. |
236
|
|
|
* nbsp - replace all spaces with 's |
237
|
|
|
* verbatim - render exactly as supplied, no escaping what-so-ever. |
238
|
|
|
* callback - render using a callback function supplied in the 'function' param. |
239
|
|
|
* @param array $params Type parameters (optional), known parameters: |
240
|
|
|
* null - string to display if $str is null, or set to TRUE to use a default 'NULL' string, |
241
|
|
|
* otherwise nothing is rendered. |
242
|
|
|
* clip - if true, clip the value to a fixed length, and append an ellipsis... |
243
|
|
|
* cliplen - the maximum length when clip is enabled (defaults to $conf['max_chars']) |
244
|
|
|
* ellipsis - the string to append to a clipped value (defaults to $lang['strellipsis']) |
245
|
|
|
* tag - an HTML element name to surround the value. |
246
|
|
|
* class - a class attribute to apply to any surrounding HTML element. |
247
|
|
|
* align - an align attribute ('left','right','center' etc.) |
248
|
|
|
* true - (type='bool') the representation of true. |
249
|
|
|
* false - (type='bool') the representation of false. |
250
|
|
|
* function - (type='callback') a function name, accepts args ($str, $params) and returns a rendering. |
251
|
|
|
* lineno - prefix each line with a line number. |
252
|
|
|
* map - an associative array. |
253
|
|
|
* |
254
|
|
|
* @return string The HTML rendered value |
255
|
|
|
*/ |
256
|
|
|
public function printVal($str, $type = null, $params = []) |
257
|
|
|
{ |
258
|
|
|
$lang = $this->lang; |
259
|
|
|
|
260
|
|
|
if (null === $this->_data) { |
261
|
|
|
$data = $this->getDatabaseAccessor(); |
262
|
|
|
} else { |
263
|
|
|
$data = $this->_data; |
264
|
|
|
} |
265
|
|
|
|
266
|
|
|
// Shortcircuit for a NULL value |
267
|
|
|
if (null === $str) { |
268
|
|
|
return isset($params['null']) |
269
|
|
|
? (true === $params['null'] ? '<i>NULL</i>' : $params['null']) |
270
|
|
|
: ''; |
271
|
|
|
} |
272
|
|
|
|
273
|
|
|
$str = $this->maybeClipStr($str, $params); |
274
|
|
|
|
275
|
|
|
$out = ''; |
276
|
|
|
$class = ''; |
277
|
|
|
|
278
|
|
|
switch ($type) { |
279
|
|
|
case 'int2': |
280
|
|
|
case 'int4': |
281
|
|
|
case 'int8': |
282
|
|
|
case 'float4': |
283
|
|
|
case 'float8': |
284
|
|
|
case 'money': |
285
|
|
|
case 'numeric': |
286
|
|
|
case 'oid': |
287
|
|
|
case 'xid': |
288
|
|
|
case 'cid': |
289
|
|
|
case 'tid': |
290
|
|
|
$align = 'right'; |
291
|
|
|
$out = \nl2br(\htmlspecialchars(ContainerUtils::br2ln($str))); |
292
|
|
|
|
293
|
|
|
break; |
294
|
|
|
case 'yesno': |
295
|
|
|
case 'bool': |
296
|
|
|
case 'boolean': |
297
|
|
|
[$str, $align, $out] = $this->printBoolean($type, $str, $params); |
298
|
|
|
|
299
|
|
|
break; |
300
|
|
|
case 'bytea': |
301
|
|
|
$tag = 'div'; |
302
|
|
|
$class = 'pre'; |
303
|
|
|
$out = $data->escapeBytea($str); |
304
|
|
|
|
305
|
|
|
break; |
306
|
|
|
case 'errormsg': |
307
|
|
|
$tag = 'pre'; |
308
|
|
|
$class = 'error'; |
309
|
|
|
$out = \htmlspecialchars($str); |
310
|
|
|
|
311
|
|
|
break; |
312
|
|
|
case 'pre': |
313
|
|
|
$tag = 'pre'; |
314
|
|
|
$out = \htmlspecialchars($str); |
315
|
|
|
|
316
|
|
|
break; |
317
|
|
|
case 'prenoescape': |
318
|
|
|
$tag = 'pre'; |
319
|
|
|
$out = $str; |
320
|
|
|
|
321
|
|
|
break; |
322
|
|
|
case 'nbsp': |
323
|
|
|
$out = \nl2br(\str_replace(' ', ' ', ContainerUtils::br2ln($str))); |
324
|
|
|
|
325
|
|
|
break; |
326
|
|
|
case 'verbatim': |
327
|
|
|
$out = $str; |
328
|
|
|
|
329
|
|
|
break; |
330
|
|
|
case 'callback': |
331
|
|
|
$out = $params['function']($str, $params); |
332
|
|
|
|
333
|
|
|
break; |
334
|
|
|
case 'prettysize': |
335
|
|
|
$out = self::formatSizeUnits($str, $lang); |
336
|
|
|
|
337
|
|
|
break; |
338
|
|
|
|
339
|
|
|
default: |
340
|
|
|
// If the string contains at least one instance of >1 space in a row, a tab |
341
|
|
|
// character, a space at the start of a line, or a space at the start of |
342
|
|
|
// the whole string then render within a pre-formatted element (<pre>). |
343
|
|
|
if (\preg_match('/(^ | |\t|\n )/m', $str)) { |
344
|
|
|
$tag = 'pre'; |
345
|
|
|
$class = 'data'; |
346
|
|
|
$out = \htmlspecialchars($str); |
347
|
|
|
} else { |
348
|
|
|
//$tag = 'span'; |
349
|
|
|
$out = \nl2br(\htmlspecialchars(ContainerUtils::br2ln($str))); |
350
|
|
|
} |
351
|
|
|
} |
352
|
|
|
|
353
|
|
|
$this->adjustClassAlignTag($class, $align, $tag, $out, $params); |
354
|
|
|
|
355
|
|
|
return $out; |
356
|
|
|
} |
357
|
|
|
|
358
|
|
|
public function adjustClassAlignTag(&$class, &$align, &$tag, &$out, $params): void |
359
|
|
|
{ |
360
|
|
|
if (isset($params['class'])) { |
361
|
|
|
$class = $params['class']; |
362
|
|
|
} |
363
|
|
|
|
364
|
|
|
if (isset($params['align'])) { |
365
|
|
|
$align = $params['align']; |
366
|
|
|
} |
367
|
|
|
|
368
|
|
|
if (!isset($tag) && (!empty($class) || isset($align))) { |
369
|
|
|
$tag = 'div'; |
370
|
|
|
} |
371
|
|
|
|
372
|
|
|
if (isset($tag)) { |
373
|
|
|
$alignattr = isset($align) ? " style=\"text-align: {$align}\"" : ''; |
374
|
|
|
$classattr = !empty($class) ? " class=\"{$class}\"" : ''; |
375
|
|
|
$out = "<{$tag}{$alignattr}{$classattr}>{$out}</{$tag}>"; |
376
|
|
|
} |
377
|
|
|
} |
378
|
|
|
|
379
|
|
|
/** |
380
|
|
|
* Gets the tabs for root view. |
381
|
|
|
* |
382
|
|
|
* @param \PHPPgAdmin\Database\ADOdbBase $data The database accesor instance |
383
|
|
|
* |
384
|
|
|
* @return array The tabs for root view |
385
|
|
|
*/ |
386
|
|
|
public function getTabsRoot($data) |
387
|
|
|
{ |
388
|
|
|
$lang = $this->lang; |
389
|
|
|
|
390
|
|
|
return [ |
391
|
|
|
'intro' => [ |
392
|
|
|
'title' => $lang['strintroduction'], |
393
|
|
|
'url' => 'intro', |
394
|
|
|
'icon' => 'Introduction', |
395
|
|
|
], |
396
|
|
|
'servers' => [ |
397
|
|
|
'title' => $lang['strservers'], |
398
|
|
|
'url' => 'servers', |
399
|
|
|
'icon' => 'Servers', |
400
|
|
|
], |
401
|
|
|
]; |
402
|
|
|
} |
403
|
|
|
|
404
|
|
|
/** |
405
|
|
|
* Gets the tabs for server view. |
406
|
|
|
* |
407
|
|
|
* @param \PHPPgAdmin\Database\ADOdbBase $data The database accesor instance |
408
|
|
|
* |
409
|
|
|
* @return array The tabs for server view |
410
|
|
|
*/ |
411
|
|
|
public function getTabsServer($data) |
412
|
|
|
{ |
413
|
|
|
$lang = $this->lang; |
414
|
|
|
$hide_users = true; |
415
|
|
|
$hide_roles = false; |
416
|
|
|
|
417
|
|
|
if ($data) { |
|
|
|
|
418
|
|
|
$hide_users = !$data->isSuperUser(); |
419
|
|
|
} |
420
|
|
|
|
421
|
|
|
$tabs = [ |
422
|
|
|
'databases' => [ |
423
|
|
|
'title' => $lang['strdatabases'], |
424
|
|
|
'url' => 'alldb', |
425
|
|
|
'urlvars' => ['subject' => 'server'], |
426
|
|
|
'help' => 'pg.database', |
427
|
|
|
'icon' => 'Databases', |
428
|
|
|
], |
429
|
|
|
'users' => [ |
430
|
|
|
'title' => $lang['strusers'], |
431
|
|
|
'url' => 'users', |
432
|
|
|
'urlvars' => ['subject' => 'server'], |
433
|
|
|
'hide' => $hide_roles, |
434
|
|
|
'help' => 'pg.user', |
435
|
|
|
'icon' => 'Users', |
436
|
|
|
], |
437
|
|
|
]; |
438
|
|
|
|
439
|
|
|
if ($data && $data->hasRoles()) { |
440
|
|
|
$tabs = \array_merge($tabs, [ |
441
|
|
|
'roles' => [ |
442
|
|
|
'title' => $lang['strroles'], |
443
|
|
|
'url' => 'roles', |
444
|
|
|
'urlvars' => ['subject' => 'server'], |
445
|
|
|
'hide' => $hide_roles, |
446
|
|
|
'help' => 'pg.role', |
447
|
|
|
'icon' => 'Roles', |
448
|
|
|
], |
449
|
|
|
]); |
450
|
|
|
} else { |
451
|
|
|
$tabs = \array_merge($tabs, [ |
452
|
|
|
'groups' => [ |
453
|
|
|
'title' => $lang['strgroups'], |
454
|
|
|
'url' => 'groups', |
455
|
|
|
'urlvars' => ['subject' => 'server'], |
456
|
|
|
'hide' => $hide_users, |
457
|
|
|
'help' => 'pg.group', |
458
|
|
|
'icon' => 'UserGroups', |
459
|
|
|
], |
460
|
|
|
]); |
461
|
|
|
} |
462
|
|
|
|
463
|
|
|
return \array_merge($tabs, [ |
464
|
|
|
'account' => [ |
465
|
|
|
'title' => $lang['straccount'], |
466
|
|
|
'url' => ($data && $data->hasRoles()) ? 'roles' : 'users', |
467
|
|
|
'urlvars' => ['subject' => 'server', 'action' => 'account'], |
468
|
|
|
'hide' => !$hide_users, |
469
|
|
|
'help' => 'pg.role', |
470
|
|
|
'icon' => 'User', |
471
|
|
|
], |
472
|
|
|
'tablespaces' => [ |
473
|
|
|
'title' => $lang['strtablespaces'], |
474
|
|
|
'url' => 'tablespaces', |
475
|
|
|
'urlvars' => ['subject' => 'server'], |
476
|
|
|
'hide' => !$data || !$data->hasTablespaces(), |
477
|
|
|
'help' => 'pg.tablespace', |
478
|
|
|
'icon' => 'Tablespaces', |
479
|
|
|
], |
480
|
|
|
'export' => [ |
481
|
|
|
'title' => $lang['strexport'], |
482
|
|
|
'url' => 'alldb', |
483
|
|
|
'urlvars' => ['subject' => 'server', 'action' => 'export'], |
484
|
|
|
'hide' => !$this->isDumpEnabled(), |
485
|
|
|
'icon' => 'Export', |
486
|
|
|
], |
487
|
|
|
]); |
488
|
|
|
} |
489
|
|
|
|
490
|
|
|
/** |
491
|
|
|
* Gets the tabs for database view. |
492
|
|
|
* |
493
|
|
|
* @param \PHPPgAdmin\Database\ADOdbBase $data The database accesor instance |
494
|
|
|
* |
495
|
|
|
* @return array The tabs for database view |
496
|
|
|
*/ |
497
|
|
|
public function getTabsDatabase($data) |
498
|
|
|
{ |
499
|
|
|
$lang = $this->lang; |
500
|
|
|
$hide_advanced = (false === $this->conf['show_advanced']); |
501
|
|
|
|
502
|
|
|
return [ |
503
|
|
|
'schemas' => [ |
504
|
|
|
'title' => $lang['strschemas'], |
505
|
|
|
'url' => 'schemas', |
506
|
|
|
'urlvars' => ['subject' => 'database'], |
507
|
|
|
'help' => 'pg.schema', |
508
|
|
|
'icon' => 'Schemas', |
509
|
|
|
], |
510
|
|
|
'sql' => [ |
511
|
|
|
'title' => $lang['strsql'], |
512
|
|
|
'url' => 'database', |
513
|
|
|
'urlvars' => ['subject' => 'database', 'action' => 'sql', 'new' => 1], |
514
|
|
|
'help' => 'pg.sql', |
515
|
|
|
'tree' => false, |
516
|
|
|
'icon' => 'SqlEditor', |
517
|
|
|
], |
518
|
|
|
'find' => [ |
519
|
|
|
'title' => $lang['strfind'], |
520
|
|
|
'url' => 'database', |
521
|
|
|
'urlvars' => ['subject' => 'database', 'action' => 'find'], |
522
|
|
|
'tree' => false, |
523
|
|
|
'icon' => 'Search', |
524
|
|
|
], |
525
|
|
|
'variables' => [ |
526
|
|
|
'title' => $lang['strvariables'], |
527
|
|
|
'url' => 'database', |
528
|
|
|
'urlvars' => ['subject' => 'database', 'action' => 'variables'], |
529
|
|
|
'help' => 'pg.variable', |
530
|
|
|
'tree' => false, |
531
|
|
|
'icon' => 'Variables', |
532
|
|
|
], |
533
|
|
|
'processes' => [ |
534
|
|
|
'title' => $lang['strprocesses'], |
535
|
|
|
'url' => 'database', |
536
|
|
|
'urlvars' => ['subject' => 'database', 'action' => 'processes'], |
537
|
|
|
'help' => 'pg.process', |
538
|
|
|
'tree' => false, |
539
|
|
|
'icon' => 'Processes', |
540
|
|
|
], |
541
|
|
|
'locks' => [ |
542
|
|
|
'title' => $lang['strlocks'], |
543
|
|
|
'url' => 'database', |
544
|
|
|
'urlvars' => ['subject' => 'database', 'action' => 'locks'], |
545
|
|
|
'help' => 'pg.locks', |
546
|
|
|
'tree' => false, |
547
|
|
|
'icon' => 'Key', |
548
|
|
|
], |
549
|
|
|
'admin' => [ |
550
|
|
|
'title' => $lang['stradmin'], |
551
|
|
|
'url' => 'database', |
552
|
|
|
'urlvars' => ['subject' => 'database', 'action' => 'admin'], |
553
|
|
|
'tree' => false, |
554
|
|
|
'icon' => 'Admin', |
555
|
|
|
], |
556
|
|
|
'privileges' => [ |
557
|
|
|
'title' => $lang['strprivileges'], |
558
|
|
|
'url' => 'privileges', |
559
|
|
|
'urlvars' => ['subject' => 'database'], |
560
|
|
|
'hide' => !isset($data->privlist['database']), |
561
|
|
|
'help' => 'pg.privilege', |
562
|
|
|
'tree' => false, |
563
|
|
|
'icon' => 'Privileges', |
564
|
|
|
], |
565
|
|
|
'languages' => [ |
566
|
|
|
'title' => $lang['strlanguages'], |
567
|
|
|
'url' => 'languages', |
568
|
|
|
'urlvars' => ['subject' => 'database'], |
569
|
|
|
'hide' => $hide_advanced, |
570
|
|
|
'help' => 'pg.language', |
571
|
|
|
'icon' => 'Languages', |
572
|
|
|
], |
573
|
|
|
'casts' => [ |
574
|
|
|
'title' => $lang['strcasts'], |
575
|
|
|
'url' => 'casts', |
576
|
|
|
'urlvars' => ['subject' => 'database'], |
577
|
|
|
'hide' => $hide_advanced, |
578
|
|
|
'help' => 'pg.cast', |
579
|
|
|
'icon' => 'Casts', |
580
|
|
|
], |
581
|
|
|
'export' => [ |
582
|
|
|
'title' => $lang['strexport'], |
583
|
|
|
'url' => 'database', |
584
|
|
|
'urlvars' => ['subject' => 'database', 'action' => 'export'], |
585
|
|
|
'hide' => !$this->isDumpEnabled(), |
586
|
|
|
'tree' => false, |
587
|
|
|
'icon' => 'Export', |
588
|
|
|
], |
589
|
|
|
]; |
590
|
|
|
} |
591
|
|
|
|
592
|
|
|
public function getTabsSchema($data) |
593
|
|
|
{ |
594
|
|
|
$lang = $this->lang; |
595
|
|
|
$hide_advanced = (false === $this->conf['show_advanced']); |
596
|
|
|
$tabs = [ |
597
|
|
|
'tables' => [ |
598
|
|
|
'title' => $lang['strtables'], |
599
|
|
|
'url' => 'tables', |
600
|
|
|
'urlvars' => ['subject' => 'schema'], |
601
|
|
|
'help' => 'pg.table', |
602
|
|
|
'icon' => 'Tables', |
603
|
|
|
], |
604
|
|
|
'views' => [ |
605
|
|
|
'title' => $lang['strviews'], |
606
|
|
|
'url' => 'views', |
607
|
|
|
'urlvars' => ['subject' => 'schema'], |
608
|
|
|
'help' => 'pg.view', |
609
|
|
|
'icon' => 'Views', |
610
|
|
|
], |
611
|
|
|
'matviews' => [ |
612
|
|
|
'title' => 'M ' . $lang['strviews'], |
613
|
|
|
'url' => 'materializedviews', |
614
|
|
|
'urlvars' => ['subject' => 'schema'], |
615
|
|
|
'help' => 'pg.matview', |
616
|
|
|
'icon' => 'MViews', |
617
|
|
|
], |
618
|
|
|
'sequences' => [ |
619
|
|
|
'title' => $lang['strsequences'], |
620
|
|
|
'url' => 'sequences', |
621
|
|
|
'urlvars' => ['subject' => 'schema'], |
622
|
|
|
'help' => 'pg.sequence', |
623
|
|
|
'icon' => 'Sequences', |
624
|
|
|
], |
625
|
|
|
'functions' => [ |
626
|
|
|
'title' => $lang['strfunctions'], |
627
|
|
|
'url' => 'functions', |
628
|
|
|
'urlvars' => ['subject' => 'schema'], |
629
|
|
|
'help' => 'pg.function', |
630
|
|
|
'icon' => 'Functions', |
631
|
|
|
], |
632
|
|
|
'fulltext' => [ |
633
|
|
|
'title' => $lang['strfulltext'], |
634
|
|
|
'url' => 'fulltext', |
635
|
|
|
'urlvars' => ['subject' => 'schema'], |
636
|
|
|
'help' => 'pg.fts', |
637
|
|
|
'tree' => true, |
638
|
|
|
'icon' => 'Fts', |
639
|
|
|
], |
640
|
|
|
'domains' => [ |
641
|
|
|
'title' => $lang['strdomains'], |
642
|
|
|
'url' => 'domains', |
643
|
|
|
'urlvars' => ['subject' => 'schema'], |
644
|
|
|
'help' => 'pg.domain', |
645
|
|
|
'icon' => 'Domains', |
646
|
|
|
], |
647
|
|
|
'aggregates' => [ |
648
|
|
|
'title' => $lang['straggregates'], |
649
|
|
|
'url' => 'aggregates', |
650
|
|
|
'urlvars' => ['subject' => 'schema'], |
651
|
|
|
'hide' => $hide_advanced, |
652
|
|
|
'help' => 'pg.aggregate', |
653
|
|
|
'icon' => 'Aggregates', |
654
|
|
|
], |
655
|
|
|
'types' => [ |
656
|
|
|
'title' => $lang['strtypes'], |
657
|
|
|
'url' => 'types', |
658
|
|
|
'urlvars' => ['subject' => 'schema'], |
659
|
|
|
'hide' => $hide_advanced, |
660
|
|
|
'help' => 'pg.type', |
661
|
|
|
'icon' => 'Types', |
662
|
|
|
], |
663
|
|
|
'operators' => [ |
664
|
|
|
'title' => $lang['stroperators'], |
665
|
|
|
'url' => 'operators', |
666
|
|
|
'urlvars' => ['subject' => 'schema'], |
667
|
|
|
'hide' => $hide_advanced, |
668
|
|
|
'help' => 'pg.operator', |
669
|
|
|
'icon' => 'Operators', |
670
|
|
|
], |
671
|
|
|
'opclasses' => [ |
672
|
|
|
'title' => $lang['stropclasses'], |
673
|
|
|
'url' => 'opclasses', |
674
|
|
|
'urlvars' => ['subject' => 'schema'], |
675
|
|
|
'hide' => $hide_advanced, |
676
|
|
|
'help' => 'pg.opclass', |
677
|
|
|
'icon' => 'OperatorClasses', |
678
|
|
|
], |
679
|
|
|
'conversions' => [ |
680
|
|
|
'title' => $lang['strconversions'], |
681
|
|
|
'url' => 'conversions', |
682
|
|
|
'urlvars' => ['subject' => 'schema'], |
683
|
|
|
'hide' => $hide_advanced, |
684
|
|
|
'help' => 'pg.conversion', |
685
|
|
|
'icon' => 'Conversions', |
686
|
|
|
], |
687
|
|
|
'privileges' => [ |
688
|
|
|
'title' => $lang['strprivileges'], |
689
|
|
|
'url' => 'privileges', |
690
|
|
|
'urlvars' => ['subject' => 'schema'], |
691
|
|
|
'help' => 'pg.privilege', |
692
|
|
|
'tree' => false, |
693
|
|
|
'icon' => 'Privileges', |
694
|
|
|
], |
695
|
|
|
'export' => [ |
696
|
|
|
'title' => $lang['strexport'], |
697
|
|
|
'url' => 'schemas', |
698
|
|
|
'urlvars' => ['subject' => 'schema', 'action' => 'export'], |
699
|
|
|
'hide' => !$this->isDumpEnabled(), |
700
|
|
|
'tree' => false, |
701
|
|
|
'icon' => 'Export', |
702
|
|
|
], |
703
|
|
|
]; |
704
|
|
|
|
705
|
|
|
if (!$data->hasFTS()) { |
706
|
|
|
unset($tabs['fulltext']); |
707
|
|
|
} |
708
|
|
|
|
709
|
|
|
return $tabs; |
710
|
|
|
} |
711
|
|
|
|
712
|
|
|
public function getTabsTable($data) |
713
|
|
|
{ |
714
|
|
|
$lang = $this->lang; |
715
|
|
|
|
716
|
|
|
return [ |
717
|
|
|
'columns' => [ |
718
|
|
|
'title' => $lang['strcolumns'], |
719
|
|
|
'url' => 'tblproperties', |
720
|
|
|
'urlvars' => ['subject' => 'table', 'table' => Decorator::field('table')], |
721
|
|
|
'icon' => 'Columns', |
722
|
|
|
'branch' => true, |
723
|
|
|
], |
724
|
|
|
'browse' => [ |
725
|
|
|
'title' => $lang['strbrowse'], |
726
|
|
|
'icon' => 'Columns', |
727
|
|
|
'url' => 'display', |
728
|
|
|
'urlvars' => ['subject' => 'table', 'table' => Decorator::field('table')], |
729
|
|
|
'return' => 'table', |
730
|
|
|
'branch' => true, |
731
|
|
|
], |
732
|
|
|
'select' => [ |
733
|
|
|
'title' => $lang['strselect'], |
734
|
|
|
'icon' => 'Search', |
735
|
|
|
'url' => 'tables', |
736
|
|
|
'urlvars' => ['subject' => 'table', 'table' => Decorator::field('table'), 'action' => 'confselectrows'], |
737
|
|
|
'help' => 'pg.sql.select', |
738
|
|
|
], |
739
|
|
|
'insert' => [ |
740
|
|
|
'title' => $lang['strinsert'], |
741
|
|
|
'url' => 'tables', |
742
|
|
|
'urlvars' => [ |
743
|
|
|
'action' => 'confinsertrow', |
744
|
|
|
'table' => Decorator::field('table'), |
745
|
|
|
], |
746
|
|
|
'help' => 'pg.sql.insert', |
747
|
|
|
'icon' => 'Operator', |
748
|
|
|
], |
749
|
|
|
'indexes' => [ |
750
|
|
|
'title' => $lang['strindexes'], |
751
|
|
|
'url' => 'indexes', |
752
|
|
|
'urlvars' => ['subject' => 'table', 'table' => Decorator::field('table')], |
753
|
|
|
'help' => 'pg.index', |
754
|
|
|
'icon' => 'Indexes', |
755
|
|
|
'branch' => true, |
756
|
|
|
], |
757
|
|
|
'constraints' => [ |
758
|
|
|
'title' => $lang['strconstraints'], |
759
|
|
|
'url' => 'constraints', |
760
|
|
|
'urlvars' => ['subject' => 'table', 'table' => Decorator::field('table')], |
761
|
|
|
'help' => 'pg.constraint', |
762
|
|
|
'icon' => 'Constraints', |
763
|
|
|
'branch' => true, |
764
|
|
|
], |
765
|
|
|
'triggers' => [ |
766
|
|
|
'title' => $lang['strtriggers'], |
767
|
|
|
'url' => 'triggers', |
768
|
|
|
'urlvars' => ['subject' => 'table', 'table' => Decorator::field('table')], |
769
|
|
|
'help' => 'pg.trigger', |
770
|
|
|
'icon' => 'Triggers', |
771
|
|
|
'branch' => true, |
772
|
|
|
], |
773
|
|
|
'rules' => [ |
774
|
|
|
'title' => $lang['strrules'], |
775
|
|
|
'url' => 'rules', |
776
|
|
|
'urlvars' => ['subject' => 'table', 'table' => Decorator::field('table')], |
777
|
|
|
'help' => 'pg.rule', |
778
|
|
|
'icon' => 'Rules', |
779
|
|
|
'branch' => true, |
780
|
|
|
], |
781
|
|
|
'admin' => [ |
782
|
|
|
'title' => $lang['stradmin'], |
783
|
|
|
'url' => 'tables', |
784
|
|
|
'urlvars' => ['subject' => 'table', 'table' => Decorator::field('table'), 'action' => 'admin'], |
785
|
|
|
'icon' => 'Admin', |
786
|
|
|
], |
787
|
|
|
'info' => [ |
788
|
|
|
'title' => $lang['strinfo'], |
789
|
|
|
'url' => 'info', |
790
|
|
|
'urlvars' => ['subject' => 'table', 'table' => Decorator::field('table')], |
791
|
|
|
'icon' => 'Statistics', |
792
|
|
|
], |
793
|
|
|
'privileges' => [ |
794
|
|
|
'title' => $lang['strprivileges'], |
795
|
|
|
'url' => 'privileges', |
796
|
|
|
'urlvars' => ['subject' => 'table', 'table' => Decorator::field('table')], |
797
|
|
|
'help' => 'pg.privilege', |
798
|
|
|
'icon' => 'Privileges', |
799
|
|
|
], |
800
|
|
|
'import' => [ |
801
|
|
|
'title' => $lang['strimport'], |
802
|
|
|
'url' => 'tblproperties', |
803
|
|
|
'urlvars' => ['subject' => 'table', 'table' => Decorator::field('table'), 'action' => 'import'], |
804
|
|
|
'icon' => 'Import', |
805
|
|
|
'hide' => false, |
806
|
|
|
], |
807
|
|
|
'export' => [ |
808
|
|
|
'title' => $lang['strexport'], |
809
|
|
|
'url' => 'tblproperties', |
810
|
|
|
'urlvars' => ['subject' => 'table', 'table' => Decorator::field('table'), 'action' => 'export'], |
811
|
|
|
'icon' => 'Export', |
812
|
|
|
'hide' => false, |
813
|
|
|
], |
814
|
|
|
]; |
815
|
|
|
} |
816
|
|
|
|
817
|
|
|
public function getTabsView($data) |
818
|
|
|
{ |
819
|
|
|
$lang = $this->lang; |
820
|
|
|
|
821
|
|
|
return [ |
822
|
|
|
'columns' => [ |
823
|
|
|
'title' => $lang['strcolumns'], |
824
|
|
|
'url' => 'viewproperties', |
825
|
|
|
'urlvars' => ['subject' => 'view', 'view' => Decorator::field('view')], |
826
|
|
|
'icon' => 'Columns', |
827
|
|
|
'branch' => true, |
828
|
|
|
], |
829
|
|
|
'browse' => [ |
830
|
|
|
'title' => $lang['strbrowse'], |
831
|
|
|
'icon' => 'Columns', |
832
|
|
|
'url' => 'display', |
833
|
|
|
'urlvars' => [ |
834
|
|
|
'action' => 'confselectrows', |
835
|
|
|
'return' => 'schema', |
836
|
|
|
'subject' => 'view', |
837
|
|
|
'view' => Decorator::field('view'), |
838
|
|
|
], |
839
|
|
|
'branch' => true, |
840
|
|
|
], |
841
|
|
|
'select' => [ |
842
|
|
|
'title' => $lang['strselect'], |
843
|
|
|
'icon' => 'Search', |
844
|
|
|
'url' => 'views', |
845
|
|
|
'urlvars' => ['action' => 'confselectrows', 'view' => Decorator::field('view')], |
846
|
|
|
'help' => 'pg.sql.select', |
847
|
|
|
], |
848
|
|
|
'definition' => [ |
849
|
|
|
'title' => $lang['strdefinition'], |
850
|
|
|
'url' => 'viewproperties', |
851
|
|
|
'urlvars' => ['subject' => 'view', 'view' => Decorator::field('view'), 'action' => 'definition'], |
852
|
|
|
'icon' => 'Definition', |
853
|
|
|
], |
854
|
|
|
'rules' => [ |
855
|
|
|
'title' => $lang['strrules'], |
856
|
|
|
'url' => 'rules', |
857
|
|
|
'urlvars' => ['subject' => 'view', 'view' => Decorator::field('view')], |
858
|
|
|
'help' => 'pg.rule', |
859
|
|
|
'icon' => 'Rules', |
860
|
|
|
'branch' => true, |
861
|
|
|
], |
862
|
|
|
'privileges' => [ |
863
|
|
|
'title' => $lang['strprivileges'], |
864
|
|
|
'url' => 'privileges', |
865
|
|
|
'urlvars' => ['subject' => 'view', 'view' => Decorator::field('view')], |
866
|
|
|
'help' => 'pg.privilege', |
867
|
|
|
'icon' => 'Privileges', |
868
|
|
|
], |
869
|
|
|
'export' => [ |
870
|
|
|
'title' => $lang['strexport'], |
871
|
|
|
'url' => 'viewproperties', |
872
|
|
|
'urlvars' => ['subject' => 'view', 'view' => Decorator::field('view'), 'action' => 'export'], |
873
|
|
|
'icon' => 'Export', |
874
|
|
|
'hide' => false, |
875
|
|
|
], |
876
|
|
|
]; |
877
|
|
|
} |
878
|
|
|
|
879
|
|
|
public function getTabsMatview($data) |
880
|
|
|
{ |
881
|
|
|
$lang = $this->lang; |
882
|
|
|
|
883
|
|
|
return [ |
884
|
|
|
'columns' => [ |
885
|
|
|
'title' => $lang['strcolumns'], |
886
|
|
|
'url' => 'materializedviewproperties', |
887
|
|
|
'urlvars' => ['subject' => 'matview', 'matview' => Decorator::field('matview')], |
888
|
|
|
'icon' => 'Columns', |
889
|
|
|
'branch' => true, |
890
|
|
|
], |
891
|
|
|
'browse' => [ |
892
|
|
|
'title' => $lang['strbrowse'], |
893
|
|
|
'icon' => 'Columns', |
894
|
|
|
'url' => 'display', |
895
|
|
|
'urlvars' => [ |
896
|
|
|
'action' => 'confselectrows', |
897
|
|
|
'return' => 'schema', |
898
|
|
|
'subject' => 'matview', |
899
|
|
|
'matview' => Decorator::field('matview'), |
900
|
|
|
], |
901
|
|
|
'branch' => true, |
902
|
|
|
], |
903
|
|
|
'select' => [ |
904
|
|
|
'title' => $lang['strselect'], |
905
|
|
|
'icon' => 'Search', |
906
|
|
|
'url' => 'materializedviews', |
907
|
|
|
'urlvars' => ['action' => 'confselectrows', 'matview' => Decorator::field('matview')], |
908
|
|
|
'help' => 'pg.sql.select', |
909
|
|
|
], |
910
|
|
|
'definition' => [ |
911
|
|
|
'title' => $lang['strdefinition'], |
912
|
|
|
'url' => 'materializedviewproperties', |
913
|
|
|
'urlvars' => ['subject' => 'matview', 'matview' => Decorator::field('matview'), 'action' => 'definition'], |
914
|
|
|
'icon' => 'Definition', |
915
|
|
|
], |
916
|
|
|
'indexes' => [ |
917
|
|
|
'title' => $lang['strindexes'], |
918
|
|
|
'url' => 'indexes', |
919
|
|
|
'urlvars' => ['subject' => 'matview', 'matview' => Decorator::field('matview')], |
920
|
|
|
'help' => 'pg.index', |
921
|
|
|
'icon' => 'Indexes', |
922
|
|
|
'branch' => true, |
923
|
|
|
], |
924
|
|
|
/*'constraints' => [ |
925
|
|
|
'title' => $lang['strconstraints'], |
926
|
|
|
'url' => 'constraints', |
927
|
|
|
'urlvars' => ['subject' => 'matview', 'matview' => Decorator::field('matview')], |
928
|
|
|
'help' => 'pg.constraint', |
929
|
|
|
'icon' => 'Constraints', |
930
|
|
|
'branch' => true, |
931
|
|
|
*/ |
932
|
|
|
|
933
|
|
|
'rules' => [ |
934
|
|
|
'title' => $lang['strrules'], |
935
|
|
|
'url' => 'rules', |
936
|
|
|
'urlvars' => ['subject' => 'matview', 'matview' => Decorator::field('matview')], |
937
|
|
|
'help' => 'pg.rule', |
938
|
|
|
'icon' => 'Rules', |
939
|
|
|
'branch' => true, |
940
|
|
|
], |
941
|
|
|
'privileges' => [ |
942
|
|
|
'title' => $lang['strprivileges'], |
943
|
|
|
'url' => 'privileges', |
944
|
|
|
'urlvars' => ['subject' => 'matview', 'matview' => Decorator::field('matview')], |
945
|
|
|
'help' => 'pg.privilege', |
946
|
|
|
'icon' => 'Privileges', |
947
|
|
|
], |
948
|
|
|
'export' => [ |
949
|
|
|
'title' => $lang['strexport'], |
950
|
|
|
'url' => 'materializedviewproperties', |
951
|
|
|
'urlvars' => ['subject' => 'matview', 'matview' => Decorator::field('matview'), 'action' => 'export'], |
952
|
|
|
'icon' => 'Export', |
953
|
|
|
'hide' => false, |
954
|
|
|
], |
955
|
|
|
]; |
956
|
|
|
} |
957
|
|
|
|
958
|
|
|
public function getTabsFunction($data) |
959
|
|
|
{ |
960
|
|
|
$lang = $this->lang; |
961
|
|
|
|
962
|
|
|
return [ |
963
|
|
|
'definition' => [ |
964
|
|
|
'title' => $lang['strdefinition'], |
965
|
|
|
'url' => 'functions', |
966
|
|
|
'urlvars' => [ |
967
|
|
|
'subject' => 'function', |
968
|
|
|
'function' => Decorator::field('function'), |
969
|
|
|
'function_oid' => Decorator::field('function_oid'), |
970
|
|
|
'action' => 'properties', |
971
|
|
|
], |
972
|
|
|
'icon' => 'Definition', |
973
|
|
|
], |
974
|
|
|
'privileges' => [ |
975
|
|
|
'title' => $lang['strprivileges'], |
976
|
|
|
'url' => 'privileges', |
977
|
|
|
'urlvars' => [ |
978
|
|
|
'subject' => 'function', |
979
|
|
|
'function' => Decorator::field('function'), |
980
|
|
|
'function_oid' => Decorator::field('function_oid'), |
981
|
|
|
], |
982
|
|
|
'icon' => 'Privileges', |
983
|
|
|
], |
984
|
|
|
'show' => [ |
985
|
|
|
'title' => $lang['strshow'] . ' ' . $lang['strdefinition'], |
986
|
|
|
'url' => 'functions', |
987
|
|
|
'urlvars' => [ |
988
|
|
|
'subject' => 'function', |
989
|
|
|
'function' => Decorator::field('function'), |
990
|
|
|
'function_oid' => Decorator::field('function_oid'), |
991
|
|
|
'action' => 'show', |
992
|
|
|
], |
993
|
|
|
'icon' => 'Search', |
994
|
|
|
], |
995
|
|
|
]; |
996
|
|
|
} |
997
|
|
|
|
998
|
|
|
public function getTabsAggregate($data) |
999
|
|
|
{ |
1000
|
|
|
$lang = $this->lang; |
1001
|
|
|
|
1002
|
|
|
return [ |
1003
|
|
|
'definition' => [ |
1004
|
|
|
'title' => $lang['strdefinition'], |
1005
|
|
|
'url' => 'aggregates', |
1006
|
|
|
'urlvars' => [ |
1007
|
|
|
'subject' => 'aggregate', |
1008
|
|
|
'aggrname' => Decorator::field('aggrname'), |
1009
|
|
|
'aggrtype' => Decorator::field('aggrtype'), |
1010
|
|
|
'action' => 'properties', |
1011
|
|
|
], |
1012
|
|
|
'icon' => 'Definition', |
1013
|
|
|
], |
1014
|
|
|
]; |
1015
|
|
|
} |
1016
|
|
|
|
1017
|
|
|
public function getTabsRole($data) |
1018
|
|
|
{ |
1019
|
|
|
$lang = $this->lang; |
1020
|
|
|
|
1021
|
|
|
return [ |
1022
|
|
|
'definition' => [ |
1023
|
|
|
'title' => $lang['strdefinition'], |
1024
|
|
|
'url' => 'roles', |
1025
|
|
|
'urlvars' => [ |
1026
|
|
|
'subject' => 'role', |
1027
|
|
|
'rolename' => Decorator::field('rolename'), |
1028
|
|
|
'action' => 'properties', |
1029
|
|
|
], |
1030
|
|
|
'icon' => 'Definition', |
1031
|
|
|
], |
1032
|
|
|
]; |
1033
|
|
|
} |
1034
|
|
|
|
1035
|
|
|
public function getTabsPopup($data) |
1036
|
|
|
{ |
1037
|
|
|
$lang = $this->lang; |
1038
|
|
|
|
1039
|
|
|
return [ |
1040
|
|
|
'sql' => [ |
1041
|
|
|
'title' => $lang['strsql'], |
1042
|
|
|
'url' => \containerInstance()->subFolder . '/src/views/sqledit', |
1043
|
|
|
'urlvars' => ['action' => 'sql', 'subject' => 'schema'], |
1044
|
|
|
'help' => 'pg.sql', |
1045
|
|
|
'icon' => 'SqlEditor', |
1046
|
|
|
], |
1047
|
|
|
'find' => [ |
1048
|
|
|
'title' => $lang['strfind'], |
1049
|
|
|
'url' => \containerInstance()->subFolder . '/src/views/sqledit', |
1050
|
|
|
'urlvars' => ['action' => 'find', 'subject' => 'schema'], |
1051
|
|
|
'icon' => 'Search', |
1052
|
|
|
], |
1053
|
|
|
]; |
1054
|
|
|
} |
1055
|
|
|
|
1056
|
|
|
public function getTabsColumn($data) |
1057
|
|
|
{ |
1058
|
|
|
$lang = $this->lang; |
1059
|
|
|
$tabs = [ |
1060
|
|
|
'properties' => [ |
1061
|
|
|
'title' => $lang['strcolprop'], |
1062
|
|
|
'url' => 'colproperties', |
1063
|
|
|
'urlvars' => [ |
1064
|
|
|
'subject' => 'column', |
1065
|
|
|
'table' => Decorator::field('table'), |
1066
|
|
|
'view' => Decorator::field('view'), |
1067
|
|
|
'column' => Decorator::field('column'), |
1068
|
|
|
], |
1069
|
|
|
'icon' => 'Column', |
1070
|
|
|
], |
1071
|
|
|
'privileges' => [ |
1072
|
|
|
'title' => $lang['strprivileges'], |
1073
|
|
|
'url' => 'privileges', |
1074
|
|
|
'urlvars' => [ |
1075
|
|
|
'subject' => 'column', |
1076
|
|
|
'table' => Decorator::field('table'), |
1077
|
|
|
'view' => Decorator::field('view'), |
1078
|
|
|
'column' => Decorator::field('column'), |
1079
|
|
|
], |
1080
|
|
|
'help' => 'pg.privilege', |
1081
|
|
|
'icon' => 'Privileges', |
1082
|
|
|
], |
1083
|
|
|
]; |
1084
|
|
|
|
1085
|
|
|
if (empty($tabs['properties']['urlvars']['table'])) { |
1086
|
|
|
unset($tabs['properties']['urlvars']['table']); |
1087
|
|
|
} |
1088
|
|
|
|
1089
|
|
|
if (empty($tabs['privileges']['urlvars']['table'])) { |
1090
|
|
|
unset($tabs['privileges']['urlvars']['table']); |
1091
|
|
|
} |
1092
|
|
|
|
1093
|
|
|
return $tabs; |
1094
|
|
|
} |
1095
|
|
|
|
1096
|
|
|
public function getTabsFulltext($data) |
1097
|
|
|
{ |
1098
|
|
|
$lang = $this->lang; |
1099
|
|
|
|
1100
|
|
|
return [ |
1101
|
|
|
'ftsconfigs' => [ |
1102
|
|
|
'title' => $lang['strftstabconfigs'], |
1103
|
|
|
'url' => 'fulltext', |
1104
|
|
|
'urlvars' => ['subject' => 'schema'], |
1105
|
|
|
'hide' => !$data->hasFTS(), |
1106
|
|
|
'help' => 'pg.ftscfg', |
1107
|
|
|
'tree' => true, |
1108
|
|
|
'icon' => 'FtsCfg', |
1109
|
|
|
], |
1110
|
|
|
'ftsdicts' => [ |
1111
|
|
|
'title' => $lang['strftstabdicts'], |
1112
|
|
|
'url' => 'fulltext', |
1113
|
|
|
'urlvars' => ['subject' => 'schema', 'action' => 'viewdicts'], |
1114
|
|
|
'hide' => !$data->hasFTS(), |
1115
|
|
|
'help' => 'pg.ftsdict', |
1116
|
|
|
'tree' => true, |
1117
|
|
|
'icon' => 'FtsDict', |
1118
|
|
|
], |
1119
|
|
|
'ftsparsers' => [ |
1120
|
|
|
'title' => $lang['strftstabparsers'], |
1121
|
|
|
'url' => 'fulltext', |
1122
|
|
|
'urlvars' => ['subject' => 'schema', 'action' => 'viewparsers'], |
1123
|
|
|
'hide' => !$data->hasFTS(), |
1124
|
|
|
'help' => 'pg.ftsparser', |
1125
|
|
|
'tree' => true, |
1126
|
|
|
'icon' => 'FtsParser', |
1127
|
|
|
], |
1128
|
|
|
]; |
1129
|
|
|
} |
1130
|
|
|
|
1131
|
|
|
/** |
1132
|
|
|
* Retrieve the tab info for a specific tab bar. |
1133
|
|
|
* |
1134
|
|
|
* @param string $section the name of the tab bar |
1135
|
|
|
* |
1136
|
|
|
* @return array array of tabs |
1137
|
|
|
*/ |
1138
|
|
|
public function getNavTabs($section) |
1139
|
|
|
{ |
1140
|
|
|
$data = $this->getDatabaseAccessor(); |
1141
|
|
|
$lang = $this->lang; |
|
|
|
|
1142
|
|
|
|
1143
|
|
|
$hide_advanced = (false === $this->conf['show_advanced']); |
|
|
|
|
1144
|
|
|
$tabs = []; |
1145
|
|
|
|
1146
|
|
|
switch ($section) { |
1147
|
|
|
case 'root': |
1148
|
|
|
$tabs = $this->getTabsRoot($data); |
1149
|
|
|
|
1150
|
|
|
break; |
1151
|
|
|
case 'server': |
1152
|
|
|
$tabs = $this->getTabsServer($data); |
1153
|
|
|
|
1154
|
|
|
break; |
1155
|
|
|
case 'database': |
1156
|
|
|
$tabs = $this->getTabsDatabase($data); |
1157
|
|
|
|
1158
|
|
|
break; |
1159
|
|
|
case 'schema': |
1160
|
|
|
$tabs = $this->getTabsSchema($data); |
1161
|
|
|
|
1162
|
|
|
break; |
1163
|
|
|
case 'table': |
1164
|
|
|
$tabs = $this->getTabsTable($data); |
1165
|
|
|
|
1166
|
|
|
break; |
1167
|
|
|
case 'view': |
1168
|
|
|
$tabs = $this->getTabsView($data); |
1169
|
|
|
|
1170
|
|
|
break; |
1171
|
|
|
case 'matview': |
1172
|
|
|
$tabs = $this->getTabsMatview($data); |
1173
|
|
|
|
1174
|
|
|
break; |
1175
|
|
|
case 'function': |
1176
|
|
|
$tabs = $this->getTabsFunction($data); |
1177
|
|
|
|
1178
|
|
|
break; |
1179
|
|
|
case 'aggregate': |
1180
|
|
|
$tabs = $this->getTabsAggregate($data); |
1181
|
|
|
|
1182
|
|
|
break; |
1183
|
|
|
case 'role': |
1184
|
|
|
$tabs = $this->getTabsRole($data); |
1185
|
|
|
|
1186
|
|
|
break; |
1187
|
|
|
case 'popup': |
1188
|
|
|
$tabs = $this->getTabsPopup($data); |
1189
|
|
|
|
1190
|
|
|
break; |
1191
|
|
|
case 'column': |
1192
|
|
|
$tabs = $this->getTabsColumn($data); |
1193
|
|
|
|
1194
|
|
|
break; |
1195
|
|
|
case 'fulltext': |
1196
|
|
|
$tabs = $this->getTabsFulltext($data); |
1197
|
|
|
|
1198
|
|
|
break; |
1199
|
|
|
} |
1200
|
|
|
|
1201
|
|
|
// Tabs hook's place |
1202
|
|
|
$plugin_functions_parameters = [ |
|
|
|
|
1203
|
|
|
'tabs' => &$tabs, |
1204
|
|
|
'section' => $section, |
1205
|
|
|
]; |
1206
|
|
|
|
1207
|
|
|
return $tabs; |
1208
|
|
|
} |
1209
|
|
|
|
1210
|
|
|
/** |
1211
|
|
|
* Get the URL for the last active tab of a particular tab bar. |
1212
|
|
|
* |
1213
|
|
|
* @param string $section |
1214
|
|
|
* |
1215
|
|
|
* @return null|mixed |
1216
|
|
|
*/ |
1217
|
|
|
public function getLastTabURL($section) |
1218
|
|
|
{ |
1219
|
|
|
//$data = $this->getDatabaseAccessor(); |
1220
|
|
|
|
1221
|
|
|
$tabs = $this->getNavTabs($section); |
1222
|
|
|
|
1223
|
|
|
if (isset($_SESSION['webdbLastTab'][$section], $tabs[$_SESSION['webdbLastTab'][$section]])) { |
1224
|
|
|
$tab = $tabs[$_SESSION['webdbLastTab'][$section]]; |
1225
|
|
|
} else { |
1226
|
|
|
$tab = \reset($tabs); |
1227
|
|
|
} |
1228
|
|
|
// $this->prtrace(['section' => $section, 'tabs' => $tabs, 'tab' => $tab]); |
1229
|
|
|
|
1230
|
|
|
return isset($tab['url']) ? $tab : null; |
1231
|
|
|
} |
1232
|
|
|
|
1233
|
|
|
abstract public function getDatabaseAccessor($database = '', $server_id = null); |
1234
|
|
|
|
1235
|
|
|
abstract public function isDumpEnabled($all = false); |
1236
|
|
|
|
1237
|
|
|
abstract public function prtrace(); |
1238
|
|
|
} |
1239
|
|
|
|