From 56b5c8e294bc7b8a91eed65b641b7f71e2e45e3f Mon Sep 17 00:00:00 2001 From: Kasun Chathuranga Date: Mon, 22 Jul 2013 08:18:21 +0530 Subject: [PATCH] Extend navigation tree item hiding to functions. procedures, events and views --- js/navigation.js | 13 ++--- libraries/navigation/Navigation.class.php | 52 +++++++++++-------- .../navigation/Nodes/Node_Database.class.php | 32 ++++++------ .../navigation/Nodes/Node_Event.class.php | 25 +++++++++ .../navigation/Nodes/Node_Function.class.php | 25 +++++++++ .../navigation/Nodes/Node_Procedure.class.php | 25 +++++++++ .../navigation/Nodes/Node_Table.class.php | 2 +- .../navigation/Nodes/Node_View.class.php | 25 +++++++++ 8 files changed, 151 insertions(+), 48 deletions(-) diff --git a/js/navigation.js b/js/navigation.js index dc0cfbc036..e1cb8b848b 100644 --- a/js/navigation.js +++ b/js/navigation.js @@ -179,13 +179,6 @@ $(function () { dialog.editorDialog(0, $(this)); }); - /** Export Routines, Triggers and Events */ - $('li.procedure a.ajax img, li.function a.ajax img, li.trigger a.ajax img, li.event a.ajax img').live('click', function (event) { - event.preventDefault(); - var dialog = new RTE.object(); - dialog.exportDialog($(this).parent()); - }); - /** New index */ $('li.new_index a.ajax').live('click', function (event) { event.preventDefault(); @@ -213,7 +206,7 @@ $(function () { }); /** Hide navigation tree item */ - $('.hideNavItem').live('click', function (event) { + $('a.hideNavItem.ajax').live('click', function (event) { event.preventDefault(); $.ajax({ url: $(this).attr('href') + '&ajax_request=true', @@ -228,7 +221,7 @@ $(function () { }); /** Show a dialog to choose navigation items to unhide */ - $('.showUnhide').live('click', function (event) { + $('a.showUnhide.ajax').live('click', function (event) { event.preventDefault(); var $msg = PMA_ajaxShowMessage(); $.get($(this).attr('href') + '&ajax_request=1', function (data) { @@ -258,7 +251,7 @@ $(function () { }); /** Unhide a hidden navigation tree item */ - $('.unhideNavItem').live('click', function (event) { + $('a.unhideNavItem.ajax').live('click', function (event) { event.preventDefault(); var $tr = $(this).parents('tr'); var $msg = PMA_ajaxShowMessage(); diff --git a/libraries/navigation/Navigation.class.php b/libraries/navigation/Navigation.class.php index bdaff5221f..a423b8caf3 100644 --- a/libraries/navigation/Navigation.class.php +++ b/libraries/navigation/Navigation.class.php @@ -98,7 +98,7 @@ class PMA_Navigation . "'" . PMA_Util::sqlAddSlashes($dbName) . "'," . "'" . (! empty($tableName)? PMA_Util::sqlAddSlashes($tableName) : "" ) . "')"; - PMA_queryAsControlUser($sqlQuery, true); + PMA_queryAsControlUser($sqlQuery, false); } /** @@ -128,7 +128,7 @@ class PMA_Navigation ? " AND `table_name`='" . PMA_Util::sqlAddSlashes($tableName) . "'" : "" ); - PMA_queryAsControlUser($sqlQuery, true); + PMA_queryAsControlUser($sqlQuery, false); } /** @@ -154,7 +154,7 @@ class PMA_Navigation . " AND `db_name`='" . PMA_Util::sqlAddSlashes($dbName) . "'" . " AND `table_name`='" . (! empty($tableName) ? PMA_Util::sqlAddSlashes($tableName) : '') . "'"; - $result = PMA_queryAsControlUser($sqlQuery, true); + $result = PMA_queryAsControlUser($sqlQuery, false); $hidden = array(); if ($result) { @@ -168,26 +168,36 @@ class PMA_Navigation } $GLOBALS['dbi']->freeResult($result); + $typeMap = array( + 'event' => __('Events:'), + 'function' => __('Functions:'), + 'procedure' => __('Procedures:'), + 'table' => __('Tables:'), + 'view' => __('Views:'), + ); if (empty($tableName)) { - if ((empty($itemType) || $itemType == 'table') - && isset($hidden['table']) - ) { - $html .= '

' . __('Tables:') . '

'; - $html .= ''; - $odd = true; - foreach ($hidden['table'] as $hiddenTable) { - $html .= ''; - $html .= ''; - $html .= ''; + foreach ($typeMap as $t => $lable) { + if ((empty($itemType) || $itemType == $t) + && isset($hidden[$t]) + ) { + $html .= '

' . $lable . '

'; + $html .= '
' . $hiddenTable . '' - . PMA_Util::getIcon('b_undo.png', __('Unhide')) - . '
'; + $odd = true; + foreach ($hidden[$t] as $hiddenItem) { + $html .= ''; + $html .= ''; + $html .= ''; + } + $html .= '
' . $hiddenItem . '' + . PMA_Util::getIcon('b_undo.png', __('Unhide')) + . '
'; } - $html .= ''; } } diff --git a/libraries/navigation/Nodes/Node_Database.class.php b/libraries/navigation/Nodes/Node_Database.class.php index af69874746..ab08d63406 100644 --- a/libraries/navigation/Nodes/Node_Database.class.php +++ b/libraries/navigation/Nodes/Node_Database.class.php @@ -234,10 +234,10 @@ class Node_Database extends Node switch ($type) { case 'tables': if (! $GLOBALS['cfg']['Servers'][$GLOBALS['server']]['DisableIS']) { - $db = PMA_Util::sqlAddSlashes($db); + $escdDb = PMA_Util::sqlAddSlashes($db); $query = "SELECT `TABLE_NAME` AS `name` "; $query .= "FROM `INFORMATION_SCHEMA`.`TABLES` "; - $query .= "WHERE `TABLE_SCHEMA`='$db' "; + $query .= "WHERE `TABLE_SCHEMA`='$escdDb' "; $query .= "AND `TABLE_TYPE`='BASE TABLE' "; if (! empty($searchClause)) { $query .= "AND `TABLE_NAME` LIKE '%"; @@ -277,10 +277,10 @@ class Node_Database extends Node break; case 'views': if (! $GLOBALS['cfg']['Servers'][$GLOBALS['server']]['DisableIS']) { - $db = PMA_Util::sqlAddSlashes($db); + $escdDb = PMA_Util::sqlAddSlashes($db); $query = "SELECT `TABLE_NAME` AS `name` "; $query .= "FROM `INFORMATION_SCHEMA`.`TABLES` "; - $query .= "WHERE `TABLE_SCHEMA`='$db' "; + $query .= "WHERE `TABLE_SCHEMA`='$escdDb' "; $query .= "AND `TABLE_TYPE`!='BASE TABLE' "; if (! empty($searchClause)) { $query .= "AND `TABLE_NAME` LIKE '%"; @@ -320,10 +320,10 @@ class Node_Database extends Node break; case 'procedures': if (! $GLOBALS['cfg']['Servers'][$GLOBALS['server']]['DisableIS']) { - $db = PMA_Util::sqlAddSlashes($db); + $escdDb = PMA_Util::sqlAddSlashes($db); $query = "SELECT `ROUTINE_NAME` AS `name` "; $query .= "FROM `INFORMATION_SCHEMA`.`ROUTINES` "; - $query .= "WHERE `ROUTINE_SCHEMA`='$db'"; + $query .= "WHERE `ROUTINE_SCHEMA`='$escdDb'"; $query .= "AND `ROUTINE_TYPE`='PROCEDURE' "; if (! empty($searchClause)) { $query .= "AND `ROUTINE_NAME` LIKE '%"; @@ -336,8 +336,8 @@ class Node_Database extends Node $query .= "LIMIT " . intval($pos) . ", $maxItems"; $retval = $GLOBALS['dbi']->fetchResult($query); } else { - $db = PMA_Util::sqlAddSlashes($db); - $query = "SHOW PROCEDURE STATUS WHERE `Db`='$db' "; + $escdDb = PMA_Util::sqlAddSlashes($db); + $query = "SHOW PROCEDURE STATUS WHERE `Db`='$escdDb' "; if (! empty($searchClause)) { $query .= "AND `Name` LIKE '%"; $query .= PMA_Util::sqlAddSlashes( @@ -360,10 +360,10 @@ class Node_Database extends Node break; case 'functions': if (! $GLOBALS['cfg']['Servers'][$GLOBALS['server']]['DisableIS']) { - $db = PMA_Util::sqlAddSlashes($db); + $escdDb = PMA_Util::sqlAddSlashes($db); $query = "SELECT `ROUTINE_NAME` AS `name` "; $query .= "FROM `INFORMATION_SCHEMA`.`ROUTINES` "; - $query .= "WHERE `ROUTINE_SCHEMA`='$db' "; + $query .= "WHERE `ROUTINE_SCHEMA`='$escdDb' "; $query .= "AND `ROUTINE_TYPE`='FUNCTION' "; if (! empty($searchClause)) { $query .= "AND `ROUTINE_NAME` LIKE '%"; @@ -376,8 +376,8 @@ class Node_Database extends Node $query .= "LIMIT " . intval($pos) . ", $maxItems"; $retval = $GLOBALS['dbi']->fetchResult($query); } else { - $db = PMA_Util::sqlAddSlashes($db); - $query = "SHOW FUNCTION STATUS WHERE `Db`='$db' "; + $escdDb = PMA_Util::sqlAddSlashes($db); + $query = "SHOW FUNCTION STATUS WHERE `Db`='$escdDb' "; if (! empty($searchClause)) { $query .= "AND `Name` LIKE '%"; $query .= PMA_Util::sqlAddSlashes( @@ -400,10 +400,10 @@ class Node_Database extends Node break; case 'events': if (! $GLOBALS['cfg']['Servers'][$GLOBALS['server']]['DisableIS']) { - $db = PMA_Util::sqlAddSlashes($db); + $escdDb = PMA_Util::sqlAddSlashes($db); $query = "SELECT `EVENT_NAME` AS `name` "; $query .= "FROM `INFORMATION_SCHEMA`.`EVENTS` "; - $query .= "WHERE `EVENT_SCHEMA`='$db' "; + $query .= "WHERE `EVENT_SCHEMA`='$escdDb' "; if (! empty($searchClause)) { $query .= "AND `EVENT_NAME` LIKE '%"; $query .= PMA_Util::sqlAddSlashes( @@ -415,8 +415,8 @@ class Node_Database extends Node $query .= "LIMIT " . intval($pos) . ", $maxItems"; $retval = $GLOBALS['dbi']->fetchResult($query); } else { - $db = PMA_Util::backquote($db); - $query = "SHOW EVENTS FROM $db "; + $escdDb = PMA_Util::backquote($db); + $query = "SHOW EVENTS FROM $escdDb "; if (! empty($searchClause)) { $query .= "WHERE `Name` LIKE '%"; $query .= PMA_Util::sqlAddSlashes( diff --git a/libraries/navigation/Nodes/Node_Event.class.php b/libraries/navigation/Nodes/Node_Event.class.php index f3c9e536b0..80b81c6081 100644 --- a/libraries/navigation/Nodes/Node_Event.class.php +++ b/libraries/navigation/Nodes/Node_Event.class.php @@ -61,6 +61,31 @@ class Node_Event extends Node $query .= "AND `EVENT_NAME`='$event' "; return $GLOBALS['dbi']->fetchValue($query); } + + /** + * Returns HTML for hide button displayed infront of the event node + * + * @return HTML for hide button + */ + public function getHtmlForControlButtons() + { + $ret = ''; + $cfgRelation = PMA_getRelationsParam(); + if ($cfgRelation['navwork']) { + $db = $this->realParent()->real_name; + $event = $this->real_name; + $ret = '' + . '' + . PMA_Util::getImage('b_close', 'Hide') + . ''; + } + return $ret; + } } ?> diff --git a/libraries/navigation/Nodes/Node_Function.class.php b/libraries/navigation/Nodes/Node_Function.class.php index 9f63d63cb5..7c18a376ef 100644 --- a/libraries/navigation/Nodes/Node_Function.class.php +++ b/libraries/navigation/Nodes/Node_Function.class.php @@ -62,6 +62,31 @@ class Node_Function extends Node $query .= "AND `ROUTINE_TYPE`='FUNCTION' "; return $GLOBALS['dbi']->fetchValue($query); } + + /** + * Returns HTML for hide button displayed infront of the function node + * + * @return HTML for hide button + */ + public function getHtmlForControlButtons() + { + $ret = ''; + $cfgRelation = PMA_getRelationsParam(); + if ($cfgRelation['navwork']) { + $db = $this->realParent()->real_name; + $function = $this->real_name; + $ret = '' + . '' + . PMA_Util::getImage('b_close', 'Hide') + . ''; + } + return $ret; + } } ?> diff --git a/libraries/navigation/Nodes/Node_Procedure.class.php b/libraries/navigation/Nodes/Node_Procedure.class.php index 6e48ea903e..3b1ba3a0ee 100644 --- a/libraries/navigation/Nodes/Node_Procedure.class.php +++ b/libraries/navigation/Nodes/Node_Procedure.class.php @@ -62,6 +62,31 @@ class Node_Procedure extends Node $query .= "AND `ROUTINE_TYPE`='PROCEDURE' "; return $GLOBALS['dbi']->fetchValue($query); } + + /** + * Returns HTML for hide button displayed infront of the table node + * + * @return HTML for hide button + */ + public function getHtmlForControlButtons() + { + $ret = ''; + $cfgRelation = PMA_getRelationsParam(); + if ($cfgRelation['navwork']) { + $db = $this->realParent()->real_name; + $procedure = $this->real_name; + $ret = '' + . '' + . PMA_Util::getImage('b_close', 'Hide') + . ''; + } + return $ret; + } } ?> diff --git a/libraries/navigation/Nodes/Node_Table.class.php b/libraries/navigation/Nodes/Node_Table.class.php index a95c55eb89..c3c1eca783 100644 --- a/libraries/navigation/Nodes/Node_Table.class.php +++ b/libraries/navigation/Nodes/Node_Table.class.php @@ -232,7 +232,7 @@ class Node_Table extends Node } /** - * Returns HTML for hide button displayed infront of a node + * Returns HTML for hide button displayed infront of the table node * * @return HTML for hide button */ diff --git a/libraries/navigation/Nodes/Node_View.class.php b/libraries/navigation/Nodes/Node_View.class.php index 3f47579a7e..7f40f6c8fb 100644 --- a/libraries/navigation/Nodes/Node_View.class.php +++ b/libraries/navigation/Nodes/Node_View.class.php @@ -39,6 +39,31 @@ class Node_View extends Node . '&token=' . $GLOBALS['token'] ); } + + /** + * Returns HTML for hide button displayed infront of the view node + * + * @return HTML for hide button + */ + public function getHtmlForControlButtons() + { + $ret = ''; + $cfgRelation = PMA_getRelationsParam(); + if ($cfgRelation['navwork']) { + $db = $this->realParent()->real_name; + $view = $this->real_name; + $ret = '' + . '' + . PMA_Util::getImage('b_close', 'Hide') + . ''; + } + return $ret; + } } ?>