Skip to content

Commit

Permalink
Coding style improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
madhuracj committed Aug 30, 2012
1 parent 7c2b8ca commit ba16e22
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 55 deletions.
1 change: 0 additions & 1 deletion browse_foreigners.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']) {
Expand Down
8 changes: 5 additions & 3 deletions db_datadict.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down Expand Up @@ -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']) {
Expand Down
20 changes: 12 additions & 8 deletions db_operations.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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),
Expand All @@ -82,7 +83,7 @@
$tables_full, $export_sql_plugin, $move, $db
);

$views = PMA_getViewsAndCreateSqlViewStandIn(
$views = PMA_getViewsAndCreateSqlViewStandIn(
$tables_full, $export_sql_plugin, $db
);

Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -213,7 +216,7 @@
*/
$response->addHTML(PMA_getHtmlForDatabaseComment($db));
}

$response->addHTML('<div class="operations_half_width">');
ob_start();
include 'libraries/display_create_table.lib.php';
Expand All @@ -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
Expand Down
14 changes: 8 additions & 6 deletions db_qbe.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,15 @@
array('query' => 1)
)
);
$response->addHTML(PMA_Message::notice(
sprintf(
__('Switch to %svisual builder%s'),
'<a href="' . $url . '">',
'</a>'
$response->addHTML(
PMA_Message::notice(
sprintf(
__('Switch to %svisual builder%s'),
'<a href="' . $url . '">',
'</a>'
)
)
));//->display();
);
}
$response->addHTML($db_qbe->getSelectionForm($cfgRelation));
?>
40 changes: 22 additions & 18 deletions db_structure.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']
)
Expand All @@ -126,7 +127,7 @@
// tables form
$response->addHTML(
'<form method="post" action="db_structure.php" '
. 'name="tablesForm" id="tablesForm">'
. 'name="tablesForm" id="tablesForm">'
);

$response->addHTML(PMA_generate_common_hidden_inputs($db));
Expand Down Expand Up @@ -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 . '&amp;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
);

Expand All @@ -186,8 +188,10 @@
if ($is_show_stats) {
if ($formatted_overhead != '') {
$overhead = '<a href="tbl_structure.php?'
. $tbl_url_query . '#showusage"><span>' . $formatted_overhead
. '</span> <span class="unit">' . $overhead_unit . '</span></a>' . "\n";
. $tbl_url_query . '#showusage">'
. '<span>' . $formatted_overhead . '</span>'
. '<span class="unit">' . $overhead_unit . '</span>'
. '</a>' . "\n";
$overhead_check .=
"markAllRows('row_tbl_" . ($i + 1) . "');";
} else {
Expand Down Expand Up @@ -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);
}

Expand All @@ -258,17 +261,17 @@
$row_count = 1;
$odd_row = true;

$response->addHTML('</tr>'
. '</tbody>'
. '</table>');
$response->addHTML(
'</tr></tbody></table>'
);

$response->addHTML(PMA_TableHeader(false, $server_slave_status));
}

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,
Expand All @@ -281,7 +284,7 @@
$is_show_stats, $ignored, $do, $colspan_for_structure
);
$response->addHTML($html_output);

} // end foreach

// Show Summary
Expand All @@ -296,8 +299,9 @@
$response->addHTML('</table>');
//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('</form>'); //end of form
Expand Down
3 changes: 1 addition & 2 deletions db_tracking.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}
Expand Down
38 changes: 21 additions & 17 deletions export.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}
}
Expand Down

0 comments on commit ba16e22

Please sign in to comment.