Add PMA_addRecentTable function, jQuery for recent tables 'onchange' event
This commit is contained in:
parent
ed646a067f
commit
c468705538
@ -1054,6 +1054,27 @@ 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 ??? 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.<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>
|
||||
@ -1467,6 +1488,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 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>
|
||||
|
||||
@ -177,4 +177,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);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@ -10,8 +10,7 @@ require_once './libraries/Message.class.php';
|
||||
/**
|
||||
* Handles the recently used tables.
|
||||
*
|
||||
* @TODO Add documentation about configuration LeftRecentTable
|
||||
* @TODO Add documentation about table pma_recent (#recent) in Documentation.html
|
||||
* @TODO Change the release version in table pma_recent (#recent in Documentation.html)
|
||||
*
|
||||
* @package phpMyAdmin
|
||||
*/
|
||||
@ -124,7 +123,8 @@ class RecentTable
|
||||
*/
|
||||
public function trim()
|
||||
{
|
||||
while (count($this->tables) > $GLOBALS['cfg']['LeftRecentTable']) {
|
||||
$max = max($GLOBALS['cfg']['LeftRecentTable'], 0);
|
||||
while (count($this->tables) > $max) {
|
||||
array_pop($this->tables);
|
||||
}
|
||||
}
|
||||
@ -137,13 +137,10 @@ class RecentTable
|
||||
public function getHtmlSelect()
|
||||
{
|
||||
$this->trim();
|
||||
|
||||
$html = '<select onchange="if (this.value != \'\') {'.
|
||||
'arr=this.value.split(\'.\');'.
|
||||
'window.parent.setDb(arr[0]);'.
|
||||
'window.parent.setTable(arr[1]);'.
|
||||
'window.parent.refreshMain(\'' . $GLOBALS['cfg']['LeftDefaultTabTable'] . '\');'.
|
||||
'}">';
|
||||
|
||||
$html = '<input type="hidden" id="LeftDefaultTabTable" value="' .
|
||||
$GLOBALS['cfg']['LeftDefaultTabTable'] . '" />';
|
||||
$html .= '<select id="recentTable">';
|
||||
$html .= '<option value="">(' . __('Recent tables') . ') ...</option>';
|
||||
foreach ($this->tables as $table) {
|
||||
$html .= '<option value="' . $table . '">' . $table . '</option>';
|
||||
|
||||
@ -12,6 +12,23 @@ 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) {
|
||||
$GLOBALS['reload'] = true;
|
||||
PMA_reloadNavigation();
|
||||
} else {
|
||||
$error = $tmp_result;
|
||||
$error->display();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is not an Ajax request so we need to generate all this output.
|
||||
*/
|
||||
@ -151,14 +168,7 @@ if (isset($GLOBALS['is_ajax_request']) && !$GLOBALS['is_ajax_request']) {
|
||||
} // end if
|
||||
|
||||
// add recently used table and reload the navigation
|
||||
$tmp_result = RecentTable::getInstance()->add($GLOBALS['db'], $GLOBALS['table']);
|
||||
if ($tmp_result === true) {
|
||||
$GLOBALS['reload'] = true;
|
||||
PMA_reloadNavigation();
|
||||
} else {
|
||||
$error = $tmp_result;
|
||||
$error->display();
|
||||
}
|
||||
PMA_addRecentTable($GLOBALS['db'], $GLOBALS['table']);
|
||||
} else {
|
||||
// no table selected, display database comment if present
|
||||
/**
|
||||
|
||||
@ -183,7 +183,7 @@ require './libraries/navigation_header.inc.php';
|
||||
require_once './libraries/RecentTable.class.php';
|
||||
|
||||
// display recently used tables
|
||||
if ($GLOBALS['cfg']['LeftRecentTable'] && count(RecentTable::getInstance()->tables)) {
|
||||
if (($GLOBALS['cfg']['LeftRecentTable'] > 0) && count(RecentTable::getInstance()->tables)) {
|
||||
echo '<div id="recentTableList">';
|
||||
echo RecentTable::getInstance()->getHtmlSelect();
|
||||
echo '</div>';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user