-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Expand file tree
/
Copy pathNavigationController.php
More file actions
97 lines (78 loc) · 3.12 KB
/
NavigationController.php
File metadata and controls
97 lines (78 loc) · 3.12 KB
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
87
88
89
90
91
92
93
94
95
96
97
<?php
declare(strict_types=1);
namespace PhpMyAdmin\Controllers;
use PhpMyAdmin\Config\PageSettings;
use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\Http\Response;
use PhpMyAdmin\Http\ServerRequest;
use PhpMyAdmin\Message;
use PhpMyAdmin\Navigation\Navigation;
use PhpMyAdmin\ResponseRenderer;
use PhpMyAdmin\Routing\Route;
use PhpMyAdmin\Utils\SessionCache;
use function __;
/**
* The navigation panel
*
* Displays server, database and table selection tree.
*/
#[Route('/navigation', ['GET', 'POST'])]
final readonly class NavigationController implements InvocableController
{
public function __construct(
private ResponseRenderer $response,
private Navigation $navigation,
private Relation $relation,
private PageSettings $pageSettings,
) {
}
public function __invoke(ServerRequest $request): Response
{
if (! $request->isAjax()) {
$this->response->addHTML(
Message::error(
__('Fatal error: The navigation can only be accessed via AJAX'),
)->getDisplay(),
);
return $this->response->response();
}
if ($request->hasBodyParam('getNaviSettings')) {
$this->pageSettings->init('Navi', 'pma_navigation_settings');
$this->response->addHTML($this->pageSettings->getErrorHTML());
$this->response->addJSON('message', $this->pageSettings->getHTML());
return $this->response->response();
}
if ($request->hasBodyParam('reload')) {
SessionCache::set('dbs_to_test', false);// Empty database list cache, see #14252
}
$relationParameters = $this->relation->getRelationParameters();
if ($relationParameters->navigationItemsHidingFeature !== null) {
$itemName = $request->getParsedBodyParamAsString('itemName', '');
$itemType = $request->getParsedBodyParamAsString('itemType', '');
$dbName = $request->getParsedBodyParamAsString('dbName', '');
if ($request->hasBodyParam('hideNavItem')) {
if ($itemName !== '' && $itemType !== '' && $dbName !== '') {
$this->navigation->hideNavigationItem($itemName, $itemType, $dbName);
}
return $this->response->response();
}
if ($request->hasBodyParam('unhideNavItem')) {
if ($itemName !== '' && $itemType !== '' && $dbName !== '') {
$this->navigation->unhideNavigationItem($itemName, $itemType, $dbName);
}
return $this->response->response();
}
if ($request->hasBodyParam('showUnhideDialog')) {
if ($dbName !== '') {
$this->response->addJSON(
'message',
$this->navigation->getItemUnhideDialog($dbName),
);
}
return $this->response->response();
}
}
$this->response->addJSON('message', $this->navigation->getDisplay($this->response));
return $this->response->response();
}
}