>
@@ -269,16 +284,20 @@ if ($num_dbs > 1) {
// Displays the list of tables from the current database
for ($t = 0; $t < $num_tables; $t++) {
$table = PMA_mysql_tablename($tables, $t);
+ $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
+ ? htmlspecialchars($tooltip_name[$table])
+ : '';
$url_title = (!empty($tooltip) && isset($tooltip[$table]))
? htmlspecialchars($tooltip[$table])
: '';
+
echo "\n";
?>
-
-
+
+
-
+
1) {
$url_title = (!empty($tooltip) && isset($tooltip[$table]))
? str_replace('"', '"', $tooltip[$table])
: '';
+ $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
+ ? str_replace('"', '"', $tooltip_name[$table])
+ : '';
+
$table_list .= '
' . "\n";
- $table_list .= '
' . "\n";
+ $table_list .= '
' . "\n";
if (PMA_USR_BROWSER_AGENT == 'IE') {
- $table_list .= ' ' . htmlspecialchars($table) . '' . "\n";
+ $table_list .= '
' . ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)) . '' . "\n";
} else {
- $table_list .= '
' . htmlspecialchars($table) . '' . "\n";
+ $table_list .= '
' . ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)) . '' . "\n";
}
} // end for $t (tables list)
@@ -318,15 +341,15 @@ if ($num_dbs > 1) {
$selected = ' selected="selected"';
$table_list_header .= '
' . "\n";
- $table_list_header .= ' ' . htmlspecialchars($db) . ' ' . "\n\n";
+ $table_list_header .= '
' . ($db_tooltip != '' && $cfg['ShowTooltipAliasTB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . ' ' . "\n\n";
} else {
$selected = '';
} // end if... else...
if (!empty($num_tables)) {
- echo '
' . "\n";
+ echo '
' . "\n";
} else {
- echo '
' . "\n";
+ echo '
' . "\n";
} // end if... else...
} // end if (light mode)
@@ -392,25 +415,41 @@ else if ($num_dbs == 1) {
if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION >= 32303
&& $num_tables) {
$tooltip = array();
+ $tooltip_name = array();
$result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
while ($tmp = PMA_mysql_fetch_array($result)) {
+ $tooltip_name[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '');
+ $tmp['Comment'] = ($cfg['ShowTooltipAliasTB'] ? $tmp['Name'] : $tmp['Comment']);
+
$tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '')
. '(' . (isset($tmp['Rows']) ? $tmp['Rows'] : '0') . ' ' . $strRows . ')';
} // end while
} // end if
+ // garvin: Get comments from PMA comments table
+ $db_tooltip = '';
+ if ($cfg['ShowTooltip'] && $cfgRelation['commwork']) {
+ $tmp_db_tooltip = PMA_getComments($db);
+ if (is_array($tmp_db_tooltip)) {
+ $db_tooltip = implode(' ', $tmp_db_tooltip);
+ }
+ }
+
// Displays the database name
echo "\n";
?>
-
+
*/
- function PMA_getComments($db, $table) {
+ function PMA_getComments($db, $table = '') {
global $cfgRelation;
+ if ($table != '') {
$com_qry = 'SELECT column_name, ' . PMA_backquote('comment') . ' FROM ' . PMA_backquote($cfgRelation['column_comments'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
$com_rs = PMA_query_as_cu($com_qry);
+ } else {
+ $com_qry = 'SELECT comment FROM ' . PMA_backquote($cfgRelation['column_comments'])
+ . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
+ . ' AND table_name = \'\''
+ . ' AND column_name = \'(db_comment)\'';
+ $com_rs = PMA_query_as_cu($com_qry);
+ }
+ $i = 0;
while ($row = @PMA_mysql_fetch_array($com_rs)) {
- $col = $row['column_name'];
+ $i++;
+ $col = ($table != '' ? $row['column_name'] : $i);
+
+ if (strlen($row['comment']) > 0) {
$comment[$col] = $row['comment'];
+ }
+
} // end while
if (isset($comment) && is_array($comment)) {
@@ -313,5 +327,85 @@ if (!defined('PMA_RELATION_LIB_INCLUDED')){
return FALSE;
}
} // end of the 'PMA_getComments()' function
+
+ /**
+ * Adds/removes slashes if required
+ *
+ * @param string the string to slash
+ *
+ * @return string the slashed string
+ *
+ * @access public
+ */
+ function PMA_handleSlashes($val) {
+ return (get_magic_quotes_gpc() ? str_replace('\\"', '"', $val) : PMA_sqlAddslashes($val));
+ } // end of the "PMA_handleSlashes()" function
+
+ /**
+ * Set a single comment to a certain value.
+ *
+ * @param string the name of the db
+ * @param string the name of the table
+ * @param string the name of the column
+ * @param string the value of the column
+ * @param string (optional) if a column is renamed, this is the name of the former key which will get deleted
+ *
+ * @return boolean true, if comment-query was made.
+ *
+ * @global array the list of relations settings
+ *
+ * @access public
+ */
+ function PMA_setComment($db, $table, $key, $value, $removekey = '') {
+ global $cfgRelation;
+
+ if ($removekey != '' AND $removekey != $key) {
+ $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['column_comments'])
+ . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
+ . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''
+ . ' AND column_name = \'' . PMA_handleSlashes($removekey) . '\'';
+ $rmv_rs = PMA_query_as_cu($remove_query);
+ unset($rmv_query);
+ }
+
+ $test_qry = 'SELECT ' . PMA_backquote('comment') . ', mimetype, transformation, transformation_options FROM ' . PMA_backquote($cfgRelation['column_comments'])
+ . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
+ . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''
+ . ' AND column_name = \'' . PMA_handleSlashes($key) . '\'';
+ $test_rs = PMA_query_as_cu($test_qry);
+
+ if ($test_rs && mysql_num_rows($test_rs) > 0) {
+ $row = @PMA_mysql_fetch_array($test_rs);
+
+ if (strlen($value) > 0 || strlen($row['mimetype']) > 0 || strlen($row['transformation']) > 0 || strlen($row['transformation_options']) > 0) {
+ $upd_query = 'UPDATE ' . PMA_backquote($cfgRelation['column_comments'])
+ . ' SET ' . PMA_backquote('comment') . ' = \'' . PMA_handleSlashes($value) . '\''
+ . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
+ . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''
+ . ' AND column_name = \'' . PMA_handleSlashes($key) . '\'';
+ } else {
+ $upd_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['column_comments'])
+ . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
+ . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\''
+ . ' AND column_name = \'' . PMA_handleSlashes($key) . '\'';
+ }
+ } else if (strlen($value) > 0) {
+ $upd_query = 'INSERT INTO ' . PMA_backquote($cfgRelation['column_comments'])
+ . ' (db_name, table_name, column_name, ' . PMA_backquote('comment') . ') '
+ . ' VALUES('
+ . '\'' . PMA_sqlAddslashes($db) . '\','
+ . '\'' . PMA_sqlAddslashes($table) . '\','
+ . '\'' . PMA_handleSlashes($key) . '\','
+ . '\'' . PMA_handleSlashes($value) . '\')';
+ }
+
+ if (isset($upd_query)){
+ $upd_rs = PMA_query_as_cu($upd_query);
+ unset($upd_query);
+ return true;
+ } else {
+ return false;
+ }
+ } // end of 'PMA_setComment()' function
} // $__PMA_RELATION_LIB__
?>