From 2ebdaf7469a4ade89fe2f6e674e24115d77ca431 Mon Sep 17 00:00:00 2001 From: Sebastian Mendel Date: Fri, 22 Sep 2006 13:45:19 +0000 Subject: [PATCH] cleanup --- ChangeLog | 1 + left.php | 308 +++++++++++++++++++++--------------------------------- 2 files changed, 121 insertions(+), 188 deletions(-) diff --git a/ChangeLog b/ChangeLog index daceab715..e7f20c0eb 100755 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ $Source$ 2006-09-22 Sebastian Mendel * libraries/ob.lib.php: refactored + * left.php: cleanup 2006-09-21 Sebastian Mendel * libraries/PMA_List.class.php: new PMA_List class diff --git a/left.php b/left.php index 7be533cfc..efee0df06 100644 --- a/left.php +++ b/left.php @@ -3,6 +3,43 @@ // vim: expandtab sw=4 ts=4 sts=4: /** * the navigation frame - displays server, db and table selection tree + * + * @uses $GLOBALS['PMA_List_Database'] + * @uses $GLOBALS['server'] + * @uses $GLOBALS['db'] + * @uses $GLOBALS['table'] + * @uses $GLOBALS['available_languages'] + * @uses $GLOBALS['lang'] + * @uses $GLOBALS['text_dir'] + * @uses $GLOBALS['charset'] + * @uses $GLOBALS['pmaThemeImage'] + * @uses $GLOBALS['strNoDatabases'] + * @uses $GLOBALS['strDatabase'] + * @uses $GLOBALS['strGo'] + * @uses $GLOBALS['strSelectADb'] + * @uses $GLOBALS['strNoTablesFound'] + * @uses $GLOBALS['cfg']['LeftFrameLight'] + * @uses $GLOBALS['cfg']['ShowTooltip'] + * @uses $GLOBALS['cfg']['ShowTooltipAliasDB'] + * @uses $GLOBALS['cfg']['DefaultTabDatabase'] + * @uses $GLOBALS['cfgRelation']['commwork']) { + * @uses PMA_List_Database::getSingleItem() + * @uses PMA_List_Database::count() + * @uses PMA_List_Database::getHtmlSelectGrouped() + * @uses PMA_List_Database::getGroupedDetails() + * @uses PMA_generate_common_url() + * @uses PMA_generate_common_hidden_inputs() + * @uses PMA_getComments(); + * @uses PMA_getTableCount() + * @uses PMA_getTableList() + * @uses PMA_getRelationsParam() + * @uses PMA_outBufferPre() + * @uses session_write_close() + * @uses strlen() + * @uses session_write_close() + * @uses is_array() + * @uses implode() + * @uses htmlspecialchars() */ /** @@ -10,44 +47,69 @@ */ require_once './libraries/common.lib.php'; +/** + * finish and cleanup left.php script execution + * + * @uses $GLOBALS['controllink'] to close it + * @uses $GLOBALS['userlink'] to close it + * @uses PMA_outBufferPost() + * @uses PMA_DBI_close() + * @access private only to be used in left.php + */ +function PMA_exitLeftFrame() +{ + echo ''; + + /** + * Close MySQL connections + */ + if (isset($GLOBALS['controllink']) && $GLOBALS['controllink']) { + @PMA_DBI_close($GLOBALS['controllink']); + } + if (isset($GLOBALS['userlink']) && $GLOBALS['userlink']) { + @PMA_DBI_close($GLOBALS['userlink']); + } + + /** + * Sends bufferized data + */ + PMA_outBufferPost(); + + exit(); +} + // free the session file, for the other frames to be loaded session_write_close(); +/** + * the output compression library + */ require_once './libraries/ob.lib.php'; -if ($GLOBALS['cfg']['OBGzip']) { - $ob_mode = PMA_outBufferModeGet(); - if ($ob_mode) { - PMA_outBufferPre($ob_mode); - } + +PMA_outBufferPre(); + +/* + * selects the database if there is only one on current server + */ +if ($GLOBALS['server'] && ! strlen($GLOBALS['db'])) { + $GLOBALS['db'] = $GLOBALS['PMA_List_Database']->getSingleItem(); } -require_once './libraries/bookmark.lib.php'; +$db_start = $GLOBALS['db']; + +/** + * the relation library + */ require_once './libraries/relation.lib.php'; $cfgRelation = PMA_getRelationsParam(); /** - * Get the list and number of available databases. - * Skipped if no server selected: in this case no database should be displayed - * before the user choose among available ones at the welcome screen. + * garvin: For re-usability, moved http-headers to a seperate file. + * It can now be included by libraries/header.inc.php, querywindow.php. */ -if ($server > 0) { - if (! isset($db) || ! strlen($db)) { - $db = $GLOBALS['PMA_List_Database']->getSingleItem(); - } -} - -$db = isset($db) ? $db : ''; -$table = isset($table) ? $table : ''; -$db_start = $db; - - -// garvin: For re-usability, moved http-headers -// to a seperate file. It can now be included by libraries/header.inc.php, -// querywindow.php. - require_once './libraries/header_http.inc.php'; -/** +/* * Displays the frame */ // xml declaration moves IE into quirks mode, making much trouble with CSS @@ -58,124 +120,26 @@ require_once './libraries/header_http.inc.php'; + dir=""> phpMyAdmin + content="text/html; charset=" /> - @@ -193,28 +157,13 @@ require_once './libraries/header_http.inc.php'; count()) { +if (! $GLOBALS['server']) { + // no server selected + PMA_exitLeftFrame(); +} elseif (! $GLOBALS['PMA_List_Database']->count()) { // no database available, so we break here - echo '

' . $strNoDatabases . '

'; - - /** - * Close MySql connections - */ - if (isset($controllink) && $controllink) { - @PMA_DBI_close($controllink); - } - if (isset($userlink) && $userlink) { - @PMA_DBI_close($userlink); - } - - /** - * Sends bufferized data - */ - if ($GLOBALS['cfg']['OBGzip'] && isset($ob_mode) && $ob_mode) { - PMA_outBufferPost($ob_mode); - } - exit(); + echo '

' . $GLOBALS['strNoDatabases'] . '

'; + PMA_exitLeftFrame(); } elseif ($GLOBALS['cfg']['LeftFrameLight'] && $GLOBALS['PMA_List_Database']->count() > 1) { // more than one database available and LeftFrameLight is true // display db selectbox @@ -227,12 +176,12 @@ if (! $GLOBALS['PMA_List_Database']->count()) {
- + getHtmlSelectGrouped(true) . "\n"; echo '' . "\n" .'
' . "\n" .'
' . "\n"; @@ -242,7 +191,7 @@ if (! $GLOBALS['PMA_List_Database']->count()) {
@@ -287,19 +237,19 @@ if ($GLOBALS['cfg']['LeftFrameLight'] && isset($db) && strlen($db)) { title="" > (' . PMA_getTableCount($db) . ') '; + echo ' (' . PMA_getTableCount($GLOBALS['db']) . ') '; } echo htmlspecialchars($disp_name); if ($GLOBALS['text_dir'] === 'ltr') { - echo ' (' . PMA_getTableCount($db) . ') '; + echo ' (' . PMA_getTableCount($GLOBALS['db']) . ') '; } echo '

'; - $table_list = PMA_getTableList($db); + $table_list = PMA_getTableList($GLOBALS['db']); if (count($table_list) > 0) { - PMA_displayTableList($table_list, true, '', $db); + PMA_displayTableList($table_list, true, '', $GLOBALS['db']); } else { - echo $strNoTablesFound; + echo $GLOBALS['strNoTablesFound']; } unset($table_list); } elseif ($GLOBALS['cfg']['LeftFrameLight']) { @@ -498,10 +448,10 @@ function PMA_displayDbList($ext_dblist) { * @uses $GLOBALS['cfg']['DefaultTabTable'] * @uses $GLOBALS['strRows'] * @uses $GLOBALS['strBrowse'] - * @global $element_counter - * @global $img_minus - * @global $img_plus - * @global $href_left + * @global integer the element counter + * @global string html code for '-' image + * @global string html code for '+' image + * @global string html code for self link * @param array $tables array of tables/tablegroups * @param boolean $visible wether the list is visible or not * @param string $tab_group_full full tab group name @@ -612,25 +562,7 @@ function PMA_displayTableList($tables, $visible = false, } echo ''; } -?> -
- - -'; +PMA_exitLeftFrame(); ?>