Skip to content

Commit

Permalink
See Changelog: Lightweight tabs, DB-based SQL history, tabbed querywi…
Browse files Browse the repository at this point in the history
…ndow.

Have fun, surely needs some debugging. :)
  • Loading branch information
Garvin Hicking committed Feb 27, 2003
1 parent bee0503 commit 4d878ae
Show file tree
Hide file tree
Showing 10 changed files with 356 additions and 88 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
Expand Up @@ -5,6 +5,13 @@ phpMyAdmin - Changelog
$Id$
$Source$

2003-02-27 Garvin Hicking <me@supergarv.de>
* libraries/common.lib.php3, tbl_properties_links.php3, db_details_links.php3,
querywindow.php3: Integrated Manuzhais patch for Lightweight Tabs.
* querywindow.php3, tbl_query_box.php3, config.inc.php3, header.inc.php3, index.php3,
libraries/config_import.lib.php3: Added (optional) DB-based SQL-history with
purging on login, made querywindow tabbed, improved Querywindow-compatibility.

2003-02-26 Garvin Hicking <me@supergarv.de>
* lang/german-*: better grammar. ;)
* libraries/display_tbl.lib.php3: Fixed transformation-link variable
Expand Down
17 changes: 12 additions & 5 deletions config.inc.php3
Expand Up @@ -183,6 +183,7 @@ $cfg['UseDbSearch'] = TRUE; // whether to enable the "database searc
// Left frame setup
$cfg['LeftFrameLight'] = TRUE; // use a select-based menu and display only the
// current tables in the left frame.
$cfg['LightTabs'] = FALSE; // use lightweight, graphically less intense menu-tabs
$cfg['ShowTooltip'] = TRUE; // display table comment as tooltip in left frame
$cfg['ShowTooltipAliasDB'] = FALSE; // if ShowToolTip is enabled, this defines that table/db comments
$cfg['ShowTooltipAliasTB'] = FALSE; // are shown (in the left menu and db_details_structure) instead of
Expand Down Expand Up @@ -373,18 +374,24 @@ $cfg['ModifyDeleteAtRight'] = FALSE; // show edit/delete links on right s
// (or at the bottom with vertical browse)
$cfg['DefaultDisplay'] = 'horizontal'; // default display direction
// (horizontal|vertical|horizontalflipped)
$cfg['HeaderFlipType'] = 'css'; // table-header rotation via faking or css? (css|fake)
$cfg['ShowBrowseComments'] = TRUE; // shows stored relation-comments in 'browse' mode.
$cfg['HeaderFlipType'] = 'css'; // table-header rotation via faking or css? (css|fake)
$cfg['ShowBrowseComments'] = TRUE; // shows stored relation-comments in 'browse' mode.
$cfg['ShowPropertyComments']= TRUE; // shows stored relation-comments in 'table property' mode.
$cfg['RepeatCells'] = 100; // repeat header names every X cells? (0 = deactivate)

$cfg['QueryFrame'] = TRUE; // displays a new frame where a link to a querybox is always displayed.
$cfg['QueryFrameJS'] = TRUE; // whether to use JavaScript functions for opening a new window for SQL commands.
// if set to 'false', the target of the querybox is always the right frame.
$cfg['QueryFrameDebug'] = FALSE; // display JS debugging link (DEVELOPERS only)
$cfg['QueryWindowWidth'] = 750; // Width of Query window
$cfg['QueryWindowHeight'] = 300; // Height of Query window

$cfg['QueryWindowWidth'] = 750; // Width of Query window
$cfg['QueryWindowHeight'] = 300; // Height of Query window
$cfg['QueryHistoryDB'] = FALSE; // Set to TRUE if you want DB-based query history.
// If FALSE, this utilizes JS-routines to display
// query history (lost by window close)
$cfg['QueryWindowDefTab'] = 'sql'; // which tab to display in the querywindow on startup
// (sql|files|history|full)
$cfg['QueryHistoryMax'] = 25; // When using DB-based query history, how many entries
// should be kept?
$cfg['BrowseMIME'] = TRUE; // Use MIME-Types (stored in column comments table) for

/**
Expand Down
20 changes: 14 additions & 6 deletions db_details_links.php3
Expand Up @@ -58,11 +58,15 @@ else {
/**
* Displays tab links
*/
?>
<table border="0" cellspacing="0" cellpadding="3" width="100%" class="tabs">

if ($cfg['LightTabs']) {
echo '&nbsp;';
} else {
echo '<table border="0" cellspacing="0" cellpadding="3" width="100%" class="tabs">
<tr>
<td width="8">&nbsp;</td>
<?php
<td width="8">&nbsp;</td>';
}

echo PMA_printTab($strStructure, 'db_details_structure.php3', $url_query);
echo PMA_printTab($strSQL, 'db_details.php3', $url_query . '&amp;db_query_force=1');
echo PMA_printTab($strExport, $lnk3, $arg3);
Expand All @@ -79,8 +83,12 @@ if ($lnk5) {
echo PMA_printTab($strDrop, $lnk5, $arg5, $att5);
} // end if
echo "\n";

if (!$cfg['LightTabs']) {
echo '</tr></table>';
} else {
echo '<br />';
}
?>
</tr>
</table>
<br />

7 changes: 7 additions & 0 deletions index.php3
Expand Up @@ -41,6 +41,13 @@ if (isset($lightm_db)) {
$url_query = PMA_generate_common_url(isset($db) ? $db : '');

header('Content-Type: text/html; charset=' . $GLOBALS['charset']);

require('./libraries/relation.lib.php3');
$cfgRelation = PMA_getRelationsParam();

if ($cfg['QueryHistoryDB'] && $cfgRelation['historywork']) {
PMA_purgeHistory($cfg['Server']['user']);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
Expand Down
41 changes: 27 additions & 14 deletions libraries/common.lib.php3
Expand Up @@ -1542,16 +1542,18 @@ if (typeof(document.getElementById) != 'undefined'
* @param string main link file, e.g. "test.php3"
* @param string link arguments
* @param string link attributes
* @param string include '?' even though no attributes are set. Can be set empty, should be '?'.
* @param boolean force display TAB as active
*
* @return string two table cells, the first beeing a separator, the second the tab itself
*
* @access public
*/
function PMA_printTab($text, $link, $args = '', $attr = '') {
global $PHP_SELF;
function PMA_printTab($text, $link, $args = '', $attr = '', $sep = '?', $active = false) {
global $PHP_SELF, $cfg;
global $db_details_links_count_tabs;

if (basename($PHP_SELF) == $link
if ((basename($PHP_SELF) == $link || $active)
&& ($text != $GLOBALS['strEmpty'] && $text != $GLOBALS['strDrop'])) {
$bgcolor = 'silver';
} else {
Expand All @@ -1563,19 +1565,30 @@ if (typeof(document.getElementById) != 'undefined'
$attr = ' ' . $attr;
}

$out = "\n" . ' '
. '<td bgcolor="' . $bgcolor . '" align="center" width="64" nowrap="nowrap" class="tab">'
. "\n" . ' ';
if (strlen($link) > 0) {
$out .= '<a href="' . $link . '?' . $args . '"' . $attr . '>'
. '<b>' . $text . '</b></a>';
if ($cfg['LightTabs']) {
$out = '';
if (strlen($link) > 0) {
$out .= '<a href="' . $link . $sep . $args . '"' . $attr . '>'
. '<b>' . $text . '</b></a>';
} else {
$out .= '<b>' . $text . '</b>';
}
$out = '[ ' . $out . ' ]&nbsp;&nbsp;&nbsp;';
} else {
$out .= '<b>' . $text . '</b>';
$out = "\n" . ' '
. '<td bgcolor="' . $bgcolor . '" align="center" width="64" nowrap="nowrap" class="tab">'
. "\n" . ' ';
if (strlen($link) > 0) {
$out .= '<a href="' . $link . $sep . $args . '"' . $attr . '>'
. '<b>' . $text . '</b></a>';
} else {
$out .= '<b>' . $text . '</b>';
}
$out .= "\n" . ' '
. '</td>'
. "\n" . ' '
. '<td width="8">&nbsp;</td>';
}
$out .= "\n" . ' '
. '</td>'
. "\n" . ' '
. '<td width="8">&nbsp;</td>';

return $out;
} // end of the 'PMA_printTab()' function
Expand Down
36 changes: 36 additions & 0 deletions libraries/config_import.lib.php3
Expand Up @@ -228,6 +228,15 @@ if (!defined('PMA_CONFIG_IMPORT_LIB_INCLUDED')) {
$cfg['LeftFrameLight'] = TRUE;
}
}

if (!isset($cfg['LightTabs'])) {
if (isset($cfgLightTabs)) {
$cfg['LightTabs'] = $cfgLightTabs;
unset($cfgLightTabs);
} else {
$cfg['LightTabs'] = FALSE;
}
}

if (!isset($cfg['ShowTooltip'])) {
if (isset($cfgShowTooltip)) {
Expand Down Expand Up @@ -698,6 +707,33 @@ if (!defined('PMA_CONFIG_IMPORT_LIB_INCLUDED')) {
}
}

if (!isset($cfg['QueryHistoryMax'])) {
if (isset($cfgQueryHistoryMax)) {
$cfg['QueryHistoryMax'] = $cfgQueryHistoryMax;
unset($cfgQueryHistoryMax);
} else {
$cfg['QueryHistoryMax'] = 25;
}
}

if (!isset($cfg['QueryHistoryDB'])) {
if (isset($cfgQueryHistoryDB)) {
$cfg['QueryHistoryDB'] = $cfgQueryHistoryDB;
unset($cfgQueryHistoryDB);
} else {
$cfg['QueryHistoryDB'] = FALSE;
}
}

if (!isset($cfg['QueryWindowDefTab'])) {
if (isset($cfgQueryWindowDefTab)) {
$cfg['QueryWindowDefTab'] = $cfgQueryWindowDefTab;
unset($cfgQueryWindowDefTab);
} else {
$cfg['QueryWindowDefTab'] = 'sql';
}
}

if (!isset($cfg['BrowseMIME'])) {
if (isset($cfgBrowseMIME)) {
$cfg['BrowseMIME'] = $cfgBrowseMIME;
Expand Down
91 changes: 88 additions & 3 deletions libraries/relation.lib.php3
Expand Up @@ -364,7 +364,7 @@ if (!defined('PMA_RELATION_LIB_INCLUDED')){
$col = ($table != '' ? $row['column_name'] : $i);

if (strlen($row['comment']) > 0) {
$comment[$col] = $row['comment'];
$comment[$col] = $row['comment'];
}

} // end while
Expand Down Expand Up @@ -395,8 +395,8 @@ if (!defined('PMA_RELATION_LIB_INCLUDED')){
* @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
* @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.
*
Expand Down Expand Up @@ -455,5 +455,90 @@ if (!defined('PMA_RELATION_LIB_INCLUDED')){
return false;
}
} // end of 'PMA_setComment()' function

/**
* Set a SQL history entry
*
* @param string the name of the db
* @param string the name of the table
* @param string the username
* @param string the sql query
*
* @return boolean true
*
* @access public
*/
function PMA_setHistory($db, $table, $username, $sqlquery) {
global $cfgRelation;

$hist_rs = PMA_query_as_cu('INSERT INTO ' . PMA_backquote($cfgRelation['history']) . ' ('
. PMA_backquote('username') . ','
. PMA_backquote('db') . ','
. PMA_backquote('table') . ','
. PMA_backquote('timevalue') . ','
. PMA_backquote('sqlquery')
. ') VALUES ('
. '\'' . PMA_sqlAddslashes($username) . '\','
. '\'' . PMA_sqlAddslashes($db) . '\','
. '\'' . PMA_sqlAddslashes($table) . '\','
. 'NOW(),'
. '\'' . PMA_handleSlashes($sqlquery) . '\')');
return true;
} // end of 'PMA_setHistory()' function

/**
* Gets a SQL history entry
*
* @param string the username
*
* @return array list of history items
*
* @access public
*/
function PMA_getHistory($username) {
global $cfgRelation;

$hist_rs = PMA_query_as_cu('SELECT '
. PMA_backquote('db') . ','
. PMA_backquote('table') . ','
. PMA_backquote('sqlquery')
. ' FROM ' . PMA_backquote($cfgRelation['history']) . ' WHERE username = \'' . PMA_handleSlashes($username) . '\' ORDER BY timevalue DESC');

$history = array();

while ($row = @PMA_mysql_fetch_array($hist_rs)) {
$history[] = $row;
}

return $history;

} // end of 'PMA_getHistory()' function

/**
* Set a SQL history entry
*
* @param string the name of the db
* @param string the name of the table
* @param string the username
* @param string the sql query
*
* @return boolean true
*
* @access public
*/
function PMA_purgeHistory($username) {
global $cfgRelation, $cfg;

$purge_rs = PMA_query_as_cu('SELECT timevalue FROM ' . PMA_backquote($cfgRelation['history']) . ' WHERE username = \'' . PMA_handleSlashes($username) . '\' ORDER BY timevalue DESC LIMIT ' . $cfg['QueryHistoryMax'] . ', 1');
$i = 0;
$row = @PMA_mysql_fetch_array($purge_rs);

if (is_array($row) && $row[0] > 0) {
$maxtime = $row[0];
$remove_rs = PMA_query_as_cu('DELETE FROM ' . PMA_backquote($cfgRelation['history']) . ' WHERE timevalue <= ' . $maxtime);
}

return true;
} // end of 'PMA_purgeHistory()' function
} // $__PMA_RELATION_LIB__
?>

0 comments on commit 4d878ae

Please sign in to comment.