Skip to content

Commit

Permalink
Adjust class hierarchy to avoid accessing methods from child classes
Browse files Browse the repository at this point in the history
Signed-off-by: Madhura Jayaratne <madhura.cj@gmail.com>
  • Loading branch information
madhuracj committed Jun 23, 2015
1 parent 312d159 commit 789d9aa
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 23 deletions.
22 changes: 1 addition & 21 deletions libraries/navigation/Nodes/Node.class.php
Expand Up @@ -741,27 +741,7 @@ private function _getWhereClause($columnName, $searchClause = '')
*/
public function getHtmlForControlButtons()
{
$ret = '';
$cfgRelation = PMA_getRelationsParam();
if (isset($cfgRelation['navwork']) && $cfgRelation['navwork']) {
if ($this instanceof Node_DatabaseChild_Container
|| $this instanceof Node_DatabaseChild
) {
$db = $this->realParent()->real_name;
$item = $this->real_name;
$ret = '<span class="navItemControls">'
. '<a href="navigation.php'
. PMA_URL_getCommon()
. '&hideNavItem=true'
. '&itemType=' . urlencode($this->getItemType())
. '&itemName=' . urlencode($item)
. '&dbName=' . urlencode($db) . '"'
. ' class="hideNavItem ajax">'
. PMA_Util::getImage('lightbulb_off.png', __('Hide'))
. '</a></span>';
}
}
return $ret;
return '';
}

/**
Expand Down
30 changes: 29 additions & 1 deletion libraries/navigation/Nodes/Node_DatabaseChild.class.php
Expand Up @@ -10,7 +10,9 @@
}

/**
* Represents a node that is a concrete child of a database node
* Represents a node that is a child of a database node
* This may either be a concrete child such as table or a container
* such as a table group
*
* @package PhpMyAdmin-Navigation
*/
Expand All @@ -22,5 +24,31 @@ abstract class Node_DatabaseChild extends Node
* @return string type of the item
*/
protected abstract function getItemType();

/**
* Returns HTML for control buttons displayed infront of a node
*
* @return String HTML for control buttons
*/
public function getHtmlForControlButtons()
{
$ret = '';
$cfgRelation = PMA_getRelationsParam();
if (isset($cfgRelation['navwork']) && $cfgRelation['navwork']) {
$db = $this->realParent()->real_name;
$item = $this->real_name;
$ret = '<span class="navItemControls">'
. '<a href="navigation.php'
. PMA_URL_getCommon()
. '&hideNavItem=true'
. '&itemType=' . urlencode($this->getItemType())
. '&itemName=' . urlencode($item)
. '&dbName=' . urlencode($db) . '"'
. ' class="hideNavItem ajax">'
. PMA_Util::getImage('lightbulb_off.png', __('Hide'))
. '</a></span>';
}
return $ret;
}
}
?>
Expand Up @@ -9,12 +9,14 @@
exit;
}

require_once 'libraries/navigation/Nodes/Node_DatabaseChild.class.php';

/**
* Represents container node that carries children of a database
*
* @package PhpMyAdmin-Navigation
*/
abstract class Node_DatabaseChild_Container extends Node
abstract class Node_DatabaseChild_Container extends Node_DatabaseChild
{
/**
* Initialises the class by setting the common variables
Expand Down

0 comments on commit 789d9aa

Please sign in to comment.