diff --git a/Documentation.html b/Documentation.html index ad89a5db4..e4f72846e 100644 --- a/Documentation.html +++ b/Documentation.html @@ -1088,6 +1088,10 @@ ALTER TABLE `pma_column_comments` If you have only one server configured, $cfg['ServerDefault'] MUST be set to that server. +
$cfg['MaxDbList'] integer
+
The maximum number of database names to be displayed in the + navigation frame and the database list.
+
$cfg['OBGzip'] string/boolean
Defines whether to use GZip output buffering for increased speed in HTTP transfers.
diff --git a/libraries/List_Database.class.php b/libraries/List_Database.class.php index 58254d559..26c19ff08 100644 --- a/libraries/List_Database.class.php +++ b/libraries/List_Database.class.php @@ -50,6 +50,9 @@ require_once './libraries/List.class.php'; */ var $_show_databases_disabled = false; + var $limit_offset = 0; + var $limit_count = 0; + /** * Constructor * @@ -88,7 +91,7 @@ require_once './libraries/List.class.php'; */ function _checkAccess() { - foreach ($this->items as $key => $db) { + foreach ($this->getItems() as $key => $db) { if (! @PMA_DBI_select_db($db, $this->_db_link_user)) { unset($this->items[$key]); } @@ -114,7 +117,7 @@ require_once './libraries/List.class.php'; return; } - foreach ($this->items as $key => $db) { + foreach ($this->getItems() as $key => $db) { if (preg_match('/' . $GLOBALS['cfg']['Server']['hide_db'] . '/', $db)) { unset($this->items[$key]); } @@ -192,7 +195,6 @@ require_once './libraries/List.class.php'; if (! $this->_checkOnlyDatabase()) { $this->items = $this->_retrieve(); - if ($GLOBALS['cfg']['NaturalOrder']) { natsort($this->items); $this->_need_to_reindex = true; @@ -307,7 +309,7 @@ require_once './libraries/List.class.php'; { $dbgroups = array(); $parts = array(); - foreach ($this->items as $key => $db) { + foreach ($this->getItems() as $key => $db) { // garvin: Get comments from PMA comments table $db_tooltip = ''; if ($GLOBALS['cfg']['ShowTooltip'] @@ -352,6 +354,20 @@ require_once './libraries/List.class.php'; return $dbgroups; } + /** + * returns a part of the items + * + * @uses PMA_List_Database::$items + * @uses PMA_List_Database::$limit_offset + * @uses PMA_List_Database::$limit_count + * @uses array_slice() + * @return array the items + */ + function getItems() + { + return(array_slice($this->items, $this->limit_offset, $this->limit_count)); + } + /** * returns html code for list with dbs * diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 91afab1e3..f2ee8556c 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -2099,6 +2099,83 @@ function PMA_pageselector($url, $rows, $pageNow = 1, $nbTotalPage = 1, return $gotopage; } // end function + +/** + * Generate navigation for db list + * + * @todo use $pos from $_url_params + * @uses $GLOBALS['strPageNumber'] + * @uses range() + * @param integer number of databases + * @param integer current position in the list + * @param array url parameters + * @param string script name for form target + * @param string target frame + * + * @access public + */ +function PMA_dbPageSelector($databases_count, $pos, $_url_params, $script, $frame) { + + if ($GLOBALS['cfg']['MaxDbList'] + && $GLOBALS['cfg']['MaxDbList'] < $databases_count) { + // Move to the beginning or to the previous page + if ($pos > 0) { + // loic1: patch #474210 from Gosha Sakovich - part 1 + if ($GLOBALS['cfg']['NavigationBarIconic']) { + $caption1 = '<<'; + $caption2 = ' < '; + $title1 = ' title="' . $GLOBALS['strPos1'] . '"'; + $title2 = ' title="' . $GLOBALS['strPrevious'] . '"'; + } else { + $caption1 = $GLOBALS['strPos1'] . ' <<'; + $caption2 = $GLOBALS['strPrevious'] . ' <'; + $title1 = ''; + $title2 = ''; + } // end if... else... + $_url_params['pos'] = 0; + echo '' + . $caption1 . ''; + $_url_params['pos'] = $pos - $GLOBALS['cfg']['MaxDbList']; + echo '' + . $caption2 . ''; + } + + echo '
' . "\n"; + echo PMA_generate_common_hidden_inputs($_url_params); + echo PMA_pageselector( + $script . PMA_generate_common_url($_url_params) . '&', + $GLOBALS['cfg']['MaxDbList'], + floor(($pos + 1) / $GLOBALS['cfg']['MaxDbList']) + 1, + ceil($databases_count / $GLOBALS['cfg']['MaxDbList'])); + echo '
'; + + if ($pos + $GLOBALS['cfg']['MaxDbList'] < $databases_count) { + if ($GLOBALS['cfg']['NavigationBarIconic']) { + $caption3 = ' > '; + $caption4 = '>>'; + $title3 = ' title="' . $GLOBALS['strNext'] . '"'; + $title4 = ' title="' . $GLOBALS['strEnd'] . '"'; + } else { + $caption3 = '> ' . $GLOBALS['strNext']; + $caption4 = '>> ' . $GLOBALS['strEnd']; + $title3 = ''; + $title4 = ''; + } // end if... else... + $_url_params['pos'] = $pos + $GLOBALS['cfg']['MaxDbList']; + echo '' + . $caption3 . ''; + $_url_params['pos'] = floor($databases_count / $GLOBALS['cfg']['MaxDbList']) * $GLOBALS['cfg']['MaxDbList']; + echo '' + . $caption4 . ''; + } + echo "\n"; + } +} + /** * replaces %u in given path with current user name * diff --git a/navigation.php b/navigation.php index b5aabdc31..aae84e189 100644 --- a/navigation.php +++ b/navigation.php @@ -72,6 +72,16 @@ function PMA_exitNavigationFrame() exit; } +// keep the offset of the db list in session before closing it +if (! isset($_SESSION['navi_limit_offset'])) { + $_SESSION['navi_limit_offset'] = 0; +} +if (isset($_REQUEST['pos'])) { + $_SESSION['navi_limit_offset'] = (int) $_REQUEST['pos']; +} +$pos = $GLOBALS['PMA_List_Database']->limit_offset = $_SESSION['navi_limit_offset']; +$GLOBALS['PMA_List_Database']->limit_count = $GLOBALS['cfg']['MaxDbList']; + // free the session file, for the other frames to be loaded session_write_close(); @@ -103,6 +113,15 @@ $cfgRelation = PMA_getRelationsParam(); */ require_once './libraries/header_http.inc.php'; +if (! isset($_SESSION['navi_limit_offset'])) { + $_SESSION['navi_limit_offset'] = 0; +} +if (isset($_REQUEST['pos'])) { + $_SESSION['navi_limit_offset'] = (int) $_REQUEST['pos']; +} +$pos = $GLOBALS['PMA_List_Database']->limit_offset = $_SESSION['navi_limit_offset']; +$GLOBALS['PMA_List_Database']->limit_count = $GLOBALS['cfg']['MaxDbList']; + /* * Displays the frame */ @@ -126,6 +145,7 @@ require_once './libraries/header_http.inc.php'; +