code cleanup

This commit is contained in:
Marc Delisle
2009-12-30 13:46:17 +00:00
parent 078eedae6e
commit d63ed916fc
5 changed files with 42 additions and 42 deletions

View File

@@ -68,7 +68,7 @@ xmlns="http://www.w3.org/TR/REC-html40">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html> <html>
<head> <head>
<meta http-equiv="Content-type" content="text/html;charset=' . (isset($charset_of_file) ? $charset_of_file : $charset) .'" /> <meta http-equiv="Content-type" content="text/html;charset=' . (isset($charset_of_file) ? $charset_of_file : $charset) . '" />
</head> </head>
<body>'); <body>');
} }
@@ -129,10 +129,10 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
{ {
global $what; global $what;
if (!PMA_exportOutputHandler('<h2>' . $GLOBALS['strDumpingData'] . ' ' . $table . '</h2>')) { if (! PMA_exportOutputHandler('<h2>' . $GLOBALS['strDumpingData'] . ' ' . $table . '</h2>')) {
return FALSE; return FALSE;
} }
if (!PMA_exportOutputHandler('<table class="width100" cellspacing="1">')) { if (! PMA_exportOutputHandler('<table class="width100" cellspacing="1">')) {
return FALSE; return FALSE;
} }
@@ -147,7 +147,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
$schema_insert .= '<td class="print"><b>' . htmlspecialchars(stripslashes(PMA_DBI_field_name($result, $i))) . '</b></td>'; $schema_insert .= '<td class="print"><b>' . htmlspecialchars(stripslashes(PMA_DBI_field_name($result, $i))) . '</b></td>';
} // end for } // end for
$schema_insert .= '</tr>'; $schema_insert .= '</tr>';
if (!PMA_exportOutputHandler($schema_insert)) { if (! PMA_exportOutputHandler($schema_insert)) {
return FALSE; return FALSE;
} }
} // end if } // end if
@@ -156,7 +156,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
while ($row = PMA_DBI_fetch_row($result)) { while ($row = PMA_DBI_fetch_row($result)) {
$schema_insert = '<tr class="print-category">'; $schema_insert = '<tr class="print-category">';
for ($j = 0; $j < $fields_cnt; $j++) { for ($j = 0; $j < $fields_cnt; $j++) {
if (!isset($row[$j]) || is_null($row[$j])) { if (! isset($row[$j]) || is_null($row[$j])) {
$value = $GLOBALS[$what . '_null']; $value = $GLOBALS[$what . '_null'];
} elseif ($row[$j] == '0' || $row[$j] != '') { } elseif ($row[$j] == '0' || $row[$j] != '') {
$value = $row[$j]; $value = $row[$j];
@@ -166,12 +166,12 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
$schema_insert .= '<td class="print">' . htmlspecialchars($value) . '</td>'; $schema_insert .= '<td class="print">' . htmlspecialchars($value) . '</td>';
} // end for } // end for
$schema_insert .= '</tr>'; $schema_insert .= '</tr>';
if (!PMA_exportOutputHandler($schema_insert)) { if (! PMA_exportOutputHandler($schema_insert)) {
return FALSE; return FALSE;
} }
} // end while } // end while
PMA_DBI_free_result($result); PMA_DBI_free_result($result);
if (!PMA_exportOutputHandler('</table>')) { if (! PMA_exportOutputHandler('</table>')) {
return FALSE; return FALSE;
} }
@@ -182,7 +182,7 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
{ {
global $cfgRelation; global $cfgRelation;
if (!PMA_exportOutputHandler('<h2>' . $GLOBALS['strTableStructure'] . ' ' .$table . '</h2>')) { if (! PMA_exportOutputHandler('<h2>' . $GLOBALS['strTableStructure'] . ' ' .$table . '</h2>')) {
return FALSE; return FALSE;
} }
@@ -208,7 +208,7 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
$fields_cnt = PMA_DBI_num_rows($result); $fields_cnt = PMA_DBI_num_rows($result);
// Check if we can use Relations (Mike Beck) // Check if we can use Relations (Mike Beck)
if ($do_relation && !empty($cfgRelation['relation'])) { if ($do_relation && ! empty($cfgRelation['relation'])) {
// Find which tables are related with the current one and write it in // Find which tables are related with the current one and write it in
// an array // an array
$res_rel = PMA_getForeigners($db, $table); $res_rel = PMA_getForeigners($db, $table);
@@ -225,7 +225,7 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
/** /**
* Displays the table structure * Displays the table structure
*/ */
if (!PMA_exportOutputHandler('<table class="width100" cellspacing="1">')) { if (! PMA_exportOutputHandler('<table class="width100" cellspacing="1">')) {
return FALSE; return FALSE;
} }
@@ -258,14 +258,14 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
} }
$schema_insert .= '</tr>'; $schema_insert .= '</tr>';
if (!PMA_exportOutputHandler($schema_insert)) { if (! PMA_exportOutputHandler($schema_insert)) {
return FALSE; return FALSE;
} }
while ($row = PMA_DBI_fetch_assoc($result)) { while ($row = PMA_DBI_fetch_assoc($result)) {
$schema_insert = '<tr class="print-category">'; $schema_insert = '<tr class="print-category">';
$type = $row['Type']; $type = $row['Type'];
// reformat mysql query output - staybyte - 9. June 2001 // reformat mysql query output - staybyte - 9. June 2001
// loic1: set or enum types: slashes single quotes inside options // loic1: set or enum types: slashes single quotes inside options
if (preg_match('/^(set|enum)\((.+)\)$/i', $type, $tmp)) { if (preg_match('/^(set|enum)\((.+)\)$/i', $type, $tmp)) {
@@ -299,7 +299,7 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
if ($zerofill) { if ($zerofill) {
$strAttribute = 'UNSIGNED ZEROFILL'; $strAttribute = 'UNSIGNED ZEROFILL';
} }
if (!isset($row['Default'])) { if (! isset($row['Default'])) {
if ($row['Null'] != 'NO') { if ($row['Null'] != 'NO') {
$row['Default'] = 'NULL'; $row['Default'] = 'NULL';
} }
@@ -313,7 +313,7 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
$fmt_pre = '<b>' . $fmt_pre; $fmt_pre = '<b>' . $fmt_pre;
$fmt_post = $fmt_post . '</b>'; $fmt_post = $fmt_post . '</b>';
} }
if ($row['Key']=='PRI') { if ($row['Key'] == 'PRI') {
$fmt_pre = '<i>' . $fmt_pre; $fmt_pre = '<i>' . $fmt_pre;
$fmt_post = $fmt_post . '</i>'; $fmt_post = $fmt_post . '</i>';
} }
@@ -336,7 +336,7 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
$schema_insert .= '</tr>'; $schema_insert .= '</tr>';
if (!PMA_exportOutputHandler($schema_insert)) { if (! PMA_exportOutputHandler($schema_insert)) {
return FALSE; return FALSE;
} }
} // end while } // end while

View File

@@ -111,7 +111,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
global $mediawiki_export_struct; global $mediawiki_export_struct;
global $mediawiki_export_data; global $mediawiki_export_data;
$result = PMA_DBI_fetch_result("SHOW COLUMNS FROM `".$db."`.`".$table."`"); $result = PMA_DBI_fetch_result("SHOW COLUMNS FROM `" . $db . "`.`" . $table . "`");
$row_cnt = count($result); $row_cnt = count($result);
$output = "{| cellpadding=\"10\" cellspacing=\"0\" border=\"1\" style=\"text-align:center;\"\n"; $output = "{| cellpadding=\"10\" cellspacing=\"0\" border=\"1\" style=\"text-align:center;\"\n";

View File

@@ -66,12 +66,12 @@ function PMA_exportFooter()
function PMA_exportHeader() function PMA_exportHeader()
{ {
PMA_exportOutputHandler( PMA_exportOutputHandler(
'<?php'.$GLOBALS['crlf'] '<?php' . $GLOBALS['crlf']
. '/**'.$GLOBALS['crlf'] . '/**' . $GLOBALS['crlf']
. ' * Export to PHP Array plugin for PHPMyAdmin'.$GLOBALS['crlf'] . ' * Export to PHP Array plugin for PHPMyAdmin' . $GLOBALS['crlf']
. ' * @author Geoffray Warnants'.$GLOBALS['crlf'] . ' * @author Geoffray Warnants' . $GLOBALS['crlf']
. ' * @version 0.2b'.$GLOBALS['crlf'] . ' * @version 0.2b' . $GLOBALS['crlf']
. ' */'.$GLOBALS['crlf'].$GLOBALS['crlf'] . ' */' . $GLOBALS['crlf'] . $GLOBALS['crlf']
); );
return true; return true;
} }
@@ -87,7 +87,7 @@ function PMA_exportHeader()
*/ */
function PMA_exportDBHeader($db) function PMA_exportDBHeader($db)
{ {
PMA_exportOutputHandler('//'.$GLOBALS['crlf'].'// Database "'.$db.'"'.$GLOBALS['crlf'].'//'.$GLOBALS['crlf']); PMA_exportOutputHandler('//' . $GLOBALS['crlf'] . '// Database "' . $db . '"' . $GLOBALS['crlf'] . '//' . $GLOBALS['crlf']);
return true; return true;
} }
@@ -150,34 +150,34 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
// Output table name as comment if this is the first record of the table // Output table name as comment if this is the first record of the table
if ($record_cnt == 1) { if ($record_cnt == 1) {
$buffer .= $crlf.'// '.$db.'.'.$table.$crlf; $buffer .= $crlf . '// ' . $db . '.' . $table . $crlf;
$buffer .= '$'.$table.' = array('.$crlf; $buffer .= '$' . $table . ' = array(' . $crlf;
$buffer .= ' array('; $buffer .= ' array(';
} else { } else {
$buffer .= ','.$crlf.' array('; $buffer .= ',' . $crlf . ' array(';
} }
for ($i = 0; $i < $columns_cnt; $i++) { for ($i = 0; $i < $columns_cnt; $i++) {
$isLastLine = ($i+1 >= $columns_cnt); $isLastLine = ($i + 1 >= $columns_cnt);
$column = $columns[$i]; $column = $columns[$i];
if (is_null($record[$i])) { if (is_null($record[$i])) {
$buffer .= "'".$column."'=>null".(!$isLastLine?',':''); $buffer .= "'" . $column . "'=>null" . (! $isLastLine ? ',' : '');
} elseif (is_numeric($record[$i])) { } elseif (is_numeric($record[$i])) {
$buffer .= "'".$column."'=>".$record[$i] . (!$isLastLine?',':''); $buffer .= "'" . $column . "'=>" . $record[$i] . (! $isLastLine ? ',' : '');
} else { } else {
$buffer .= "'".$column."'=>'".addslashes($record[$i]) . "'" . (!$isLastLine?',':''); $buffer .= "'" . $column . "'=>'" . addslashes($record[$i]) . "'" . (! $isLastLine ? ',' : '');
} }
} }
$buffer .= ')'; $buffer .= ')';
} }
$buffer .= $crlf.');'.$crlf; $buffer .= $crlf . ');' . $crlf;
if (!PMA_exportOutputHandler($buffer)) { if (! PMA_exportOutputHandler($buffer)) {
return FALSE; return FALSE;
} }

View File

@@ -127,7 +127,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
{ {
global $what; global $what;
if (!PMA_exportOutputHandler('== ' . $GLOBALS['strDumpingData'] . ' ' . $table . "\n\n")) { if (! PMA_exportOutputHandler('== ' . $GLOBALS['strDumpingData'] . ' ' . $table . "\n\n")) {
return FALSE; return FALSE;
} }
@@ -142,7 +142,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
$text_output .= '|' . htmlspecialchars(stripslashes(PMA_DBI_field_name($result, $i))); $text_output .= '|' . htmlspecialchars(stripslashes(PMA_DBI_field_name($result, $i)));
} // end for } // end for
$text_output .= "\n|------\n"; $text_output .= "\n|------\n";
if (!PMA_exportOutputHandler($text_output)) { if (! PMA_exportOutputHandler($text_output)) {
return FALSE; return FALSE;
} }
} // end if } // end if
@@ -151,7 +151,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
while ($row = PMA_DBI_fetch_row($result)) { while ($row = PMA_DBI_fetch_row($result)) {
$text_output = ''; $text_output = '';
for ($j = 0; $j < $fields_cnt; $j++) { for ($j = 0; $j < $fields_cnt; $j++) {
if (!isset($row[$j]) || is_null($row[$j])) { if (! isset($row[$j]) || is_null($row[$j])) {
$value = $GLOBALS[$what . '_null']; $value = $GLOBALS[$what . '_null'];
} elseif ($row[$j] == '0' || $row[$j] != '') { } elseif ($row[$j] == '0' || $row[$j] != '') {
$value = $row[$j]; $value = $row[$j];
@@ -161,7 +161,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
$text_output .= '|' . htmlspecialchars($value); $text_output .= '|' . htmlspecialchars($value);
} // end for } // end for
$text_output .= "\n"; $text_output .= "\n";
if (!PMA_exportOutputHandler($text_output)) { if (! PMA_exportOutputHandler($text_output)) {
return FALSE; return FALSE;
} }
} // end while } // end while
@@ -174,7 +174,7 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
{ {
global $cfgRelation; global $cfgRelation;
if (!PMA_exportOutputHandler('== ' . $GLOBALS['strTableStructure'] . ' ' .$table . "\n\n")) { if (! PMA_exportOutputHandler('== ' . $GLOBALS['strTableStructure'] . ' ' .$table . "\n\n")) {
return FALSE; return FALSE;
} }
@@ -200,7 +200,7 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
$fields_cnt = PMA_DBI_num_rows($result); $fields_cnt = PMA_DBI_num_rows($result);
// Check if we can use Relations (Mike Beck) // Check if we can use Relations (Mike Beck)
if ($do_relation && !empty($cfgRelation['relation'])) { if ($do_relation && ! empty($cfgRelation['relation'])) {
// Find which tables are related with the current one and write it in // Find which tables are related with the current one and write it in
// an array // an array
$res_rel = PMA_getForeigners($db, $table); $res_rel = PMA_getForeigners($db, $table);
@@ -247,7 +247,7 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
} }
$text_output .= "\n|------\n"; $text_output .= "\n|------\n";
if (!PMA_exportOutputHandler($text_output)) { if (! PMA_exportOutputHandler($text_output)) {
return FALSE; return FALSE;
} }
@@ -288,7 +288,7 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
if ($zerofill) { if ($zerofill) {
$strAttribute = 'UNSIGNED ZEROFILL'; $strAttribute = 'UNSIGNED ZEROFILL';
} }
if (!isset($row['Default'])) { if (! isset($row['Default'])) {
if ($row['Null'] != 'NO') { if ($row['Null'] != 'NO') {
$row['Default'] = 'NULL'; $row['Default'] = 'NULL';
} }
@@ -325,7 +325,7 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
$text_output .= "\n"; $text_output .= "\n";
if (!PMA_exportOutputHandler($text_output)) { if (! PMA_exportOutputHandler($text_output)) {
return FALSE; return FALSE;
} }
} // end while } // end while

View File

@@ -174,7 +174,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
$buffer .= ' ' . $column . ': ' . $record[$i] . $crlf; $buffer .= ' ' . $column . ': ' . $record[$i] . $crlf;
} }
if (!PMA_exportOutputHandler($buffer)) { if (! PMA_exportOutputHandler($buffer)) {
return FALSE; return FALSE;
} }
} }