Skip to content

Commit

Permalink
Coding style improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
madhuracj committed Apr 14, 2012
1 parent ef68eaa commit 8e62b92
Show file tree
Hide file tree
Showing 10 changed files with 153 additions and 103 deletions.
20 changes: 14 additions & 6 deletions db_create.php
Expand Up @@ -12,7 +12,7 @@
$GLOBALS['js_include'][] = 'functions.js';

require_once 'libraries/mysql_charsets.lib.php';
if (!PMA_DRIZZLE) {
if (! PMA_DRIZZLE) {
include_once 'libraries/replication.inc.php';
}
require 'libraries/build_html_for_db.lib.php';
Expand Down Expand Up @@ -41,9 +41,11 @@
* Builds and executes the db creation sql query
*/
$sql_query = 'CREATE DATABASE ' . PMA_backquote($new_db);
if (!empty($db_collation)) {
if (! empty($db_collation)) {
list($db_charset) = explode('_', $db_collation);
if (in_array($db_charset, $mysql_charsets) && in_array($db_collation, $mysql_collations[$db_charset])) {
if (in_array($db_charset, $mysql_charsets)
&& in_array($db_collation, $mysql_collations[$db_charset])
) {
$sql_query .= ' DEFAULT' . PMA_generateCharsetQueryPart($db_collation);
}
$db_collation_for_ajax = $db_collation;
Expand Down Expand Up @@ -85,10 +87,13 @@
*/
$extra_data['sql_query'] = PMA_showMessage(null, $sql_query, 'success');

//Construct the html for the new database, so that it can be appended to the list of databases on server_databases.php
//Construct the html for the new database, so that it can be appended to
// the list of databases on server_databases.php

/**
* Build the array to be passed to {@link PMA_generate_common_url} to generate the links
* Build the array to be passed to {@link PMA_generate_common_url}
* to generate the links
*
* @global array $GLOBALS['db_url_params']
* @name $db_url_params
*/
Expand Down Expand Up @@ -127,7 +132,10 @@
);
}

list($column_order, $generated_html) = PMA_buildHtmlForDb($current, $is_superuser, (isset($checkall) ? $checkall : ''), $url_query, $column_order, $replication_types, $replication_info);
list($column_order, $generated_html) = PMA_buildHtmlForDb(
$current, $is_superuser, (isset($checkall) ? $checkall : ''),
$url_query, $column_order, $replication_types, $replication_info
);
$new_db_string .= $generated_html;

$new_db_string .= '</tr>';
Expand Down
7 changes: 4 additions & 3 deletions db_datadict.php
Expand Up @@ -204,9 +204,10 @@
$field_name = $row['Field'];

if (PMA_MYSQL_INT_VERSION < 50025
&& ! empty($analyzed_sql[0]['create_table_fields'][$field_name]['type'])
&& $analyzed_sql[0]['create_table_fields'][$field_name]['type'] == 'TIMESTAMP'
&& $analyzed_sql[0]['create_table_fields'][$field_name]['timestamp_not_null']) {
&& ! empty($analyzed_sql[0]['create_table_fields'][$field_name]['type'])
&& $analyzed_sql[0]['create_table_fields'][$field_name]['type'] == 'TIMESTAMP'
&& $analyzed_sql[0]['create_table_fields'][$field_name]['timestamp_not_null']
) {
// here, we have a TIMESTAMP that SHOW FULL COLUMNS reports as having the
// NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
// the latter.
Expand Down
6 changes: 4 additions & 2 deletions db_export.php
Expand Up @@ -48,7 +48,8 @@
$table_select = $selected_tbl;
}

// Check if the selected tables are defined in $_GET (from clicking Back button on export.php)
// Check if the selected tables are defined in $_GET
// (from clicking Back button on export.php)
if (isset($_GET['table_select'])) {
$_GET['table_select'] = urldecode($_GET['table_select']);
$_GET['table_select'] = explode(",", $_GET['table_select']);
Expand All @@ -62,7 +63,8 @@
$is_selected = '';
}
} elseif (! empty($unselectall)
|| (! empty($table_select) && !in_array($each_table['Name'], $table_select))) {
|| (! empty($table_select) && !in_array($each_table['Name'], $table_select))
) {
$is_selected = '';
} else {
$is_selected = ' selected="selected"';
Expand Down
36 changes: 25 additions & 11 deletions db_operations.php
Expand Up @@ -60,10 +60,15 @@
} else {
$sql_query = ''; // in case target db exists
$_error = false;
if ($move || (isset($create_database_before_copying) && $create_database_before_copying)) {
if ($move
|| (isset($create_database_before_copying)
&& $create_database_before_copying)
) {
// lower_case_table_names=1 `DB` becomes `db`
if (!PMA_DRIZZLE) {
$lower_case_table_names = PMA_DBI_fetch_value('SHOW VARIABLES LIKE "lower_case_table_names"', 0, 1);
if (! PMA_DRIZZLE) {
$lower_case_table_names = PMA_DBI_fetch_value(
'SHOW VARIABLES LIKE "lower_case_table_names"', 0, 1
);
if ($lower_case_table_names === '1') {
$newname = PMA_strtolower($newname);
}
Expand Down Expand Up @@ -206,7 +211,9 @@
unset($triggers);

// this does not apply to a rename operation
if (isset($GLOBALS['add_constraints']) && !empty($GLOBALS['sql_constraints_query'])) {
if (isset($GLOBALS['add_constraints'])
&& ! empty($GLOBALS['sql_constraints_query'])
) {
$GLOBALS['sql_constraints_query_full_db'][] = $GLOBALS['sql_constraints_query'];
unset($GLOBALS['sql_constraints_query']);
}
Expand Down Expand Up @@ -245,21 +252,24 @@
PMA_DBI_select_db($newname);
foreach ($GLOBALS['sql_constraints_query_full_db'] as $one_query) {
PMA_DBI_query($one_query);
// and prepare to display them
// and prepare to display them
$GLOBALS['sql_query'] .= "\n" . $one_query;
}

unset($GLOBALS['sql_constraints_query_full_db'], $one_query);
}

if (!PMA_DRIZZLE && PMA_MYSQL_INT_VERSION >= 50100) {
if (! PMA_DRIZZLE && PMA_MYSQL_INT_VERSION >= 50100) {
// here DELIMITER is not used because it's not part of the
// language; each statement is sent one by one

// to avoid selecting alternatively the current and new db
// we would need to modify the CREATE definitions to qualify
// the db name
$event_names = PMA_DBI_fetch_result('SELECT EVENT_NAME FROM information_schema.EVENTS WHERE EVENT_SCHEMA= \'' . PMA_sqlAddSlashes($db, true) . '\';');
$event_names = PMA_DBI_fetch_result(
'SELECT EVENT_NAME FROM information_schema.EVENTS WHERE EVENT_SCHEMA= \''
. PMA_sqlAddSlashes($db, true) . '\';'
);
if ($event_names) {
foreach ($event_names as $event_name) {
PMA_DBI_select_db($db);
Expand Down Expand Up @@ -447,7 +457,7 @@
// 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
&& ! $db_is_information_schema
&& (PMA_DRIZZLE || $db != 'mysql')) {
?>
<div class="operations_half_width">
Expand Down Expand Up @@ -534,8 +544,10 @@
<?php
unset($drop_clause);

if (isset($_COOKIE) && isset($_COOKIE['pma_switch_to_new'])
&& $_COOKIE['pma_switch_to_new'] == 'true') {
if (isset($_COOKIE)
&& isset($_COOKIE['pma_switch_to_new'])
&& $_COOKIE['pma_switch_to_new'] == 'true'
) {
$pma_switch_to_new = 'true';
}
?>
Expand Down Expand Up @@ -580,7 +592,9 @@
. '</form></div>' . "\n";

if ($num_tables > 0
&& ! $cfgRelation['allworks'] && $cfg['PmaNoRelation_DisableWarning'] == false) {
&& ! $cfgRelation['allworks']
&& $cfg['PmaNoRelation_DisableWarning'] == false
) {
$message = PMA_Message::notice(__('The phpMyAdmin configuration storage has been deactivated. To find out why click %shere%s.'));
$message->addParam('<a href="' . $cfg['PmaAbsoluteUri'] . 'chk_rel.php?' . $url_query . '">', false);
$message->addParam('</a>', false);
Expand Down
8 changes: 5 additions & 3 deletions db_printview.php
Expand Up @@ -115,7 +115,8 @@
$odd_row = true;
foreach ($tables as $sts_data) {
if (PMA_Table::isMerge($db, $sts_data['TABLE_NAME'])
|| strtoupper($sts_data['ENGINE']) == 'FEDERATED') {
|| strtoupper($sts_data['ENGINE']) == 'FEDERATED'
) {
$merged_size = true;
} else {
$merged_size = false;
Expand Down Expand Up @@ -171,8 +172,9 @@
}

if (! empty($sts_data['Create_time'])
|| ! empty($sts_data['Update_time'])
|| ! empty($sts_data['Check_time'])) {
|| ! empty($sts_data['Update_time'])
|| ! empty($sts_data['Check_time'])
) {
echo $needs_break;
?>
<table width="100%">
Expand Down

0 comments on commit 8e62b92

Please sign in to comment.