getItems() becomes getLimitedItems($offset, $count)

This commit is contained in:
Marc Delisle
2007-06-20 11:52:06 +00:00
parent 4f9eb57c15
commit 7d750dded7
2 changed files with 22 additions and 23 deletions

View File

@@ -50,9 +50,6 @@ require_once './libraries/List.class.php';
*/
var $_show_databases_disabled = false;
var $limit_offset = 0;
var $limit_count = 0;
/**
* Constructor
*
@@ -303,13 +300,15 @@ require_once './libraries/List.class.php';
* @uses implode()
* @uses strstr()
* @uses explode()
* @param integer $offset
* @param integer $count
* @return array db list
*/
function getGroupedDetails()
function getGroupedDetails($offset, $count)
{
$dbgroups = array();
$parts = array();
foreach ($this->getItems() as $key => $db) {
foreach ($this->getLimitedItems($offset, $count) as $key => $db) {
// garvin: Get comments from PMA comments table
$db_tooltip = '';
if ($GLOBALS['cfg']['ShowTooltip']
@@ -358,14 +357,14 @@ require_once './libraries/List.class.php';
* 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
* @param integer $offset
* @param integer $count
* @return array some items
*/
function getItems()
function getLimitedItems($offset, $count)
{
return(array_slice($this->items, $this->limit_offset, $this->limit_count));
return(array_slice($this->items, $offset, $count));
}
/**
@@ -373,14 +372,14 @@ require_once './libraries/List.class.php';
*
* @return string html code list
*/
function getHtmlListGrouped($selected = '')
function getHtmlListGrouped($selected = '', $offset, $count)
{
if (true === $selected) {
$selected = $this->getDefault();
}
$return = '<ul id="databaseList" xml:lang="en" dir="ltr">' . "\n";
foreach ($this->getGroupedDetails() as $group => $dbs) {
foreach ($this->getGroupedDetails($offset, $count) as $group => $dbs) {
if (count($dbs) > 1) {
$return .= '<li>' . $group . '<ul>' . "\n";
// wether display db_name cuted by the group part
@@ -417,7 +416,7 @@ require_once './libraries/List.class.php';
*
* @return string html code select
*/
function getHtmlSelectGrouped($selected = '')
function getHtmlSelectGrouped($selected = '', $offset, $count)
{
if (true === $selected) {
$selected = $this->getDefault();
@@ -427,7 +426,7 @@ require_once './libraries/List.class.php';
. ' onchange="if (this.value != \'\') window.parent.openDb(this.value);">' . "\n"
. '<option value="" dir="' . $GLOBALS['text_dir'] . '">'
. '(' . $GLOBALS['strDatabases'] . ') ...</option>' . "\n";
foreach ($this->getGroupedDetails() as $group => $dbs) {
foreach ($this->getGroupedDetails($offset, $count) as $group => $dbs) {
if (count($dbs) > 1) {
$return .= '<optgroup label="' . htmlspecialchars($group)
. '">' . "\n";

View File

@@ -79,8 +79,7 @@ if (! isset($_SESSION['navi_limit_offset'])) {
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'];
$pos = $_SESSION['navi_limit_offset'];
// free the session file, for the other frames to be loaded
session_write_close();
@@ -119,8 +118,7 @@ if (! isset($_SESSION['navi_limit_offset'])) {
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'];
$pos = $_SESSION['navi_limit_offset'];
/*
* Displays the frame
@@ -202,14 +200,14 @@ if (! $GLOBALS['server']) {
<label for="lightm_db"><?php echo $GLOBALS['strDatabase']; ?></label>
<?php
echo PMA_generate_common_hidden_inputs() . "\n";
echo $GLOBALS['PMA_List_Database']->getHtmlSelectGrouped(true) . "\n";
echo $GLOBALS['PMA_List_Database']->getHtmlSelectGrouped(true, $_SESSION['navi_limit_offset'], $GLOBALS['cfg']['MaxDbList']) . "\n";
echo '<noscript>' . "\n"
.'<input type="submit" name="Go" value="' . $GLOBALS['strGo'] . '" />' . "\n"
.'</noscript>' . "\n"
.'</form>' . "\n"
.'</div>' . "\n";
} else {
echo $GLOBALS['PMA_List_Database']->getHtmlListGrouped(true) . "\n";
echo $GLOBALS['PMA_List_Database']->getHtmlListGrouped(true, $_SESSION['navi_limit_offset'], $GLOBALS['cfg']['MaxDbList']) . "\n";
}
}
?>
@@ -282,7 +280,7 @@ if ($GLOBALS['cfg']['LeftFrameLight'] && strlen($GLOBALS['db'])) {
echo '<p>' . $GLOBALS['strSelectADb'] . '</p>' . "\n";
} else {
$common_url_query = PMA_generate_common_url();
PMA_displayDbList($GLOBALS['PMA_List_Database']->getGroupedDetails());
PMA_displayDbList($GLOBALS['PMA_List_Database']->getGroupedDetails($_SESSION['navi_limit_offset'],$GLOBALS['cfg']['MaxDbList']), $_SESSION['navi_limit_offset'],$GLOBALS['cfg']['MaxDbList']);
}
/**
@@ -305,14 +303,16 @@ if ($GLOBALS['cfg']['LeftFrameLight'] && strlen($GLOBALS['db'])) {
* @global $db_start
* @global $common_url_query
* @param array $ext_dblist extended db list
* @param integer $offset
* @param integer $count
*/
function PMA_displayDbList($ext_dblist) {
function PMA_displayDbList($ext_dblist, $offset, $count) {
global $element_counter, $img_minus, $img_plus, $href_left,
$db_start, $common_url_query;
// get table list, for all databases
// doing this in one step takes advantage of a single query with information_schema!
$tables_full = PMA_DBI_get_tables_full($GLOBALS['PMA_List_Database']->getItems());
$tables_full = PMA_DBI_get_tables_full($GLOBALS['PMA_List_Database']->getLimitedItems($offset, $count));
$url_dbgroup = '';
echo '<ul id="leftdatabaselist">';