Adjust class hierarchy to avoid accessing methods from child classes

Signed-off-by: Madhura Jayaratne <madhura.cj@gmail.com>
This commit is contained in:
Madhura Jayaratne 2015-06-23 18:34:32 +05:30
parent 312d159922
commit 789d9aa018
3 changed files with 33 additions and 23 deletions

View File

@ -741,27 +741,7 @@ class Node
*/
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 '';
}
/**

View File

@ -10,7 +10,9 @@ if (! defined('PHPMYADMIN')) {
}
/**
* 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
*/
@ -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;
}
}
?>

View File

@ -9,12 +9,14 @@ if (! defined('PHPMYADMIN')) {
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