Move navigation node CSS class generation to Node object

Signed-off-by: Michal Čihař <michal@cihar.com>
This commit is contained in:
Michal Čihař 2014-05-10 09:34:37 +02:00
parent ef81d95ab5
commit e82c53f93d
2 changed files with 28 additions and 14 deletions

View File

@ -839,14 +839,6 @@ class PMA_NavigationTree
|| (! in_array($parentName, $sterile) && ! $node->isNew)
|| (in_array($node->real_name, $sterile))
) {
$loaded = '';
if ($node->is_group) {
$loaded = ' loaded';
}
$container = '';
if ($node->type == Node::CONTAINER) {
$container = ' container';
}
$retval .= "<div class='block'>";
$iClass = '';
if ($class == 'first') {
@ -866,7 +858,6 @@ class PMA_NavigationTree
}
}
if ($match) {
$loaded = ' loaded';
if (! $node->is_group) {
$icon = PMA_Util::getImage(
'b_minus.png'
@ -885,16 +876,14 @@ class PMA_NavigationTree
}
}
if ($match) {
$loaded = ' loaded';
$icon = PMA_Util::getImage('b_minus.png');
break;
}
}
if (! $GLOBALS['cfg']['NavigationTreeDisableDatabaseExpansion']) {
$retval .= "<a class='expander$loaded$container'";
} else {
$retval .= "<a";
$retval .= '<a class="' . $note->getCssClasses($match) . '"';
if ($GLOBALS['cfg']['NavigationTreeDisableDatabaseExpansion']) {
$icon = "";
}
$retval .= " href='#'>";

View File

@ -457,5 +457,30 @@ class Node
{
return '';
}
/**
* Returns CSS classes for a node
*
* @param boolean $match Whether the node matched loaded tree
*
* @return String with html classes.
*/
public function getCssClasses($match)
{
if ($GLOBALS['cfg']['NavigationTreeDisableDatabaseExpansion']) {
return '';
}
$result = array('expander');
if ($this->is_group || $match) {
$result[] = 'loaded';
}
if ($this->type == Node::CONTAINER) {
$result[] = 'container';
}
return implode(' ', $result);
}
}
?>