Skip to content

Commit

Permalink
Added tooltips to navigation tree with comments for databases, tables…
Browse files Browse the repository at this point in the history
…, columns, events and routines
  • Loading branch information
roccivic committed Oct 30, 2012
1 parent b436fca commit 4245465
Show file tree
Hide file tree
Showing 8 changed files with 145 additions and 2 deletions.
6 changes: 5 additions & 1 deletion libraries/navigation/NavigationTree.class.php
Expand Up @@ -808,7 +808,11 @@ private function _renderNode($node, $recursive = -1, $class = '')
$retval .= htmlspecialchars($node->name);
$retval .= "</a>";
} else {
$retval .= "<a$linkClass href='$link'>";
$title = $node->getComment();
if ($title) {
$title = " title='" . htmlentities($title, ENT_QUOTES) . "'";

This comment has been minimized.

Copy link
@lem9

lem9 May 22, 2013

Contributor

Hi Rouslan,
is htmlentities() used here for some protection? Because it mangles special characters, see https://sourceforge.net/p/phpmyadmin/bugs/3927.

By the way, this is not valid XHTML (you should be generating double-quotes rather that single-quotes).

These problems have been fixed for version 4.0.3, see ea5a1b2 and 685fa95

}
$retval .= "<a$linkClass$title href='$link'>";
$retval .= htmlspecialchars($node->real_name);
$retval .= "</a>";
}
Expand Down
11 changes: 11 additions & 0 deletions libraries/navigation/Nodes/Node.class.php
Expand Up @@ -364,6 +364,17 @@ public function getData($type, $pos, $searchClause = '')
return PMA_DBI_fetch_result($query);
}

/**
* Returns the comment associated with node
* This method should be overridden by specific type of nodes
*
* @return string
*/
public function getComment()
{
return '';
}

/**
* Returns the number of children of type $type present inside this container
* This method is overridden by the Node_Database and Node_Table classes
Expand Down
25 changes: 25 additions & 0 deletions libraries/navigation/Nodes/Node_Column.class.php
Expand Up @@ -35,6 +35,31 @@ public function __construct($name, $type = Node::OBJECT, $is_group = false)
. '&amp;token=' . $GLOBALS['token']
);
}

/**
* Returns the comment associated with node
* This method should be overridden by specific type of nodes
*
* @return string
*/
public function getComment()
{
$db = $this->_commonFunctions->sqlAddSlashes(
$this->realParent()->realParent()->real_name
);
$table = $this->_commonFunctions->sqlAddSlashes(
$this->realParent()->real_name
);
$column = $this->_commonFunctions->sqlAddSlashes(
$this->real_name
);
$query = "SELECT `COLUMN_COMMENT` ";
$query .= "FROM `INFORMATION_SCHEMA`.`COLUMNS` ";
$query .= "WHERE `TABLE_SCHEMA`='$db' ";
$query .= "AND `TABLE_NAME`='$table' ";
$query .= "AND `COLUMN_NAME`='$column' ";
return PMA_DBI_fetch_value($query);
}
}

?>
12 changes: 12 additions & 0 deletions libraries/navigation/Nodes/Node_Database.class.php
Expand Up @@ -424,6 +424,18 @@ public function getData($type, $pos, $searchClause = '')
}
return $retval;
}


/**
* Returns the comment associated with node
* This method should be overridden by specific type of nodes
*
* @return string
*/
public function getComment()
{
return PMA_getDbComment($this->real_name);
}
}

?>
21 changes: 21 additions & 0 deletions libraries/navigation/Nodes/Node_Event.class.php
Expand Up @@ -36,6 +36,27 @@ public function __construct($name, $type = Node::OBJECT, $is_group = false)
);
$this->classes = 'event';
}

/**
* Returns the comment associated with node
* This method should be overridden by specific type of nodes
*
* @return string
*/
public function getComment()
{
$db = $this->_commonFunctions->sqlAddSlashes(
$this->realParent()->real_name
);
$event = $this->_commonFunctions->sqlAddSlashes(
$this->real_name
);
$query = "SELECT `EVENT_COMMENT` ";
$query .= "FROM `INFORMATION_SCHEMA`.`EVENTS` ";
$query .= "WHERE `EVENT_SCHEMA`='$db' ";
$query .= "AND `EVENT_NAME`='$event' ";
return PMA_DBI_fetch_value($query);
}
}

?>
22 changes: 22 additions & 0 deletions libraries/navigation/Nodes/Node_Function.class.php
Expand Up @@ -36,6 +36,28 @@ public function __construct($name, $type = Node::OBJECT, $is_group = false)
);
$this->classes = 'function';
}

/**
* Returns the comment associated with node
* This method should be overridden by specific type of nodes
*
* @return string
*/
public function getComment()
{
$db = $this->_commonFunctions->sqlAddSlashes(
$this->realParent()->real_name
);
$routine = $this->_commonFunctions->sqlAddSlashes(
$this->real_name
);
$query = "SELECT `ROUTINE_COMMENT` ";
$query .= "FROM `INFORMATION_SCHEMA`.`ROUTINES` ";
$query .= "WHERE `ROUTINE_SCHEMA`='$db' ";
$query .= "AND `ROUTINE_NAME`='$routine' ";
$query .= "AND `ROUTINE_TYPE`='FUNCTION' ";
return PMA_DBI_fetch_value($query);
}
}

?>
22 changes: 22 additions & 0 deletions libraries/navigation/Nodes/Node_Procedure.class.php
Expand Up @@ -36,6 +36,28 @@ public function __construct($name, $type = Node::OBJECT, $is_group = false)
);
$this->classes = 'procedure';
}

/**
* Returns the comment associated with node
* This method should be overridden by specific type of nodes
*
* @return string
*/
public function getComment()
{
$db = $this->_commonFunctions->sqlAddSlashes(
$this->realParent()->real_name
);
$routine = $this->_commonFunctions->sqlAddSlashes(
$this->real_name
);
$query = "SELECT `ROUTINE_COMMENT` ";
$query .= "FROM `INFORMATION_SCHEMA`.`ROUTINES` ";
$query .= "WHERE `ROUTINE_SCHEMA`='$db' ";
$query .= "AND `ROUTINE_NAME`='$routine' ";
$query .= "AND `ROUTINE_TYPE`='PROCEDURE' ";
return PMA_DBI_fetch_value($query);
}
}

?>
28 changes: 27 additions & 1 deletion libraries/navigation/Nodes/Node_Table.class.php
Expand Up @@ -185,14 +185,40 @@ public function getData($type, $pos, $searchClause = '')
$pos--;
}
}

}
break;
default:
break;
}
return $retval;
}

/**
* Returns the comment associated with node
* This method should be overridden by specific type of nodes
*
* @return string
*/
public function getComment()
{
$db = $this->realParent()->real_name;
$table = $this->_commonFunctions->sqlAddSlashes($this->real_name);
if (! $GLOBALS['cfg']['Servers'][$GLOBALS['server']]['DisableIS']) {
$db = $this->_commonFunctions->sqlAddSlashes($db);
$query = "SELECT `TABLE_COMMENT` ";
$query .= "FROM `INFORMATION_SCHEMA`.`TABLES` ";
$query .= "WHERE `TABLE_SCHEMA`='$db' ";
$query .= "AND `TABLE_NAME`='$table' ";
$retval = PMA_DBI_fetch_value($query);
} else {
$db = $this->_commonFunctions->backquote($db);
$query = "SHOW TABLE STATUS FROM $db ";
$query .= "WHERE Name = '$table'";
$arr = PMA_DBI_fetch_assoc(PMA_DBI_try_query($query));
$retval = $arr['Comment'];
}
return $retval;
}
}

?>

0 comments on commit 4245465

Please sign in to comment.