From 989161e2bdf7a7e907e4da48beba16433ad6fcb1 Mon Sep 17 00:00:00 2001 From: Kasun Chathuranga Date: Mon, 29 Jul 2013 17:03:35 +0530 Subject: [PATCH 1/2] Move common code to a common ancestor --- .../Nodes/Node_DatabaseChild.class.php | 52 +++++++++++++++++++ .../navigation/Nodes/Node_Event.class.php | 27 +++------- .../navigation/Nodes/Node_Function.class.php | 27 +++------- .../navigation/Nodes/Node_Procedure.class.php | 27 +++------- .../navigation/Nodes/Node_Table.class.php | 27 +++------- .../navigation/Nodes/Node_View.class.php | 27 +++------- 6 files changed, 87 insertions(+), 100 deletions(-) create mode 100644 libraries/navigation/Nodes/Node_DatabaseChild.class.php diff --git a/libraries/navigation/Nodes/Node_DatabaseChild.class.php b/libraries/navigation/Nodes/Node_DatabaseChild.class.php new file mode 100644 index 0000000000..dbd1aaed61 --- /dev/null +++ b/libraries/navigation/Nodes/Node_DatabaseChild.class.php @@ -0,0 +1,52 @@ +realParent()->real_name; + $item = $this->real_name; + $ret = '' + . '' + . PMA_Util::getImage('b_close', 'Hide') + . ''; + } + return $ret; + } + + /** + * Returns the type of the item reprsented by the node. + * + * @return string type of the item + */ + protected abstract function getItemType(); +} +?> \ No newline at end of file diff --git a/libraries/navigation/Nodes/Node_Event.class.php b/libraries/navigation/Nodes/Node_Event.class.php index 80b81c6081..4c5039a3e2 100644 --- a/libraries/navigation/Nodes/Node_Event.class.php +++ b/libraries/navigation/Nodes/Node_Event.class.php @@ -9,12 +9,14 @@ if (! defined('PHPMYADMIN')) { exit; } +require_once 'libraries/navigation/Nodes/Node_DatabaseChild.class.php'; + /** * Represents a event node in the navigation tree * * @package PhpMyAdmin-Navigation */ -class Node_Event extends Node +class Node_Event extends Node_DatabaseChild { /** * Initialises the class @@ -63,28 +65,13 @@ class Node_Event extends Node } /** - * Returns HTML for hide button displayed infront of the event node + * Returns the type of the item represented by the node. * - * @return HTML for hide button + * @return string type of the item */ - public function getHtmlForControlButtons() + protected function getItemType() { - $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; + return 'event'; } } diff --git a/libraries/navigation/Nodes/Node_Function.class.php b/libraries/navigation/Nodes/Node_Function.class.php index 7c18a376ef..d097dfd88f 100644 --- a/libraries/navigation/Nodes/Node_Function.class.php +++ b/libraries/navigation/Nodes/Node_Function.class.php @@ -9,12 +9,14 @@ if (! defined('PHPMYADMIN')) { exit; } +require_once 'libraries/navigation/Nodes/Node_DatabaseChild.class.php'; + /** * Represents a function node in the navigation tree * * @package PhpMyAdmin-Navigation */ -class Node_Function extends Node +class Node_Function extends Node_DatabaseChild { /** * Initialises the class @@ -64,28 +66,13 @@ class Node_Function extends Node } /** - * Returns HTML for hide button displayed infront of the function node + * Returns the type of the item represented by the node. * - * @return HTML for hide button + * @return string type of the item */ - public function getHtmlForControlButtons() + protected function getItemType() { - $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; + return 'function'; } } diff --git a/libraries/navigation/Nodes/Node_Procedure.class.php b/libraries/navigation/Nodes/Node_Procedure.class.php index 3b1ba3a0ee..f12240379f 100644 --- a/libraries/navigation/Nodes/Node_Procedure.class.php +++ b/libraries/navigation/Nodes/Node_Procedure.class.php @@ -9,12 +9,14 @@ if (! defined('PHPMYADMIN')) { exit; } +require_once 'libraries/navigation/Nodes/Node_DatabaseChild.class.php'; + /** * Represents a procedure node in the navigation tree * * @package PhpMyAdmin-Navigation */ -class Node_Procedure extends Node +class Node_Procedure extends Node_DatabaseChild { /** * Initialises the class @@ -64,28 +66,13 @@ class Node_Procedure extends Node } /** - * Returns HTML for hide button displayed infront of the table node + * Returns the type of the item represented by the node. * - * @return HTML for hide button + * @return string type of the item */ - public function getHtmlForControlButtons() + protected function getItemType() { - $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; + return 'procedure'; } } diff --git a/libraries/navigation/Nodes/Node_Table.class.php b/libraries/navigation/Nodes/Node_Table.class.php index c3c1eca783..211d0d88b8 100644 --- a/libraries/navigation/Nodes/Node_Table.class.php +++ b/libraries/navigation/Nodes/Node_Table.class.php @@ -9,12 +9,14 @@ if (! defined('PHPMYADMIN')) { exit; } +require_once 'libraries/navigation/Nodes/Node_DatabaseChild.class.php'; + /** * Represents a columns node in the navigation tree * * @package PhpMyAdmin-Navigation */ -class Node_Table extends Node +class Node_Table extends Node_DatabaseChild { /** * Initialises the class @@ -232,28 +234,13 @@ class Node_Table extends Node } /** - * Returns HTML for hide button displayed infront of the table node + * Returns the type of the item represented by the node. * - * @return HTML for hide button + * @return string type of the item */ - public function getHtmlForControlButtons() + protected function getItemType() { - $ret = ''; - $cfgRelation = PMA_getRelationsParam(); - if ($cfgRelation['navwork']) { - $db = $this->realParent()->real_name; - $table = $this->real_name; - $ret = '' - . '' - . PMA_Util::getImage('b_close', 'Hide') - . ''; - } - return $ret; + return 'table'; } } diff --git a/libraries/navigation/Nodes/Node_View.class.php b/libraries/navigation/Nodes/Node_View.class.php index 7f40f6c8fb..8e02f4ee3d 100644 --- a/libraries/navigation/Nodes/Node_View.class.php +++ b/libraries/navigation/Nodes/Node_View.class.php @@ -9,12 +9,14 @@ if (! defined('PHPMYADMIN')) { exit; } +require_once 'libraries/navigation/Nodes/Node_DatabaseChild.class.php'; + /** * Represents a view node in the navigation tree * * @package PhpMyAdmin-Navigation */ -class Node_View extends Node +class Node_View extends Node_DatabaseChild { /** * Initialises the class @@ -41,28 +43,13 @@ class Node_View extends Node } /** - * Returns HTML for hide button displayed infront of the view node + * Returns the type of the item represented by the node. * - * @return HTML for hide button + * @return string type of the item */ - public function getHtmlForControlButtons() + protected function getItemType() { - $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; + return 'view'; } } From b76a1e27a95ea59edb0f3ec21229efca471f6d91 Mon Sep 17 00:00:00 2001 From: Kasun Chathuranga Date: Mon, 29 Jul 2013 17:26:11 +0530 Subject: [PATCH 2/2] Fix comment --- libraries/navigation/Nodes/Node_DatabaseChild.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/navigation/Nodes/Node_DatabaseChild.class.php b/libraries/navigation/Nodes/Node_DatabaseChild.class.php index dbd1aaed61..e080e4ab37 100644 --- a/libraries/navigation/Nodes/Node_DatabaseChild.class.php +++ b/libraries/navigation/Nodes/Node_DatabaseChild.class.php @@ -17,7 +17,7 @@ if (! defined('PHPMYADMIN')) { abstract class Node_DatabaseChild extends Node { /** - * Returns HTML for hide button displayed infront of the table node + * Returns HTML for hide button displayed infront of the database child node * * @return HTML for hide button */ @@ -49,4 +49,4 @@ abstract class Node_DatabaseChild extends Node */ protected abstract function getItemType(); } -?> \ No newline at end of file +?>