You've already forked phpmyadmin
mirror of
https://github.com/phpmyadmin/phpmyadmin.git
synced 2026-10-28 07:41:55 +03:00
Preload the navigation tree to save an ajax request and don't store the pagination position in the session
This commit is contained in:
@@ -38,7 +38,8 @@ $(document).ready(function() {
|
||||
$throbber.insertBefore($icon);
|
||||
var params = {
|
||||
a_path: $(this).find('span.a_path').text(),
|
||||
v_path: $(this).find('span.v_path').text()
|
||||
v_path: $(this).find('span.v_path').text(),
|
||||
pos: $(this).find('span.pos').text()
|
||||
};
|
||||
var url = $('#pma_navigation').find('a.navigation_url').attr('href');
|
||||
$.get(url, params, function (data) {
|
||||
@@ -48,8 +49,8 @@ $(document).ready(function() {
|
||||
$destination.append(data.message);
|
||||
$icon.removeClass('ic_b_plus').addClass('ic_b_minus');
|
||||
$destination.children('div.list_container').show('fast', function () {
|
||||
ScrollHandler.displayScrollbar();
|
||||
});
|
||||
ScrollHandler.displayScrollbar();
|
||||
});
|
||||
if ($destination.find('ul > li').length == 1) {
|
||||
$destination.find('ul > li')
|
||||
.find('a.expander.container')
|
||||
@@ -78,7 +79,8 @@ function PMA_reloadNavigation() {
|
||||
.first()
|
||||
.css('visibility', 'visible');
|
||||
var params = {
|
||||
reload: true
|
||||
reload: true,
|
||||
pos: $('#pma_navigation_tree').find('a.expander:first > span.pos').text()
|
||||
};
|
||||
var count = 0;
|
||||
$('#pma_navigation_tree').find('a.expander:visible').each(function () {
|
||||
@@ -366,18 +368,10 @@ var ResizeHandler = function () {
|
||||
$collapser.html(this.getSymbol($('#pma_navigation').width()));
|
||||
}; // End of ResizeHandler
|
||||
|
||||
|
||||
/* Performed on load */
|
||||
$(function(){
|
||||
if ($('#pma_navigation_tree').length) {
|
||||
// Load the navigation into the initial page
|
||||
var url = $('#pma_navigation').find('a.navigation_url').attr('href');
|
||||
$.get(url, 'full=true', function (data) {
|
||||
if (data.success) {
|
||||
$('#pma_navigation_tree').html(data.message).children('div').show();
|
||||
ScrollHandler.displayScrollbar();
|
||||
}
|
||||
});
|
||||
if ($('#pma_navigation').length) {
|
||||
$('#pma_navigation_tree').children('div').show();
|
||||
// Fire up the resize and scroll handlers
|
||||
new ResizeHandler();
|
||||
ScrollHandler.init();
|
||||
|
||||
@@ -12,7 +12,7 @@ if (! defined('PHPMYADMIN')) {
|
||||
require_once 'libraries/Scripts.class.php';
|
||||
require_once 'libraries/RecentTable.class.php';
|
||||
require_once 'libraries/Menu.class.php';
|
||||
require_once 'libraries/navigation/NavigationHeader.class.php';
|
||||
require_once 'libraries/navigation/Navigation.class.php';
|
||||
|
||||
/**
|
||||
* Class used to output the HTTP and HTML headers
|
||||
@@ -312,7 +312,7 @@ class PMA_Header
|
||||
$retval .= $this->_scripts->getDisplay();
|
||||
$retval .= $this->_getBodyStart();
|
||||
if ($this->_menuEnabled && $GLOBALS['server'] > 0) {
|
||||
$nav = new PMA_NavigationHeader();
|
||||
$nav = new PMA_Navigation();
|
||||
$retval .= $nav->getDisplay();
|
||||
}
|
||||
// Include possible custom headers
|
||||
|
||||
@@ -1,5 +1,33 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
|
||||
// The Nodes are the building blocks for the navigation tree
|
||||
require_once 'libraries/navigation/Nodes/Node.class.php';
|
||||
// All of the below Nodes inherit from the base Node
|
||||
require_once 'libraries/navigation/Nodes/Node_Column.class.php';
|
||||
require_once 'libraries/navigation/Nodes/Node_Database.class.php';
|
||||
require_once 'libraries/navigation/Nodes/Node_Event.class.php';
|
||||
require_once 'libraries/navigation/Nodes/Node_Function.class.php';
|
||||
require_once 'libraries/navigation/Nodes/Node_Index.class.php';
|
||||
require_once 'libraries/navigation/Nodes/Node_Procedure.class.php';
|
||||
require_once 'libraries/navigation/Nodes/Node_Table.class.php';
|
||||
require_once 'libraries/navigation/Nodes/Node_Trigger.class.php';
|
||||
require_once 'libraries/navigation/Nodes/Node_View.class.php';
|
||||
// Containers. Also inherit from the base Node
|
||||
require_once 'libraries/navigation/Nodes/Node_Column_Container.class.php';
|
||||
require_once 'libraries/navigation/Nodes/Node_Event_Container.class.php';
|
||||
require_once 'libraries/navigation/Nodes/Node_Function_Container.class.php';
|
||||
require_once 'libraries/navigation/Nodes/Node_Index_Container.class.php';
|
||||
require_once 'libraries/navigation/Nodes/Node_Procedure_Container.class.php';
|
||||
require_once 'libraries/navigation/Nodes/Node_Table_Container.class.php';
|
||||
require_once 'libraries/navigation/Nodes/Node_Trigger_Container.class.php';
|
||||
require_once 'libraries/navigation/Nodes/Node_View_Container.class.php';
|
||||
|
||||
// Generates a collapsible tree of database objects
|
||||
require_once 'libraries/navigation/NavigationTree.class.php';
|
||||
|
||||
require_once 'libraries/navigation/NavigationHeader.class.php';
|
||||
|
||||
/**
|
||||
* Functionality for the navigation frame
|
||||
*
|
||||
@@ -23,16 +51,32 @@ class PMA_Navigation {
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
$this->pos = $_SESSION['tmp_user_values']['navi_limit_offset'];
|
||||
if (isset($_REQUEST['pos'])) {
|
||||
$pos = (int) $_REQUEST['pos'];
|
||||
$_SESSION['tmp_user_values']['navi_limit_offset'] = $pos;
|
||||
$this->pos = $pos;
|
||||
$this->pos = (int) $_REQUEST['pos'];
|
||||
}
|
||||
if (! isset($this->pos)) {
|
||||
$this->pos = $this->_getNavigationDbPos();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the database position for the page selector
|
||||
*
|
||||
* return int
|
||||
*/
|
||||
private function _getNavigationDbPos() {
|
||||
$query = "SELECT (COUNT(`SCHEMA_NAME`) DIV %d) * %d ";
|
||||
$query .= "FROM `INFORMATION_SCHEMA`.`SCHEMATA` ";
|
||||
$query .= "WHERE `SCHEMA_NAME` <= '%s'";
|
||||
|
||||
return PMA_DBI_fetch_value(
|
||||
sprintf(
|
||||
$query,
|
||||
(int)$GLOBALS['cfg']['MaxDbList'],
|
||||
(int)$GLOBALS['cfg']['MaxDbList'],
|
||||
PMA_CommonFunctions::getInstance()->sqlAddSlashes($GLOBALS['db'])
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,8 +88,15 @@ class PMA_Navigation {
|
||||
{
|
||||
/* Init */
|
||||
$retval = '';
|
||||
$tree = new PMA_NavigationTree($this->pos);
|
||||
if (! empty($_REQUEST['full']) || ! empty($_REQUEST['reload'])) {
|
||||
if (! PMA_Response::getInstance()->isAjax()) {
|
||||
$header = new PMA_NavigationHeader();
|
||||
$retval = $header->getDisplay();
|
||||
}
|
||||
$tree = new PMA_NavigationTree($this->pos);
|
||||
if (! PMA_Response::getInstance()->isAjax()
|
||||
|| ! empty($_REQUEST['full'])
|
||||
|| ! empty($_REQUEST['reload'])
|
||||
) {
|
||||
$_url_params = array('pos' => $this->pos, 'server' => $GLOBALS['server']);
|
||||
$num_db = PMA_DBI_fetch_value(
|
||||
"SELECT COUNT(*) FROM `INFORMATION_SCHEMA`.`SCHEMATA`"
|
||||
@@ -58,15 +109,23 @@ class PMA_Navigation {
|
||||
'frame_navigation',
|
||||
$GLOBALS['cfg']['MaxDbList']
|
||||
);
|
||||
$retval .= $tree->renderState();
|
||||
$treeRender = $tree->renderState();
|
||||
} else {
|
||||
$retval = $tree->renderPath();
|
||||
$treeRender = $tree->renderPath();
|
||||
}
|
||||
|
||||
if (! $retval) {
|
||||
$retval = PMA_Message::error(
|
||||
if (! $treeRender) {
|
||||
$retval .= PMA_Message::error(
|
||||
__('An error has occured while loading the navigation tree')
|
||||
);
|
||||
} else {
|
||||
$retval .= $treeRender;
|
||||
}
|
||||
|
||||
if (! PMA_Response::getInstance()->isAjax()) {
|
||||
$retval .= '</div>';
|
||||
$retval .= '</div>';
|
||||
$retval .= '</div>';
|
||||
}
|
||||
|
||||
return $retval;
|
||||
|
||||
@@ -20,16 +20,11 @@ class PMA_NavigationHeader
|
||||
if (empty($GLOBALS['url_query'])) {
|
||||
$GLOBALS['url_query'] = PMA_generate_common_url();
|
||||
}
|
||||
|
||||
$link_url = PMA_generate_common_url(
|
||||
array(
|
||||
'ajax_request' => true
|
||||
)
|
||||
);
|
||||
$link = sprintf(
|
||||
'<a class="hide navigation_url" href="navigation.php%s"></a>',
|
||||
$link_url
|
||||
);
|
||||
|
||||
$buffer = '<div id="pma_navigation">';
|
||||
$buffer .= '<div id="pma_navigation_resizer"></div>';
|
||||
@@ -39,21 +34,15 @@ class PMA_NavigationHeader
|
||||
$buffer .= '<div id="pma_navigation_scrollbar_handle">';
|
||||
$buffer .= '</div>';
|
||||
$buffer .= '</div>';
|
||||
$buffer .= $link;
|
||||
$buffer .= sprintf(
|
||||
'<a class="hide navigation_url" href="navigation.php%s"></a>',
|
||||
$link_url
|
||||
);
|
||||
$buffer .= $this->logo();
|
||||
$buffer .= $this->links();
|
||||
$buffer .= $this->serverChoice();
|
||||
$buffer .= $this->recent();
|
||||
$buffer .= '<div id="pma_navigation_tree">';
|
||||
$buffer .= '<div style="text-align:center; margin-top:1em;">';
|
||||
$buffer .= $this->_commonFunctions->getImage(
|
||||
'ajax_clock_small.gif',
|
||||
__('Loading')
|
||||
);
|
||||
$buffer .= '</div>';
|
||||
$buffer .= '</div>';
|
||||
$buffer .= '</div>';
|
||||
$buffer .= '</div>';
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
|
||||
@@ -535,7 +535,7 @@ class PMA_NavigationTree {
|
||||
$retval .= "<a class='expander$loaded$container' target='_self' href='#'>";
|
||||
$retval .= "<span class='hide a_path'>" . $a_path . "</span>";
|
||||
$retval .= "<span class='hide v_path'>" . $v_path . "</span>";
|
||||
|
||||
$retval .= "<span class='hide pos'>" . $this->pos . "</span>";
|
||||
$retval .= $icon;
|
||||
|
||||
$retval .= "</a>";
|
||||
|
||||
@@ -9,31 +9,6 @@
|
||||
// Include common functionalities
|
||||
require_once './libraries/common.inc.php';
|
||||
|
||||
// The Nodes are the building blocks for the navigation tree
|
||||
require_once './libraries/navigation/Nodes/Node.class.php';
|
||||
// All of the below Nodes inherit from the base Node
|
||||
require_once './libraries/navigation/Nodes/Node_Column.class.php';
|
||||
require_once './libraries/navigation/Nodes/Node_Database.class.php';
|
||||
require_once './libraries/navigation/Nodes/Node_Event.class.php';
|
||||
require_once './libraries/navigation/Nodes/Node_Function.class.php';
|
||||
require_once './libraries/navigation/Nodes/Node_Index.class.php';
|
||||
require_once './libraries/navigation/Nodes/Node_Procedure.class.php';
|
||||
require_once './libraries/navigation/Nodes/Node_Table.class.php';
|
||||
require_once './libraries/navigation/Nodes/Node_Trigger.class.php';
|
||||
require_once './libraries/navigation/Nodes/Node_View.class.php';
|
||||
// Containers. Also inherit from the base Node
|
||||
require_once './libraries/navigation/Nodes/Node_Column_Container.class.php';
|
||||
require_once './libraries/navigation/Nodes/Node_Event_Container.class.php';
|
||||
require_once './libraries/navigation/Nodes/Node_Function_Container.class.php';
|
||||
require_once './libraries/navigation/Nodes/Node_Index_Container.class.php';
|
||||
require_once './libraries/navigation/Nodes/Node_Procedure_Container.class.php';
|
||||
require_once './libraries/navigation/Nodes/Node_Table_Container.class.php';
|
||||
require_once './libraries/navigation/Nodes/Node_Trigger_Container.class.php';
|
||||
require_once './libraries/navigation/Nodes/Node_View_Container.class.php';
|
||||
|
||||
// Generates a collapsible tree of database objects
|
||||
require_once './libraries/navigation/NavigationTree.class.php';
|
||||
|
||||
// Also initialises the collapsible tree class
|
||||
require_once './libraries/navigation/Navigation.class.php';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user