|
1
|
|
|
<?php |
|
2
|
|
|
|
|
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* PHPPgAdmin v6.0.0-beta.30 |
|
5
|
|
|
*/ |
|
6
|
|
|
|
|
7
|
|
|
namespace PHPPgAdmin\XHtml; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Class to render tables. Formerly part of Misc.php. |
|
11
|
|
|
*/ |
|
|
|
|
|
|
12
|
|
|
class HTMLNavbarController extends HTMLController |
|
13
|
|
|
{ |
|
14
|
|
|
public $controller_name = 'HTMLNavbarController'; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Display a bread crumb trail. |
|
18
|
|
|
* |
|
19
|
|
|
* @param $do_print true to echo, false to return html |
|
20
|
|
|
* @param mixed $trail |
|
|
|
|
|
|
21
|
|
|
* @param null|mixed $from |
|
|
|
|
|
|
22
|
|
|
*/ |
|
23
|
|
|
public function printTrail($trail = [], $do_print = true, $from = null) |
|
24
|
|
|
{ |
|
25
|
|
|
if (null === $from) { |
|
26
|
|
|
$from = __METHOD__; |
|
27
|
|
|
} |
|
28
|
|
|
$lang = $this->lang; |
|
29
|
|
|
$this->misc = $this->misc; |
|
30
|
|
|
|
|
31
|
|
|
$trail_html = $this->printTopbar(false, $from); |
|
32
|
|
|
|
|
33
|
|
|
if (is_string($trail)) { |
|
34
|
|
|
$trail = $this->getTrail($trail); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
//$this->prtrace($trail); |
|
38
|
|
|
|
|
39
|
|
|
$trail_html .= '<div class="trail" data-controller="'.$this->controller_name.'"><table><tr>'; |
|
40
|
|
|
|
|
41
|
|
|
foreach ($trail as $crumb) { |
|
42
|
|
|
$trail_html .= '<td class="crumb">'; |
|
43
|
|
|
$crumblink = '<a'; |
|
44
|
|
|
|
|
45
|
|
|
if (isset($crumb['url'])) { |
|
46
|
|
|
$crumblink .= " href=\"{$crumb['url']}\""; |
|
47
|
|
|
//$this->prtrace('crumb_url', $crumb['url']); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
if (isset($crumb['title'])) { |
|
51
|
|
|
$crumblink .= " title=\"{$crumb['title']}\""; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
$crumblink .= '>'; |
|
55
|
|
|
|
|
56
|
|
|
if (isset($crumb['title'])) { |
|
57
|
|
|
$iconalt = $crumb['title']; |
|
58
|
|
|
} else { |
|
59
|
|
|
$iconalt = 'Database Root'; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
if (isset($crumb['icon']) && $icon = $this->misc->icon($crumb['icon'])) { |
|
63
|
|
|
$crumblink .= "<span class=\"icon\"><img src=\"{$icon}\" alt=\"{$iconalt}\" /></span>"; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
$crumblink .= '<span class="label">'.htmlspecialchars($crumb['text']).'</span></a>'; |
|
67
|
|
|
|
|
68
|
|
|
if (isset($crumb['help'])) { |
|
69
|
|
|
$trail_html .= $this->misc->printHelp($crumblink, $crumb['help'], false); |
|
70
|
|
|
} else { |
|
71
|
|
|
$trail_html .= $crumblink; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
$trail_html .= "{$lang['strseparator']}"; |
|
75
|
|
|
$trail_html .= '</td>'; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
$trail_html .= "</tr></table></div>\n"; |
|
79
|
|
|
if ($do_print) { |
|
80
|
|
|
echo $trail_html; |
|
81
|
|
|
} else { |
|
82
|
|
|
return $trail_html; |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* Display the navlinks. |
|
88
|
|
|
* |
|
89
|
|
|
* @param $navlinks - An array with the the attributes and values that will be shown. See printLinksList for array format. |
|
90
|
|
|
* @param $place - Place where the $navlinks are displayed. Like 'display-browse', where 'display' is the file (display.php) |
|
|
|
|
|
|
91
|
|
|
* @param $env - Associative array of defined variables in the scope of the caller. |
|
92
|
|
|
* Allows to give some environnement details to plugins. |
|
93
|
|
|
* and 'browse' is the place inside that code (doBrowse). |
|
94
|
|
|
* @param bool $do_print if true, print html, if false, return html |
|
95
|
|
|
* @param mixed $from |
|
|
|
|
|
|
96
|
|
|
*/ |
|
|
|
|
|
|
97
|
|
|
public function printNavLinks($navlinks, $place, $env, $do_print, $from) |
|
98
|
|
|
{ |
|
99
|
|
|
if (null === $from || false === $from) { |
|
100
|
|
|
$from = __METHOD__; |
|
101
|
|
|
} |
|
102
|
|
|
//$this->prtrace($navlinks); |
|
103
|
|
|
$plugin_manager = $this->plugin_manager; |
|
104
|
|
|
|
|
105
|
|
|
// Navlinks hook's place |
|
106
|
|
|
$plugin_functions_parameters = [ |
|
107
|
|
|
'navlinks' => &$navlinks, |
|
108
|
|
|
'place' => $place, |
|
109
|
|
|
'env' => $env, |
|
110
|
|
|
]; |
|
111
|
|
|
$plugin_manager->do_hook('navlinks', $plugin_functions_parameters); |
|
112
|
|
|
|
|
113
|
|
|
if (count($navlinks) > 0) { |
|
114
|
|
|
if ($do_print) { |
|
115
|
|
|
$this->printLinksList($navlinks, 'navlink', true, $from); |
|
116
|
|
|
} else { |
|
117
|
|
|
return $this->printLinksList($navlinks, 'navlink', false, $from); |
|
118
|
|
|
} |
|
119
|
|
|
} |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* Display navigation tabs. |
|
124
|
|
|
* |
|
125
|
|
|
* @param $tabs The name of current section (Ex: intro, server, ...), or an array with tabs (Ex: sqledit.php doFind function) |
|
|
|
|
|
|
126
|
|
|
* @param $activetab the name of the tab to be highlighted |
|
|
|
|
|
|
127
|
|
|
* @param $print if false, return html |
|
|
|
|
|
|
128
|
|
|
* @param mixed $alltabs |
|
|
|
|
|
|
129
|
|
|
* @param mixed $do_print |
|
|
|
|
|
|
130
|
|
|
* @param null|mixed $from |
|
|
|
|
|
|
131
|
|
|
*/ |
|
132
|
|
|
public function printTabs($alltabs, $activetab, $do_print = true, $from = null) |
|
133
|
|
|
{ |
|
134
|
|
|
if (null === $from || false === $from) { |
|
135
|
|
|
$from = __METHOD__; |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
$lang = $this->lang; |
|
|
|
|
|
|
139
|
|
|
$this->misc = $this->misc; |
|
140
|
|
|
$data = $this->misc->getDatabaseAccessor(); |
|
|
|
|
|
|
141
|
|
|
|
|
142
|
|
|
if (is_string($alltabs)) { |
|
143
|
|
|
$_SESSION['webdbLastTab'][$alltabs] = $activetab; |
|
144
|
|
|
$alltabs = $this->misc->getNavTabs($alltabs); |
|
145
|
|
|
} |
|
146
|
|
|
//$this->prtrace($tabs); |
|
147
|
|
|
$tabs_html = ''; |
|
148
|
|
|
|
|
149
|
|
|
//Getting only visible tabs |
|
150
|
|
|
$tabs = []; |
|
151
|
|
|
if (count($alltabs) > 0) { |
|
152
|
|
|
foreach ($alltabs as $tab_id => $tab) { |
|
153
|
|
|
if (!isset($tab['hide']) || true !== $tab['hide']) { |
|
154
|
|
|
$tabs[$tab_id] = $tab; |
|
155
|
|
|
$tabs[$tab_id]['active'] = $active = ($tab_id == $activetab) ? ' active' : ''; |
|
|
|
|
|
|
156
|
|
|
$tabs[$tab_id]['tablink'] = str_replace(['&', '.php'], ['&', ''], htmlentities($this->getActionUrl($tab, $_REQUEST, $from))); |
|
157
|
|
|
if (isset($tab['icon']) && $icon = $this->misc->icon($tab['icon'])) { |
|
158
|
|
|
$tabs[$tab_id]['iconurl'] = $icon; |
|
159
|
|
|
} |
|
160
|
|
|
if (isset($tab['help'])) { |
|
161
|
|
|
$tabs[$tab_id]['helpurl'] = str_replace('&', '&', $this->misc->getHelpLink($tab['help'])); |
|
162
|
|
|
} |
|
163
|
|
|
} |
|
164
|
|
|
} |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
//$this->prtrace($tabs); |
|
168
|
|
|
|
|
169
|
|
|
if (count($tabs) > 0) { |
|
170
|
|
|
$width = (int) (100 / count($tabs)).'%'; |
|
171
|
|
|
|
|
172
|
|
|
$viewVars = [ |
|
173
|
|
|
'width' => $width, |
|
174
|
|
|
'tabs' => $tabs, |
|
175
|
|
|
'controller_name' => $this->controller_name, |
|
176
|
|
|
]; |
|
177
|
|
|
|
|
178
|
|
|
$tabs_html = $this->getContainer()->view->fetch('components/tabs.twig', $viewVars); |
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
|
|
if ($do_print) { |
|
182
|
|
|
echo $tabs_html; |
|
183
|
|
|
} else { |
|
184
|
|
|
return $tabs_html; |
|
185
|
|
|
} |
|
186
|
|
|
} |
|
187
|
|
|
|
|
188
|
|
|
/** |
|
189
|
|
|
* Get the URL for the last active tab of a particular tab bar. |
|
190
|
|
|
* |
|
191
|
|
|
* @param mixed $section |
|
|
|
|
|
|
192
|
|
|
*/ |
|
193
|
|
|
public function getLastTabURL($section) |
|
194
|
|
|
{ |
|
195
|
|
|
$lang = $this->lang; |
|
|
|
|
|
|
196
|
|
|
$this->misc = $this->misc; |
|
197
|
|
|
|
|
198
|
|
|
$tabs = $this->misc->getNavTabs($section); |
|
199
|
|
|
|
|
200
|
|
|
if (isset($_SESSION['webdbLastTab'][$section], $tabs[$_SESSION['webdbLastTab'][$section]])) { |
|
201
|
|
|
$tab = $tabs[$_SESSION['webdbLastTab'][$section]]; |
|
202
|
|
|
} else { |
|
203
|
|
|
$tab = reset($tabs); |
|
204
|
|
|
} |
|
205
|
|
|
$this->prtrace(['section' => $section, 'tabs' => $tabs, 'tab' => $tab], 'getLastTabURL'); |
|
206
|
|
|
|
|
207
|
|
|
return isset($tab['url']) ? $tab : null; |
|
208
|
|
|
} |
|
209
|
|
|
|
|
210
|
|
|
/** |
|
211
|
|
|
* [printTopbar description]. |
|
212
|
|
|
* |
|
213
|
|
|
* @param bool $do_print true to print, false to return html |
|
214
|
|
|
* @param null|mixed $from |
|
|
|
|
|
|
215
|
|
|
* |
|
216
|
|
|
* @return string |
|
217
|
|
|
*/ |
|
218
|
|
|
private function printTopbar($do_print = true, $from = null) |
|
|
|
|
|
|
219
|
|
|
{ |
|
220
|
|
|
if (null === $from || false === $from) { |
|
221
|
|
|
$from = __METHOD__; |
|
222
|
|
|
} |
|
223
|
|
|
|
|
224
|
|
|
$lang = $this->lang; |
|
225
|
|
|
$plugin_manager = $this->plugin_manager; |
|
226
|
|
|
$this->misc = $this->misc; |
|
227
|
|
|
$appName = $this->misc->appName; |
|
228
|
|
|
$appVersion = $this->misc->appVersion; |
|
229
|
|
|
$appLangFiles = $this->misc->appLangFiles; |
|
|
|
|
|
|
230
|
|
|
|
|
231
|
|
|
$server_info = $this->misc->getServerInfo(); |
|
232
|
|
|
$server_id = $this->misc->getServerId(); |
|
233
|
|
|
$reqvars = $this->misc->getRequestVars('table'); |
|
234
|
|
|
|
|
235
|
|
|
$topbar_html = '<div class="topbar" data-controller="'.$this->controller_name.'"><table style="width: 100%"><tr><td>'; |
|
236
|
|
|
|
|
237
|
|
|
if ($server_info && isset($server_info['platform'], $server_info['username'])) { |
|
238
|
|
|
// top left informations when connected |
|
239
|
|
|
$topbar_html .= sprintf( |
|
240
|
|
|
$lang['strtopbar'], |
|
241
|
|
|
'<span class="platform">'.htmlspecialchars($server_info['platform']).'</span>', |
|
242
|
|
|
'<span class="host">'.htmlspecialchars((empty($server_info['host'])) ? 'localhost' : $server_info['host']).'</span>', |
|
243
|
|
|
'<span class="port">'.htmlspecialchars($server_info['port']).'</span>', |
|
244
|
|
|
'<span class="username">'.htmlspecialchars($server_info['username']).'</span>' |
|
245
|
|
|
); |
|
246
|
|
|
|
|
247
|
|
|
$topbar_html .= '</td>'; |
|
248
|
|
|
|
|
249
|
|
|
// top right informations when connected |
|
250
|
|
|
|
|
251
|
|
|
$toplinks = [ |
|
252
|
|
|
'sql' => [ |
|
253
|
|
|
'attr' => [ |
|
254
|
|
|
'href' => [ |
|
255
|
|
|
'url' => SUBFOLDER.'/src/views/sqledit', |
|
256
|
|
|
'urlvars' => array_merge($reqvars, [ |
|
|
|
|
|
|
257
|
|
|
'action' => 'sql', |
|
258
|
|
|
]), |
|
|
|
|
|
|
259
|
|
|
], |
|
260
|
|
|
'target' => 'sqledit', |
|
261
|
|
|
'id' => 'toplink_sql', |
|
262
|
|
|
], |
|
263
|
|
|
'content' => $lang['strsql'], |
|
264
|
|
|
], |
|
265
|
|
|
'history' => [ |
|
266
|
|
|
'attr' => [ |
|
267
|
|
|
'href' => [ |
|
268
|
|
|
'url' => SUBFOLDER.'/src/views/history', |
|
269
|
|
|
'urlvars' => array_merge($reqvars, [ |
|
|
|
|
|
|
270
|
|
|
'action' => 'pophistory', |
|
271
|
|
|
]), |
|
|
|
|
|
|
272
|
|
|
], |
|
273
|
|
|
'id' => 'toplink_history', |
|
274
|
|
|
], |
|
275
|
|
|
'content' => $lang['strhistory'], |
|
276
|
|
|
], |
|
277
|
|
|
'find' => [ |
|
278
|
|
|
'attr' => [ |
|
279
|
|
|
'href' => [ |
|
280
|
|
|
'url' => SUBFOLDER.'/src/views/sqledit', |
|
281
|
|
|
'urlvars' => array_merge($reqvars, [ |
|
|
|
|
|
|
282
|
|
|
'action' => 'find', |
|
283
|
|
|
]), |
|
|
|
|
|
|
284
|
|
|
], |
|
285
|
|
|
'target' => 'sqledit', |
|
286
|
|
|
'id' => 'toplink_find', |
|
287
|
|
|
], |
|
288
|
|
|
'content' => $lang['strfind'], |
|
289
|
|
|
], |
|
290
|
|
|
'logout' => [ |
|
291
|
|
|
'attr' => [ |
|
292
|
|
|
'href' => [ |
|
293
|
|
|
'url' => SUBFOLDER.'/src/views/servers', |
|
294
|
|
|
'urlvars' => [ |
|
295
|
|
|
'action' => 'logout', |
|
296
|
|
|
'logoutServer' => "{$server_info['host']}:{$server_info['port']}:{$server_info['sslmode']}", |
|
297
|
|
|
], |
|
298
|
|
|
], |
|
299
|
|
|
'id' => 'toplink_logout', |
|
300
|
|
|
], |
|
301
|
|
|
'content' => $lang['strlogout'], |
|
302
|
|
|
], |
|
303
|
|
|
]; |
|
304
|
|
|
|
|
305
|
|
|
// Toplink hook's place |
|
306
|
|
|
$plugin_functions_parameters = [ |
|
307
|
|
|
'toplinks' => &$toplinks, |
|
308
|
|
|
]; |
|
309
|
|
|
|
|
310
|
|
|
$plugin_manager->do_hook('toplinks', $plugin_functions_parameters); |
|
311
|
|
|
|
|
312
|
|
|
$topbar_html .= '<td style="text-align: right">'; |
|
313
|
|
|
|
|
314
|
|
|
$topbar_html .= $this->printLinksList($toplinks, 'toplink', [], false, $from); |
|
|
|
|
|
|
315
|
|
|
|
|
316
|
|
|
$topbar_html .= '</td>'; |
|
317
|
|
|
|
|
318
|
|
|
$sql_window_id = htmlentities('sqledit:'.$server_id); |
|
319
|
|
|
$history_window_id = htmlentities('history:'.$server_id); |
|
320
|
|
|
|
|
321
|
|
|
$topbar_html .= "<script type=\"text/javascript\"> |
|
322
|
|
|
$('#toplink_sql').click(function() { |
|
323
|
|
|
window.open($(this).attr('href'),'{$sql_window_id}','toolbar=no,width=750,height=520,resizable=yes,scrollbars=yes').focus(); |
|
324
|
|
|
return false; |
|
325
|
|
|
}); |
|
326
|
|
|
|
|
327
|
|
|
$('#toplink_history').click(function() { |
|
328
|
|
|
window.open($(this).attr('href'),'{$history_window_id}','toolbar=no,width=700,height=500,resizable=yes,scrollbars=yes').focus(); |
|
329
|
|
|
return false; |
|
330
|
|
|
}); |
|
331
|
|
|
|
|
332
|
|
|
$('#toplink_find').click(function() { |
|
333
|
|
|
window.open($(this).attr('href'),'{$sql_window_id}','toolbar=no,width=750,height=520,resizable=yes,scrollbars=yes').focus(); |
|
334
|
|
|
return false; |
|
335
|
|
|
}); |
|
336
|
|
|
"; |
|
337
|
|
|
|
|
338
|
|
|
if (isset($_SESSION['sharedUsername'])) { |
|
339
|
|
|
$topbar_html .= sprintf(" |
|
|
|
|
|
|
340
|
|
|
$('#toplink_logout').click(function() { |
|
341
|
|
|
return confirm('%s'); |
|
342
|
|
|
});", str_replace("'", "\\'", $lang['strconfdropcred'])); |
|
|
|
|
|
|
343
|
|
|
} |
|
344
|
|
|
|
|
345
|
|
|
$topbar_html .= ' |
|
346
|
|
|
</script>'; |
|
347
|
|
|
} else { |
|
348
|
|
|
$topbar_html .= "<span class=\"appname\">{$appName}</span> <span class=\"version\">{$appVersion}</span>"; |
|
349
|
|
|
} |
|
350
|
|
|
/* |
|
351
|
|
|
echo "<td style=\"text-align: right; width: 1%\">"; |
|
352
|
|
|
|
|
353
|
|
|
echo "<form method=\"get\"><select name=\"language\" onchange=\"this.form.submit()\">\n"; |
|
354
|
|
|
$language = isset($_SESSION['webdbLanguage']) ? $_SESSION['webdbLanguage'] : 'english'; |
|
355
|
|
|
foreach ($appLangFiles as $k => $v) { |
|
356
|
|
|
echo "<option value=\"{$k}\"", |
|
357
|
|
|
($k == $language) ? ' selected="selected"' : '', |
|
358
|
|
|
">{$v}</option>\n"; |
|
359
|
|
|
} |
|
360
|
|
|
echo "</select>\n"; |
|
361
|
|
|
echo "<noscript><input type=\"submit\" value=\"Set Language\"></noscript>\n"; |
|
362
|
|
|
foreach ($_GET as $key => $val) { |
|
363
|
|
|
if ($key == 'language') continue; |
|
364
|
|
|
echo "<input type=\"hidden\" name=\"$key\" value=\"", htmlspecialchars($val), "\" />\n"; |
|
365
|
|
|
} |
|
366
|
|
|
echo "</form>\n"; |
|
367
|
|
|
|
|
368
|
|
|
echo "</td>"; |
|
369
|
|
|
*/ |
|
370
|
|
|
$topbar_html .= "</tr></table></div>\n"; |
|
371
|
|
|
|
|
372
|
|
|
if ($do_print) { |
|
373
|
|
|
echo $topbar_html; |
|
374
|
|
|
} else { |
|
375
|
|
|
return $topbar_html; |
|
376
|
|
|
} |
|
377
|
|
|
} |
|
378
|
|
|
|
|
379
|
|
|
private function getHREFSubject($subject) |
|
|
|
|
|
|
380
|
|
|
{ |
|
381
|
|
|
$vars = $this->misc->getSubjectParams($subject); |
|
382
|
|
|
ksort($vars['params']); |
|
383
|
|
|
|
|
384
|
|
|
return "{$vars['url']}?".http_build_query($vars['params'], '', '&'); |
|
385
|
|
|
} |
|
386
|
|
|
|
|
387
|
|
|
/** |
|
388
|
|
|
* Create a bread crumb trail of the object hierarchy. |
|
389
|
|
|
* |
|
390
|
|
|
* @param $object the type of object at the end of the trail |
|
391
|
|
|
* @param null|mixed $subject |
|
|
|
|
|
|
392
|
|
|
*/ |
|
393
|
|
|
private function getTrail($subject = null) |
|
|
|
|
|
|
394
|
|
|
{ |
|
395
|
|
|
$lang = $this->lang; |
|
396
|
|
|
$plugin_manager = $this->plugin_manager; |
|
397
|
|
|
$this->misc = $this->misc; |
|
398
|
|
|
$appName = $this->misc->appName; |
|
399
|
|
|
|
|
400
|
|
|
$data = $this->misc->getDatabaseAccessor(); |
|
|
|
|
|
|
401
|
|
|
|
|
402
|
|
|
$trail = []; |
|
403
|
|
|
$vars = ''; |
|
|
|
|
|
|
404
|
|
|
$done = false; |
|
405
|
|
|
|
|
406
|
|
|
$trail['root'] = [ |
|
407
|
|
|
'text' => $appName, |
|
408
|
|
|
'url' => SUBFOLDER.'/src/views/servers', |
|
409
|
|
|
'icon' => 'Introduction', |
|
410
|
|
|
]; |
|
411
|
|
|
|
|
412
|
|
|
if ('root' == $subject) { |
|
413
|
|
|
$done = true; |
|
414
|
|
|
} |
|
415
|
|
|
|
|
416
|
|
|
if (!$done) { |
|
417
|
|
|
$server_info = $this->misc->getServerInfo(); |
|
418
|
|
|
$trail['server'] = [ |
|
419
|
|
|
'title' => $lang['strserver'], |
|
420
|
|
|
'text' => $server_info['desc'], |
|
421
|
|
|
'url' => $this->getHREFSubject('server'), |
|
422
|
|
|
'help' => 'pg.server', |
|
423
|
|
|
'icon' => 'Server', |
|
424
|
|
|
]; |
|
425
|
|
|
} |
|
426
|
|
|
if ('server' == $subject) { |
|
427
|
|
|
$done = true; |
|
428
|
|
|
} |
|
429
|
|
|
|
|
430
|
|
|
if (isset($_REQUEST['database']) && !$done) { |
|
431
|
|
|
$trail['database'] = [ |
|
432
|
|
|
'title' => $lang['strdatabase'], |
|
433
|
|
|
'text' => $_REQUEST['database'], |
|
434
|
|
|
'url' => $this->getHREFSubject('database'), |
|
435
|
|
|
'help' => 'pg.database', |
|
436
|
|
|
'icon' => 'Database', |
|
437
|
|
|
]; |
|
438
|
|
|
} elseif (isset($_REQUEST['rolename']) && !$done) { |
|
439
|
|
|
$trail['role'] = [ |
|
440
|
|
|
'title' => $lang['strrole'], |
|
441
|
|
|
'text' => $_REQUEST['rolename'], |
|
442
|
|
|
'url' => $this->getHREFSubject('role'), |
|
443
|
|
|
'help' => 'pg.role', |
|
444
|
|
|
'icon' => 'Roles', |
|
445
|
|
|
]; |
|
446
|
|
|
} |
|
447
|
|
|
if ('database' == $subject || 'role' == $subject) { |
|
448
|
|
|
$done = true; |
|
449
|
|
|
} |
|
450
|
|
|
|
|
451
|
|
|
if (isset($_REQUEST['schema']) && !$done) { |
|
452
|
|
|
$trail['schema'] = [ |
|
453
|
|
|
'title' => $lang['strschema'], |
|
454
|
|
|
'text' => $_REQUEST['schema'], |
|
455
|
|
|
'url' => $this->getHREFSubject('schema'), |
|
456
|
|
|
'help' => 'pg.schema', |
|
457
|
|
|
'icon' => 'Schema', |
|
458
|
|
|
]; |
|
459
|
|
|
} |
|
460
|
|
|
if ('schema' == $subject) { |
|
461
|
|
|
$done = true; |
|
462
|
|
|
} |
|
463
|
|
|
|
|
464
|
|
|
if (isset($_REQUEST['table']) && !$done) { |
|
465
|
|
|
$trail['table'] = [ |
|
466
|
|
|
'title' => $lang['strtable'], |
|
467
|
|
|
'text' => $_REQUEST['table'], |
|
468
|
|
|
'url' => $this->getHREFSubject('table'), |
|
469
|
|
|
'help' => 'pg.table', |
|
470
|
|
|
'icon' => 'Table', |
|
471
|
|
|
]; |
|
472
|
|
|
} elseif (isset($_REQUEST['view']) && !$done) { |
|
473
|
|
|
$trail['view'] = [ |
|
474
|
|
|
'title' => $lang['strview'], |
|
475
|
|
|
'text' => $_REQUEST['view'], |
|
476
|
|
|
'url' => $this->getHREFSubject('view'), |
|
477
|
|
|
'help' => 'pg.view', |
|
478
|
|
|
'icon' => 'View', |
|
479
|
|
|
]; |
|
480
|
|
|
} elseif (isset($_REQUEST['matview']) && !$done) { |
|
481
|
|
|
$trail['matview'] = [ |
|
482
|
|
|
'title' => 'M'.$lang['strview'], |
|
483
|
|
|
'text' => $_REQUEST['matview'], |
|
484
|
|
|
'url' => $this->getHREFSubject('matview'), |
|
485
|
|
|
'help' => 'pg.matview', |
|
486
|
|
|
'icon' => 'MViews', |
|
487
|
|
|
]; |
|
488
|
|
|
} elseif (isset($_REQUEST['ftscfg']) && !$done) { |
|
489
|
|
|
$trail['ftscfg'] = [ |
|
490
|
|
|
'title' => $lang['strftsconfig'], |
|
491
|
|
|
'text' => $_REQUEST['ftscfg'], |
|
492
|
|
|
'url' => $this->getHREFSubject('ftscfg'), |
|
493
|
|
|
'help' => 'pg.ftscfg.example', |
|
494
|
|
|
'icon' => 'Fts', |
|
495
|
|
|
]; |
|
496
|
|
|
} |
|
497
|
|
|
if ('table' == $subject || 'view' == $subject || 'matview' == $subject || 'ftscfg' == $subject) { |
|
498
|
|
|
$done = true; |
|
499
|
|
|
} |
|
500
|
|
|
|
|
501
|
|
|
if (!$done && !is_null($subject)) { |
|
502
|
|
|
switch ($subject) { |
|
503
|
|
|
case 'function': |
|
504
|
|
|
$trail[$subject] = [ |
|
505
|
|
|
'title' => $lang['str'.$subject], |
|
506
|
|
|
'text' => $_REQUEST[$subject], |
|
507
|
|
|
'url' => $this->getHREFSubject('function'), |
|
508
|
|
|
'help' => 'pg.function', |
|
509
|
|
|
'icon' => 'Function', |
|
510
|
|
|
]; |
|
511
|
|
|
|
|
512
|
|
|
break; |
|
513
|
|
|
case 'aggregate': |
|
514
|
|
|
$trail[$subject] = [ |
|
515
|
|
|
'title' => $lang['straggregate'], |
|
516
|
|
|
'text' => $_REQUEST['aggrname'], |
|
517
|
|
|
'url' => $this->getHREFSubject('aggregate'), |
|
518
|
|
|
'help' => 'pg.aggregate', |
|
519
|
|
|
'icon' => 'Aggregate', |
|
520
|
|
|
]; |
|
521
|
|
|
|
|
522
|
|
|
break; |
|
523
|
|
|
case 'column': |
|
524
|
|
|
$trail['column'] = [ |
|
525
|
|
|
'title' => $lang['strcolumn'], |
|
526
|
|
|
'text' => $_REQUEST['column'], |
|
527
|
|
|
'icon' => 'Column', |
|
528
|
|
|
'url' => $this->getHREFSubject('column'), |
|
529
|
|
|
]; |
|
530
|
|
|
|
|
531
|
|
|
break; |
|
532
|
|
|
default: |
|
533
|
|
|
if (isset($_REQUEST[$subject])) { |
|
534
|
|
|
switch ($subject) { |
|
535
|
|
|
case 'domain':$icon = 'Domain'; |
|
536
|
|
|
|
|
537
|
|
|
break; |
|
538
|
|
|
case 'sequence':$icon = 'Sequence'; |
|
539
|
|
|
|
|
540
|
|
|
break; |
|
541
|
|
|
case 'type':$icon = 'Type'; |
|
542
|
|
|
|
|
543
|
|
|
break; |
|
544
|
|
|
case 'operator':$icon = 'Operator'; |
|
545
|
|
|
|
|
546
|
|
|
break; |
|
547
|
|
|
default:$icon = null; |
|
548
|
|
|
|
|
549
|
|
|
break; |
|
550
|
|
|
} |
|
551
|
|
|
$trail[$subject] = [ |
|
552
|
|
|
'title' => array_key_exists('str'.$subject, $lang) ? $lang['str'.$subject] : $subject, |
|
553
|
|
|
'text' => $_REQUEST[$subject], |
|
554
|
|
|
'help' => 'pg.'.$subject, |
|
555
|
|
|
'icon' => $icon, |
|
556
|
|
|
]; |
|
557
|
|
|
} |
|
558
|
|
|
} |
|
559
|
|
|
} |
|
560
|
|
|
|
|
561
|
|
|
// Trail hook's place |
|
562
|
|
|
$plugin_functions_parameters = [ |
|
563
|
|
|
'trail' => &$trail, |
|
564
|
|
|
'section' => $subject, |
|
565
|
|
|
]; |
|
566
|
|
|
|
|
567
|
|
|
$plugin_manager->do_hook('trail', $plugin_functions_parameters); |
|
568
|
|
|
|
|
569
|
|
|
//$this->prtrace($trail); |
|
570
|
|
|
|
|
571
|
|
|
return $trail; |
|
572
|
|
|
} |
|
573
|
|
|
|
|
574
|
|
|
/** |
|
575
|
|
|
* Display a list of links. |
|
576
|
|
|
* |
|
577
|
|
|
* @param $links An associative array of links to print. See printLink function for |
|
|
|
|
|
|
578
|
|
|
* the links array format. |
|
579
|
|
|
* @param $class an optional class or list of classes seprated by a space |
|
|
|
|
|
|
580
|
|
|
* WARNING: This field is NOT escaped! No user should be able to inject something here, use with care |
|
581
|
|
|
* @param bool $do_print true to echo, false to return |
|
582
|
|
|
* @param null|mixed $from |
|
|
|
|
|
|
583
|
|
|
*/ |
|
584
|
|
|
private function printLinksList($links, $class = '', $do_print = true, $from = null) |
|
|
|
|
|
|
585
|
|
|
{ |
|
586
|
|
|
if (null === $from || false === $from) { |
|
587
|
|
|
$from = __METHOD__; |
|
588
|
|
|
} |
|
589
|
|
|
$this->misc = $this->misc; |
|
590
|
|
|
$list_html = "<ul class=\"{$class}\">\n"; |
|
591
|
|
|
foreach ($links as $link) { |
|
592
|
|
|
$list_html .= "\t<li>"; |
|
593
|
|
|
$list_html .= str_replace('.php', '', $this->printLink($link, false, $from)); |
|
594
|
|
|
$list_html .= "</li>\n"; |
|
595
|
|
|
} |
|
596
|
|
|
$list_html .= "</ul>\n"; |
|
597
|
|
|
if ($do_print) { |
|
598
|
|
|
echo $list_html; |
|
599
|
|
|
} else { |
|
600
|
|
|
return $list_html; |
|
601
|
|
|
} |
|
602
|
|
|
} |
|
603
|
|
|
} |
|
604
|
|
|
|