1
0
mirror of https://github.com/phpmyadmin/phpmyadmin.git synced 2026-10-28 07:41:55 +03:00

Merge commit 'ab6d16ed2f4728c9f066353a851621a352ef969f'

This commit is contained in:
Marc Delisle
2011-05-24 08:18:25 -04:00
16 changed files with 366 additions and 8 deletions

View File

@@ -1054,6 +1054,29 @@ ALTER TABLE `pma_column_comments`
</ul>
</dd>
<dt id="recent">
<span id="cfg_Servers_recent">$cfg['Servers'][$i]['recent']</span> string
</dt>
<dd>
Since release 3.5.0 you can show recently used tables in the left navigation frame.
It helps you to jump across table directly, without the need to select the database,
and then select the table. Using
<a href="#cfg_LeftRecentTable" class="configrule">$cfg['LeftRecentTable']</a>
you can configure the maximum number of recent tables shown. When you select a table
from the list, it will jump to the page specified in
<a href="#cfg_LeftDefaultTabTable" class="configrule">$cfg['LeftDefaultTabTable']</a>.<br/><br/>
Without configuring the storage, you can still access the recently used tables,
but it will disappear after you logout.<br/><br/>
To allow the usage of this functionality:
<ul>
<li>set up <a href="#pmadb">pmadb</a> and the phpMyAdmin configuration storage</li>
<li>put the table name in <tt>$cfg['Servers'][$i]['recent']</tt> (e.g. 'pma_recent')</li>
</ul>
</dd>
<dt id="tracking">
<span id="cfg_Servers_tracking">$cfg['Servers'][$i]['tracking']</span> string
</dt>
@@ -1469,6 +1492,10 @@ CREATE DATABASE,ALTER DATABASE,DROP DATABASE</pre>
<dd>Defines how many sublevels should be displayed when splitting
up tables by the above separator.</dd>
<dt id="cfg_LeftRecentTable">$cfg['LeftRecentTable'] integer</dt>
<dd>The maximum number of recently used tables shown in the left navigation
frame. Set this to 0 (zero) to disable the listing of recent tables.</dd>
<dt id="cfg_ShowTooltip">$cfg['ShowTooltip'] boolean</dt>
<dd>Defines whether to display table comment as tool-tip in left frame or
not.</dd>

View File

@@ -52,6 +52,7 @@ $cfg['Servers'][$i]['AllowNoPassword'] = false;
// $cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages';
// $cfg['Servers'][$i]['column_info'] = 'pma_column_info';
// $cfg['Servers'][$i]['history'] = 'pma_history';
// $cfg['Servers'][$i]['recent'] = 'pma_recent';
// $cfg['Servers'][$i]['tracking'] = 'pma_tracking';
// $cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords';
// $cfg['Servers'][$i]['userconfig'] = 'pma_userconfig';

View File

@@ -2287,6 +2287,10 @@ $(document).ready(function() {
}
});
$('#update_recent_tables').ready(function() {
window.parent.frame_navigation.PMA_reloadRecentTable();
});
}) // end of $(document).ready()
/**

View File

@@ -167,6 +167,19 @@ function clear_fast_filter() {
elm.focus();
}
/**
* Reloads the recent tables list.
*/
function PMA_reloadRecentTable() {
$.get('navigation.php',
{ 'token' : window.parent.token, 'ajax_request' : true, 'recent_table' : true },
function (data) {
if (data.success == true) {
$('#recentTable').html(data.options);
}
});
}
/* Performed on load */
$(document).ready(function(){
/* Display filter */
@@ -179,4 +192,14 @@ $(document).ready(function(){
$('#clear_fast_filter').click(clear_fast_filter);
$('#fast_filter').focus(function (evt) {evt.target.select();});
$('#fast_filter').keyup(function (evt) {fast_filter(evt.target.value);});
/* Jump to recent table */
$('#recentTable').change(function() {
if (this.value != '') {
var arr = this.value.split('.');
window.parent.setDb(arr[0]);
window.parent.setTable(arr[1]);
window.parent.refreshMain($('#LeftDefaultTabTable')[0].value);
}
});
});

View File

@@ -0,0 +1,200 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
*
* @package phpMyAdmin
*/
require_once './libraries/Message.class.php';
/**
* Handles the recently used tables.
*
* @TODO Change the release version in table pma_recent (#recent in Documentation.html)
*
* @package phpMyAdmin
*/
class RecentTable
{
/**
* Defines the internal PMA table which contains recent tables.
*
* @access private
* @var string
*/
private $pma_table;
/**
* Reference to session variable containing recently used tables.
*
* @access public
* @var array
*/
public $tables;
/**
* RecentTable instance.
*
* @var RecentTable
*/
private static $_instance;
public function __construct()
{
if (strlen($GLOBALS['cfg']['Server']['pmadb']) &&
strlen($GLOBALS['cfg']['Server']['recent'])) {
$this->pma_table = PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) .".".
PMA_backquote($GLOBALS['cfg']['Server']['recent']);
}
if (! isset($_SESSION['tmp_user_values']['recent_tables'])) {
$_SESSION['tmp_user_values']['recent_tables'] =
isset($this->pma_table) ? $this->getFromDb() : array();
}
$this->tables =& $_SESSION['tmp_user_values']['recent_tables'];
}
/**
* Returns class instance.
*
* @return RecentTable
*/
public static function getInstance()
{
if (is_null(self::$_instance)) {
self::$_instance = new RecentTable();
}
return self::$_instance;
}
/**
* Returns recently used tables from phpMyAdmin database.
*
* @uses $pma_table
* @uses PMA_query_as_controluser()
* @uses PMA_DBI_fetch_array()
* @uses json_decode()
*
* @return array
*/
public function getFromDb()
{
// Read from phpMyAdmin database, if recent tables is not in session
$sql_query =
" SELECT `tables` FROM " . $this->pma_table .
" WHERE `username` = '" . $GLOBALS['cfg']['Server']['user'] . "'";
$row = PMA_DBI_fetch_array(PMA_query_as_controluser($sql_query));
if (isset($row[0])) {
return json_decode($row[0]);
} else {
return array();
}
}
/**
* Save recent tables into phpMyAdmin database.
*
* @uses PMA_DBI_try_query()
* @uses json_decode()
* @uses PMA_Message
*
* @return true|PMA_Message
*/
public function saveToDb()
{
$username = $GLOBALS['cfg']['Server']['user'];
$sql_query =
" REPLACE INTO " . $this->pma_table . " (`username`, `tables`)" .
" VALUES ('" . $username . "', '" . PMA_sqlAddslashes(json_encode($this->tables)) . "')";
$success = PMA_DBI_try_query($sql_query, $GLOBALS['controllink']);
if (!$success) {
$message = PMA_Message::error(__('Could not save recent table'));
$message->addMessage('<br /><br />');
$message->addMessage(PMA_Message::rawError(PMA_DBI_getError($GLOBALS['controllink'])));
return $message;
}
return true;
}
/**
* Trim recent table according to the LeftRecentTable configuration.
*
* @return boolean True if trimming occurred
*/
public function trim()
{
$max = max($GLOBALS['cfg']['LeftRecentTable'], 0);
$trimming_occured = count($this->tables) > $max;
while (count($this->tables) > $max) {
array_pop($this->tables);
}
return $trimming_occured;
}
/**
* Return options for HTML select.
*
* @return string
*/
public function getHtmlSelectOption()
{
// trim and save, in case where the configuration is changed
if ($this->trim() && isset($this->pma_table)) {
$this->saveToDb();
}
$html = '<option value="">(' . __('Recent tables') . ') ...</option>';
if (count($this->tables)) {
foreach ($this->tables as $table) {
$html .= '<option value="' . $table . '">' . $table . '</option>';
}
} else {
$html .= '<option value="">' . __('There are no recent tables') . '</option>';
}
return $html;
}
/**
* Return HTML select.
*
* @return string
*/
public function getHtmlSelect()
{
$html = '<input type="hidden" id="LeftDefaultTabTable" value="' .
$GLOBALS['cfg']['LeftDefaultTabTable'] . '" />';
$html .= '<select id="recentTable">';
$html .= $this->getHtmlSelectOption();
$html .= '</select>';
return $html;
}
/**
* Add recently used tables.
*
* @param string $db Database name where the table is located
* @param string $table Table name
*
* @return true|PMA_Message True if success, PMA_Message if not
*/
public function add($db, $table)
{
$table_str = $db . '.' . $table;
// add only if this is new table
if (! isset($this->tables[0]) || $this->tables[0] != $table_str) {
array_unshift($this->tables, $table_str);
$this->tables = array_merge(array_unique($this->tables));
$this->trim();
if (isset($this->pma_table)) {
return $this->saveToDb();
}
}
return true;
}
}
?>

View File

@@ -338,6 +338,13 @@ $cfg['Servers'][$i]['history'] = '';
*/
$cfg['Servers'][$i]['designer_coords'] = '';
/**
* table to store recently used tables
* - leave blank for no "persistent" recently used tables
* SUGGESTED: 'pma_recent'
*/
$cfg['Servers'][$i]['recent'] = '';
/**
* table to store SQL tracking
* - leave blank for no SQL tracking
@@ -794,6 +801,13 @@ $cfg['LeftLogoLink'] = 'main.php';
*/
$cfg['LeftLogoLinkWindow'] = 'main';
/**
* number of recently used tables displayed in the navigation frame
*
* @global integer $cfg['LeftRecentTable']
*/
$cfg['LeftRecentTable'] = 10;
/**
* display a JavaScript table filter in the left frame
* when more then x tables are present

View File

@@ -159,6 +159,7 @@ $cfg_db['_validators'] = array(
'Import/skip_queries' => 'validate_non_negative_number',
'InsertRows' => 'validate_positive_number',
'LeftFrameTableLevel' => 'validate_positive_number',
'LeftRecentTable' => 'validate_non_negative_number',
'LimitChars' => 'validate_positive_number',
'LoginCookieValidity' => 'validate_positive_number',
'LoginCookieStore' => 'validate_non_negative_number',

View File

@@ -283,6 +283,8 @@ $strConfigLeftLogoLinkWindow_desc = __('Open the linked page in the main window
$strConfigLeftLogoLinkWindow_name = __('Logo link target');
$strConfigLeftPointerEnable_desc = __('Highlight server under the mouse cursor');
$strConfigLeftPointerEnable_name = __('Enable highlighting');
$strConfigLeftRecentTable_desc = __('Maximum number of recently used tables; set 0 to disable');
$strConfigLeftRecentTable_name = __('Recently used tables');
$strConfigLightTabs_desc = __('Use less graphically intense tabs');
$strConfigLightTabs_name = __('Light tabs');
$strConfigLimitChars_desc = __('Maximum number of characters shown in any non-numeric column on browse view');
@@ -401,6 +403,8 @@ $strConfigServers_pmadb_desc = __('Database used for relations, bookmarks, and P
$strConfigServers_pmadb_name = __('Database name');
$strConfigServers_port_desc = __('Port on which MySQL server is listening, leave empty for default');
$strConfigServers_port_name = __('Server port');
$strConfigServers_recent_desc = __('Leave blank for no "persistent" recently used tables across sessions, suggested: [kbd]pma_recent[/kbd]');
$strConfigServers_recent_name = __('Recently used table');
$strConfigServers_relation_desc = __('Leave blank for no [a@http://wiki.phpmyadmin.net/pma/relation]relation-links[/a] support, suggested: [kbd]pma_relation[/kbd]');
$strConfigServers_relation_name = __('Relation table');
$strConfigServers_ShowDatabasesCommand_desc = __('SQL command to fetch available databases');

View File

@@ -73,6 +73,7 @@ $forms['Servers']['Server_pmadb'] = array('Servers' => array(1 => array(
'table_info' => 'pma_table_info',
'column_info' => 'pma_column_info',
'history' => 'pma_history',
'recent' => 'pma_recent',
'tracking' => 'pma_tracking',
'table_coords' => 'pma_table_coords',
'pdf_pages' => 'pma_pdf_pages',
@@ -162,7 +163,8 @@ $forms['Left_frame']['Left_frame'] = array(
'LeftDisplayLogo',
'LeftLogoLink',
'LeftLogoLinkWindow',
'LeftPointerEnable');
'LeftPointerEnable',
'LeftRecentTable');
$forms['Left_frame']['Left_servers'] = array(
'LeftDisplayServers',
'DisplayServersList');

View File

@@ -77,7 +77,8 @@ $forms['Left_frame']['Left_frame'] = array(
'LeftDisplayLogo',
'LeftLogoLink',
'LeftLogoLinkWindow',
'LeftPointerEnable');
'LeftPointerEnable',
'LeftRecentTable');
$forms['Left_frame']['Left_databases'] = array(
'DisplayDatabasesList',
'LeftFrameDBTree',

View File

@@ -8,12 +8,26 @@ if (! defined('PHPMYADMIN')) {
exit;
}
/**
*
*/
require_once './libraries/common.inc.php';
require_once './libraries/RecentTable.class.php';
/**
* Add recently used table and reload the navigation.
*
* @param string $db Database name where the table is located.
* @param string $table The table name
*/
function PMA_addRecentTable($db, $table) {
$tmp_result = RecentTable::getInstance()->add($db, $table);
if ($tmp_result === true) {
echo '<span class="hide" id="update_recent_tables"></span>';
} else {
$error = $tmp_result;
$error->display();
}
}
/**
* This is not an Ajax request so we need to generate all this output.
*/
@@ -151,6 +165,11 @@ if (isset($GLOBALS['is_ajax_request']) && !$GLOBALS['is_ajax_request']) {
.'&quot;' . htmlspecialchars($show_comment)
.'&quot;</span>' . "\n";
} // end if
// add recently used table and reload the navigation
if ($GLOBALS['cfg']['LeftRecentTable'] > 0) {
PMA_addRecentTable($GLOBALS['db'], $GLOBALS['table']);
}
} else {
// no table selected, display database comment if present
/**

View File

@@ -138,6 +138,10 @@ function PMA_printRelationsParamDiagnostic($cfgRelation)
PMA_printDiagMessageForFeature(__('Designer'), 'designerwork', $messages);
PMA_printDiagMessageForParameter('recent', isset($cfgRelation['recent']), $messages, 'recent');
PMA_printDiagMessageForFeature(__('Persistent recently used tables'), 'recentwork', $messages);
PMA_printDiagMessageForParameter('tracking', isset($cfgRelation['tracking']), $messages, 'tracking');
PMA_printDiagMessageForFeature(__('Tracking'), 'trackingwork', $messages);
@@ -220,6 +224,7 @@ function PMA__getRelationsParam()
$cfgRelation['commwork'] = false;
$cfgRelation['mimework'] = false;
$cfgRelation['historywork'] = false;
$cfgRelation['recentwork'] = false;
$cfgRelation['trackingwork'] = false;
$cfgRelation['designerwork'] = false;
$cfgRelation['userconfigwork'] = false;
@@ -271,6 +276,8 @@ function PMA__getRelationsParam()
$cfgRelation['pdf_pages'] = $curr_table[0];
} elseif ($curr_table[0] == $GLOBALS['cfg']['Server']['history']) {
$cfgRelation['history'] = $curr_table[0];
} elseif ($curr_table[0] == $GLOBALS['cfg']['Server']['recent']) {
$cfgRelation['recent'] = $curr_table[0];
} elseif ($curr_table[0] == $GLOBALS['cfg']['Server']['tracking']) {
$cfgRelation['tracking'] = $curr_table[0];
} elseif ($curr_table[0] == $GLOBALS['cfg']['Server']['userconfig']) {
@@ -325,6 +332,10 @@ function PMA__getRelationsParam()
$cfgRelation['historywork'] = true;
}
if (isset($cfgRelation['recent'])) {
$cfgRelation['recentwork'] = true;
}
if (isset($cfgRelation['tracking'])) {
$cfgRelation['trackingwork'] = true;
}
@@ -346,8 +357,9 @@ function PMA__getRelationsParam()
if ($cfgRelation['relwork'] && $cfgRelation['displaywork']
&& $cfgRelation['pdfwork'] && $cfgRelation['commwork']
&& $cfgRelation['mimework'] && $cfgRelation['historywork']
&& $cfgRelation['trackingwork'] && $cfgRelation['userconfigwork']
&& $cfgRelation['bookmarkwork'] && $cfgRelation['designerwork']) {
&& $cfgRelation['recentwork'] && $cfgRelation['trackingwork']
&& $cfgRelation['userconfigwork'] && $cfgRelation['bookmarkwork']
&& $cfgRelation['designerwork']) {
$cfgRelation['allworks'] = true;
}

View File

@@ -53,6 +53,16 @@ function PMA_exitNavigationFrame()
exit;
}
require_once './libraries/common.lib.php';
require_once './libraries/RecentTable.class.php';
/**
* Check if it is an ajax request to reload the recent tables list.
*/
if ($GLOBALS['is_ajax_request'] && $_REQUEST['recent_table']) {
PMA_ajaxResponse('', true, array('options' => RecentTable::getInstance()->getHtmlSelectOption()) );
}
// keep the offset of the db list in session before closing it
if (! isset($_SESSION['tmp_user_values']['navi_limit_offset'])) {
$_SESSION['tmp_user_values']['navi_limit_offset'] = 0;
@@ -179,6 +189,14 @@ require_once './libraries/header_http.inc.php';
<body id="body_leftFrame">
<?php
require './libraries/navigation_header.inc.php';
// display recently used tables
if ($GLOBALS['cfg']['LeftRecentTable'] > 0) {
echo '<div id="recentTableList">';
echo RecentTable::getInstance()->getHtmlSelect();
echo '</div>';
}
if (! $GLOBALS['server']) {
// no server selected
PMA_exitNavigationFrame();

View File

@@ -105,6 +105,18 @@ CREATE TABLE IF NOT EXISTS `pma_pdf_pages` (
-- --------------------------------------------------------
--
-- Table structure for table `pma_recent`
--
CREATE TABLE IF NOT EXISTS `pma_recent` (
`username` varchar(64) COLLATE utf8_bin NOT NULL,
`tables` blob NOT NULL,
PRIMARY KEY (`username`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- --------------------------------------------------------
--
-- Table structure for table `pma_relation`
--

View File

@@ -83,6 +83,16 @@ div#pmalogo {
background-color: <?php echo $GLOBALS['cfg']['NaviBackground']; ?>;
padding:.3em;
}
div#recentTableList {
text-align: center;
margin-bottom: 0.5em;
}
div#recentTableList select {
width: 100%;
}
div#pmalogo,
div#leftframelinks,
div#databaseList {

View File

@@ -94,11 +94,21 @@ button {
div#pmalogo {
<?php //better echo $GLOBALS['cfg']['logoBGC']; ?>
}
div#recentTableList {
text-align: center;
margin: 20px 10px 0px 10px;
}
div#recentTableList select {
width: 100%;
}
div#pmalogo,
div#leftframelinks,
div#databaseList {
text-align: center;
margin: 20px 10px 0px 10px;
margin: 5px 10px 0px 10px;
}
ul#databaseList {