From ba16e22315f5ec8a35ddf2703b785087dd9f376a Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Fri, 31 Aug 2012 00:46:35 +0530 Subject: [PATCH] Coding style improvements --- browse_foreigners.php | 1 - db_datadict.php | 8 +++++--- db_operations.php | 20 ++++++++++++-------- db_qbe.php | 14 ++++++++------ db_structure.php | 40 ++++++++++++++++++++++------------------ db_tracking.php | 3 +-- export.php | 38 +++++++++++++++++++++----------------- 7 files changed, 69 insertions(+), 55 deletions(-) diff --git a/browse_foreigners.php b/browse_foreigners.php index b20007f8a4ba..b6f2d8b4c903 100644 --- a/browse_foreigners.php +++ b/browse_foreigners.php @@ -214,7 +214,6 @@ function formupdate(fieldmd5, key) { $val_ordered_current_equals_data = false; $key_ordered_current_equals_data = false; foreach ($keys as $key_ordered_current_row => $value) { - //for ($i = 0; $i < $count; $i++) { $hcount++; if ($cfg['RepeatCells'] > 0 && $hcount > $cfg['RepeatCells']) { diff --git a/db_datadict.php b/db_datadict.php index 4a1d51774e7c..3ce6d6022d5f 100644 --- a/db_datadict.php +++ b/db_datadict.php @@ -124,9 +124,11 @@ // and SHOW CREATE TABLE says NOT NULL // http://bugs.mysql.com/20910. + $show_create_table_query = 'SHOW CREATE TABLE ' + . PMA_CommonFunctions::getInstance()->backquote($db) . '.' + . PMA_CommonFunctions::getInstance()->backquote($table); $show_create_table = PMA_DBI_fetch_value( - 'SHOW CREATE TABLE ' . PMA_CommonFunctions::getInstance()->backquote($db) . '.' . PMA_CommonFunctions::getInstance()->backquote($table), - 0, 1 + $show_create_table_query, 0, 1 ); $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table)); } @@ -185,7 +187,7 @@ } $extracted_columnspec = PMA_CommonFunctions::getInstance()->extractColumnSpec($row['Type']); - + // reformat mysql query output // set or enum types: slashes single quotes inside options if ('set' == $extracted_columnspec['type'] || 'enum' == $extracted_columnspec['type']) { diff --git a/db_operations.php b/db_operations.php index bed41307b5be..cfd4d5b14a55 100644 --- a/db_operations.php +++ b/db_operations.php @@ -33,8 +33,9 @@ /** * Rename/move or copy database */ -if (strlen($db) && (! empty($_REQUEST['db_rename']) || ! empty($_REQUEST['db_copy']))) { - +if (strlen($db) + && (! empty($_REQUEST['db_rename']) || ! empty($_REQUEST['db_copy'])) +) { if (! empty($_REQUEST['db_rename'])) { $move = true; } else { @@ -70,7 +71,7 @@ // remove all foreign key constraints, otherwise we can get errors $export_sql_plugin = PMA_getPlugin( "export", - "sql", + "sql", 'libraries/plugins/export/', array( 'single_table' => isset($single_table), @@ -82,7 +83,7 @@ $tables_full, $export_sql_plugin, $move, $db ); - $views = PMA_getViewsAndCreateSqlViewStandIn( + $views = PMA_getViewsAndCreateSqlViewStandIn( $tables_full, $export_sql_plugin, $db ); @@ -113,7 +114,7 @@ // Duplicate the bookmarks for this db (done once for each db) PMA_duplicateBookmarks($_error, $db); - + if (! $_error && $move) { /** * cleanup pmadb stuff for this db @@ -140,7 +141,9 @@ if (! $_error && $move) { $db = $_REQUEST['newname']; } elseif (! $_error) { - if (isset($_REQUEST['switch_to_new']) && $_REQUEST['switch_to_new'] == 'true') { + if (isset($_REQUEST['switch_to_new']) + && $_REQUEST['switch_to_new'] == 'true' + ) { $GLOBALS['PMA_Config']->setCookie('pma_switch_to_new', 'true'); $db = $_REQUEST['newname']; } else { @@ -213,7 +216,7 @@ */ $response->addHTML(PMA_getHtmlForDatabaseComment($db)); } - + $response->addHTML('
'); ob_start(); include 'libraries/display_create_table.lib.php'; @@ -230,7 +233,8 @@ } // Drop link if allowed - // Don't even try to drop information_schema. You won't be able to. Believe me. You won't. + // Don't even try to drop information_schema. + // You won't be able to. Believe me. You won't. // Don't allow to easily drop mysql database, RFE #1327514. if (($is_superuser || $GLOBALS['cfg']['AllowUserDropDatabase']) && ! $db_is_information_schema diff --git a/db_qbe.php b/db_qbe.php index f7628c5fc0a0..940758cccf2e 100644 --- a/db_qbe.php +++ b/db_qbe.php @@ -54,13 +54,15 @@ array('query' => 1) ) ); - $response->addHTML(PMA_Message::notice( - sprintf( - __('Switch to %svisual builder%s'), - '', - '' + $response->addHTML( + PMA_Message::notice( + sprintf( + __('Switch to %svisual builder%s'), + '', + '' + ) ) - ));//->display(); + ); } $response->addHTML($db_qbe->getSelectionForm($cfgRelation)); ?> diff --git a/db_structure.php b/db_structure.php index 7d71d7562d9d..95af33d04bc6 100644 --- a/db_structure.php +++ b/db_structure.php @@ -117,7 +117,8 @@ $_url_params['sort_order'] = $_REQUEST['sort_order']; } -$response->addHTML($common_functions->getListNavigator( +$response->addHTML( + $common_functions->getListNavigator( $total_num_tables, $pos, $_url_params, 'db_structure.php', 'frame_content', $GLOBALS['cfg']['MaxTableList'] ) @@ -126,7 +127,7 @@ // tables form $response->addHTML( '
' + . 'name="tablesForm" id="tablesForm">' ); $response->addHTML(PMA_generate_common_hidden_inputs($db)); @@ -158,16 +159,17 @@ $drop_query = ''; $drop_message = ''; $overhead = ''; - + $table_is_view = false; $table_encoded = urlencode($current_table['TABLE_NAME']); // Sets parameters for links $tbl_url_query = $url_query . '&table=' . $table_encoded; // do not list the previous table's size info for a view - + list($current_table, $formatted_size, $unit, $formatted_overhead, $overhead_unit, $overhead_size, $table_is_view, $sum_size) - = PMA_getStuffForEngineTypeTable($current_table, $db_is_information_schema, + = PMA_getStuffForEngineTypeTable( + $current_table, $db_is_information_schema, $is_show_stats, $table_is_view, $sum_size, $overhead_size ); @@ -186,8 +188,10 @@ if ($is_show_stats) { if ($formatted_overhead != '') { $overhead = '' . $formatted_overhead - . ' ' . $overhead_unit . '' . "\n"; + . $tbl_url_query . '#showusage">' + . '' . $formatted_overhead . '' + . '' . $overhead_unit . '' + . '' . "\n"; $overhead_check .= "markAllRows('row_tbl_" . ($i + 1) . "');"; } else { @@ -240,14 +244,13 @@ * the code easier to read without this operator. */ list($browse_table, $search_table, $browse_table_label, $empty_table, - $tracking_icon - ) = PMA_getHtmlForActionLinks( + $tracking_icon) = PMA_getHtmlForActionLinks( $current_table, $table_is_view, $tbl_url_query, $titles, $truename, $db_is_information_schema, $url_query ); - + if (! $db_is_information_schema) { - list($drop_query, $drop_message) + list($drop_query, $drop_message) = PMA_getTableDropQueryAndMessage($table_is_view, $current_table); } @@ -258,9 +261,9 @@ $row_count = 1; $odd_row = true; - $response->addHTML('' - . '' - . ''); + $response->addHTML( + '' + ); $response->addHTML(PMA_TableHeader(false, $server_slave_status)); } @@ -268,7 +271,7 @@ list($do, $ignored) = PMA_getServerSlaveStatus( $server_slave_status, $truename ); - + list($html_output, $odd_row) = PMA_getHtmlForStructureTableRow( $i, $odd_row, $table_is_view, $current_table, $checked, $browse_table_label, $tracking_icon, $server_slave_status, @@ -281,7 +284,7 @@ $is_show_stats, $ignored, $do, $colspan_for_structure ); $response->addHTML($html_output); - + } // end foreach // Show Summary @@ -296,8 +299,9 @@ $response->addHTML(''); //check all $response->addHTML( - PMA_getHtmlForCheckAllTables($pmaThemeImage, $text_dir, - $overhead_check, $db_is_information_schema, $hidden_fields + PMA_getHtmlForCheckAllTables( + $pmaThemeImage, $text_dir, $overhead_check, + $db_is_information_schema, $hidden_fields ) ); $response->addHTML('
'); //end of form diff --git a/db_tracking.php b/db_tracking.php index 24d63417f962..daeeb170b353 100644 --- a/db_tracking.php +++ b/db_tracking.php @@ -171,8 +171,7 @@ } } } - // If $value is a table. - } else { + } else { // If $value is a table. if (PMA_Tracker::getVersion($GLOBALS['db'], $value['Name']) == -1) { $my_tables[] = $value['Name']; } diff --git a/export.php b/export.php index abe366d99f74..6aabeb2ac51c 100644 --- a/export.php +++ b/export.php @@ -324,7 +324,8 @@ function PMA_exportOutputHandler($line) $filename = PMA_sanitizeFilename($filename); // Grab basic dump extension and mime type - // Check if the user already added extension; get the substring where the extension would be if it was included + // Check if the user already added extension; + // get the substring where the extension would be if it was included $extension_start_pos = strlen($filename) - strlen( $export_plugin->getProperties()->getExtension() ) - 1; @@ -359,22 +360,21 @@ function PMA_exportOutputHandler($line) || ($quick_export && $_REQUEST['quick_export_onserverover'] != 'saveitover')) ) { - $message = PMA_Message::error(__( - 'File %s already exists on server, change filename or check' - . ' overwrite option.' - )); + $message = PMA_Message::error( + __('File %s already exists on server, change filename or check overwrite option.') + ); $message->addParam($save_filename); } else { if (is_file($save_filename) && ! is_writable($save_filename)) { - $message = PMA_Message::error(__( - 'The web server does not have permission to save the file %s.' - )); + $message = PMA_Message::error( + __('The web server does not have permission to save the file %s.') + ); $message->addParam($save_filename); } else { if (! $file_handle = @fopen($save_filename, 'w')) { - $message = PMA_Message::error(__( - 'The web server does not have permission to save the file %s.' - )); + $message = PMA_Message::error( + __('The web server does not have permission to save the file %s.') + ); $message->addParam($save_filename); } } @@ -624,7 +624,9 @@ function PMA_exportOutputHandler($line) } // now export the triggers (needs to be done after the data because // triggers can modify already imported tables) - if ($GLOBALS[$what . '_structure_or_data'] == 'structure' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') { + if ($GLOBALS[$what . '_structure_or_data'] == 'structure' + || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data' + ) { if (! $export_plugin->exportStructure( $db, $table, $crlf, $err_url, 'triggers', $export_type, @@ -636,7 +638,9 @@ function PMA_exportOutputHandler($line) } foreach ($views as $view) { // no data export for a view - if ($GLOBALS[$what . '_structure_or_data'] == 'structure' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') { + if ($GLOBALS[$what . '_structure_or_data'] == 'structure' + || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data' + ) { if (! $export_plugin->exportStructure( $db, $view, $crlf, $err_url, 'create_view', $export_type, @@ -665,7 +669,9 @@ function PMA_exportOutputHandler($line) } $is_view = PMA_Table::isView($db, $table); - if ($GLOBALS[$what . '_structure_or_data'] == 'structure' || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data') { + if ($GLOBALS[$what . '_structure_or_data'] == 'structure' + || $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data' + ) { if (! $export_plugin->exportStructure( $db, $table, $crlf, $err_url, $is_view ? 'create_view' : 'create_table', $export_type, @@ -693,9 +699,7 @@ function PMA_exportOutputHandler($line) $local_query = 'SELECT * FROM ' . $common_functions->backquote($db) . '.' . $common_functions->backquote($table) . $add_query; } - if (! $export_plugin->exportData($db, $table, $crlf, $err_url, - $local_query - )) { + if (! $export_plugin->exportData($db, $table, $crlf, $err_url, $local_query)) { break; } }