Use PMA_extractFieldSpec instead of own code in export plugins

This commit is contained in:
Michal Čihař 2011-08-04 16:38:42 +02:00
parent 236eb052bc
commit d29cf3227d
3 changed files with 6 additions and 85 deletions

View File

@ -273,40 +273,10 @@ if (isset($plugin_list)) {
foreach ($columns as $column) {
$schema_insert = '<tr class="print-category">';
$type = $column['Type'];
// reformat mysql query output
// set or enum types: slashes single quotes inside options
if (preg_match('/^(set|enum)\((.+)\)$/i', $type, $tmp)) {
$tmp[2] = substr(preg_replace('/([^,])\'\'/', '\\1\\\'', ',' . $tmp[2]), 1);
$type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
$type_nowrap = '';
$binary = 0;
$unsigned = 0;
$zerofill = 0;
} else {
$type_nowrap = ' nowrap="nowrap"';
$type = preg_replace('/BINARY/i', '', $type);
$type = preg_replace('/ZEROFILL/i', '', $type);
$type = preg_replace('/UNSIGNED/i', '', $type);
if (empty($type)) {
$type = '&nbsp;';
}
$extracted_fieldspec = PMA_extractFieldSpec($column['Type']);
$type = $extracted_fieldspec['print_type'];
$binary = preg_match('/BINARY/i', $column['Type']);
$unsigned = preg_match('/UNSIGNED/i', $column['Type']);
$zerofill = preg_match('/ZEROFILL/i', $column['Type']);
}
$attribute = '&nbsp;';
if ($binary) {
$attribute = 'BINARY';
}
if ($unsigned) {
$attribute = 'UNSIGNED';
}
if ($zerofill) {
$attribute = 'UNSIGNED ZEROFILL';
}
if (! isset($column['Default'])) {
if ($column['Null'] != 'NO') {
$column['Default'] = 'NULL';

View File

@ -391,30 +391,8 @@ if (isset($plugin_list)) {
$fields = PMA_DBI_get_columns($db, $table);
foreach ($fields as $row) {
$type = $row['Type'];
// reformat mysql query output
// set or enum types: slashes single quotes inside options
if (preg_match('/^(set|enum)\((.+)\)$/i', $type, $tmp)) {
$tmp[2] = substr(preg_replace('/([^,])\'\'/', '\\1\\\'', ',' . $tmp[2]), 1);
$type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
$type_nowrap = '';
$binary = 0;
$unsigned = 0;
$zerofill = 0;
} else {
$type_nowrap = ' nowrap="nowrap"';
$type = preg_replace('/BINARY/i', '', $type);
$type = preg_replace('/ZEROFILL/i', '', $type);
$type = preg_replace('/UNSIGNED/i', '', $type);
if (empty($type)) {
$type = '&nbsp;';
}
$binary = preg_match('/BINARY/i', $row['Type']);
$unsigned = preg_match('/UNSIGNED/i', $row['Type']);
$zerofill = preg_match('/ZEROFILL/i', $row['Type']);
}
$extracted_fieldspec = PMA_extractFieldSpec($row['Type']);
$type = $extracted_fieldspec['print_type'];
if (!isset($row['Default'])) {
if ($row['Null'] != 'NO') {
$row['Default'] = 'NULL';

View File

@ -317,36 +317,9 @@ if (isset($plugin_list)) {
$columns = PMA_DBI_get_columns($db, $table);
foreach ($columns as $column) {
$extracted_fieldspec = PMA_extractFieldSpec($column['Type']);
$type = $extracted_fieldspec['print_type'];
$field_name = $column['Field'];
$GLOBALS['odt_buffer'] .= '<table:table-row>';
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars($field_name) . '</text:p>'
. '</table:table-cell>';
// reformat mysql query output
// set or enum types: slashes single quotes inside options
$type = $column['Type'];
if (preg_match('/^(set|enum)\((.+)\)$/i', $type, $tmp)) {
$tmp[2] = substr(preg_replace('/([^,])\'\'/', '\\1\\\'', ',' . $tmp[2]), 1);
$type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
$type_nowrap = '';
$binary = 0;
$unsigned = 0;
$zerofill = 0;
} else {
$type_nowrap = ' nowrap="nowrap"';
$type = preg_replace('/BINARY/i', '', $type);
$type = preg_replace('/ZEROFILL/i', '', $type);
$type = preg_replace('/UNSIGNED/i', '', $type);
if (empty($type)) {
$type = '&nbsp;';
}
$binary = preg_match('/BINARY/i', $column['Type']);
$unsigned = preg_match('/UNSIGNED/i', $column['Type']);
$zerofill = preg_match('/ZEROFILL/i', $column['Type']);
}
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
. '<text:p>' . htmlspecialchars($type) . '</text:p>'
. '</table:table-cell>';