navigation.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * The navigation panel - displays server, db and table selection tree
  5. *
  6. * @package PhpMyAdmin-Navigation
  7. */
  8. // Include common functionalities
  9. use PhpMyAdmin\Config\PageSettings;
  10. use PhpMyAdmin\Navigation\Navigation;
  11. use PhpMyAdmin\Relation;
  12. use PhpMyAdmin\Response;
  13. use PhpMyAdmin\Util;
  14. require_once './libraries/common.inc.php';
  15. // Also initialises the collapsible tree class
  16. $response = Response::getInstance();
  17. $navigation = new Navigation();
  18. if (! $response->isAjax()) {
  19. $response->addHTML(
  20. PhpMyAdmin\Message::error(
  21. __('Fatal error: The navigation can only be accessed via AJAX')
  22. )
  23. );
  24. exit;
  25. }
  26. if (isset($_POST['getNaviSettings']) && $_POST['getNaviSettings']) {
  27. $response->addJSON('message', PageSettings::getNaviSettings());
  28. exit();
  29. }
  30. if (isset($_POST['reload'])) {
  31. Util::cacheSet('dbs_to_test', false);// Empty database list cache, see #14252
  32. }
  33. $relation = new Relation();
  34. $cfgRelation = $relation->getRelationsParam();
  35. if ($cfgRelation['navwork']) {
  36. if (isset($_POST['hideNavItem'])) {
  37. if (! empty($_POST['itemName'])
  38. && ! empty($_POST['itemType'])
  39. && ! empty($_POST['dbName'])
  40. ) {
  41. $navigation->hideNavigationItem(
  42. $_POST['itemName'],
  43. $_POST['itemType'],
  44. $_POST['dbName'],
  45. (! empty($_POST['tableName']) ? $_POST['tableName'] : null)
  46. );
  47. }
  48. exit;
  49. }
  50. if (isset($_POST['unhideNavItem'])) {
  51. if (! empty($_POST['itemName'])
  52. && ! empty($_POST['itemType'])
  53. && ! empty($_POST['dbName'])
  54. ) {
  55. $navigation->unhideNavigationItem(
  56. $_POST['itemName'],
  57. $_POST['itemType'],
  58. $_POST['dbName'],
  59. (! empty($_POST['tableName']) ? $_POST['tableName'] : null)
  60. );
  61. }
  62. exit;
  63. }
  64. if (isset($_POST['showUnhideDialog'])) {
  65. if (! empty($_POST['dbName'])) {
  66. $response->addJSON(
  67. 'message',
  68. $navigation->getItemUnhideDialog($_POST['dbName'])
  69. );
  70. }
  71. exit;
  72. }
  73. }
  74. // Do the magic
  75. $response->addJSON('message', $navigation->getDisplay());