Fix duplicate code
This commit is contained in:
parent
b78899aa99
commit
35c725515b
@ -269,41 +269,11 @@ if (isset($plugin_list)) {
|
||||
. '</table:table-cell>';
|
||||
$GLOBALS['odt_buffer'] .= '</table:table-row>';
|
||||
|
||||
$columns = PMA_DBI_get_columns($db, $table);
|
||||
$columns = PMA_DBI_get_columns($db, $view);
|
||||
foreach ($columns as $column) {
|
||||
$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>';
|
||||
|
||||
$extracted_columnspec = PMA_extractColumnSpec($column['Type']);
|
||||
$type = htmlspecialchars($extracted_columnspec['print_type']);
|
||||
if (empty($type)) {
|
||||
$type = ' ';
|
||||
}
|
||||
|
||||
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
|
||||
. '<text:p>' . htmlspecialchars($type) . '</text:p>'
|
||||
. '</table:table-cell>';
|
||||
if (!isset($column['Default'])) {
|
||||
if ($column['Null'] != 'NO') {
|
||||
$column['Default'] = 'NULL';
|
||||
} else {
|
||||
$column['Default'] = '';
|
||||
}
|
||||
} else {
|
||||
$column['Default'] = $column['Default'];
|
||||
}
|
||||
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
|
||||
. '<text:p>' . (($column['Null'] == '' || $column['Null'] == 'NO') ? __('No') : __('Yes')) . '</text:p>'
|
||||
. '</table:table-cell>';
|
||||
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
|
||||
. '<text:p>' . htmlspecialchars($column['Default']) . '</text:p>'
|
||||
. '</table:table-cell>';
|
||||
|
||||
$GLOBALS['odt_buffer'] .= PMA_formatOneColumnDefinition($column);
|
||||
$GLOBALS['odt_buffer'] .= '</table:table-row>';
|
||||
} // end while
|
||||
} // end foreach
|
||||
|
||||
$GLOBALS['odt_buffer'] .= '</table:table>';
|
||||
return true;
|
||||
@ -416,36 +386,7 @@ if (isset($plugin_list)) {
|
||||
|
||||
$columns = PMA_DBI_get_columns($db, $table);
|
||||
foreach ($columns as $column) {
|
||||
$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>';
|
||||
|
||||
$extracted_columnspec = PMA_extractColumnSpec($column['Type']);
|
||||
$type = htmlspecialchars($extracted_columnspec['print_type']);
|
||||
if (empty($type)) {
|
||||
$type = ' ';
|
||||
}
|
||||
|
||||
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
|
||||
. '<text:p>' . htmlspecialchars($type) . '</text:p>'
|
||||
. '</table:table-cell>';
|
||||
if (!isset($column['Default'])) {
|
||||
if ($column['Null'] != 'NO') {
|
||||
$column['Default'] = 'NULL';
|
||||
} else {
|
||||
$column['Default'] = '';
|
||||
}
|
||||
} else {
|
||||
$column['Default'] = $column['Default'];
|
||||
}
|
||||
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
|
||||
. '<text:p>' . (($column['Null'] == '' || $column['Null'] == 'NO') ? __('No') : __('Yes')) . '</text:p>'
|
||||
. '</table:table-cell>';
|
||||
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
|
||||
. '<text:p>' . htmlspecialchars($column['Default']) . '</text:p>'
|
||||
. '</table:table-cell>';
|
||||
$GLOBALS['odt_buffer'] .= PMA_formatOneColumnDefinition($column);
|
||||
|
||||
if ($do_relation && $have_rel) {
|
||||
if (isset($res_rel[$field_name])) {
|
||||
@ -477,7 +418,7 @@ if (isset($plugin_list)) {
|
||||
}
|
||||
}
|
||||
$GLOBALS['odt_buffer'] .= '</table:table-row>';
|
||||
} // end while
|
||||
} // end foreach
|
||||
|
||||
$GLOBALS['odt_buffer'] .= '</table:table>';
|
||||
return true;
|
||||
@ -587,5 +528,53 @@ if (isset($plugin_list)) {
|
||||
return PMA_exportOutputHandler($dump);
|
||||
} // end of the 'PMA_exportStructure' function
|
||||
|
||||
/**
|
||||
* Formats the definition for one column
|
||||
*
|
||||
* @param array $column info about this column
|
||||
*
|
||||
* @return string Formatted column definition
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function PMA_formatOneColumnDefinition(
|
||||
$column
|
||||
) {
|
||||
$field_name = $column['Field'];
|
||||
$definition = '<table:table-row>';
|
||||
$definition .= '<table:table-cell office:value-type="string">'
|
||||
. '<text:p>' . htmlspecialchars($field_name) . '</text:p>'
|
||||
. '</table:table-cell>';
|
||||
|
||||
$extracted_columnspec = PMA_extractColumnSpec($column['Type']);
|
||||
$type = htmlspecialchars($extracted_columnspec['print_type']);
|
||||
if (empty($type)) {
|
||||
$type = ' ';
|
||||
}
|
||||
|
||||
$definition .= '<table:table-cell office:value-type="string">'
|
||||
. '<text:p>' . htmlspecialchars($type) . '</text:p>'
|
||||
. '</table:table-cell>';
|
||||
if (! isset($column['Default'])) {
|
||||
if ($column['Null'] != 'NO') {
|
||||
$column['Default'] = 'NULL';
|
||||
} else {
|
||||
$column['Default'] = '';
|
||||
}
|
||||
} else {
|
||||
$column['Default'] = $column['Default'];
|
||||
}
|
||||
$definition .= '<table:table-cell office:value-type="string">'
|
||||
. '<text:p>'
|
||||
. (($column['Null'] == '' || $column['Null'] == 'NO')
|
||||
? __('No')
|
||||
: __('Yes'))
|
||||
. '</text:p>'
|
||||
. '</table:table-cell>';
|
||||
$definition .= '<table:table-cell office:value-type="string">'
|
||||
. '<text:p>' . htmlspecialchars($column['Default']) . '</text:p>'
|
||||
. '</table:table-cell>';
|
||||
return $definition;
|
||||
}
|
||||
} // end else
|
||||
?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user