Move code for geting navigation node icon into Node class

Signed-off-by: Michal Čihař <michal@cihar.com>
This commit is contained in:
Michal Čihař 2014-05-10 09:42:53 +02:00
parent e320d423e2
commit a56ec50fb2
2 changed files with 19 additions and 11 deletions

View File

@ -873,21 +873,11 @@ class PMA_NavigationTree
if (strpos($class, 'last') === false) {
$retval .= "<b></b>";
}
$icon = PMA_Util::getImage('b_plus.png', __('Expand/Collapse'));
$match = $this->_findTreeMatch($this->_aPath, 'aPath_clean');
$match |= $this->_findTreeMatch($this->_vPath, 'vPath_clean');
if ($match && ! $node->is_group) {
$icon = PMA_Util::getImage(
'b_minus.png'
);
}
$retval .= '<a class="' . $note->getCssClasses($match) . '"';
if ($GLOBALS['cfg']['NavigationTreeDisableDatabaseExpansion']) {
$icon = "";
}
$retval .= " href='#'>";
$retval .= "<span class='hide aPath'>";
$retval .= $paths['aPath'];
@ -899,7 +889,7 @@ class PMA_NavigationTree
$retval .= $this->_pos;
$retval .= "</span>";
$retval .= $this->_getPaginationParamsHtml($node);
$retval .= $icon;
$retval .= $node->getIcon($match);
$retval .= "</a>";
$retval .= "</div>";

View File

@ -482,5 +482,23 @@ class Node
return implode(' ', $result);
}
/**
* Returns icon for the node
*
* @param boolean $match Whether the node matched loaded tree
*
* @return String with image name
*/
public function getIcon($match)
{
if ($GLOBALS['cfg']['NavigationTreeDisableDatabaseExpansion']) {
return '';
} elseif ($match && ! $node->is_group) {
return PMA_Util::getImage('b_minus.png');
} else {
return PMA_Util::getImage('b_plus.png', __('Expand/Collapse'));
}
}
}
?>