Skip to content

Commit

Permalink
Update recent tables through index,php instead of navigation.php
Browse files Browse the repository at this point in the history
  • Loading branch information
roccivic committed Oct 30, 2012
1 parent 307fff3 commit 4d4c8a9
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 42 deletions.
12 changes: 12 additions & 0 deletions index.php
Expand Up @@ -41,6 +41,18 @@
exit;
}

/**
* Check if it is an ajax request to reload the recent tables list.
*/
require_once 'libraries/RecentTable.class.php';
if ($GLOBALS['is_ajax_request'] && ! empty($_REQUEST['recent_table'])) {
$response = PMA_Response::getInstance();
$response->addJSON(
'options',
PMA_RecentTable::getInstance()->getHtmlSelectOption()
);
exit;
}

if ($GLOBALS['PMA_Config']->isGitRevision()) {
if (isset($_REQUEST['git_revision']) && $GLOBALS['is_ajax_request'] == true) {
Expand Down
18 changes: 11 additions & 7 deletions js/functions.js
Expand Up @@ -3231,13 +3231,17 @@ AJAX.registerOnload('functions.js', function() {
return false;
});

$('#update_recent_tables').ready(function() {
if (window.parent.frame_navigation != undefined
&& window.parent.frame_navigation.PMA_reloadRecentTable != undefined)
{
window.parent.frame_navigation.PMA_reloadRecentTable();
}
});
if ($('#update_recent_tables').length) {
$.get(
$('#update_recent_tables').attr('href'),
function (data) {
if (data.success == true) {
$('#recentTable').html(data.options);
}
}
);
}

}); // end of $()

/**
Expand Down
17 changes: 0 additions & 17 deletions js/navigation.js
Expand Up @@ -235,23 +235,6 @@ function clear_fast_db_filter()
fast_db_filter('');
}

/**
* Reloads the recent tables list.
*/
function PMA_reloadRecentTable()
{
$.get('navigation.php', {
'token': window.parent.token,
'server': window.parent.server,
'ajax_request': true,
'recent_table': true},
function (data) {
if (data.success == true) {
$('#recentTable').html(data.options);
}
});
}

/* Performed on load */
$(function(){

Expand Down
12 changes: 7 additions & 5 deletions libraries/Header.class.php
Expand Up @@ -329,10 +329,6 @@ public function getDisplay()
if (! $GLOBALS['cfg']['ShowHint']) {
$retval .= '<span id="no_hint" class="hide"></span>';
}
$retval .= $this->_addRecentTable(
$GLOBALS['db'],
$GLOBALS['table']
);
$retval .= $this->_getWarnings();
if ($this->_menuEnabled && $GLOBALS['server'] > 0) {
$retval .= $this->_menu->getDisplay();
Expand All @@ -349,6 +345,10 @@ public function getDisplay()
}
}
}
$retval .= $this->_addRecentTable(
$GLOBALS['db'],
$GLOBALS['table']
);
}
return $retval;
}
Expand Down Expand Up @@ -545,7 +545,9 @@ private function _addRecentTable($db, $table)
if ($this->_menuEnabled && strlen($table) && $GLOBALS['cfg']['LeftRecentTable'] > 0) {
$tmp_result = PMA_RecentTable::getInstance()->add($db, $table);
if ($tmp_result === true) {
$retval = '<span class="hide" id="update_recent_tables"></span>';
$params = array('ajax_request' => true, 'recent_table' => true);
$url = 'index.php' . PMA_generate_common_url($params);
$retval = '<a class="hide" id="update_recent_tables" href="' . $url . '"></a>';
} else {
$error = $tmp_result;
$retval = $error->getDisplay();
Expand Down
13 changes: 0 additions & 13 deletions navigation.php
Expand Up @@ -25,19 +25,6 @@ function PMA_exitNavigationFrame()
}

require_once 'libraries/Util.class.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']) {
$response = PMA_Response::getInstance();
$response->addJSON(
'options',
PMA_RecentTable::getInstance()->getHtmlSelectOption()
);
exit;
}

// keep the offset of the db list in session before closing it
if (! isset($_SESSION['tmp_user_values']['navi_limit_offset'])) {
Expand Down

0 comments on commit 4d4c8a9

Please sign in to comment.