From 2abe91a499daed4ae5ecc5ad6f1b8c36cc85abfc Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Thu, 15 Jan 2015 23:45:35 +0530 Subject: [PATCH 1/7] Add configuration option ShowNavigationAsTree with true as default Signed-off-by: Atul Pratap Singh --- libraries/Header.class.php | 1 + libraries/config.default.php | 7 +++++++ libraries/config/messages.inc.php | 2 ++ libraries/config/setup.forms.php | 1 + libraries/config/user_preferences.forms.php | 1 + 5 files changed, 12 insertions(+) diff --git a/libraries/Header.class.php b/libraries/Header.class.php index cddcdc569f..dad848345e 100644 --- a/libraries/Header.class.php +++ b/libraries/Header.class.php @@ -237,6 +237,7 @@ class PMA_Header 'db' => $db, 'token' => $_SESSION[' PMA_token '], 'text_dir' => $GLOBALS['text_dir'], + 'show_navigation_as_tree'=> $GLOBALS['cfg']['ShowNavigationAsTree'], 'pma_absolute_uri' => $GLOBALS['cfg']['PmaAbsoluteUri'], 'pma_text_default_tab' => PMA_Util::getTitleForTarget( $GLOBALS['cfg']['DefaultTabTable'] diff --git a/libraries/config.default.php b/libraries/config.default.php index b26de7449f..52301bf2e7 100644 --- a/libraries/config.default.php +++ b/libraries/config.default.php @@ -810,6 +810,13 @@ $cfg['CaptchaLoginPrivateKey'] = ''; * Navigation panel setup */ +/** + * Whether to display navigation panel as tree or as pre-4.0 style + * + * @global boolean $cfg['ShowNavigationAsTree'] + */ +$cfg['ShowNavigationAsTree'] = true; + /** * maximum number of first level databases displayed in navigation panel * diff --git a/libraries/config/messages.inc.php b/libraries/config/messages.inc.php index c9e0083957..36198d23f8 100644 --- a/libraries/config/messages.inc.php +++ b/libraries/config/messages.inc.php @@ -415,6 +415,8 @@ $strConfigMemoryLimit_desc = __( . '([kbd]0[/kbd] for no limit).' ); $strConfigMemoryLimit_name = __('Memory limit'); +$strConfigShowNavigationAsTree_desc = __('Whether to display navigation panel in tree style or in pre-4.0 style'); +$strConfigShowNavigationAsTree_name = __('Show Navigation as tree'); $strConfigNavigationLinkWithMainPanel_desc = __('Link with main panel by highlighting the current database or table.'); $strConfigNavigationLinkWithMainPanel_name = __('Link with main panel'); $strConfigNavigationDisplayLogo_desc = __('Show logo in navigation panel.'); diff --git a/libraries/config/setup.forms.php b/libraries/config/setup.forms.php index 459df114f8..c6809e51b2 100644 --- a/libraries/config/setup.forms.php +++ b/libraries/config/setup.forms.php @@ -162,6 +162,7 @@ $forms['Sql_queries']['Sql_box'] = array('SQLQuery' => array( 'ShowAsPHP', 'Refresh')); $forms['Navi_panel']['Navi_panel'] = array( + 'ShowNavigationAsTree', 'NavigationLinkWithMainPanel', 'NavigationDisplayLogo', 'NavigationLogoLink', diff --git a/libraries/config/user_preferences.forms.php b/libraries/config/user_preferences.forms.php index 17ca1425ab..11a2a6faab 100644 --- a/libraries/config/user_preferences.forms.php +++ b/libraries/config/user_preferences.forms.php @@ -73,6 +73,7 @@ $forms['Sql_queries']['Sql_box'] = array( 'SQLQuery/ShowAsPHP', 'SQLQuery/Refresh'); $forms['Navi_panel']['Navi_panel'] = array( + 'ShowNavigationAsTree', 'NavigationLinkWithMainPanel', 'NavigationDisplayLogo', 'NavigationLogoLink', From 12f584f1f709a1e29ab2b8a7a5978233a4f86eef Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Fri, 16 Jan 2015 04:32:20 +0530 Subject: [PATCH 2/7] Some rearrangements, prepare to add support for old style navigation Signed-off-by: Atul Pratap Singh --- libraries/navigation/Navigation.class.php | 68 ++++++++++++++----- .../navigation/NavigationHeader.class.php | 9 --- libraries/navigation/NavigationTree.class.php | 22 +----- 3 files changed, 52 insertions(+), 47 deletions(-) diff --git a/libraries/navigation/Navigation.class.php b/libraries/navigation/Navigation.class.php index da0bf099e2..70bf40bc2a 100644 --- a/libraries/navigation/Navigation.class.php +++ b/libraries/navigation/Navigation.class.php @@ -34,30 +34,45 @@ class PMA_Navigation $header = new PMA_NavigationHeader(); $retval = $header->getDisplay(); } - $tree = new PMA_NavigationTree(); - if (! PMA_Response::getInstance()->isAjax() - || ! empty($_REQUEST['full']) - || ! empty($_REQUEST['reload']) - ) { - $treeRender = $tree->renderState(); - } else { - $treeRender = $tree->renderPath(); - } + if ($GLOBALS['cfg']['ShowNavigationAsTree']) { + $class = ' class="list_container'; + if ($GLOBALS['cfg']['NavigationLinkWithMainPanel']) { + $class .= ' synced'; + } + if ($GLOBALS['cfg']['NavigationTreePointerEnable']) { + $class .= ' highlight'; + } + $class .= '"'; + $retval .= '
'; + $tree = new PMA_NavigationTree(); + if (! PMA_Response::getInstance()->isAjax() + || ! empty($_REQUEST['full']) + || ! empty($_REQUEST['reload']) + ) { + $treeRender = $this->_quickWarp(); + $treeRender .= $tree->renderState(); + } else { + $treeRender = $tree->renderPath(); + } - if (! $treeRender) { - $retval .= PMA_Message::error( - __('An error has occurred while loading the navigation tree') - )->getDisplay(); + if (! $treeRender) { + $retval .= PMA_Message::error( + __('An error has occurred while loading the navigation tree') + )->getDisplay(); + } else { + $retval .= $treeRender; + } + $retval .= '
'; // pma_navigation_tree } else { - $retval .= $treeRender; + // provide legacy pre-4.0 navigation + $retval .= $this->_quickWarp(); } if (! PMA_Response::getInstance()->isAjax()) { // closes the tags that were opened by the navigation header - $retval .= ''; - $retval .= ''; + $retval .= ''; // pma_navigation_content $retval .= $this->_getDropHandler(); - $retval .= ''; + $retval .= ''; // pma_navigation } return $retval; @@ -219,5 +234,24 @@ class PMA_Navigation $html .= ''; return $html; } + + /** + * Display quick warp links, contain Recents and Favorites + * + * @return string HTML code + */ + private function _quickWarp() + { + $retval = '
'; + if ($GLOBALS['cfg']['NumRecentTables'] > 0) { + $retval .= PMA_RecentFavoriteTable::getInstance('recent')->getHtml(); + } + if ($GLOBALS['cfg']['NumFavoriteTables'] > 0) { + $retval .= PMA_RecentFavoriteTable::getInstance('favorite')->getHtml(); + } + $retval .= '
'; + $retval .= '
'; + return $retval; + } } ?> diff --git a/libraries/navigation/NavigationHeader.class.php b/libraries/navigation/NavigationHeader.class.php index 61ede894cb..0e6ea62fce 100644 --- a/libraries/navigation/NavigationHeader.class.php +++ b/libraries/navigation/NavigationHeader.class.php @@ -32,14 +32,6 @@ class PMA_NavigationHeader 'ajax_request' => true ) ); - $class = ' class="list_container'; - if ($GLOBALS['cfg']['NavigationLinkWithMainPanel']) { - $class .= ' synced'; - } - if ($GLOBALS['cfg']['NavigationTreePointerEnable']) { - $class .= ' highlight'; - } - $class .= '"'; $buffer = '
'; $buffer .= '
'; $buffer .= '
'; @@ -61,7 +53,6 @@ class PMA_NavigationHeader ) ); $buffer .= '
'; // pma_navigation_header - $buffer .= '
'; return $buffer; } diff --git a/libraries/navigation/NavigationTree.class.php b/libraries/navigation/NavigationTree.class.php index 1772d760ed..fdb747a725 100644 --- a/libraries/navigation/NavigationTree.class.php +++ b/libraries/navigation/NavigationTree.class.php @@ -768,8 +768,7 @@ class PMA_NavigationTree public function renderState() { $this->_buildPath(); - $retval = $this->_quickWarp(); - $retval .= '
'; + $retval = '
'; $retval .= '
    '; $retval .= $this->_fastFilterHtml($this->_tree); if (! $GLOBALS['cfg']['NavigationTreeDisableDatabaseExpansion']) { @@ -1351,24 +1350,5 @@ class PMA_NavigationTree return strcasecmp($a->name, $b->name); } } - - /** - * Display quick warp links, contain Recents and Favorites - * - * @return string HTML code - */ - private function _quickWarp() - { - $retval = '
    '; - if ($GLOBALS['cfg']['NumRecentTables'] > 0) { - $retval .= PMA_RecentFavoriteTable::getInstance('recent')->getHtml(); - } - if ($GLOBALS['cfg']['NumFavoriteTables'] > 0) { - $retval .= PMA_RecentFavoriteTable::getInstance('favorite')->getHtml(); - } - $retval .= '
    '; - $retval .= '
    '; - return $retval; - } } ?> From b295b6442c02f03e70486a195031344d789e7008 Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Sun, 18 Jan 2015 01:59:27 +0530 Subject: [PATCH 3/7] 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 .= '
    '; $retval .= $this->_fastFilterHtml($this->_tree); - if (! $GLOBALS['cfg']['NavigationTreeDisableDatabaseExpansion']) { + if (! $GLOBALS['cfg']['NavigationTreeDisableDatabaseExpansion'] + || ! $GLOBALS['cfg']['ShowNavigationAsTree'] + ) { $retval .= $this->_controls(); } $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; From 4fa06442c55dc1fa59a7fb499b7ebd94697cefca Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Sun, 18 Jan 2015 02:34:02 +0530 Subject: [PATCH 4/7] Render tables tree on selecting a database using select box Signed-off-by: Atul Pratap Singh --- js/navigation.js | 73 +++++++++++++------ libraries/navigation/Navigation.class.php | 29 ++++---- .../navigation/NavigationHeader.class.php | 9 +++ libraries/navigation/NavigationTree.class.php | 28 ++++--- libraries/navigation/Nodes/Node.class.php | 4 +- themes/original/css/navigation.css.php | 2 + themes/pmahomme/css/navigation.css.php | 2 + 7 files changed, 98 insertions(+), 49 deletions(-) diff --git a/js/navigation.js b/js/navigation.js index f994951840..eab0c4c77d 100644 --- a/js/navigation.js +++ b/js/navigation.js @@ -8,36 +8,49 @@ /** * Loads child items of a node and executes a given callback * + * @param isNode * @param $expandElem expander * @param callback callback function * * @returns void */ -function loadChildNodes($expandElem, callback) { - if (!$expandElem.hasClass('expander')) { - return; +function loadChildNodes(isNode, $expandElem, callback) { + if (isNode) { + if (!$expandElem.hasClass('expander')) { + return; + } + var $destination = $expandElem.closest('li'); + + var searchClause = PMA_fastFilter.getSearchClause(); + var searchClause2 = PMA_fastFilter.getSearchClause2($expandElem); + + var params = { + aPath: $expandElem.find('span.aPath').text(), + vPath: $expandElem.find('span.vPath').text(), + pos: $expandElem.find('span.pos').text(), + pos2_name: $expandElem.find('span.pos2_name').text(), + pos2_value: $expandElem.find('span.pos2_value').text(), + searchClause: searchClause, + searchClause2: searchClause2 + }; + } else { + var $destination = $('#pma_navigation_tree_content'); + var params = { + aPath: $expandElem.attr('aPath'), + vPath: $expandElem.attr('vPath'), + pos: $expandElem.attr('pos') + }; } - var $destination = $expandElem.closest('li'); - - var searchClause = PMA_fastFilter.getSearchClause(); - var searchClause2 = PMA_fastFilter.getSearchClause2($expandElem); - - var params = { - aPath: $expandElem.find('span.aPath').text(), - vPath: $expandElem.find('span.vPath').text(), - pos: $expandElem.find('span.pos').text(), - pos2_name: $expandElem.find('span.pos2_name').text(), - pos2_value: $expandElem.find('span.pos2_value').text(), - searchClause: searchClause, - searchClause2: searchClause2 - }; var url = $('#pma_navigation').find('a.navigation_url').attr('href'); $.get(url, params, function (data) { if (typeof data !== 'undefined' && data.success === true) { - $expandElem.addClass('loaded'); + if (isNode) { + $expandElem.addClass('loaded'); + } $destination.find('div.list_container').remove(); // FIXME: Hack, there shouldn't be a list container there $destination.append(data.message); + $destination.children('div.list_container').first().show(); if (data._debug){ $('#session_debug').replaceWith(data._debug); } @@ -135,6 +148,10 @@ $(function () { $icon.attr('src', icon_reload_src); }, 1000); }); + + $(document).on("change", '#navi_db_select', function (event) { + $(this).closest('form').trigger('submit'); + }); /** * Register event handler for click on the collapse all @@ -510,7 +527,7 @@ function expandTreeNode($expandElem, callback) { $icon.hide(); $throbber.insertBefore($icon); - loadChildNodes($expandElem, function (data) { + loadChildNodes(true, $expandElem, function (data) { if (typeof data !== 'undefined' && data.success === true) { var $destination = $expandElem.closest('li'); $icon.removeClass('ic_b_plus').addClass('ic_b_minus'); @@ -586,6 +603,13 @@ function PMA_showCurrentNavigation() { } else { handleTableOrDb(table, $dbItem); } + } else { + if (! PMA_commonParams.get('show_navigation_as_tree')) { + loadChildNodes(false, $('option:selected', $('#navi_db_select')), function (data) { + return; + }); + return; + } } } PMA_showFullName($('#pma_navigation_tree')); @@ -688,7 +712,7 @@ function PMA_showCurrentNavigation() { } function loadAndShowTableOrView($expander, $relatedContainer, itemName) { - loadChildNodes($expander, function (data) { + loadChildNodes(true, $expander, function (data) { var $whichItem = findLoadedItem( $relatedContainer.children('div.list_container'), itemName, null, true @@ -825,12 +849,17 @@ function PMA_navigationTreePagination($this) { if (typeof data !== 'undefined' && data.success) { if (isDbSelector) { var val = PMA_fastFilter.getSearchClause(); - $('#pma_navigation_tree') + if (PMA_commonParams.get('show_navigation_as_tree')) { + var $div_elem = $('#pma_navigation_tree'); + } else { + var $div_elem = $('#pma_navigation_select_database'); + } + $div_elem .html(data.message) .children('div') .show(); if (val) { - $('#pma_navigation_tree') + $div_elem .find('li.fast_filter input.searchClause') .val(val); } diff --git a/libraries/navigation/Navigation.class.php b/libraries/navigation/Navigation.class.php index f5d680f57d..3deaff09a1 100644 --- a/libraries/navigation/Navigation.class.php +++ b/libraries/navigation/Navigation.class.php @@ -33,19 +33,11 @@ class PMA_Navigation if (! PMA_Response::getInstance()->isAjax()) { $header = new PMA_NavigationHeader(); $retval = $header->getDisplay(); - $class = ' class="list_container'; - if ($GLOBALS['cfg']['NavigationLinkWithMainPanel']) { - $class .= ' synced'; - } - if ($GLOBALS['cfg']['NavigationTreePointerEnable']) { - $class .= ' highlight'; - } - $class .= '"'; - $retval .= '
'; } - $tree = new PMA_NavigationTree(); - if ($GLOBALS['cfg']['ShowNavigationAsTree']) { - + $tree = new PMA_NavigationTree(); + if ($GLOBALS['cfg']['ShowNavigationAsTree'] + // || $GLOBALS['db'] == '' + ) { if (! PMA_Response::getInstance()->isAjax() || ! empty($_REQUEST['full']) || ! empty($_REQUEST['reload']) @@ -64,9 +56,16 @@ class PMA_Navigation $retval .= $treeRender; } } else { - // provide legacy pre-4.0 navigation - $retval .= $this->_quickWarp(); - $retval .= $tree->renderDbSelect(); + // provide legacy pre-4.0 navigation + if (! PMA_Response::getInstance()->isAjax() + || ! empty($_REQUEST['full']) + || ! empty($_REQUEST['reload']) + ) { + $retval .= $this->_quickWarp(); + $retval .= $tree->renderDbSelect(); + } else { + $retval = $tree->renderPath(); + } } if (! PMA_Response::getInstance()->isAjax()) { diff --git a/libraries/navigation/NavigationHeader.class.php b/libraries/navigation/NavigationHeader.class.php index 0e6ea62fce..61ede894cb 100644 --- a/libraries/navigation/NavigationHeader.class.php +++ b/libraries/navigation/NavigationHeader.class.php @@ -32,6 +32,14 @@ class PMA_NavigationHeader 'ajax_request' => true ) ); + $class = ' class="list_container'; + if ($GLOBALS['cfg']['NavigationLinkWithMainPanel']) { + $class .= ' synced'; + } + if ($GLOBALS['cfg']['NavigationTreePointerEnable']) { + $class .= ' highlight'; + } + $class .= '"'; $buffer = '
'; $buffer .= '
'; $buffer .= '
'; @@ -53,6 +61,7 @@ class PMA_NavigationHeader ) ); $buffer .= '
'; // pma_navigation_header + $buffer .= '
'; return $buffer; } diff --git a/libraries/navigation/NavigationTree.class.php b/libraries/navigation/NavigationTree.class.php index e06f2ccc31..cb4ead3d76 100644 --- a/libraries/navigation/NavigationTree.class.php +++ b/libraries/navigation/NavigationTree.class.php @@ -630,7 +630,7 @@ class PMA_NavigationTree { if ($node->type != Node::CONTAINER || $GLOBALS['cfg']['NavigationTreeDisableDatabaseExpansion'] - || ! $GLOBALS['cfg']['ShowNavigationAsTree'] + //|| ! $GLOBALS['cfg']['ShowNavigationAsTree'] ) { return; } @@ -775,7 +775,7 @@ class PMA_NavigationTree $retval .= '
    '; $retval .= $this->_fastFilterHtml($this->_tree); if (! $GLOBALS['cfg']['NavigationTreeDisableDatabaseExpansion'] - || ! $GLOBALS['cfg']['ShowNavigationAsTree'] + //|| ! $GLOBALS['cfg']['ShowNavigationAsTree'] ) { $retval .= $this->_controls(); } @@ -817,6 +817,9 @@ class PMA_NavigationTree $retval .= $this->_fastFilterHtml($node); $retval .= $this->_getPageSelector($node); $children = $node->children; + if (! $GLOBALS['cfg']['ShowNavigationAsTree']) { + $this->_setVisibility(); + } usort($children, array('PMA_NavigationTree', 'sortNode')); for ($i=0, $nbChildren = count($children); $i < $nbChildren; $i++) { if ($i + 1 != $nbChildren) { @@ -1163,21 +1166,25 @@ class PMA_NavigationTree ); $children = $this->_tree->children; $node = $children[0]; - $retval .= '
    '; + $url_params = array( + 'token' => $_SESSION[' PMA_token '], + 'server' => $GLOBALS['server'] + ); + $retval .= ''; + $retval .= PMA_getHiddenFields($url_params); $retval .= '
'; + $retval .= ''; + $retval .= '
'; return $retval; } diff --git a/libraries/navigation/Nodes/Node.class.php b/libraries/navigation/Nodes/Node.class.php index 20d57a7c4b..c4ae81668b 100644 --- a/libraries/navigation/Nodes/Node.class.php +++ b/libraries/navigation/Nodes/Node.class.php @@ -716,7 +716,7 @@ class Node public function getCssClasses($match) { if ($GLOBALS['cfg']['NavigationTreeDisableDatabaseExpansion'] - || ! $GLOBALS['cfg']['ShowNavigationAsTree'] + //|| ! $GLOBALS['cfg']['ShowNavigationAsTree'] ) { return ''; } @@ -743,7 +743,7 @@ class Node public function getIcon($match) { if ($GLOBALS['cfg']['NavigationTreeDisableDatabaseExpansion'] - || ! $GLOBALS['cfg']['ShowNavigationAsTree'] + //|| ! $GLOBALS['cfg']['ShowNavigationAsTree'] ) { return ''; } elseif ($match && ! $this->is_group) { diff --git a/themes/original/css/navigation.css.php b/themes/original/css/navigation.css.php index ea84f8c46a..252760b7de 100644 --- a/themes/original/css/navigation.css.php +++ b/themes/original/css/navigation.css.php @@ -120,6 +120,8 @@ if (! defined('PMA_MINIMUM_COMMON') && ! defined('TESTSUITE')) { height: 74%; position: relative; } +#pma_navigation_select_database { +} #pma_navigation_tree_content { width: 100%; overflow: hidden; diff --git a/themes/pmahomme/css/navigation.css.php b/themes/pmahomme/css/navigation.css.php index fef92c63a3..9c1713c8c8 100644 --- a/themes/pmahomme/css/navigation.css.php +++ b/themes/pmahomme/css/navigation.css.php @@ -106,6 +106,8 @@ if (! defined('PMA_MINIMUM_COMMON') && ! defined('TESTSUITE')) { height: 74%; position: relative; } +#pma_navigation_select_database { +} #pma_navigation_tree_content { width: 100%; overflow: hidden; From 8177dafb9a8873770196f9ea745dba89f980cbb1 Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Mon, 19 Jan 2015 03:55:36 +0530 Subject: [PATCH 5/7] Maybe 250 is too high, but 25 is very low and will create pagination trouble, so setting it to 100, see https://sourceforge.net/p/phpmyadmin/mailman/message/31333321/ Signed-off-by: Atul Pratap Singh --- doc/config.rst | 2 +- libraries/config.default.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/config.rst b/doc/config.rst index 1459f13dd1..4cda5c081f 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -1391,7 +1391,7 @@ Navigation panel setup .. config:option:: $cfg['FirstLevelNavigationItems'] :type: integer - :default: 25 + :default: 100 The number of first level databases that can be displayed on each page of navigation tree. diff --git a/libraries/config.default.php b/libraries/config.default.php index 52301bf2e7..995270b72c 100644 --- a/libraries/config.default.php +++ b/libraries/config.default.php @@ -822,7 +822,7 @@ $cfg['ShowNavigationAsTree'] = true; * * @global integer $cfg['FirstLevelNavigationItems'] */ -$cfg['FirstLevelNavigationItems'] = 25; +$cfg['FirstLevelNavigationItems'] = 100; /** * maximum number of items displayed in navigation panel From e20b5584ea44911aaec9c0ec7c6d7b82c6dab162 Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Wed, 21 Jan 2015 06:08:23 +0530 Subject: [PATCH 6/7] Update sessionStorage to maintain state and few other changes Signed-off-by: Atul Pratap Singh --- js/navigation.js | 48 +++++++++++------- libraries/navigation/NavigationTree.class.php | 3 +- themes/original/css/navigation.css.php | 25 +++++++++ themes/pmahomme/css/navigation.css.php | 24 +++++++++ themes/pmahomme/img/select_bg.png | Bin 0 -> 303 bytes 5 files changed, 81 insertions(+), 19 deletions(-) create mode 100644 themes/pmahomme/img/select_bg.png diff --git a/js/navigation.js b/js/navigation.js index eab0c4c77d..17d10b3ac0 100644 --- a/js/navigation.js +++ b/js/navigation.js @@ -38,19 +38,25 @@ function loadChildNodes(isNode, $expandElem, callback) { var params = { aPath: $expandElem.attr('aPath'), vPath: $expandElem.attr('vPath'), - pos: $expandElem.attr('pos') + pos: $expandElem.attr('pos'), + pos2_name: '', + pos2_value: '' }; } var url = $('#pma_navigation').find('a.navigation_url').attr('href'); $.get(url, params, function (data) { if (typeof data !== 'undefined' && data.success === true) { - if (isNode) { - $expandElem.addClass('loaded'); - } $destination.find('div.list_container').remove(); // FIXME: Hack, there shouldn't be a list container there $destination.append(data.message); - $destination.children('div.list_container').first().show(); + if (isNode) { + $expandElem.addClass('loaded'); + } else { + $destination.children() + .first() + .css({border: '0px', margin: '0em', padding : '0em'}) + .slideDown('slow'); + } if (data._debug){ $('#session_debug').replaceWith(data._debug); } @@ -401,10 +407,6 @@ $(function () { }); }); - if ($('#pma_navigation_tree').hasClass('synced')) { - PMA_showCurrentNavigation(); - } - // Add/Remove favorite table using Ajax. $(document).on("click", ".favorite_table_anchor", function (event) { event.preventDefault(); @@ -459,7 +461,9 @@ $(function () { } }); // Initialize if no previous state is defined - if (typeof storage.navTree === 'undefined') { + if ( ($('#pma_navigation_tree_content').length && typeof storage.navTree === 'undefined') + || ($('#pma_navigation_db_select').length && typeof storage.navSelect === 'undefined') + ) { navTreeStateUpdate(); } else if (PMA_commonParams.get('server') === storage.server && PMA_commonParams.get('token') === storage.token @@ -467,8 +471,16 @@ $(function () { // Restore the tree from storage $('#pma_navigation_tree_content').html(storage.navTree); $('div.pageselector.dbselector').html(storage.page); + $('#pma_navigation_db_select').html(storage.navSelect); } } + + if ($('#pma_navigation_tree').hasClass('synced')) { + if ($("#navi_db_select").length) { + $("#navi_db_select").val(PMA_commonParams.get('db')); + } + PMA_showCurrentNavigation(); + } }); /** @@ -484,6 +496,7 @@ function navTreeStateUpdate() { // content to be stored exceeds storage capacity try { storage.setItem('navTree', $('#pma_navigation_tree_content').html()); + storage.setItem('navSelect', $('#pma_navigation_db_select').html()); storage.setItem('server', PMA_commonParams.get('server')); storage.setItem('token', PMA_commonParams.get('token')); storage.setItem('page', $('div.pageselector.dbselector').html()); @@ -492,6 +505,7 @@ function navTreeStateUpdate() { // state is no more valid, so remove it storage.removeItem('navTree'); storage.removeItem('server'); + storage.removeItem('navSelect'); storage.removeItem('token'); storage.removeItem('page'); } @@ -604,8 +618,11 @@ function PMA_showCurrentNavigation() { handleTableOrDb(table, $dbItem); } } else { - if (! PMA_commonParams.get('show_navigation_as_tree')) { + if ($('#navi_db_select').length + && $('option:selected', $('#navi_db_select')).length + ) { loadChildNodes(false, $('option:selected', $('#navi_db_select')), function (data) { + navTreeStateUpdate(); return; }); return; @@ -849,17 +866,12 @@ function PMA_navigationTreePagination($this) { if (typeof data !== 'undefined' && data.success) { if (isDbSelector) { var val = PMA_fastFilter.getSearchClause(); - if (PMA_commonParams.get('show_navigation_as_tree')) { - var $div_elem = $('#pma_navigation_tree'); - } else { - var $div_elem = $('#pma_navigation_select_database'); - } - $div_elem + $('#pma_navigation_tree') .html(data.message) .children('div') .show(); if (val) { - $div_elem + $('#pma_navigation_tree') .find('li.fast_filter input.searchClause') .val(val); } diff --git a/libraries/navigation/NavigationTree.class.php b/libraries/navigation/NavigationTree.class.php index cb4ead3d76..31ec6474ea 100644 --- a/libraries/navigation/NavigationTree.class.php +++ b/libraries/navigation/NavigationTree.class.php @@ -1170,6 +1170,7 @@ class PMA_NavigationTree 'token' => $_SESSION[' PMA_token '], 'server' => $GLOBALS['server'] ); + $retval .= '
'; $retval .= '
'; $retval .= PMA_getHiddenFields($url_params); $retval .= '
'; - $retval .= '
'; + $retval .= '
'; return $retval; } diff --git a/themes/original/css/navigation.css.php b/themes/original/css/navigation.css.php index 252760b7de..08c325c9f5 100644 --- a/themes/original/css/navigation.css.php +++ b/themes/original/css/navigation.css.php @@ -120,8 +120,33 @@ if (! defined('PMA_MINIMUM_COMMON') && ! defined('TESTSUITE')) { height: 74%; position: relative; } + #pma_navigation_select_database { + text-align: left; + padding: 0px 0px 0px; + border: 0; + margin: 0; } + +#pma_navigation_db_select { + margin-top: 0.5em; + border-: 1px solid #666; + margin-: 0.75em; +} +#pma_navigation_db_select select { + background: url("./themes/pmahomme/img/select_bg.png") repeat scroll 0 0; + -webkit-border-radius: 2px; + border-radius: 2px; + border: 1px solid #bbb; + border-left: 0px; + border-top: 1px solid #bbb; + color: #333; + padding: 4px 6px; + margin: 0px 0px 0.5em; + width: 92%; + font-size: 1.11em; +} + #pma_navigation_tree_content { width: 100%; overflow: hidden; diff --git a/themes/pmahomme/css/navigation.css.php b/themes/pmahomme/css/navigation.css.php index 9c1713c8c8..fdb392f971 100644 --- a/themes/pmahomme/css/navigation.css.php +++ b/themes/pmahomme/css/navigation.css.php @@ -107,7 +107,31 @@ if (! defined('PMA_MINIMUM_COMMON') && ! defined('TESTSUITE')) { position: relative; } #pma_navigation_select_database { + text-align: left; + padding: 0px 0px 0px; + border: 0; + margin: 0; } + +#pma_navigation_db_select { + margin-top: 0.5em; + border-: 1px solid #666; + margin-: 0.75em; +} +#pma_navigation_db_select select { + background: url("./themes/pmahomme/img/select_bg.png") repeat scroll 0 0; + -webkit-border-radius: 2px; + border-radius: 2px; + border: 1px solid #bbb; + border-left: 0px; + border-top: 1px solid #bbb; + color: #333; + padding: 4px 6px; + margin: 0px 0px 0.5em; + width: 92%; + font-size: 1.11em; +} + #pma_navigation_tree_content { width: 100%; overflow: hidden; diff --git a/themes/pmahomme/img/select_bg.png b/themes/pmahomme/img/select_bg.png new file mode 100644 index 0000000000000000000000000000000000000000..210e97c1f73d238d6856ff65b5663316be3baad4 GIT binary patch literal 303 zcmeAS@N?(olHy`uVBq!ia0vp^OhBB%!VDziO#cJ`DaPU;cPEB*=VV?2Il2KpA+CS_ z{{8ah%g>)b|NZ;-`}gl3KYo1u`t{SNPk;XW`TqU;w{PD*fByXI*RTKo|9|}WahCq7 zIG{$(0*}aI1_o|n5N2eUHAey{$X?><>&kwgQAAvsQ8qzd0Vver>Eal|aXq$gA@5-W z5f^zLUA}KDk%|Ue6gDhb!aPNkHKnzJp;<3MK;1xUv zP8~YZZ7ki%Z9UUn`Lgv)ONp7DoGo<#I%Cixvqh7!r|*X01+#Ng@b=d#Wzp$PyDa)HhO literal 0 HcmV?d00001 From 7d60c8c6f9eecda1c876d4ee24cd7f50aca56782 Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Fri, 23 Jan 2015 22:53:41 +0530 Subject: [PATCH 7/7] more js linkages for db-specific tree with select box Signed-off-by: Atul Pratap Singh --- js/common.js | 10 ++- js/navigation.js | 77 +++++++++++++------ libraries/navigation/Navigation.class.php | 1 - libraries/navigation/NavigationTree.class.php | 37 +++++---- libraries/navigation/Nodes/Node.class.php | 2 - themes/original/css/navigation.css.php | 4 +- themes/pmahomme/css/navigation.css.php | 4 +- 7 files changed, 86 insertions(+), 49 deletions(-) diff --git a/js/common.js b/js/common.js index ed7b44d551..44bfaaac9e 100644 --- a/js/common.js +++ b/js/common.js @@ -31,11 +31,11 @@ var PMA_commonParams = (function () { var updateNavigation = false; for (var i in obj) { if (params[i] !== undefined && params[i] !== obj[i]) { + if (i == 'db' || i == 'table') { + updateNavigation = true; + } reload = true; } - if (i == 'db' || i == 'table') { - updateNavigation = true; - } params[i] = obj[i]; } if (updateNavigation && @@ -65,7 +65,9 @@ var PMA_commonParams = (function () { */ set: function (name, value) { var updateNavigation = false; - if (name == 'db' || name == 'table') { + if (name == 'db' || name == 'table' + && params[name] !== value + ) { updateNavigation = true; } params[name] = value; diff --git a/js/navigation.js b/js/navigation.js index 17d10b3ac0..47fd49aedd 100644 --- a/js/navigation.js +++ b/js/navigation.js @@ -48,13 +48,18 @@ function loadChildNodes(isNode, $expandElem, callback) { $.get(url, params, function (data) { if (typeof data !== 'undefined' && data.success === true) { $destination.find('div.list_container').remove(); // FIXME: Hack, there shouldn't be a list container there - $destination.append(data.message); if (isNode) { + $destination.append(data.message); $expandElem.addClass('loaded'); } else { + $destination.html(data.message); $destination.children() .first() - .css({border: '0px', margin: '0em', padding : '0em'}) + .css({ + border: '0px', + margin: '0em', + padding : '0em' + }) .slideDown('slow'); } if (data._debug){ @@ -617,15 +622,23 @@ function PMA_showCurrentNavigation() { } else { handleTableOrDb(table, $dbItem); } - } else { - if ($('#navi_db_select').length + } else if ($('#navi_db_select').length && $('option:selected', $('#navi_db_select')).length + ) { + if (! PMA_selectCurrentDb()) { + return; + } + // If loaded database in navigation is not same as current one + if ( $('#pma_navigation_tree_content span.loaded_db:first').text() + !== $('#navi_db_select').val() ) { loadChildNodes(false, $('option:selected', $('#navi_db_select')), function (data) { - navTreeStateUpdate(); - return; + handleTableOrDb(table, $('#pma_navigation_tree_content')); + var $children = $('#pma_navigation_tree_content').children('div.list_container'); + $children.promise().done(navTreeStateUpdate); }); - return; + } else { + handleTableOrDb(table, $('#pma_navigation_tree_content')); } } } @@ -639,6 +652,7 @@ function PMA_showCurrentNavigation() { var $tableContainer = $container.children('ul').children('li.tableContainer'); if ($tableContainer.length > 0) { var $expander = $tableContainer.children('div:first').children('a.expander'); + $tableContainer.addClass('selected'); expandTreeNode($expander, function () { scrollToView($dbItem, true); }); @@ -772,8 +786,13 @@ function PMA_showCurrentNavigation() { function PMA_reloadNavigation(callback) { var params = { reload: true, - pos: $('#pma_navigation_tree').find('a.expander:first > span.pos').text() + pos: $('#pma_navigation_tree div.dbselector select').val() }; + if ($('#navi_db_select').length) { + params.db = PMA_commonParams.get('db'); + requestNaviReload(params); + return; + } // Traverse the navigation tree backwards to generate all the actual // and virtual paths, as well as the positions in the pagination at // various levels, if necessary. @@ -810,22 +829,36 @@ function PMA_reloadNavigation(callback) { count++; } }); - var url = $('#pma_navigation').find('a.navigation_url').attr('href'); - $.post(url, params, function (data) { - if (typeof data !== 'undefined' && data.success) { - $('#pma_navigation_tree').html(data.message).children('div').show(); - if ($('#pma_navigation_tree').hasClass('synced')) { - PMA_showCurrentNavigation(); + requestNaviReload(params); + function requestNaviReload(params) { + var url = $('#pma_navigation').find('a.navigation_url').attr('href'); + $.post(url, params, function (data) { + if (typeof data !== 'undefined' && data.success) { + $('#pma_navigation_tree').html(data.message).children('div').show(); + if ($('#pma_navigation_tree').hasClass('synced')) { + PMA_selectCurrentDb(); + PMA_showCurrentNavigation(); + } + // Fire the callback, if any + if (typeof callback === 'function') { + callback.call(); + } + navTreeStateUpdate(); + } else { + PMA_ajaxShowMessage(data.error); } - // Fire the callback, if any - if (typeof callback === 'function') { - callback.call(); - } - navTreeStateUpdate(); - } else { - PMA_ajaxShowMessage(data.error); + }); + } +} + +function PMA_selectCurrentDb() { + if ($('#navi_db_select').length) { + $('#navi_db_select').val(PMA_commonParams.get('db')); + if ($('#navi_db_select').val() !== PMA_commonParams.get('db')) { + return false; } - }); + return true; + } } /** diff --git a/libraries/navigation/Navigation.class.php b/libraries/navigation/Navigation.class.php index 3deaff09a1..39b6180a88 100644 --- a/libraries/navigation/Navigation.class.php +++ b/libraries/navigation/Navigation.class.php @@ -36,7 +36,6 @@ class PMA_Navigation } $tree = new PMA_NavigationTree(); if ($GLOBALS['cfg']['ShowNavigationAsTree'] - // || $GLOBALS['db'] == '' ) { if (! PMA_Response::getInstance()->isAjax() || ! empty($_REQUEST['full']) diff --git a/libraries/navigation/NavigationTree.class.php b/libraries/navigation/NavigationTree.class.php index 31ec6474ea..79711d20a4 100644 --- a/libraries/navigation/NavigationTree.class.php +++ b/libraries/navigation/NavigationTree.class.php @@ -630,7 +630,6 @@ class PMA_NavigationTree { if ($node->type != Node::CONTAINER || $GLOBALS['cfg']['NavigationTreeDisableDatabaseExpansion'] - //|| ! $GLOBALS['cfg']['ShowNavigationAsTree'] ) { return; } @@ -775,7 +774,6 @@ class PMA_NavigationTree $retval .= '
    '; $retval .= $this->_fastFilterHtml($this->_tree); if (! $GLOBALS['cfg']['NavigationTreeDisableDatabaseExpansion'] - //|| ! $GLOBALS['cfg']['ShowNavigationAsTree'] ) { $retval .= $this->_controls(); } @@ -814,21 +812,30 @@ class PMA_NavigationTree $this->groupTree(); $retval = ""; } @@ -1165,7 +1172,7 @@ class PMA_NavigationTree array('dbselector') ); $children = $this->_tree->children; - $node = $children[0]; + array_shift($children); $url_params = array( 'token' => $_SESSION[' PMA_token '], 'server' => $GLOBALS['server'] @@ -1190,14 +1197,16 @@ class PMA_NavigationTree $retval .= ' selected="selected"'; } $retval .= '>' . htmlspecialchars($node->real_name); - //if (! empty($db['num_tables'])) { - // $return .= ' (' . $db['num_tables'] . ')'; - //} $retval .= ''; } } $retval .= ''; - $retval .= '
    '; + $retval .= ''; + $retval .= '
    '; + $retval .= '
    '; + $retval .= __('Please select a database.'); + $retval .= '
    '; + $retval .= '
    '; return $retval; } diff --git a/libraries/navigation/Nodes/Node.class.php b/libraries/navigation/Nodes/Node.class.php index c4ae81668b..2c55f3504c 100644 --- a/libraries/navigation/Nodes/Node.class.php +++ b/libraries/navigation/Nodes/Node.class.php @@ -716,7 +716,6 @@ class Node public function getCssClasses($match) { if ($GLOBALS['cfg']['NavigationTreeDisableDatabaseExpansion'] - //|| ! $GLOBALS['cfg']['ShowNavigationAsTree'] ) { return ''; } @@ -743,7 +742,6 @@ class Node public function getIcon($match) { if ($GLOBALS['cfg']['NavigationTreeDisableDatabaseExpansion'] - //|| ! $GLOBALS['cfg']['ShowNavigationAsTree'] ) { return ''; } elseif ($match && ! $this->is_group) { diff --git a/themes/original/css/navigation.css.php b/themes/original/css/navigation.css.php index 08c325c9f5..d3cc4754eb 100644 --- a/themes/original/css/navigation.css.php +++ b/themes/original/css/navigation.css.php @@ -130,7 +130,6 @@ if (! defined('PMA_MINIMUM_COMMON') && ! defined('TESTSUITE')) { #pma_navigation_db_select { margin-top: 0.5em; - border-: 1px solid #666; margin-: 0.75em; } #pma_navigation_db_select select { @@ -138,11 +137,10 @@ if (! defined('PMA_MINIMUM_COMMON') && ! defined('TESTSUITE')) { -webkit-border-radius: 2px; border-radius: 2px; border: 1px solid #bbb; - border-left: 0px; border-top: 1px solid #bbb; color: #333; padding: 4px 6px; - margin: 0px 0px 0.5em; + margin: 0px 0px 0px; width: 92%; font-size: 1.11em; } diff --git a/themes/pmahomme/css/navigation.css.php b/themes/pmahomme/css/navigation.css.php index fdb392f971..3ea9d9aaa1 100644 --- a/themes/pmahomme/css/navigation.css.php +++ b/themes/pmahomme/css/navigation.css.php @@ -115,7 +115,6 @@ if (! defined('PMA_MINIMUM_COMMON') && ! defined('TESTSUITE')) { #pma_navigation_db_select { margin-top: 0.5em; - border-: 1px solid #666; margin-: 0.75em; } #pma_navigation_db_select select { @@ -123,11 +122,10 @@ if (! defined('PMA_MINIMUM_COMMON') && ! defined('TESTSUITE')) { -webkit-border-radius: 2px; border-radius: 2px; border: 1px solid #bbb; - border-left: 0px; border-top: 1px solid #bbb; color: #333; padding: 4px 6px; - margin: 0px 0px 0.5em; + margin: 0px 0px 0px; width: 92%; font-size: 1.11em; }