Merge branch 'origin/master' into Weblate.
[phpmyadmin.git] / navigation.php
blob168b244b169fccf5546f92b97fcb92d675a056a4
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * The navigation panel - displays server, db and table selection tree
6 * @package PhpMyAdmin-Navigation
7 */
8 declare(strict_types=1);
10 use PhpMyAdmin\Config\PageSettings;
11 use PhpMyAdmin\Navigation\Navigation;
12 use PhpMyAdmin\Relation;
13 use PhpMyAdmin\Response;
15 if (! defined('ROOT_PATH')) {
16 define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
19 require_once ROOT_PATH . 'libraries/common.inc.php';
21 // Also initialises the collapsible tree class
22 $response = Response::getInstance();
23 $navigation = new Navigation();
24 if (! $response->isAjax()) {
25 $response->addHTML(
26 PhpMyAdmin\Message::error(
27 __('Fatal error: The navigation can only be accessed via AJAX')
30 exit;
33 if (isset($_POST['getNaviSettings']) && $_POST['getNaviSettings']) {
34 $response->addJSON('message', PageSettings::getNaviSettings());
35 exit();
38 $relation = new Relation($GLOBALS['dbi']);
39 $cfgRelation = $relation->getRelationsParam();
40 if ($cfgRelation['navwork']) {
41 if (isset($_POST['hideNavItem'])) {
42 if (! empty($_POST['itemName'])
43 && ! empty($_POST['itemType'])
44 && ! empty($_POST['dbName'])
45 ) {
46 $navigation->hideNavigationItem(
47 $_POST['itemName'],
48 $_POST['itemType'],
49 $_POST['dbName'],
50 (! empty($_POST['tableName']) ? $_POST['tableName'] : null)
53 exit;
56 if (isset($_POST['unhideNavItem'])) {
57 if (! empty($_POST['itemName'])
58 && ! empty($_POST['itemType'])
59 && ! empty($_POST['dbName'])
60 ) {
61 $navigation->unhideNavigationItem(
62 $_POST['itemName'],
63 $_POST['itemType'],
64 $_POST['dbName'],
65 (! empty($_POST['tableName']) ? $_POST['tableName'] : null)
68 exit;
71 if (isset($_POST['showUnhideDialog'])) {
72 if (! empty($_POST['dbName'])) {
73 $response->addJSON(
74 'message',
75 $navigation->getItemUnhideDialog($_POST['dbName'])
78 exit;
82 // Do the magic
83 $response->addJSON('message', $navigation->getDisplay());