1
0
mirror of https://github.com/phpmyadmin/phpmyadmin.git synced 2026-10-28 07:41:55 +03:00

Hide tables in navigation tree

This commit is contained in:
Kasun Chathuranga
2013-07-20 23:13:25 +05:30
parent 342e0a6b33
commit 66d01fcffb
10 changed files with 120 additions and 5 deletions

View File

@@ -313,8 +313,9 @@ CREATE TABLE IF NOT EXISTS `pma__navigation` (
`username` varchar(64) NOT NULL,
`item_name` varchar(64) NOT NULL,
`item_type` varchar(64) NOT NULL,
`db_name` varchar(64) DEFAULT NULL,
`table_name` varchar(64) DEFAULT NULL
`db_name` varchar(64) NOT NULL,
`table_name` varchar(64) NOT NULL,
PRIMARY KEY (`username`,`item_name`,`item_type`,`db_name`,`table_name`)
)
COMMENT='Hidden items of navigation tree'
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;

View File

@@ -299,8 +299,9 @@ CREATE TABLE IF NOT EXISTS `pma__navigation` (
`username` varchar(64) NOT NULL,
`item_name` varchar(64) NOT NULL,
`item_type` varchar(64) NOT NULL,
`db_name` varchar(64) DEFAULT NULL,
`table_name` varchar(64) DEFAULT NULL
`db_name` varchar(64) NOT NULL,
`table_name` varchar(64) NOT NULL,
PRIMARY KEY (`username`,`item_name`,`item_type`,`db_name`,`table_name`)
)
COMMENT='Hidden items of navigation tree'
COLLATE utf8_bin;

View File

@@ -211,6 +211,21 @@ $(function () {
event.preventDefault();
PMA_createViewDialog($(this));
});
/** Hide navigation tree item */
$('.hideNavItem').live('click', function (event) {
event.preventDefault();
$.ajax({
url: $(this).attr('href') + '&ajax_request=true',
success: function(data) {
if (data.success === true) {
PMA_reloadNavigation();
} else {
PMA_ajaxShowMessage(data.error);
}
}
});
});
});
/**

View File

@@ -949,6 +949,7 @@ class PMA_NavigationTree
if ($node->type == Node::CONTAINER) {
$retval .= "</i>";
}
$retval .= $node->getHtmlForHideButton();
$wrap = true;
} else {
$node->visible = true;

View File

@@ -451,5 +451,14 @@ class Node
return $whereClause;
}
/**
* Returns HTML for hide button displayed infront of a node
*
* @return HTML for hide button
*/
public function getHtmlForHideButton()
{
return '';
}
}
?>

View File

@@ -440,6 +440,31 @@ class Node_Database extends Node
default:
break;
}
// Remove hidden items so that they are not displayed in navigation tree
$cfgRelation = PMA_getRelationsParam();
if ($cfgRelation['navwork']) {
$navTable = PMA_Util::backquote($cfgRelation['db'])
. "." . PMA_Util::backquote($cfgRelation['navigation']);
$sqlQuery = "SELECT `item_name` FROM " . $navTable
. " WHERE `username`='" . $cfgRelation['user'] . "'"
. " AND `item_type`='" . substr($type, 0, -1) . "'"
. " AND `db_name`='" . PMA_Util::sqlAddSlashes($db) . "'";
$result = PMA_queryAsControlUser($sqlQuery, false);
if ($result) {
$hiddenItems = array();
while ($row = $GLOBALS['dbi']->fetchArray($result)) {
$hiddenItems[] = $row[0];
}
foreach ($retval as $key => $item) {
if (in_array($item, $hiddenItems)) {
unset($retval[$key]);
}
}
}
$GLOBALS['dbi']->freeResult($result);
}
return $retval;
}

View File

@@ -230,6 +230,26 @@ class Node_Table extends Node
}
return $retval;
}
/**
* Returns HTML for hide button displayed infront of a node
*
* @return HTML for hide button
*/
public function getHtmlForHideButton()
{
$db = $this->realParent()->real_name;
$table = $this->real_name;
return '<span class="tableControls">'
. '<a href="navigation.php?'
. PMA_generate_common_url()
. '&hideNavItem=true&itemType=table'
. '&itemName=' . urldecode($table)
. '&dbName=' . urldecode($db) . '"'
. ' class="hideNavItem ajax">'
. PMA_Util::getImage('b_close', 'Hide')
. '</a></span>';
}
}
?>

View File

@@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* the navigation frame - displays server, db and table selection tree
* The navigation panel - displays server, db and table selection tree
*
* @package PhpMyAdmin-Navigation
*/
@@ -12,6 +12,25 @@ require_once './libraries/common.inc.php';
// Also initialises the collapsible tree class
require_once './libraries/navigation/Navigation.class.php';
$cfgRelation = PMA_getRelationsParam();
if (isset($_REQUEST['hideNavItem']) && $cfgRelation['navwork']) {
if (! empty($_REQUEST['itemName']) && ! empty($_REQUEST['itemType'])) {
$navTable = PMA_Util::backquote($cfgRelation['db'])
. "." . PMA_Util::backquote($cfgRelation['navigation']);
$sqlQuery = "INSERT INTO " . $navTable
. "(`username`, `item_name`, `item_type`, `db_name`, `table_name`)"
. " VALUES ("
. "'" . $GLOBALS['cfg']['Server']['user'] . "',"
. "'" . $_REQUEST['itemName'] . "',"
. "'" . $_REQUEST['itemType'] . "',"
. "'" . (! empty($_REQUEST['dbName']) ? $_REQUEST['dbName'] : "") . "',"
. "'" . (! empty($_REQUEST['tableName']) ? $_REQUEST['tableName'] : "")
. "')";
PMA_queryAsControlUser($sqlQuery, true);
}
exit;
}
// Do the magic
$response = PMA_Response::getInstance();
if ($response->isAjax()) {

View File

@@ -119,6 +119,18 @@ if (! defined('PMA_MINIMUM_COMMON') && ! defined('TESTSUITE')) {
color: <?php echo $GLOBALS['cfg']['NaviPointerColor']; ?>;
background-color: <?php echo $GLOBALS['cfg']['NaviPointerBackground']; ?>;
}
#pma_navigation_tree li .tableControls {
display: none;
padding-left: 4px;
}
#pma_navigation_tree li.activePointer .tableControls {
display: inline;
opacity: 0.5;
}
#pma_navigation_tree li.activePointer .tableControls:hover {
display: inline;
opacity: 1.0;
}
#pma_navigation_tree ul {
clear: both;
padding: 0;

View File

@@ -104,6 +104,18 @@ if (! defined('PMA_MINIMUM_COMMON') && ! defined('TESTSUITE')) {
color: <?php echo $GLOBALS['cfg']['NaviPointerColor']; ?>;
background-color: <?php echo $GLOBALS['cfg']['NaviPointerBackground']; ?>;
}
#pma_navigation_tree li .tableControls {
display: none;
padding-left: 4px;
}
#pma_navigation_tree li.activePointer .tableControls {
display: inline;
opacity: 0.5;
}
#pma_navigation_tree li.activePointer .tableControls:hover {
display: inline;
opacity: 1.0;
}
#pma_navigation_tree ul {
clear: both;
padding: 0;