code cleanup

This commit is contained in:
Marc Delisle
2009-12-29 15:21:05 +00:00
parent f1f04a1b3b
commit 2519dd3855

View File

@@ -322,14 +322,14 @@ function PMA_getColumnAlphaName($num)
if ($num > 701) { if ($num > 701) {
return $num; return $num;
} else if ($num <= 26) { } elseif ($num <= 26) {
if ($num == 0) { if ($num == 0) {
$sCol = chr(($A + 26) - 1); $sCol = chr(($A + 26) - 1);
} else { } else {
$sCol = chr(($A + $num) - 1); $sCol = chr(($A + $num) - 1);
} }
} else { } else {
$iRemain = (($num / 26))-1; $iRemain = (($num / 26)) - 1;
if (($num % 26) == 0) { if (($num % 26) == 0) {
$sCol = PMA_getColumnAlphaName($iRemain) . PMA_getColumnAlphaName($num % 26); $sCol = PMA_getColumnAlphaName($iRemain) . PMA_getColumnAlphaName($num % 26);
} else { } else {
@@ -446,7 +446,7 @@ function PMA_getDecimalSize(&$cell) {
$m = $curr_size - 1; $m = $curr_size - 1;
$d = $decPrecision; $d = $decPrecision;
return array($m, $d, ($m.",".$d)); return array($m, $d, ($m . "," . $d));
} }
/** /**
@@ -482,13 +482,13 @@ function PMA_detectSize($last_cumulative_size, $last_cumulative_type, $curr_type
/** /**
* If the cell is NULL, don't treat it as a varchar * If the cell is NULL, don't treat it as a varchar
*/ */
if (!strcmp('NULL', $cell)) { if (! strcmp('NULL', $cell)) {
return $last_cumulative_size; return $last_cumulative_size;
} }
/** /**
* What to do if the current cell is of type VARCHAR * What to do if the current cell is of type VARCHAR
*/ */
else if ($curr_type == VARCHAR) { elseif ($curr_type == VARCHAR) {
/** /**
* The last cumlative type was VARCHAR * The last cumlative type was VARCHAR
*/ */
@@ -502,7 +502,7 @@ function PMA_detectSize($last_cumulative_size, $last_cumulative_type, $curr_type
/** /**
* The last cumlative type was DECIMAL * The last cumlative type was DECIMAL
*/ */
else if ($last_cumulative_type == DECIMAL) { elseif ($last_cumulative_type == DECIMAL) {
$oldM = PMA_getM($last_cumulative_size); $oldM = PMA_getM($last_cumulative_size);
if ($curr_size >= $oldM) { if ($curr_size >= $oldM) {
@@ -514,7 +514,7 @@ function PMA_detectSize($last_cumulative_size, $last_cumulative_type, $curr_type
/** /**
* The last cumlative type was INT * The last cumlative type was INT
*/ */
else if ($last_cumulative_type == INT) { elseif ($last_cumulative_type == INT) {
if ($curr_size >= $last_cumulative_size) { if ($curr_size >= $last_cumulative_size) {
return $curr_size; return $curr_size;
} else { } else {
@@ -524,7 +524,7 @@ function PMA_detectSize($last_cumulative_size, $last_cumulative_type, $curr_type
/** /**
* This is the first row to be analyzed * This is the first row to be analyzed
*/ */
else if (!isset($last_cumulative_type) || $last_cumulative_type == NONE) { elseif (! isset($last_cumulative_type) || $last_cumulative_type == NONE) {
return $curr_size; return $curr_size;
} }
/** /**
@@ -541,7 +541,7 @@ function PMA_detectSize($last_cumulative_size, $last_cumulative_type, $curr_type
/** /**
* What to do if the current cell is of type DECIMAL * What to do if the current cell is of type DECIMAL
*/ */
else if ($curr_type == DECIMAL) { elseif ($curr_type == DECIMAL) {
/** /**
* The last cumlative type was VARCHAR * The last cumlative type was VARCHAR
*/ */
@@ -558,7 +558,7 @@ function PMA_detectSize($last_cumulative_size, $last_cumulative_type, $curr_type
/** /**
* The last cumlative type was DECIMAL * The last cumlative type was DECIMAL
*/ */
else if ($last_cumulative_type == DECIMAL) { elseif ($last_cumulative_type == DECIMAL) {
$size = PMA_getDecimalSize($cell); $size = PMA_getDecimalSize($cell);
$oldM = PMA_getM($last_cumulative_size); $oldM = PMA_getM($last_cumulative_size);
@@ -575,7 +575,7 @@ function PMA_detectSize($last_cumulative_size, $last_cumulative_type, $curr_type
/** /**
* The last cumlative type was INT * The last cumlative type was INT
*/ */
else if ($last_cumulative_type == INT) { elseif ($last_cumulative_type == INT) {
/* Convert $last_cumulative_size from int to decimal format */ /* Convert $last_cumulative_size from int to decimal format */
$size = PMA_getDecimalSize($cell); $size = PMA_getDecimalSize($cell);
@@ -588,7 +588,7 @@ function PMA_detectSize($last_cumulative_size, $last_cumulative_type, $curr_type
/** /**
* This is the first row to be analyzed * This is the first row to be analyzed
*/ */
else if (!isset($last_cumulative_type) || $last_cumulative_type == NONE) { elseif (! isset($last_cumulative_type) || $last_cumulative_type == NONE) {
/* First row of the column */ /* First row of the column */
$size = PMA_getDecimalSize($cell); $size = PMA_getDecimalSize($cell);
@@ -608,7 +608,7 @@ function PMA_detectSize($last_cumulative_size, $last_cumulative_type, $curr_type
/** /**
* What to do if the current cell is of type INT * What to do if the current cell is of type INT
*/ */
else if ($curr_type == INT) { elseif ($curr_type == INT) {
/** /**
* The last cumlative type was VARCHAR * The last cumlative type was VARCHAR
*/ */
@@ -622,7 +622,7 @@ function PMA_detectSize($last_cumulative_size, $last_cumulative_type, $curr_type
/** /**
* The last cumlative type was DECIMAL * The last cumlative type was DECIMAL
*/ */
else if ($last_cumulative_type == DECIMAL) { elseif ($last_cumulative_type == DECIMAL) {
$oldM = PMA_getM($last_cumulative_size); $oldM = PMA_getM($last_cumulative_size);
$oldD = PMA_getD($last_cumulative_size); $oldD = PMA_getD($last_cumulative_size);
$oldInt = $oldM - $oldD; $oldInt = $oldM - $oldD;
@@ -634,13 +634,13 @@ function PMA_detectSize($last_cumulative_size, $last_cumulative_type, $curr_type
return $last_cumulative_size; return $last_cumulative_size;
} else { } else {
/* Use $newInt + $oldD as new M */ /* Use $newInt + $oldD as new M */
return (($newInt + $oldD).",".$oldD); return (($newInt + $oldD) . "," . $oldD);
} }
} }
/** /**
* The last cumlative type was INT * The last cumlative type was INT
*/ */
else if ($last_cumulative_type == INT) { elseif ($last_cumulative_type == INT) {
if ($curr_size >= $last_cumulative_size) { if ($curr_size >= $last_cumulative_size) {
return $curr_size; return $curr_size;
} else { } else {
@@ -650,7 +650,7 @@ function PMA_detectSize($last_cumulative_size, $last_cumulative_type, $curr_type
/** /**
* This is the first row to be analyzed * This is the first row to be analyzed
*/ */
else if (!isset($last_cumulative_type) || $last_cumulative_type == NONE) { elseif (!isset($last_cumulative_type) || $last_cumulative_type == NONE) {
return $curr_size; return $curr_size;
} }
/** /**
@@ -701,13 +701,13 @@ function PMA_detectType($last_cumulative_type, &$cell) {
* Else, we call it varchar for simplicity * Else, we call it varchar for simplicity
*/ */
if (!strcmp('NULL', $cell)) { if (! strcmp('NULL', $cell)) {
if ($last_cumulative_type === NULL || $last_cumulative_type == NONE) { if ($last_cumulative_type === NULL || $last_cumulative_type == NONE) {
return NONE; return NONE;
} else { } else {
return $last_cumulative_type; return $last_cumulative_type;
} }
} else if (is_numeric($cell)) { } elseif (is_numeric($cell)) {
if ($cell == (string)(float)$cell && strpos($cell, ".") !== false && substr_count($cell, ".") == 1) { if ($cell == (string)(float)$cell && strpos($cell, ".") !== false && substr_count($cell, ".") == 1) {
return DECIMAL; return DECIMAL;
} else { } else {
@@ -767,7 +767,7 @@ function PMA_analyzeTable(&$table) {
$curr_size = 0; $curr_size = 0;
/* If the passed array is not of the correct form, do not process it */ /* If the passed array is not of the correct form, do not process it */
if (is_array($table) && !is_array($table[TBL_NAME]) && is_array($table[COL_NAMES]) && is_array($table[ROWS])) { if (is_array($table) && ! is_array($table[TBL_NAME]) && is_array($table[COL_NAMES]) && is_array($table[ROWS])) {
/* Analyze each column */ /* Analyze each column */
for ($i = 0; $i < $numCols; ++$i) { for ($i = 0; $i < $numCols; ++$i) {
/* Analyze the column in each row */ /* Analyze the column in each row */
@@ -800,7 +800,7 @@ function PMA_analyzeTable(&$table) {
/* Check to ensure that all types are valid */ /* Check to ensure that all types are valid */
$len = count($types); $len = count($types);
for ($n = 0; $n < $len; ++$n) { for ($n = 0; $n < $len; ++$n) {
if (!strcmp(NONE, $types[$n])) { if (! strcmp(NONE, $types[$n])) {
$types[$n] = VARCHAR; $types[$n] = VARCHAR;
$sizes[$n] = '10'; $sizes[$n] = '10';
} }
@@ -993,7 +993,7 @@ function PMA_buildSQL($db_name, &$tables, &$analyses = NULL, &$additional_sql =
} }
/* Don't put quotes around NULL fields */ /* Don't put quotes around NULL fields */
if (!strcmp($tables[$i][ROWS][$j][$k], 'NULL')) { if (! strcmp($tables[$i][ROWS][$j][$k], 'NULL')) {
$is_varchar = false; $is_varchar = false;
} }
@@ -1084,16 +1084,16 @@ function PMA_buildSQL($db_name, &$tables, &$analyses = NULL, &$additional_sql =
$db_ops_url = 'db_operations.php' . PMA_generate_common_url($params); $db_ops_url = 'db_operations.php' . PMA_generate_common_url($params);
$message = '<br /><br />'; $message = '<br /><br />';
$message .= '<strong>'.$GLOBALS['strImportNoticePt1'].'</strong><br />'; $message .= '<strong>' . $GLOBALS['strImportNoticePt1'] . '</strong><br />';
$message .= '<ul><li>'.$GLOBALS['strImportNoticePt2'].'</li>'; $message .= '<ul><li>' . $GLOBALS['strImportNoticePt2'] . '</li>';
$message .= '<li>'.$GLOBALS['strImportNoticePt3'].'</li>'; $message .= '<li>' . $GLOBALS['strImportNoticePt3'] . '</li>';
$message .= '<li>'.$GLOBALS['strImportNoticePt4'].'</li>'; $message .= '<li>' . $GLOBALS['strImportNoticePt4'] . '</li>';
$message .= sprintf('<br /><li><a href="%s" title="%s">%s</a> (<a href="%s" title="%s">'.$GLOBALS['strOptions'].'</a>)</li>', $message .= sprintf('<br /><li><a href="%s" title="%s">%s</a> (<a href="%s" title="%s">' . $GLOBALS['strOptions'] . '</a>)</li>',
$db_url, $db_url,
$GLOBALS['strGoToDatabase'].': '.PMA_backquote($db_name), $GLOBALS['strGoToDatabase'] . ': ' . PMA_backquote($db_name),
$db_name, $db_name,
$db_ops_url, $db_ops_url,
$GLOBALS['strEdit'].' '.PMA_backquote($db_name).' '.$GLOBALS['strSettings']); $GLOBALS['strEdit'] . ' ' . PMA_backquote($db_name) . ' ' . $GLOBALS['strSettings']);
$message .= '<ul>'; $message .= '<ul>';
@@ -1109,19 +1109,19 @@ function PMA_buildSQL($db_name, &$tables, &$analyses = NULL, &$additional_sql =
unset($params); unset($params);
if (!PMA_isView($db_name, $tables[$i][TBL_NAME])) { if (! PMA_isView($db_name, $tables[$i][TBL_NAME])) {
$message .= sprintf('<li><a href="%s" title="%s">%s</a> (<a href="%s" title="%s">'.$GLOBALS['strStructure'].'</a>) (<a href="%s" title="%s">'.$GLOBALS['strOptions'].'</a>)</li>', $message .= sprintf('<li><a href="%s" title="%s">%s</a> (<a href="%s" title="%s">' . $GLOBALS['strStructure'] . '</a>) (<a href="%s" title="%s">' . $GLOBALS['strOptions'] . '</a>)</li>',
$tbl_url, $tbl_url,
$GLOBALS['strGoToTable'].': '.PMA_backquote($tables[$i][TBL_NAME]), $GLOBALS['strGoToTable'] . ': ' . PMA_backquote($tables[$i][TBL_NAME]),
$tables[$i][TBL_NAME], $tables[$i][TBL_NAME],
$tbl_struct_url, $tbl_struct_url,
PMA_backquote($tables[$i][TBL_NAME]).' '.$GLOBALS['strStructureLC'], PMA_backquote($tables[$i][TBL_NAME]) . ' ' . $GLOBALS['strStructureLC'],
$tbl_ops_url, $tbl_ops_url,
$GLOBALS['strEdit'].' '.PMA_backquote($tables[$i][TBL_NAME]).' '.$GLOBALS['strSettings']); $GLOBALS['strEdit'] . ' ' . PMA_backquote($tables[$i][TBL_NAME]) . ' ' . $GLOBALS['strSettings']);
} else { } else {
$message .= sprintf('<li><a href="%s" title="%s">%s</a></li>', $message .= sprintf('<li><a href="%s" title="%s">%s</a></li>',
$tbl_url, $tbl_url,
$GLOBALS['strGoToView'].': '.PMA_backquote($tables[$i][TBL_NAME]), $GLOBALS['strGoToView'] . ': ' . PMA_backquote($tables[$i][TBL_NAME]),
$tables[$i][TBL_NAME]); $tables[$i][TBL_NAME]);
} }
} }