diff --git a/libraries/export/htmlword.php b/libraries/export/htmlword.php index c6c1484f84..46485cf070 100644 --- a/libraries/export/htmlword.php +++ b/libraries/export/htmlword.php @@ -204,34 +204,7 @@ if (isset($plugin_list)) { $columns = PMA_DBI_get_columns($db, $view); foreach ($columns as $column) { - $schema_insert .= ''; - - $extracted_columnspec = PMA_extractColumnSpec($column['Type']); - $type = htmlspecialchars($extracted_columnspec['print_type']); - if (empty($type)) { - $type = ' '; - } - - if (! isset($column['Default'])) { - if ($column['Null'] != 'NO') { - $column['Default'] = 'NULL'; - } - } - - $fmt_pre = ''; - $fmt_post = ''; - if (in_array($column['Field'], $unique_keys)) { - $fmt_pre = '' . $fmt_pre; - $fmt_post = $fmt_post . ''; - } - if ($column['Key'] == 'PRI') { - $fmt_pre = '' . $fmt_pre; - $fmt_post = $fmt_post . ''; - } - $schema_insert .= '' . $fmt_pre . htmlspecialchars($column['Field']) . $fmt_post . ''; - $schema_insert .= '' . htmlspecialchars($type) . ''; - $schema_insert .= '' . (($column['Null'] == '' || $column['Null'] == 'NO') ? __('No') : __('Yes')) . ''; - $schema_insert .= '' . htmlspecialchars(isset($column['Default']) ? $column['Default'] : '') . ''; + $schema_insert .= PMA_getOneColumnDefinition($column); $schema_insert .= ''; } @@ -267,17 +240,6 @@ if (isset($plugin_list)) { $schema_insert = ''; - /** - * Get the unique keys in the table - */ - $unique_keys = array(); - $keys = PMA_DBI_get_table_indexes($db, $table); - foreach ($keys as $key) { - if ($key['Non_unique'] == 0) { - $unique_keys[] = $key['Column_name']; - } - } - /** * Gets fields properties */ @@ -334,36 +296,7 @@ if (isset($plugin_list)) { $columns = PMA_DBI_get_columns($db, $table); foreach ($columns as $column) { - - $schema_insert .= ''; - - $extracted_columnspec = PMA_extractColumnSpec($column['Type']); - $type = htmlspecialchars($extracted_columnspec['print_type']); - if (empty($type)) { - $type = ' '; - } - - if (! isset($column['Default'])) { - if ($column['Null'] != 'NO') { - $column['Default'] = 'NULL'; - } - } - - $fmt_pre = ''; - $fmt_post = ''; - if (in_array($column['Field'], $unique_keys)) { - $fmt_pre = '' . $fmt_pre; - $fmt_post = $fmt_post . ''; - } - if ($column['Key'] == 'PRI') { - $fmt_pre = '' . $fmt_pre; - $fmt_post = $fmt_post . ''; - } - $schema_insert .= '' . $fmt_pre . htmlspecialchars($column['Field']) . $fmt_post . ''; - $schema_insert .= '' . htmlspecialchars($type) . ''; - $schema_insert .= '' . (($column['Null'] == '' || $column['Null'] == 'NO') ? __('No') : __('Yes')) . ''; - $schema_insert .= '' . htmlspecialchars(isset($column['Default']) ? $column['Default'] : '') . ''; - + $schema_insert .= PMA_getOneColumnDefinition($column); $field_name = $column['Field']; if ($do_relation && $have_rel) { @@ -470,5 +403,71 @@ if (isset($plugin_list)) { return PMA_exportOutputHandler($dump); } + /** + * Gets the definition for one column + * + * @param array $column info about this column + * + * @return string Formatted column definition + * + * @access public + */ + function PMA_getOneColumnDefinition( + $column + ) { + /** + * Get the unique keys in the table + */ + $unique_keys = array(); + $keys = PMA_DBI_get_table_indexes($db, $table); + foreach ($keys as $key) { + if ($key['Non_unique'] == 0) { + $unique_keys[] = $key['Column_name']; + } + } + + /** + * Formats the definition + */ + $definition = ''; + $extracted_columnspec = PMA_extractColumnSpec($column['Type']); + $type = htmlspecialchars($extracted_columnspec['print_type']); + if (empty($type)) { + $type = ' '; + } + + if (! isset($column['Default'])) { + if ($column['Null'] != 'NO') { + $column['Default'] = 'NULL'; + } + } + + $fmt_pre = ''; + $fmt_post = ''; + if (in_array($column['Field'], $unique_keys)) { + $fmt_pre = '' . $fmt_pre; + $fmt_post = $fmt_post . ''; + } + if ($column['Key'] == 'PRI') { + $fmt_pre = '' . $fmt_pre; + $fmt_post = $fmt_post . ''; + } + $definition .= '' . $fmt_pre + . htmlspecialchars($column['Field']) . $fmt_post . ''; + $definition .= '' . htmlspecialchars($type) + . ''; + $definition .= '' + . (($column['Null'] == '' || $column['Null'] == 'NO') + ? __('No') + : __('Yes')) + . ''; + $definition .= '' + . htmlspecialchars(isset($column['Default']) + ? $column['Default'] + : '') + . ''; + + return $definition; + } } ?>