diff options
author | Madhura Jayaratne <madhura.cj@gmail.com> | 2012-06-03 19:10:47 +0400 |
---|---|---|
committer | Madhura Jayaratne <madhura.cj@gmail.com> | 2012-06-03 19:10:47 +0400 |
commit | 6f9253b59e190c9e1ee8f1885c1e8c41b4fb8755 (patch) | |
tree | 66932de29d663a796540ab1c83def905d3016ea9 /navigation.php | |
parent | ddcb03fdc2a94d976ba4d1410d590634fe726e84 (diff) |
Various coding style improvements
Diffstat (limited to 'navigation.php')
-rw-r--r-- | navigation.php | 162 |
1 files changed, 121 insertions, 41 deletions
diff --git a/navigation.php b/navigation.php index a341fd89b9..3a97eb3d66 100644 --- a/navigation.php +++ b/navigation.php @@ -12,7 +12,8 @@ require_once 'libraries/common.inc.php'; /** - * finish and cleanup navigation.php script execution, only to be used in navigation.php + * finish and cleanup navigation.php script execution, + * only to be used in navigation.php * * @access private */ @@ -29,14 +30,20 @@ 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']) { - PMA_ajaxResponse('', true, array('options' => PMA_RecentTable::getInstance()->getHtmlSelectOption())); + PMA_ajaxResponse( + '', + true, + array('options' => PMA_RecentTable::getInstance()->getHtmlSelectOption()) + ); } // 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; } -if (! isset($_SESSION['tmp_user_values']['table_limit_offset']) || $_SESSION['tmp_user_values']['table_limit_offset_db'] != $db) { +if (! isset($_SESSION['tmp_user_values']['table_limit_offset']) + || $_SESSION['tmp_user_values']['table_limit_offset_db'] != $db +) { $_SESSION['tmp_user_values']['table_limit_offset'] = 0; $_SESSION['tmp_user_values']['table_limit_offset_db'] = $db; } @@ -121,7 +128,9 @@ require_once 'libraries/header_http.inc.php'; if (typeof(onLoadHandler) == "function") { onLoadHandler(); } - if (typeof(PMA_setFrameSize) != 'undefined' && typeof(PMA_setFrameSize) == 'function') { + if (typeof(PMA_setFrameSize) != 'undefined' + && typeof(PMA_setFrameSize) == 'function' + ) { PMA_setFrameSize(); } onloadCnt++; @@ -131,7 +140,9 @@ require_once 'libraries/header_http.inc.php'; if (typeof(resizeHandler) == "function") { resizeHandler(); } - if (typeof(PMA_saveFrameSize) != 'undefined' && typeof(PMA_saveFrameSize) == 'function') { + if (typeof(PMA_saveFrameSize) != 'undefined' + && typeof(PMA_saveFrameSize) == 'function' + ) { PMA_saveFrameSize(); } }; @@ -174,7 +185,9 @@ if (! $GLOBALS['server']) { // no database available, so we break here echo '<p>' . __('No databases') . '</p>'; PMA_exitNavigationFrame(); -} elseif ($GLOBALS['cfg']['LeftFrameLight'] && count($GLOBALS['pma']->databases) > 1) { +} elseif ($GLOBALS['cfg']['LeftFrameLight'] + && count($GLOBALS['pma']->databases) > 1 +) { $list = $cfg['DisplayDatabasesList']; if ($list === 'auto') { if (empty($GLOBALS['db'])) { @@ -224,8 +237,9 @@ if (! $GLOBALS['server']) { // Don't display expansible/collapsible database info if: // 1. $GLOBALS['server'] == 0 (no server selected) // This is the case when there are multiple servers and -// '$GLOBALS['cfg']['ServerDefault'] = 0' is set. In that case, we want the welcome -// screen to appear with no database info displayed. +// '$GLOBALS['cfg']['ServerDefault'] = 0' is set. +// In that case, we want the welcome screen to appear with no database +// info displayed. // 2. there is only one database available (ie either only one database exists // or $GLOBALS['cfg']['Servers']['only_db'] is defined and is not an array) // In this case, the database should not be collapsible/expandable @@ -240,7 +254,12 @@ $element_counter = 0; if ($GLOBALS['cfg']['LeftFrameLight'] && strlen($GLOBALS['db'])) { - $table_list = PMA_getTableList($GLOBALS['db'], null, $tpos, $cfg['MaxTableList']); + $table_list = PMA_getTableList( + $GLOBALS['db'], + null, + $tpos, + $cfg['MaxTableList'] + ); $table_count = PMA_getTableCount($GLOBALS['db']); // show selected databasename as link to DefaultTabDatabase-page @@ -281,18 +300,28 @@ if ($GLOBALS['cfg']['LeftFrameLight'] && strlen($GLOBALS['db'])) { */ if (! empty($table_list)) { // upper table list paginator - if (count($table_list) <= $GLOBALS['cfg']['MaxTableList'] && $table_count > $GLOBALS['cfg']['MaxTableList']) { + if (count($table_list) <= $GLOBALS['cfg']['MaxTableList'] + && $table_count > $GLOBALS['cfg']['MaxTableList'] + ) { $_url_params = array( 'tpos' => 'true', 'pos' => $tpos, 'db' => $GLOBALS['db'] ); - PMA_listNavigator($table_count, $tpos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxTableList']); + PMA_listNavigator( + $table_count, $tpos, $_url_params, 'navigation.php', + 'frame_navigation', $GLOBALS['cfg']['MaxTableList'] + ); } PMA_displayTableList($table_list, true, '', $GLOBALS['db']); // lower table list paginator - if (count($table_list) <= $GLOBALS['cfg']['MaxTableList'] && $table_count > $GLOBALS['cfg']['MaxTableList']) { - PMA_listNavigator($table_count, $tpos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxTableList']); + if (count($table_list) <= $GLOBALS['cfg']['MaxTableList'] + && $table_count > $GLOBALS['cfg']['MaxTableList'] + ) { + PMA_listNavigator( + $table_count, $tpos, $_url_params, 'navigation.php', + 'frame_navigation', $GLOBALS['cfg']['MaxTableList'] + ); } } else { echo __('No tables found in database.'); @@ -301,9 +330,16 @@ if ($GLOBALS['cfg']['LeftFrameLight'] && strlen($GLOBALS['db'])) { if (!PMA_is_system_schema($db)) { $class = ''; $GLOBALS['cfg']['AjaxEnable'] ? $class="ajax" : ''; - echo '<ul id="newtable"><li><a target="frame_content" href="tbl_create.php' . PMA_generate_common_url(array('db' => $GLOBALS['db'])) . '" class="'.$class .'" >' - . PMA_getImage('b_snewtbl.png', _pgettext('short form', 'Create table'), array('id' => "icon_newtable")) - . _pgettext('short form', 'Create table') . '</a></li></ul>'; + echo '<ul id="newtable"><li><a target="frame_content" href="tbl_create.php' + . PMA_generate_common_url(array('db' => $GLOBALS['db'])) + . '" class="'.$class .'" >' + . PMA_getImage( + 'b_snewtbl.png', + _pgettext('short form', 'Create table'), + array('id' => "icon_newtable") + ) + . _pgettext('short form', 'Create table') + . '</a></li></ul>'; } } elseif ($GLOBALS['cfg']['LeftFrameLight']) { /* No need to tell user to select database if we're showing complete list */ @@ -313,25 +349,38 @@ if ($GLOBALS['cfg']['LeftFrameLight'] && strlen($GLOBALS['db'])) { } else { echo '<div id="databaseList">' . "\n"; $_url_params = array('pos' => $pos); - PMA_listNavigator(count($GLOBALS['pma']->databases), $pos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxDbList']); + PMA_listNavigator( + count($GLOBALS['pma']->databases), $pos, $_url_params, 'navigation.php', + 'frame_navigation', $GLOBALS['cfg']['MaxDbList'] + ); echo '</div>' . "\n"; $common_url_query = PMA_generate_common_url(); - PMA_displayDbList($GLOBALS['pma']->databases->getGroupedDetails($_SESSION['tmp_user_values']['navi_limit_offset'], $GLOBALS['cfg']['MaxDbList']), $_SESSION['tmp_user_values']['navi_limit_offset'], $GLOBALS['cfg']['MaxDbList']); + PMA_displayDbList( + $GLOBALS['pma']->databases->getGroupedDetails( + $_SESSION['tmp_user_values']['navi_limit_offset'], + $GLOBALS['cfg']['MaxDbList'] + ), + $_SESSION['tmp_user_values']['navi_limit_offset'], + $GLOBALS['cfg']['MaxDbList'] + ); } /** * displays collapsable db list * - * @global integer $element_counter - * @global string $img_minus - * @global string $img_plus - * @global string $href_left - * @global string $db_start - * @global string $common_url_query * @param array $ext_dblist extended db list * @param integer $offset * @param integer $count + * + * @return void + * + * @global integer $element_counter + * @global string $img_minus + * @global string $img_plus + * @global string $href_left + * @global string $db_start + * @global string $common_url_query */ function PMA_displayDbList($ext_dblist, $offset, $count) { @@ -339,8 +388,11 @@ function PMA_displayDbList($ext_dblist, $offset, $count) $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']->databases->getLimitedItems($offset, $count)); + // doing this in one step takes advantage of + // a single query with information_schema! + $tables_full = PMA_DBI_get_tables_full( + $GLOBALS['pma']->databases->getLimitedItems($offset, $count) + ); $url_dbgroup = ''; echo '<ul id="leftdatabaselist">'; @@ -458,9 +510,14 @@ function PMA_displayDbList($ext_dblist, $offset, $count) </a> <?php } - if (($GLOBALS['cfg']['Server']['CountTables'] === false) || $db['num_tables']) { + if (($GLOBALS['cfg']['Server']['CountTables'] === false) + || $db['num_tables'] + ) { if (isset($tables_full[$db['name']])) { - $tables = PMA_getTableList($db['name'], $tables_full[$db['name']]); + $tables = PMA_getTableList( + $db['name'], + $tables_full[$db['name']] + ); } elseif (isset($tables_full[strtolower($db['name'])])) { // on windows with lower_case_table_names = 1 // MySQL returns @@ -468,7 +525,10 @@ function PMA_displayDbList($ext_dblist, $offset, $count) // but information_schema.TABLES gives `test` // bug #1436171 // sf.net/tracker/?func=detail&aid=1436171&group_id=23067&atid=377408 - $tables = PMA_getTableList($db['name'], $tables_full[strtolower($db['name'])]); + $tables = PMA_getTableList( + $db['name'], + $tables_full[strtolower($db['name'])] + ); } else { $tables = PMA_getTableList($db['name']); } @@ -499,14 +559,17 @@ function PMA_displayDbList($ext_dblist, $offset, $count) * calls itself recursively if table in given list * is a list itself * - * @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 whether the list is visible or not * @param string $tab_group_full full tab group name * @param string $table_db db of this table + * + * @return void + * + * @global integer the element counter + * @global string html code for '-' image + * @global string html code for '+' image + * @global string html code for self link */ function PMA_displayTableList( $tables, $visible = false, @@ -526,7 +589,9 @@ function PMA_displayTableList( } foreach ($tables as $group => $table) { // only allow grouping if the group has more than 1 table - if (isset($table['is' . $sep . 'group']) && $table['tab' . $sep . 'count'] > 1) { + if (isset($table['is' . $sep . 'group']) + && $table['tab' . $sep . 'count'] > 1 + ) { $common_url_query = $GLOBALS['common_url_query'] . '&tbl_group=' . urlencode($tab_group_full . $group); @@ -539,7 +604,8 @@ function PMA_displayTableList( || strpos($GLOBALS['table'], $group) === 0) ) { printf( - $href_left, $element_counter, + $href_left, + $element_counter, $GLOBALS['common_url_query'] . '&tbl_group=' . $tab_group_full ); printf($img_minus, $element_counter); @@ -596,7 +662,9 @@ function PMA_displayTableList( } } } - $link_title = PMA_getTitleForTarget($GLOBALS['cfg']['LeftDefaultTabTable']); + $link_title = PMA_getTitleForTarget( + $GLOBALS['cfg']['LeftDefaultTabTable'] + ); // quick access icon next to each table name echo '<li>' . "\n"; echo '<a class="tableicon" title="' @@ -609,11 +677,21 @@ function PMA_displayTableList( .'&table=' . urlencode($table['Name']) .'&goto=' . $GLOBALS['cfg']['LeftDefaultTabTable'] . '" >'; - $attr = array('id' => 'icon_' . htmlspecialchars($table_db . '.' . $table['Name'])); + $attr = array( + 'id' => 'icon_' . htmlspecialchars($table_db . '.' . $table['Name']) + ); if (PMA_Table::isView($table_db, $table['Name'])) { - echo PMA_getImage('s_views.png', htmlspecialchars($link_title), $attr); + echo PMA_getImage( + 's_views.png', + htmlspecialchars($link_title), + $attr + ); } else { - echo PMA_getImage('b_browse.png', htmlspecialchars($link_title), $attr); + echo PMA_getImage( + 'b_browse.png', + htmlspecialchars($link_title), + $attr + ); } echo '</a>'; @@ -623,12 +701,14 @@ function PMA_displayTableList( .urlencode($table['Name']) . '&pos=0'; echo '<a href="' . $href . '" title="' . htmlspecialchars( - PMA_getTitleForTarget($GLOBALS['cfg']['DefaultTabTable']) . ': ' . $table['Comment'] + PMA_getTitleForTarget($GLOBALS['cfg']['DefaultTabTable']) + . ': ' . $table['Comment'] .' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . __('Rows') . ')' ) .'" id="' . htmlspecialchars($table_db . '.' . $table['Name']) . '">' // preserve spaces in table name - . str_replace(' ', ' ', htmlspecialchars($table['disp_name'])) . '</a>'; + . str_replace(' ', ' ', htmlspecialchars($table['disp_name'])) + . '</a>'; echo '</li>' . "\n"; } } |