navigation.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. require_once './libraries/common.inc.php';
  14. // Also initialises the collapsible tree class
  15. $response = Response::getInstance();
  16. $navigation = new Navigation();
  17. if (! $response->isAjax()) {
  18. $response->addHTML(
  19. PhpMyAdmin\Message::error(
  20. __('Fatal error: The navigation can only be accessed via AJAX')
  21. )
  22. );
  23. exit;
  24. }
  25. if (isset($_POST['getNaviSettings']) && $_POST['getNaviSettings']) {
  26. $response->addJSON('message', PageSettings::getNaviSettings());
  27. exit();
  28. }
  29. $relation = new Relation();
  30. $cfgRelation = $relation->getRelationsParam();
  31. if ($cfgRelation['navwork']) {
  32. if (isset($_POST['hideNavItem'])) {
  33. if (! empty($_POST['itemName'])
  34. && ! empty($_POST['itemType'])
  35. && ! empty($_POST['dbName'])
  36. ) {
  37. $navigation->hideNavigationItem(
  38. $_POST['itemName'],
  39. $_POST['itemType'],
  40. $_POST['dbName'],
  41. (! empty($_POST['tableName']) ? $_POST['tableName'] : null)
  42. );
  43. }
  44. exit;
  45. }
  46. if (isset($_POST['unhideNavItem'])) {
  47. if (! empty($_POST['itemName'])
  48. && ! empty($_POST['itemType'])
  49. && ! empty($_POST['dbName'])
  50. ) {
  51. $navigation->unhideNavigationItem(
  52. $_POST['itemName'],
  53. $_POST['itemType'],
  54. $_POST['dbName'],
  55. (! empty($_POST['tableName']) ? $_POST['tableName'] : null)
  56. );
  57. }
  58. exit;
  59. }
  60. if (isset($_POST['showUnhideDialog'])) {
  61. if (! empty($_POST['dbName'])) {
  62. $response->addJSON(
  63. 'message',
  64. $navigation->getItemUnhideDialog($_POST['dbName'])
  65. );
  66. }
  67. exit;
  68. }
  69. }
  70. // Do the magic
  71. $response->addJSON('message', $navigation->getDisplay());