From b295b6442c02f03e70486a195031344d789e7008 Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Sun, 18 Jan 2015 01:59:27 +0530 Subject: [PATCH] Render a database select in existing Node engine Signed-off-by: Atul Pratap Singh --- libraries/navigation/Navigation.class.php | 10 +-- libraries/navigation/NavigationTree.class.php | 62 ++++++++++++++++++- libraries/navigation/Nodes/Node.class.php | 16 +++-- 3 files changed, 78 insertions(+), 10 deletions(-) diff --git a/libraries/navigation/Navigation.class.php b/libraries/navigation/Navigation.class.php index 70bf40bc2a..f5d680f57d 100644 --- a/libraries/navigation/Navigation.class.php +++ b/libraries/navigation/Navigation.class.php @@ -33,8 +33,6 @@ class PMA_Navigation if (! PMA_Response::getInstance()->isAjax()) { $header = new PMA_NavigationHeader(); $retval = $header->getDisplay(); - } - if ($GLOBALS['cfg']['ShowNavigationAsTree']) { $class = ' class="list_container'; if ($GLOBALS['cfg']['NavigationLinkWithMainPanel']) { $class .= ' synced'; @@ -44,7 +42,10 @@ class PMA_Navigation } $class .= '"'; $retval .= '
'; + } $tree = new PMA_NavigationTree(); + if ($GLOBALS['cfg']['ShowNavigationAsTree']) { + if (! PMA_Response::getInstance()->isAjax() || ! empty($_REQUEST['full']) || ! empty($_REQUEST['reload']) @@ -62,14 +63,15 @@ class PMA_Navigation } else { $retval .= $treeRender; } - $retval .= '
'; // pma_navigation_tree } else { // provide legacy pre-4.0 navigation - $retval .= $this->_quickWarp(); + $retval .= $this->_quickWarp(); + $retval .= $tree->renderDbSelect(); } if (! PMA_Response::getInstance()->isAjax()) { // closes the tags that were opened by the navigation header + $retval .= ''; // pma_navigation_tree $retval .= ''; // pma_navigation_content $retval .= $this->_getDropHandler(); $retval .= ''; // pma_navigation diff --git a/libraries/navigation/NavigationTree.class.php b/libraries/navigation/NavigationTree.class.php index fdb747a725..e06f2ccc31 100644 --- a/libraries/navigation/NavigationTree.class.php +++ b/libraries/navigation/NavigationTree.class.php @@ -145,7 +145,9 @@ class PMA_NavigationTree // Initialise the tree by creating a root node $node = PMA_NodeFactory::getInstance('Node_Database_Container', 'root'); $this->_tree = $node; - if ($GLOBALS['cfg']['NavigationTreeEnableGrouping']) { + if ($GLOBALS['cfg']['NavigationTreeEnableGrouping'] + && $GLOBALS['cfg']['ShowNavigationAsTree'] + ) { $this->_tree->separator = $GLOBALS['cfg']['NavigationTreeDbSeparator']; $this->_tree->separator_depth = 10000; } @@ -628,6 +630,7 @@ class PMA_NavigationTree { if ($node->type != Node::CONTAINER || $GLOBALS['cfg']['NavigationTreeDisableDatabaseExpansion'] + || ! $GLOBALS['cfg']['ShowNavigationAsTree'] ) { return; } @@ -771,7 +774,9 @@ class PMA_NavigationTree $retval = '
'; $retval .= ''; @@ -1133,6 +1138,59 @@ class PMA_NavigationTree } return $retval; } + + + /** + * Renders a database select box like the pre-4.0 navigation panel + * + * @return string HTML code + */ + public function renderDbSelect() + { + $this->_buildPath(); + $this->_tree->is_group = false; + $retval = '
'; + // Provide for pagination in database select + $retval .= PMA_Util::getListNavigator( + $this->_tree->getPresence('databases', ''), + $this->_pos, + array('server' => $GLOBALS['server']), + 'navigation.php', + 'frame_navigation', + $GLOBALS['cfg']['FirstLevelNavigationItems'], + 'pos', + array('dbselector') + ); + $children = $this->_tree->children; + $node = $children[0]; + $retval .= '
'; + $retval .= '
'; + return $retval; + } /** * Makes some nodes visible based on the which node is active diff --git a/libraries/navigation/Nodes/Node.class.php b/libraries/navigation/Nodes/Node.class.php index d5259da428..20d57a7c4b 100644 --- a/libraries/navigation/Nodes/Node.class.php +++ b/libraries/navigation/Nodes/Node.class.php @@ -366,7 +366,9 @@ class Node public function getData($type, $pos, $searchClause = '') { $maxItems = $GLOBALS['cfg']['FirstLevelNavigationItems']; - if (!$GLOBALS['cfg']['NavigationTreeEnableGrouping']) { + if (!$GLOBALS['cfg']['NavigationTreeEnableGrouping'] + || !$GLOBALS['cfg']['ShowNavigationAsTree'] + ) { if (! $GLOBALS['cfg']['Server']['DisableIS']) { $query = "SELECT `SCHEMA_NAME` "; $query .= "FROM `INFORMATION_SCHEMA`.`SCHEMATA` "; @@ -544,7 +546,9 @@ class Node */ public function getPresence($type = '', $searchClause = '') { - if (!$GLOBALS['cfg']['NavigationTreeEnableGrouping']) { + if (!$GLOBALS['cfg']['NavigationTreeEnableGrouping'] + || !$GLOBALS['cfg']['ShowNavigationAsTree'] + ) { if (!$GLOBALS['cfg']['Server']['DisableIS']) { $query = "SELECT COUNT(*) "; $query .= "FROM INFORMATION_SCHEMA.SCHEMATA "; @@ -711,7 +715,9 @@ class Node */ public function getCssClasses($match) { - if ($GLOBALS['cfg']['NavigationTreeDisableDatabaseExpansion']) { + if ($GLOBALS['cfg']['NavigationTreeDisableDatabaseExpansion'] + || ! $GLOBALS['cfg']['ShowNavigationAsTree'] + ) { return ''; } @@ -736,7 +742,9 @@ class Node */ public function getIcon($match) { - if ($GLOBALS['cfg']['NavigationTreeDisableDatabaseExpansion']) { + if ($GLOBALS['cfg']['NavigationTreeDisableDatabaseExpansion'] + || ! $GLOBALS['cfg']['ShowNavigationAsTree'] + ) { return ''; } elseif ($match && ! $this->is_group) { $this->visible = true;