Improve create-release script to handle QA branches higher than QA_4_8.
[phpmyadmin.git] / navigation.php
blob9a94ba7329eac7cf14a6a2ae51b80ba5a753a082
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\DatabaseInterface;
12 use PhpMyAdmin\Di\Container;
13 use PhpMyAdmin\Message;
14 use PhpMyAdmin\Navigation\Navigation;
15 use PhpMyAdmin\Relation;
16 use PhpMyAdmin\Response;
17 use PhpMyAdmin\Template;
18 use PhpMyAdmin\Util;
20 if (! defined('ROOT_PATH')) {
21 define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
24 require_once ROOT_PATH . 'libraries/common.inc.php';
26 $container = Container::getDefaultContainer();
27 $container->set(Response::class, Response::getInstance());
29 /** @var Response $response */
30 $response = $container->get(Response::class);
32 /** @var DatabaseInterface $dbi */
33 $dbi = $container->get(DatabaseInterface::class);
35 /** @var Navigation $navigation */
36 $navigation = $containerBuilder->get('navigation');
37 if (! $response->isAjax()) {
38 $response->addHTML(
39 Message::error(
40 __('Fatal error: The navigation can only be accessed via AJAX')
43 exit;
46 if (isset($_POST['getNaviSettings']) && $_POST['getNaviSettings']) {
47 $response->addJSON('message', PageSettings::getNaviSettings());
48 exit;
51 if (isset($_POST['reload'])) {
52 Util::cacheSet('dbs_to_test', false);// Empty database list cache, see #14252
55 /** @var Relation $relation */
56 $relation = $containerBuilder->get('relation');
57 $cfgRelation = $relation->getRelationsParam();
58 if ($cfgRelation['navwork']) {
59 if (isset($_POST['hideNavItem'])) {
60 if (! empty($_POST['itemName'])
61 && ! empty($_POST['itemType'])
62 && ! empty($_POST['dbName'])
63 ) {
64 $navigation->hideNavigationItem(
65 $_POST['itemName'],
66 $_POST['itemType'],
67 $_POST['dbName'],
68 (! empty($_POST['tableName']) ? $_POST['tableName'] : null)
71 exit;
74 if (isset($_POST['unhideNavItem'])) {
75 if (! empty($_POST['itemName'])
76 && ! empty($_POST['itemType'])
77 && ! empty($_POST['dbName'])
78 ) {
79 $navigation->unhideNavigationItem(
80 $_POST['itemName'],
81 $_POST['itemType'],
82 $_POST['dbName'],
83 (! empty($_POST['tableName']) ? $_POST['tableName'] : null)
86 exit;
89 if (isset($_POST['showUnhideDialog'])) {
90 if (! empty($_POST['dbName'])) {
91 $response->addJSON(
92 'message',
93 $navigation->getItemUnhideDialog($_POST['dbName'])
96 exit;
100 // Do the magic
101 $response->addJSON('message', $navigation->getDisplay());