[Phpmyadmin-git] [SCM] phpMyAdmin branch, master, updated. RELEASE_3_4_3_1-12840-g3769b84
Michal Čihař
nijel at users.sourceforge.net
Tue Aug 2 15:53:31 CEST 2011
The branch, master has been updated
via 3769b849aa6a72f8816cf6bc2cacbff506a2fe85 (commit)
from 7e7be00f8466bb380e0c1d4370aa43ece0b1780f (commit)
- Log -----------------------------------------------------------------
commit 3769b849aa6a72f8816cf6bc2cacbff506a2fe85
Author: Michal Čihař <mcihar at suse.cz>
Date: Tue Aug 2 15:53:19 2011 +0200
Forgot to reindent some files
-----------------------------------------------------------------------
Summary of changes:
libraries/export/php_array.php | 226 +++++++++---------
libraries/export/texytext.php | 516 ++++++++++++++++++++--------------------
libraries/export/xls.php | 258 ++++++++++----------
libraries/export/xlsx.php | 256 ++++++++++----------
libraries/export/xml.php | 502 +++++++++++++++++++-------------------
libraries/export/yaml.php | 234 +++++++++---------
6 files changed, 996 insertions(+), 996 deletions(-)
diff --git a/libraries/export/php_array.php b/libraries/export/php_array.php
index 783afe0..6424759 100644
--- a/libraries/export/php_array.php
+++ b/libraries/export/php_array.php
@@ -30,134 +30,134 @@ if (isset($plugin_list)) {
);
} else {
-/**
- * Set of functions used to build exports of tables
- */
+ /**
+ * Set of functions used to build exports of tables
+ */
+
+ /**
+ * Outputs export footer
+ *
+ * @return bool Whether it suceeded
+ *
+ * @access public
+ */
+ function PMA_exportFooter()
+ {
+ return true;
+ }
-/**
- * Outputs export footer
- *
- * @return bool Whether it suceeded
- *
- * @access public
- */
-function PMA_exportFooter()
-{
- return true;
-}
+ /**
+ * Outputs export header
+ *
+ * @return bool Whether it suceeded
+ *
+ * @access public
+ */
+ function PMA_exportHeader()
+ {
+ PMA_exportOutputHandler(
+ '<?php' . $GLOBALS['crlf']
+ . '/**' . $GLOBALS['crlf']
+ . ' * Export to PHP Array plugin for PHPMyAdmin' . $GLOBALS['crlf']
+ . ' * @version 0.2b' . $GLOBALS['crlf']
+ . ' */' . $GLOBALS['crlf'] . $GLOBALS['crlf']
+ );
+ return true;
+ }
-/**
- * Outputs export header
- *
- * @return bool Whether it suceeded
- *
- * @access public
- */
-function PMA_exportHeader()
-{
- PMA_exportOutputHandler(
- '<?php' . $GLOBALS['crlf']
- . '/**' . $GLOBALS['crlf']
- . ' * Export to PHP Array plugin for PHPMyAdmin' . $GLOBALS['crlf']
- . ' * @version 0.2b' . $GLOBALS['crlf']
- . ' */' . $GLOBALS['crlf'] . $GLOBALS['crlf']
- );
- return true;
-}
+ /**
+ * Outputs database header
+ *
+ * @param string $db Database name
+ * @return bool Whether it suceeded
+ *
+ * @access public
+ */
+ function PMA_exportDBHeader($db)
+ {
+ PMA_exportOutputHandler('//' . $GLOBALS['crlf'] . '// Database "' . $db . '"' . $GLOBALS['crlf'] . '//' . $GLOBALS['crlf']);
+ return true;
+ }
-/**
- * Outputs database header
- *
- * @param string $db Database name
- * @return bool Whether it suceeded
- *
- * @access public
- */
-function PMA_exportDBHeader($db)
-{
- PMA_exportOutputHandler('//' . $GLOBALS['crlf'] . '// Database "' . $db . '"' . $GLOBALS['crlf'] . '//' . $GLOBALS['crlf']);
- return true;
-}
+ /**
+ * Outputs database footer
+ *
+ * @param string $db Database name
+ * @return bool Whether it suceeded
+ *
+ * @access public
+ */
+ function PMA_exportDBFooter($db)
+ {
+ return true;
+ }
-/**
- * Outputs database footer
- *
- * @param string $db Database name
- * @return bool Whether it suceeded
- *
- * @access public
- */
-function PMA_exportDBFooter($db)
-{
- return true;
-}
+ /**
+ * Outputs CREATE DATABASE statement
+ *
+ * @param string $db Database name
+ * @return bool Whether it suceeded
+ *
+ * @access public
+ */
+ function PMA_exportDBCreate($db)
+ {
+ return true;
+ }
-/**
- * Outputs CREATE DATABASE statement
- *
- * @param string $db Database name
- * @return bool Whether it suceeded
- *
- * @access public
- */
-function PMA_exportDBCreate($db)
-{
- return true;
-}
+ /**
+ * Outputs the content of a table as a fragment of PHP code
+ *
+ * @param string $db database name
+ * @param string $table table name
+ * @param string $crlf the end of line sequence
+ * @param string $error_url the url to go back in case of error
+ * @param string $sql_query SQL query for obtaining data
+ * @return bool Whether it suceeded
+ *
+ * @access public
+ */
+ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
+ {
+ $result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
+
+ $columns_cnt = PMA_DBI_num_fields($result);
+ for ($i = 0; $i < $columns_cnt; $i++) {
+ $columns[$i] = stripslashes(PMA_DBI_field_name($result, $i));
+ }
+ unset($i);
-/**
- * Outputs the content of a table as a fragment of PHP code
- *
- * @param string $db database name
- * @param string $table table name
- * @param string $crlf the end of line sequence
- * @param string $error_url the url to go back in case of error
- * @param string $sql_query SQL query for obtaining data
- * @return bool Whether it suceeded
- *
- * @access public
- */
-function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
-{
- $result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
+ $buffer = '';
+ $record_cnt = 0;
+ while ($record = PMA_DBI_fetch_row($result)) {
- $columns_cnt = PMA_DBI_num_fields($result);
- for ($i = 0; $i < $columns_cnt; $i++) {
- $columns[$i] = stripslashes(PMA_DBI_field_name($result, $i));
- }
- unset($i);
+ $record_cnt++;
- $buffer = '';
- $record_cnt = 0;
- while ($record = PMA_DBI_fetch_row($result)) {
+ // Output table name as comment if this is the first record of the table
+ if ($record_cnt == 1) {
+ $buffer .= $crlf . '// ' . $db . '.' . $table . $crlf;
+ $buffer .= '$' . $table . ' = array(' . $crlf;
+ $buffer .= ' array(';
+ } else {
+ $buffer .= ',' . $crlf . ' array(';
+ }
- $record_cnt++;
- // Output table name as comment if this is the first record of the table
- if ($record_cnt == 1) {
- $buffer .= $crlf . '// ' . $db . '.' . $table . $crlf;
- $buffer .= '$' . $table . ' = array(' . $crlf;
- $buffer .= ' array(';
- } else {
- $buffer .= ',' . $crlf . ' array(';
- }
+ for ($i = 0; $i < $columns_cnt; $i++) {
+ $buffer .= "'" . $columns[$i]. "'=>" . var_export($record[$i], true) . (($i + 1 >= $columns_cnt) ? '' : ',');
+ }
+ $buffer .= ')';
+ }
- for ($i = 0; $i < $columns_cnt; $i++) {
- $buffer .= "'" . $columns[$i]. "'=>" . var_export($record[$i], true) . (($i + 1 >= $columns_cnt) ? '' : ',');
+ $buffer .= $crlf . ');' . $crlf;
+ if (! PMA_exportOutputHandler($buffer)) {
+ return false;
}
- $buffer .= ')';
- }
+ PMA_DBI_free_result($result);
- $buffer .= $crlf . ');' . $crlf;
- if (! PMA_exportOutputHandler($buffer)) {
- return false;
+ return true;
}
- PMA_DBI_free_result($result);
-
- return true;
-}
-
}
diff --git a/libraries/export/texytext.php b/libraries/export/texytext.php
index 06de740..d248c1b 100644
--- a/libraries/export/texytext.php
+++ b/libraries/export/texytext.php
@@ -32,302 +32,302 @@ if (isset($plugin_list)) {
);
} else {
-/**
- * Outputs export footer
- *
- * @return bool Whether it suceeded
- *
- * @access public
- */
-function PMA_exportFooter() {
- return true;
-}
-
-/**
- * Outputs export header
- *
- * @return bool Whether it suceeded
- *
- * @access public
- */
-function PMA_exportHeader() {
- return true;
-}
-
-/**
- * Outputs database header
- *
- * @param string $db Database name
- * @return bool Whether it suceeded
- *
- * @access public
- */
-function PMA_exportDBHeader($db) {
- return PMA_exportOutputHandler('===' . __('Database') . ' ' . $db . "\n\n");
-}
-
-/**
- * Outputs database footer
- *
- * @param string $db Database name
- * @return bool Whether it suceeded
- *
- * @access public
- */
-function PMA_exportDBFooter($db) {
- return true;
-}
-
-/**
- * Outputs CREATE DATABASE statement
- *
- * @param string $db Database name
- * @return bool Whether it suceeded
- *
- * @access public
- */
-function PMA_exportDBCreate($db) {
- return true;
-}
-
-/**
- * Outputs the content of a table in Texy format
- *
- * @param string $db database name
- * @param string $table table name
- * @param string $crlf the end of line sequence
- * @param string $error_url the url to go back in case of error
- * @param string $sql_query SQL query for obtaining data
- * @return bool Whether it suceeded
- *
- * @access public
- */
-function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
-{
- global $what;
-
- if (! PMA_exportOutputHandler('== ' . __('Dumping data for table') . ' ' . $table . "\n\n")) {
- return false;
+ /**
+ * Outputs export footer
+ *
+ * @return bool Whether it suceeded
+ *
+ * @access public
+ */
+ function PMA_exportFooter() {
+ return true;
}
- // Gets the data from the database
- $result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
- $fields_cnt = PMA_DBI_num_fields($result);
-
- // If required, get fields name at the first line
- if (isset($GLOBALS[$what . '_columns'])) {
- $text_output = "|------\n";
- for ($i = 0; $i < $fields_cnt; $i++) {
- $text_output .= '|' . htmlspecialchars(stripslashes(PMA_DBI_field_name($result, $i)));
- } // end for
- $text_output .= "\n|------\n";
- if (! PMA_exportOutputHandler($text_output)) {
- return false;
- }
- } // end if
-
- // Format the data
- while ($row = PMA_DBI_fetch_row($result)) {
- $text_output = '';
- for ($j = 0; $j < $fields_cnt; $j++) {
- if (! isset($row[$j]) || is_null($row[$j])) {
- $value = $GLOBALS[$what . '_null'];
- } elseif ($row[$j] == '0' || $row[$j] != '') {
- $value = $row[$j];
- } else {
- $value = ' ';
- }
- $text_output .= '|' . htmlspecialchars($value);
- } // end for
- $text_output .= "\n";
- if (! PMA_exportOutputHandler($text_output)) {
- return false;
- }
- } // end while
- PMA_DBI_free_result($result);
-
- return true;
-}
-
-/**
- * Outputs table's structure
- *
- * @param string $db database name
- * @param string $table table name
- * @param string $crlf the end of line sequence
- * @param string $error_url the url to go back in case of error
- * @param bool $do_relation whether to include relation comments
- * @param bool $do_comments whether to include the pmadb-style column comments
- * as comments in the structure; this is deprecated
- * but the parameter is left here because export.php
- * calls PMA_exportStructure() also for other export
- * types which use this parameter
- * @param bool $do_mime whether to include mime comments
- * @param bool $dates whether to include creation/update/check dates
- * @param string $export_mode 'create_table', 'triggers', 'create_view', 'stand_in'
- * @param string $export_type 'server', 'database', 'table'
- * @return bool Whether it suceeded
- *
- * @access public
- */
-function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = false, $do_comments = false, $do_mime = false, $dates = false, $export_mode, $export_type)
-{
- global $cfgRelation;
-
- if (! PMA_exportOutputHandler('== ' . __('Table structure for table') . ' ' .$table . "\n\n")) {
- return false;
+ /**
+ * Outputs export header
+ *
+ * @return bool Whether it suceeded
+ *
+ * @access public
+ */
+ function PMA_exportHeader() {
+ return true;
}
/**
- * Get the unique keys in the table
+ * Outputs database header
+ *
+ * @param string $db Database name
+ * @return bool Whether it suceeded
+ *
+ * @access public
*/
- $keys_query = 'SHOW KEYS FROM ' . PMA_backquote($table) . ' FROM '. PMA_backquote($db);
- $keys_result = PMA_DBI_query($keys_query);
- $unique_keys = array();
- while ($key = PMA_DBI_fetch_assoc($keys_result)) {
- if ($key['Non_unique'] == 0) {
- $unique_keys[] = $key['Column_name'];
- }
+ function PMA_exportDBHeader($db) {
+ return PMA_exportOutputHandler('===' . __('Database') . ' ' . $db . "\n\n");
}
- PMA_DBI_free_result($keys_result);
/**
- * Gets fields properties
+ * Outputs database footer
+ *
+ * @param string $db Database name
+ * @return bool Whether it suceeded
+ *
+ * @access public
*/
- PMA_DBI_select_db($db);
-
- // Check if we can use Relations
- if ($do_relation && ! empty($cfgRelation['relation'])) {
- // Find which tables are related with the current one and write it in
- // an array
- $res_rel = PMA_getForeigners($db, $table);
+ function PMA_exportDBFooter($db) {
+ return true;
+ }
- if ($res_rel && count($res_rel) > 0) {
- $have_rel = true;
- } else {
- $have_rel = false;
- }
- } else {
- $have_rel = false;
- } // end if
+ /**
+ * Outputs CREATE DATABASE statement
+ *
+ * @param string $db Database name
+ * @return bool Whether it suceeded
+ *
+ * @access public
+ */
+ function PMA_exportDBCreate($db) {
+ return true;
+ }
/**
- * Displays the table structure
+ * Outputs the content of a table in Texy format
+ *
+ * @param string $db database name
+ * @param string $table table name
+ * @param string $crlf the end of line sequence
+ * @param string $error_url the url to go back in case of error
+ * @param string $sql_query SQL query for obtaining data
+ * @return bool Whether it suceeded
+ *
+ * @access public
*/
+ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
+ {
+ global $what;
- $columns_cnt = 4;
- if ($do_relation && $have_rel) {
- $columns_cnt++;
- }
- if ($do_comments && $cfgRelation['commwork']) {
- $columns_cnt++;
- }
- if ($do_mime && $cfgRelation['mimework']) {
- $columns_cnt++;
- }
+ if (! PMA_exportOutputHandler('== ' . __('Dumping data for table') . ' ' . $table . "\n\n")) {
+ return false;
+ }
- $text_output = "|------\n";
- $text_output .= '|' . htmlspecialchars(__('Column'));
- $text_output .= '|' . htmlspecialchars(__('Type'));
- $text_output .= '|' . htmlspecialchars(__('Null'));
- $text_output .= '|' . htmlspecialchars(__('Default'));
- if ($do_relation && $have_rel) {
- $text_output .= '|' . htmlspecialchars(__('Links to'));
- }
- if ($do_comments) {
- $text_output .= '|' . htmlspecialchars(__('Comments'));
- $comments = PMA_getComments($db, $table);
- }
- if ($do_mime && $cfgRelation['mimework']) {
- $text_output .= '|' . htmlspecialchars('MIME');
- $mime_map = PMA_getMIME($db, $table, true);
- }
- $text_output .= "\n|------\n";
+ // Gets the data from the database
+ $result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
+ $fields_cnt = PMA_DBI_num_fields($result);
+
+ // If required, get fields name at the first line
+ if (isset($GLOBALS[$what . '_columns'])) {
+ $text_output = "|------\n";
+ for ($i = 0; $i < $fields_cnt; $i++) {
+ $text_output .= '|' . htmlspecialchars(stripslashes(PMA_DBI_field_name($result, $i)));
+ } // end for
+ $text_output .= "\n|------\n";
+ if (! PMA_exportOutputHandler($text_output)) {
+ return false;
+ }
+ } // end if
+
+ // Format the data
+ while ($row = PMA_DBI_fetch_row($result)) {
+ $text_output = '';
+ for ($j = 0; $j < $fields_cnt; $j++) {
+ if (! isset($row[$j]) || is_null($row[$j])) {
+ $value = $GLOBALS[$what . '_null'];
+ } elseif ($row[$j] == '0' || $row[$j] != '') {
+ $value = $row[$j];
+ } else {
+ $value = ' ';
+ }
+ $text_output .= '|' . htmlspecialchars($value);
+ } // end for
+ $text_output .= "\n";
+ if (! PMA_exportOutputHandler($text_output)) {
+ return false;
+ }
+ } // end while
+ PMA_DBI_free_result($result);
- if (! PMA_exportOutputHandler($text_output)) {
- return false;
+ return true;
}
- $columns = PMA_DBI_get_columns($db, $table);
- foreach ($columns as $column) {
-
- $text_output = '';
- $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 = ' ';
- }
+ /**
+ * Outputs table's structure
+ *
+ * @param string $db database name
+ * @param string $table table name
+ * @param string $crlf the end of line sequence
+ * @param string $error_url the url to go back in case of error
+ * @param bool $do_relation whether to include relation comments
+ * @param bool $do_comments whether to include the pmadb-style column comments
+ * as comments in the structure; this is deprecated
+ * but the parameter is left here because export.php
+ * calls PMA_exportStructure() also for other export
+ * types which use this parameter
+ * @param bool $do_mime whether to include mime comments
+ * @param bool $dates whether to include creation/update/check dates
+ * @param string $export_mode 'create_table', 'triggers', 'create_view', 'stand_in'
+ * @param string $export_type 'server', 'database', 'table'
+ * @return bool Whether it suceeded
+ *
+ * @access public
+ */
+ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = false, $do_comments = false, $do_mime = false, $dates = false, $export_mode, $export_type)
+ {
+ global $cfgRelation;
- $binary = preg_match('/BINARY/i', $column['Type']);
- $unsigned = preg_match('/UNSIGNED/i', $column['Type']);
- $zerofill = preg_match('/ZEROFILL/i', $column['Type']);
- }
- $attribute = ' ';
- if ($binary) {
- $attribute = 'BINARY';
- }
- if ($unsigned) {
- $attribute = 'UNSIGNED';
- }
- if ($zerofill) {
- $attribute = 'UNSIGNED ZEROFILL';
+ if (! PMA_exportOutputHandler('== ' . __('Table structure for table') . ' ' .$table . "\n\n")) {
+ return false;
}
- if (! isset($column['Default'])) {
- if ($column['Null'] != 'NO') {
- $column['Default'] = 'NULL';
+
+ /**
+ * Get the unique keys in the table
+ */
+ $keys_query = 'SHOW KEYS FROM ' . PMA_backquote($table) . ' FROM '. PMA_backquote($db);
+ $keys_result = PMA_DBI_query($keys_query);
+ $unique_keys = array();
+ while ($key = PMA_DBI_fetch_assoc($keys_result)) {
+ if ($key['Non_unique'] == 0) {
+ $unique_keys[] = $key['Column_name'];
}
}
+ PMA_DBI_free_result($keys_result);
- $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 . '//';
- }
- $text_output .= '|' . $fmt_pre . htmlspecialchars($column['Field']) . $fmt_post;
- $text_output .= '|' . htmlspecialchars($type);
- $text_output .= '|' . htmlspecialchars(($column['Null'] == '' || $column['Null'] == 'NO') ? __('No') : __('Yes'));
- $text_output .= '|' . htmlspecialchars(isset($column['Default']) ? $column['Default'] : '');
+ /**
+ * Gets fields properties
+ */
+ PMA_DBI_select_db($db);
- $field_name = $column['Field'];
+ // Check if we can use Relations
+ if ($do_relation && ! empty($cfgRelation['relation'])) {
+ // Find which tables are related with the current one and write it in
+ // an array
+ $res_rel = PMA_getForeigners($db, $table);
+ if ($res_rel && count($res_rel) > 0) {
+ $have_rel = true;
+ } else {
+ $have_rel = false;
+ }
+ } else {
+ $have_rel = false;
+ } // end if
+
+ /**
+ * Displays the table structure
+ */
+
+ $columns_cnt = 4;
if ($do_relation && $have_rel) {
- $text_output .= '|' . (isset($res_rel[$field_name]) ? htmlspecialchars($res_rel[$field_name]['foreign_table'] . ' (' . $res_rel[$field_name]['foreign_field'] . ')') : '');
+ $columns_cnt++;
}
if ($do_comments && $cfgRelation['commwork']) {
- $text_output .= '|' . (isset($comments[$field_name]) ? htmlspecialchars($comments[$field_name]) : '');
+ $columns_cnt++;
}
if ($do_mime && $cfgRelation['mimework']) {
- $text_output .= '|' . (isset($mime_map[$field_name]) ? htmlspecialchars(str_replace('_', '/', $mime_map[$field_name]['mimetype'])) : '');
+ $columns_cnt++;
}
- $text_output .= "\n";
+ $text_output = "|------\n";
+ $text_output .= '|' . htmlspecialchars(__('Column'));
+ $text_output .= '|' . htmlspecialchars(__('Type'));
+ $text_output .= '|' . htmlspecialchars(__('Null'));
+ $text_output .= '|' . htmlspecialchars(__('Default'));
+ if ($do_relation && $have_rel) {
+ $text_output .= '|' . htmlspecialchars(__('Links to'));
+ }
+ if ($do_comments) {
+ $text_output .= '|' . htmlspecialchars(__('Comments'));
+ $comments = PMA_getComments($db, $table);
+ }
+ if ($do_mime && $cfgRelation['mimework']) {
+ $text_output .= '|' . htmlspecialchars('MIME');
+ $mime_map = PMA_getMIME($db, $table, true);
+ }
+ $text_output .= "\n|------\n";
if (! PMA_exportOutputHandler($text_output)) {
return false;
}
- } // end while
- return true;
-}
+ $columns = PMA_DBI_get_columns($db, $table);
+ foreach ($columns as $column) {
+
+ $text_output = '';
+ $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 = ' ';
+ }
+
+ $binary = preg_match('/BINARY/i', $column['Type']);
+ $unsigned = preg_match('/UNSIGNED/i', $column['Type']);
+ $zerofill = preg_match('/ZEROFILL/i', $column['Type']);
+ }
+ $attribute = ' ';
+ if ($binary) {
+ $attribute = 'BINARY';
+ }
+ if ($unsigned) {
+ $attribute = 'UNSIGNED';
+ }
+ if ($zerofill) {
+ $attribute = 'UNSIGNED ZEROFILL';
+ }
+ 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 . '//';
+ }
+ $text_output .= '|' . $fmt_pre . htmlspecialchars($column['Field']) . $fmt_post;
+ $text_output .= '|' . htmlspecialchars($type);
+ $text_output .= '|' . htmlspecialchars(($column['Null'] == '' || $column['Null'] == 'NO') ? __('No') : __('Yes'));
+ $text_output .= '|' . htmlspecialchars(isset($column['Default']) ? $column['Default'] : '');
+
+ $field_name = $column['Field'];
+
+ if ($do_relation && $have_rel) {
+ $text_output .= '|' . (isset($res_rel[$field_name]) ? htmlspecialchars($res_rel[$field_name]['foreign_table'] . ' (' . $res_rel[$field_name]['foreign_field'] . ')') : '');
+ }
+ if ($do_comments && $cfgRelation['commwork']) {
+ $text_output .= '|' . (isset($comments[$field_name]) ? htmlspecialchars($comments[$field_name]) : '');
+ }
+ if ($do_mime && $cfgRelation['mimework']) {
+ $text_output .= '|' . (isset($mime_map[$field_name]) ? htmlspecialchars(str_replace('_', '/', $mime_map[$field_name]['mimetype'])) : '');
+ }
+
+ $text_output .= "\n";
+
+ if (! PMA_exportOutputHandler($text_output)) {
+ return false;
+ }
+ } // end while
+
+ return true;
+ }
}
?>
diff --git a/libraries/export/xls.php b/libraries/export/xls.php
index 5747f08..3ff6f6a 100644
--- a/libraries/export/xls.php
+++ b/libraries/export/xls.php
@@ -30,164 +30,164 @@ if (isset($plugin_list)) {
);
} else {
-/* Append the PHPExcel directory to the include path variable */
-set_include_path(get_include_path() . PATH_SEPARATOR . getcwd() . '/libraries/PHPExcel/');
+ /* Append the PHPExcel directory to the include path variable */
+ set_include_path(get_include_path() . PATH_SEPARATOR . getcwd() . '/libraries/PHPExcel/');
-require_once './libraries/PHPExcel/PHPExcel.php';
-require_once './libraries/PHPExcel/PHPExcel/Writer/Excel5.php';
+ require_once './libraries/PHPExcel/PHPExcel.php';
+ require_once './libraries/PHPExcel/PHPExcel/Writer/Excel5.php';
-/**
- * Outputs export footer
- *
- * @return bool Whether it suceeded
- *
- * @access public
- */
-function PMA_exportFooter() {
- global $workbook;
- global $tmp_filename;
-
- $tmp_filename = tempnam(realpath($GLOBALS['cfg']['TempDir']), 'pma_xls_');
-
- $workbookWriter = new PHPExcel_Writer_Excel5($workbook);
- $workbookWriter->setTempDir(realpath($GLOBALS['cfg']['TempDir']));
- $workbookWriter->save($tmp_filename);
-
- if (!PMA_exportOutputHandler(file_get_contents($tmp_filename))) {
- return false;
- }
+ /**
+ * Outputs export footer
+ *
+ * @return bool Whether it suceeded
+ *
+ * @access public
+ */
+ function PMA_exportFooter() {
+ global $workbook;
+ global $tmp_filename;
- unlink($tmp_filename);
+ $tmp_filename = tempnam(realpath($GLOBALS['cfg']['TempDir']), 'pma_xls_');
- unset($GLOBALS['workbook']);
- unset($GLOBALS['sheet_index']);
+ $workbookWriter = new PHPExcel_Writer_Excel5($workbook);
+ $workbookWriter->setTempDir(realpath($GLOBALS['cfg']['TempDir']));
+ $workbookWriter->save($tmp_filename);
- return true;
-}
+ if (!PMA_exportOutputHandler(file_get_contents($tmp_filename))) {
+ return false;
+ }
-/**
- * Outputs export header
- *
- * @return bool Whether it suceeded
- *
- * @access public
- */
-function PMA_exportHeader() {
- global $db;
+ unlink($tmp_filename);
- /* Initialize the workbook */
- $GLOBALS['workbook'] = new PHPExcel();
- $GLOBALS['sheet_index'] = 0;
- global $workbook;
+ unset($GLOBALS['workbook']);
+ unset($GLOBALS['sheet_index']);
- $workbook->getProperties()->setCreator('phpMyAdmin ' . PMA_VERSION);
- $workbook->getProperties()->setLastModifiedBy('phpMyAdmin ' . PMA_VERSION);
- $workbook->getProperties()->setTitle($db);
- $workbook->getProperties()->setSubject('phpMyAdmin ' . PMA_VERSION . ' XLS Dump');
+ return true;
+ }
- return true;
-}
+ /**
+ * Outputs export header
+ *
+ * @return bool Whether it suceeded
+ *
+ * @access public
+ */
+ function PMA_exportHeader() {
+ global $db;
-/**
- * Outputs database header
- *
- * @param string $db Database name
- * @return bool Whether it suceeded
- *
- * @access public
- */
-function PMA_exportDBHeader($db) {
+ /* Initialize the workbook */
+ $GLOBALS['workbook'] = new PHPExcel();
+ $GLOBALS['sheet_index'] = 0;
+ global $workbook;
+ $workbook->getProperties()->setCreator('phpMyAdmin ' . PMA_VERSION);
+ $workbook->getProperties()->setLastModifiedBy('phpMyAdmin ' . PMA_VERSION);
+ $workbook->getProperties()->setTitle($db);
+ $workbook->getProperties()->setSubject('phpMyAdmin ' . PMA_VERSION . ' XLS Dump');
- return true;
-}
+ return true;
+ }
-/**
- * Outputs database footer
- *
- * @param string $db Database name
- * @return bool Whether it suceeded
- *
- * @access public
- */
-function PMA_exportDBFooter($db) {
- return true;
-}
+ /**
+ * Outputs database header
+ *
+ * @param string $db Database name
+ * @return bool Whether it suceeded
+ *
+ * @access public
+ */
+ function PMA_exportDBHeader($db) {
-/**
- * Outputs CREATE DATABASE statement
- *
- * @param string $db Database name
- * @return bool Whether it suceeded
- *
- * @access public
- */
-function PMA_exportDBCreate($db) {
- return true;
-}
-/**
- * Outputs the content of a table in XLS format
- *
- * @param string $db database name
- * @param string $table table name
- * @param string $crlf the end of line sequence
- * @param string $error_url the url to go back in case of error
- * @param string $sql_query SQL query for obtaining data
- * @return bool Whether it suceeded
- *
- * @access public
- */
-function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
- global $workbook;
- global $sheet_index;
+ return true;
+ }
/**
- * Get the data from the database using the original query
+ * Outputs database footer
+ *
+ * @param string $db Database name
+ * @return bool Whether it suceeded
+ *
+ * @access public
*/
- $result = PMA_DBI_fetch_result($sql_query);
- $row_cnt = count($result);
+ function PMA_exportDBFooter($db) {
+ return true;
+ }
- if ($row_cnt > 0) {
- $col_names = array_keys($result[0]);
- $fields_cnt = count($result[0]);
- $row_offset = 1;
+ /**
+ * Outputs CREATE DATABASE statement
+ *
+ * @param string $db Database name
+ * @return bool Whether it suceeded
+ *
+ * @access public
+ */
+ function PMA_exportDBCreate($db) {
+ return true;
+ }
- /* Only one sheet is created on workbook initialization */
- if ($sheet_index > 0) {
- $workbook->createSheet();
- }
+ /**
+ * Outputs the content of a table in XLS format
+ *
+ * @param string $db database name
+ * @param string $table table name
+ * @param string $crlf the end of line sequence
+ * @param string $error_url the url to go back in case of error
+ * @param string $sql_query SQL query for obtaining data
+ * @return bool Whether it suceeded
+ *
+ * @access public
+ */
+ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
+ global $workbook;
+ global $sheet_index;
+
+ /**
+ * Get the data from the database using the original query
+ */
+ $result = PMA_DBI_fetch_result($sql_query);
+ $row_cnt = count($result);
+
+ if ($row_cnt > 0) {
+ $col_names = array_keys($result[0]);
+ $fields_cnt = count($result[0]);
+ $row_offset = 1;
+
+ /* Only one sheet is created on workbook initialization */
+ if ($sheet_index > 0) {
+ $workbook->createSheet();
+ }
- $workbook->setActiveSheetIndex($sheet_index);
- $workbook->getActiveSheet()->setTitle(substr($table, 0, 31));
+ $workbook->setActiveSheetIndex($sheet_index);
+ $workbook->getActiveSheet()->setTitle(substr($table, 0, 31));
- if (isset($GLOBALS['xls_columns']) && $GLOBALS['xls_columns']) {
- for ($i = 0; $i < $fields_cnt; ++$i) {
- $workbook->getActiveSheet()->setCellValueByColumnAndRow($i, $row_offset, $col_names[$i]);
+ if (isset($GLOBALS['xls_columns']) && $GLOBALS['xls_columns']) {
+ for ($i = 0; $i < $fields_cnt; ++$i) {
+ $workbook->getActiveSheet()->setCellValueByColumnAndRow($i, $row_offset, $col_names[$i]);
+ }
+ $row_offset++;
}
- $row_offset++;
- }
- for ($r = 0; ($r < 65536) && ($r < $row_cnt); ++$r) {
- for ($c = 0; $c < $fields_cnt; ++$c) {
- if (!isset($result[$r][$col_names[$c]]) || is_null($result[$r][$col_names[$c]])) {
- $workbook->getActiveSheet()->setCellValueByColumnAndRow($c, ($r + $row_offset), $GLOBALS['xls_null']);
- } elseif ($result[$r][$col_names[$c]] == '0' || $result[$r][$col_names[$c]] != '') {
- /**
- * @todo we should somehow handle character set here!
- */
- $workbook->getActiveSheet()->setCellValueByColumnAndRow($c, ($r + $row_offset), $result[$r][$col_names[$c]]);
- } else {
- $workbook->getActiveSheet()->setCellValueByColumnAndRow($c, ($r + $row_offset), '');
+ for ($r = 0; ($r < 65536) && ($r < $row_cnt); ++$r) {
+ for ($c = 0; $c < $fields_cnt; ++$c) {
+ if (!isset($result[$r][$col_names[$c]]) || is_null($result[$r][$col_names[$c]])) {
+ $workbook->getActiveSheet()->setCellValueByColumnAndRow($c, ($r + $row_offset), $GLOBALS['xls_null']);
+ } elseif ($result[$r][$col_names[$c]] == '0' || $result[$r][$col_names[$c]] != '') {
+ /**
+ * @todo we should somehow handle character set here!
+ */
+ $workbook->getActiveSheet()->setCellValueByColumnAndRow($c, ($r + $row_offset), $result[$r][$col_names[$c]]);
+ } else {
+ $workbook->getActiveSheet()->setCellValueByColumnAndRow($c, ($r + $row_offset), '');
+ }
}
}
+
+ $sheet_index++;
}
- $sheet_index++;
+ return true;
}
- return true;
-}
-
}
?>
diff --git a/libraries/export/xlsx.php b/libraries/export/xlsx.php
index 8f5cb19..b06a615 100644
--- a/libraries/export/xlsx.php
+++ b/libraries/export/xlsx.php
@@ -30,163 +30,163 @@ if (isset($plugin_list)) {
);
} else {
-/* Append the PHPExcel directory to the include path variable */
-set_include_path(get_include_path() . PATH_SEPARATOR . getcwd() . '/libraries/PHPExcel/');
+ /* Append the PHPExcel directory to the include path variable */
+ set_include_path(get_include_path() . PATH_SEPARATOR . getcwd() . '/libraries/PHPExcel/');
-require_once './libraries/PHPExcel/PHPExcel.php';
-require_once './libraries/PHPExcel/PHPExcel/Writer/Excel2007.php';
+ require_once './libraries/PHPExcel/PHPExcel.php';
+ require_once './libraries/PHPExcel/PHPExcel/Writer/Excel2007.php';
-/**
- * Outputs export footer
- *
- * @return bool Whether it suceeded
- *
- * @access public
- */
-function PMA_exportFooter() {
- global $workbook;
- global $tmp_filename;
-
- $tmp_filename = tempnam(realpath($GLOBALS['cfg']['TempDir']), 'pma_xlsx_');
-
- $workbookWriter = new PHPExcel_Writer_Excel2007($workbook);
- $workbookWriter->save($tmp_filename);
-
- if (!PMA_exportOutputHandler(file_get_contents($tmp_filename))) {
- return false;
- }
+ /**
+ * Outputs export footer
+ *
+ * @return bool Whether it suceeded
+ *
+ * @access public
+ */
+ function PMA_exportFooter() {
+ global $workbook;
+ global $tmp_filename;
- unlink($tmp_filename);
+ $tmp_filename = tempnam(realpath($GLOBALS['cfg']['TempDir']), 'pma_xlsx_');
- unset($GLOBALS['workbook']);
- unset($GLOBALS['sheet_index']);
+ $workbookWriter = new PHPExcel_Writer_Excel2007($workbook);
+ $workbookWriter->save($tmp_filename);
- return true;
-}
+ if (!PMA_exportOutputHandler(file_get_contents($tmp_filename))) {
+ return false;
+ }
-/**
- * Outputs export header
- *
- * @return bool Whether it suceeded
- *
- * @access public
- */
-function PMA_exportHeader() {
- global $db;
+ unlink($tmp_filename);
- /* Initialize the workbook */
- $GLOBALS['workbook'] = new PHPExcel();
- $GLOBALS['sheet_index'] = 0;
- global $workbook;
+ unset($GLOBALS['workbook']);
+ unset($GLOBALS['sheet_index']);
- $workbook->getProperties()->setCreator('phpMyAdmin ' . PMA_VERSION);
- $workbook->getProperties()->setLastModifiedBy('phpMyAdmin ' . PMA_VERSION);
- $workbook->getProperties()->setTitle($db);
- $workbook->getProperties()->setSubject('phpMyAdmin ' . PMA_VERSION . ' XLSX Dump');
+ return true;
+ }
- return true;
-}
+ /**
+ * Outputs export header
+ *
+ * @return bool Whether it suceeded
+ *
+ * @access public
+ */
+ function PMA_exportHeader() {
+ global $db;
-/**
- * Outputs database header
- *
- * @param string $db Database name
- * @return bool Whether it suceeded
- *
- * @access public
- */
-function PMA_exportDBHeader($db) {
+ /* Initialize the workbook */
+ $GLOBALS['workbook'] = new PHPExcel();
+ $GLOBALS['sheet_index'] = 0;
+ global $workbook;
+ $workbook->getProperties()->setCreator('phpMyAdmin ' . PMA_VERSION);
+ $workbook->getProperties()->setLastModifiedBy('phpMyAdmin ' . PMA_VERSION);
+ $workbook->getProperties()->setTitle($db);
+ $workbook->getProperties()->setSubject('phpMyAdmin ' . PMA_VERSION . ' XLSX Dump');
- return true;
-}
+ return true;
+ }
-/**
- * Outputs database footer
- *
- * @param string $db Database name
- * @return bool Whether it suceeded
- *
- * @access public
- */
-function PMA_exportDBFooter($db) {
- return true;
-}
+ /**
+ * Outputs database header
+ *
+ * @param string $db Database name
+ * @return bool Whether it suceeded
+ *
+ * @access public
+ */
+ function PMA_exportDBHeader($db) {
-/**
- * Outputs CREATE DATABASE statement
- *
- * @param string $db Database name
- * @return bool Whether it suceeded
- *
- * @access public
- */
-function PMA_exportDBCreate($db) {
- return true;
-}
-/**
- * Outputs the content of a table in XLSX format
- *
- * @param string $db database name
- * @param string $table table name
- * @param string $crlf the end of line sequence
- * @param string $error_url the url to go back in case of error
- * @param string $sql_query SQL query for obtaining data
- * @return bool Whether it suceeded
- *
- * @access public
- */
-function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
- global $workbook;
- global $sheet_index;
+ return true;
+ }
/**
- * Get the data from the database using the original query
+ * Outputs database footer
+ *
+ * @param string $db Database name
+ * @return bool Whether it suceeded
+ *
+ * @access public
*/
- $result = PMA_DBI_fetch_result($sql_query);
- $row_cnt = count($result);
+ function PMA_exportDBFooter($db) {
+ return true;
+ }
- if ($row_cnt > 0) {
- $col_names = array_keys($result[0]);
- $fields_cnt = count($result[0]);
- $row_offset = 1;
+ /**
+ * Outputs CREATE DATABASE statement
+ *
+ * @param string $db Database name
+ * @return bool Whether it suceeded
+ *
+ * @access public
+ */
+ function PMA_exportDBCreate($db) {
+ return true;
+ }
- /* Only one sheet is created on workbook initialization */
- if ($sheet_index > 0) {
- $workbook->createSheet();
- }
+ /**
+ * Outputs the content of a table in XLSX format
+ *
+ * @param string $db database name
+ * @param string $table table name
+ * @param string $crlf the end of line sequence
+ * @param string $error_url the url to go back in case of error
+ * @param string $sql_query SQL query for obtaining data
+ * @return bool Whether it suceeded
+ *
+ * @access public
+ */
+ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
+ global $workbook;
+ global $sheet_index;
+
+ /**
+ * Get the data from the database using the original query
+ */
+ $result = PMA_DBI_fetch_result($sql_query);
+ $row_cnt = count($result);
+
+ if ($row_cnt > 0) {
+ $col_names = array_keys($result[0]);
+ $fields_cnt = count($result[0]);
+ $row_offset = 1;
+
+ /* Only one sheet is created on workbook initialization */
+ if ($sheet_index > 0) {
+ $workbook->createSheet();
+ }
- $workbook->setActiveSheetIndex($sheet_index);
- $workbook->getActiveSheet()->setTitle(substr($table, 0, 31));
+ $workbook->setActiveSheetIndex($sheet_index);
+ $workbook->getActiveSheet()->setTitle(substr($table, 0, 31));
- if (isset($GLOBALS['xlsx_columns']) && $GLOBALS['xlsx_columns']) {
- for ($i = 0; $i < $fields_cnt; ++$i) {
- $workbook->getActiveSheet()->setCellValueByColumnAndRow($i, $row_offset, $col_names[$i]);
+ if (isset($GLOBALS['xlsx_columns']) && $GLOBALS['xlsx_columns']) {
+ for ($i = 0; $i < $fields_cnt; ++$i) {
+ $workbook->getActiveSheet()->setCellValueByColumnAndRow($i, $row_offset, $col_names[$i]);
+ }
+ $row_offset++;
}
- $row_offset++;
- }
- for ($r = 0; ($r < 65536) && ($r < $row_cnt); ++$r) {
- for ($c = 0; $c < $fields_cnt; ++$c) {
- if (!isset($result[$r][$col_names[$c]]) || is_null($result[$r][$col_names[$c]])) {
- $workbook->getActiveSheet()->setCellValueByColumnAndRow($c, ($r + $row_offset), $GLOBALS['xlsx_null']);
- } elseif ($result[$r][$col_names[$c]] == '0' || $result[$r][$col_names[$c]] != '') {
- /**
- * @todo we should somehow handle character set here!
- */
- $workbook->getActiveSheet()->setCellValueByColumnAndRow($c, ($r + $row_offset), $result[$r][$col_names[$c]]);
- } else {
- $workbook->getActiveSheet()->setCellValueByColumnAndRow($c, ($r + $row_offset), '');
+ for ($r = 0; ($r < 65536) && ($r < $row_cnt); ++$r) {
+ for ($c = 0; $c < $fields_cnt; ++$c) {
+ if (!isset($result[$r][$col_names[$c]]) || is_null($result[$r][$col_names[$c]])) {
+ $workbook->getActiveSheet()->setCellValueByColumnAndRow($c, ($r + $row_offset), $GLOBALS['xlsx_null']);
+ } elseif ($result[$r][$col_names[$c]] == '0' || $result[$r][$col_names[$c]] != '') {
+ /**
+ * @todo we should somehow handle character set here!
+ */
+ $workbook->getActiveSheet()->setCellValueByColumnAndRow($c, ($r + $row_offset), $result[$r][$col_names[$c]]);
+ } else {
+ $workbook->getActiveSheet()->setCellValueByColumnAndRow($c, ($r + $row_offset), '');
+ }
}
}
+
+ $sheet_index++;
}
- $sheet_index++;
+ return true;
}
- return true;
-}
-
}
?>
diff --git a/libraries/export/xml.php b/libraries/export/xml.php
index 26953af..b55d1e9 100644
--- a/libraries/export/xml.php
+++ b/libraries/export/xml.php
@@ -48,295 +48,295 @@ if (isset($plugin_list)) {
$plugin_list['xml']['options'][] = array('type' => 'end_group');
} else {
-/**
- * Outputs export footer
- *
- * @return bool Whether it suceeded
- *
- * @access public
- */
-function PMA_exportFooter() {
- $foot = '</pma_xml_export>';
-
- return PMA_exportOutputHandler($foot);
-}
-
-/**
- * Outputs export header
- *
- * @return bool Whether it suceeded
- *
- * @access public
- */
-function PMA_exportHeader() {
- global $crlf;
- global $cfg;
- global $db;
- global $table;
- global $tables;
-
- $export_struct = isset($GLOBALS['xml_export_functions']) || isset($GLOBALS['xml_export_procedures'])
- || isset($GLOBALS['xml_export_tables']) || isset($GLOBALS['xml_export_triggers'])
- || isset($GLOBALS['xml_export_views']);
- $export_data = isset($GLOBALS['xml_export_contents']) ? true : false;
-
- if ($GLOBALS['output_charset_conversion']) {
- $charset = $GLOBALS['charset_of_file'];
- } else {
- $charset = 'utf-8';
+ /**
+ * Outputs export footer
+ *
+ * @return bool Whether it suceeded
+ *
+ * @access public
+ */
+ function PMA_exportFooter() {
+ $foot = '</pma_xml_export>';
+
+ return PMA_exportOutputHandler($foot);
}
- $head = '<?xml version="1.0" encoding="' . $charset . '"?>' . $crlf
- . '<!--' . $crlf
- . '- phpMyAdmin XML Dump' . $crlf
- . '- version ' . PMA_VERSION . $crlf
- . '- http://www.phpmyadmin.net' . $crlf
- . '-' . $crlf
- . '- ' . __('Host') . ': ' . $cfg['Server']['host'];
- if (!empty($cfg['Server']['port'])) {
- $head .= ':' . $cfg['Server']['port'];
- }
- $head .= $crlf
- . '- ' . __('Generation Time') . ': ' . PMA_localisedDate() . $crlf
- . '- ' . __('Server version') . ': ' . PMA_MYSQL_STR_VERSION . $crlf
- . '- ' . __('PHP Version') . ': ' . phpversion() . $crlf
- . '-->' . $crlf . $crlf;
-
- $head .= '<pma_xml_export version="1.0"' . (($export_struct) ? ' xmlns:pma="http://www.phpmyadmin.net/some_doc_url/"' : '') . '>' . $crlf;
-
- if ($export_struct) {
- $result = PMA_DBI_fetch_result('SELECT `DEFAULT_CHARACTER_SET_NAME`, `DEFAULT_COLLATION_NAME` FROM `information_schema`.`SCHEMATA` WHERE `SCHEMA_NAME` = \''.PMA_sqlAddSlashes($db).'\' LIMIT 1');
- $db_collation = $result[0]['DEFAULT_COLLATION_NAME'];
- $db_charset = $result[0]['DEFAULT_CHARACTER_SET_NAME'];
-
- $head .= ' <!--' . $crlf;
- $head .= ' - Structure schemas' . $crlf;
- $head .= ' -->' . $crlf;
- $head .= ' <pma:structure_schemas>' . $crlf;
- $head .= ' <pma:database name="' . htmlspecialchars($db) . '" collation="' . $db_collation . '" charset="' . $db_charset . '">' . $crlf;
-
- if (count($tables) == 0) {
- $tables[] = $table;
+ /**
+ * Outputs export header
+ *
+ * @return bool Whether it suceeded
+ *
+ * @access public
+ */
+ function PMA_exportHeader() {
+ global $crlf;
+ global $cfg;
+ global $db;
+ global $table;
+ global $tables;
+
+ $export_struct = isset($GLOBALS['xml_export_functions']) || isset($GLOBALS['xml_export_procedures'])
+ || isset($GLOBALS['xml_export_tables']) || isset($GLOBALS['xml_export_triggers'])
+ || isset($GLOBALS['xml_export_views']);
+ $export_data = isset($GLOBALS['xml_export_contents']) ? true : false;
+
+ if ($GLOBALS['output_charset_conversion']) {
+ $charset = $GLOBALS['charset_of_file'];
+ } else {
+ $charset = 'utf-8';
}
- foreach ($tables as $table) {
- // Export tables and views
- $result = PMA_DBI_fetch_result('SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table), 0);
- $tbl = $result[$table][1];
+ $head = '<?xml version="1.0" encoding="' . $charset . '"?>' . $crlf
+ . '<!--' . $crlf
+ . '- phpMyAdmin XML Dump' . $crlf
+ . '- version ' . PMA_VERSION . $crlf
+ . '- http://www.phpmyadmin.net' . $crlf
+ . '-' . $crlf
+ . '- ' . __('Host') . ': ' . $cfg['Server']['host'];
+ if (!empty($cfg['Server']['port'])) {
+ $head .= ':' . $cfg['Server']['port'];
+ }
+ $head .= $crlf
+ . '- ' . __('Generation Time') . ': ' . PMA_localisedDate() . $crlf
+ . '- ' . __('Server version') . ': ' . PMA_MYSQL_STR_VERSION . $crlf
+ . '- ' . __('PHP Version') . ': ' . phpversion() . $crlf
+ . '-->' . $crlf . $crlf;
+
+ $head .= '<pma_xml_export version="1.0"' . (($export_struct) ? ' xmlns:pma="http://www.phpmyadmin.net/some_doc_url/"' : '') . '>' . $crlf;
+
+ if ($export_struct) {
+ $result = PMA_DBI_fetch_result('SELECT `DEFAULT_CHARACTER_SET_NAME`, `DEFAULT_COLLATION_NAME` FROM `information_schema`.`SCHEMATA` WHERE `SCHEMA_NAME` = \''.PMA_sqlAddSlashes($db).'\' LIMIT 1');
+ $db_collation = $result[0]['DEFAULT_COLLATION_NAME'];
+ $db_charset = $result[0]['DEFAULT_CHARACTER_SET_NAME'];
+
+ $head .= ' <!--' . $crlf;
+ $head .= ' - Structure schemas' . $crlf;
+ $head .= ' -->' . $crlf;
+ $head .= ' <pma:structure_schemas>' . $crlf;
+ $head .= ' <pma:database name="' . htmlspecialchars($db) . '" collation="' . $db_collation . '" charset="' . $db_charset . '">' . $crlf;
+
+ if (count($tables) == 0) {
+ $tables[] = $table;
+ }
- $is_view = PMA_isView($db, $table);
+ foreach ($tables as $table) {
+ // Export tables and views
+ $result = PMA_DBI_fetch_result('SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table), 0);
+ $tbl = $result[$table][1];
- if ($is_view) {
- $type = 'view';
- } else {
- $type = 'table';
- }
-
- if ($is_view && ! isset($GLOBALS['xml_export_views'])) {
- continue;
- }
-
- if (! $is_view && ! isset($GLOBALS['xml_export_tables'])) {
- continue;
+ $is_view = PMA_isView($db, $table);
+
+ if ($is_view) {
+ $type = 'view';
+ } else {
+ $type = 'table';
+ }
+
+ if ($is_view && ! isset($GLOBALS['xml_export_views'])) {
+ continue;
+ }
+
+ if (! $is_view && ! isset($GLOBALS['xml_export_tables'])) {
+ continue;
+ }
+
+ $head .= ' <pma:' . $type . ' name="' . $table . '">' . $crlf;
+
+ $tbl = " " . htmlspecialchars($tbl);
+ $tbl = str_replace("\n", "\n ", $tbl);
+
+ $head .= $tbl . ';' . $crlf;
+ $head .= ' </pma:' . $type . '>' . $crlf;
+
+ if (isset($GLOBALS['xml_export_triggers']) && $GLOBALS['xml_export_triggers']) {
+ // Export triggers
+ $triggers = PMA_DBI_get_triggers($db, $table);
+ if ($triggers) {
+ foreach ($triggers as $trigger) {
+ $code = $trigger['create'];
+ $head .= ' <pma:trigger name="' . $trigger['name'] . '">' . $crlf;
+
+ // Do some formatting
+ $code = substr(rtrim($code), 0, -3);
+ $code = " " . htmlspecialchars($code);
+ $code = str_replace("\n", "\n ", $code);
+
+ $head .= $code . $crlf;
+ $head .= ' </pma:trigger>' . $crlf;
+ }
+
+ unset($trigger);
+ unset($triggers);
+ }
+ }
}
- $head .= ' <pma:' . $type . ' name="' . $table . '">' . $crlf;
-
- $tbl = " " . htmlspecialchars($tbl);
- $tbl = str_replace("\n", "\n ", $tbl);
-
- $head .= $tbl . ';' . $crlf;
- $head .= ' </pma:' . $type . '>' . $crlf;
-
- if (isset($GLOBALS['xml_export_triggers']) && $GLOBALS['xml_export_triggers']) {
- // Export triggers
- $triggers = PMA_DBI_get_triggers($db, $table);
- if ($triggers) {
- foreach ($triggers as $trigger) {
- $code = $trigger['create'];
- $head .= ' <pma:trigger name="' . $trigger['name'] . '">' . $crlf;
+ if (isset($GLOBALS['xml_export_functions']) && $GLOBALS['xml_export_functions']) {
+ // Export functions
+ $functions = PMA_DBI_get_procedures_or_functions($db, 'FUNCTION');
+ if ($functions) {
+ foreach ($functions as $function) {
+ $head .= ' <pma:function name="' . $function . '">' . $crlf;
// Do some formatting
- $code = substr(rtrim($code), 0, -3);
- $code = " " . htmlspecialchars($code);
- $code = str_replace("\n", "\n ", $code);
+ $sql = PMA_DBI_get_definition($db, 'FUNCTION', $function);
+ $sql = rtrim($sql);
+ $sql = " " . htmlspecialchars($sql);
+ $sql = str_replace("\n", "\n ", $sql);
- $head .= $code . $crlf;
- $head .= ' </pma:trigger>' . $crlf;
+ $head .= $sql . $crlf;
+ $head .= ' </pma:function>' . $crlf;
}
- unset($trigger);
- unset($triggers);
+ unset($create_func);
+ unset($function);
+ unset($functions);
}
}
- }
-
- if (isset($GLOBALS['xml_export_functions']) && $GLOBALS['xml_export_functions']) {
- // Export functions
- $functions = PMA_DBI_get_procedures_or_functions($db, 'FUNCTION');
- if ($functions) {
- foreach ($functions as $function) {
- $head .= ' <pma:function name="' . $function . '">' . $crlf;
-
- // Do some formatting
- $sql = PMA_DBI_get_definition($db, 'FUNCTION', $function);
- $sql = rtrim($sql);
- $sql = " " . htmlspecialchars($sql);
- $sql = str_replace("\n", "\n ", $sql);
-
- $head .= $sql . $crlf;
- $head .= ' </pma:function>' . $crlf;
- }
- unset($create_func);
- unset($function);
- unset($functions);
- }
- }
-
- if (isset($GLOBALS['xml_export_procedures']) && $GLOBALS['xml_export_procedures']) {
- // Export procedures
- $procedures = PMA_DBI_get_procedures_or_functions($db, 'PROCEDURE');
- if ($procedures) {
- foreach ($procedures as $procedure) {
- $head .= ' <pma:procedure name="' . $procedure . '">' . $crlf;
-
- // Do some formatting
- $sql = PMA_DBI_get_definition($db, 'PROCEDURE', $procedure);
- $sql = rtrim($sql);
- $sql = " " . htmlspecialchars($sql);
- $sql = str_replace("\n", "\n ", $sql);
-
- $head .= $sql . $crlf;
- $head .= ' </pma:procedure>' . $crlf;
- }
+ if (isset($GLOBALS['xml_export_procedures']) && $GLOBALS['xml_export_procedures']) {
+ // Export procedures
+ $procedures = PMA_DBI_get_procedures_or_functions($db, 'PROCEDURE');
+ if ($procedures) {
+ foreach ($procedures as $procedure) {
+ $head .= ' <pma:procedure name="' . $procedure . '">' . $crlf;
+
+ // Do some formatting
+ $sql = PMA_DBI_get_definition($db, 'PROCEDURE', $procedure);
+ $sql = rtrim($sql);
+ $sql = " " . htmlspecialchars($sql);
+ $sql = str_replace("\n", "\n ", $sql);
+
+ $head .= $sql . $crlf;
+ $head .= ' </pma:procedure>' . $crlf;
+ }
- unset($create_proc);
- unset($procedure);
- unset($procedures);
+ unset($create_proc);
+ unset($procedure);
+ unset($procedures);
+ }
}
- }
- unset($result);
+ unset($result);
- $head .= ' </pma:database>' . $crlf;
- $head .= ' </pma:structure_schemas>' . $crlf;
+ $head .= ' </pma:database>' . $crlf;
+ $head .= ' </pma:structure_schemas>' . $crlf;
- if ($export_data) {
- $head .= $crlf;
+ if ($export_data) {
+ $head .= $crlf;
+ }
}
- }
-
- return PMA_exportOutputHandler($head);
-}
-/**
- * Outputs database header
- *
- * @param string $db Database name
- * @return bool Whether it suceeded
- *
- * @access public
- */
-function PMA_exportDBHeader($db) {
- global $crlf;
-
- if (isset($GLOBALS['xml_export_contents']) && $GLOBALS['xml_export_contents']) {
- $head = ' <!--' . $crlf
- . ' - ' . __('Database') . ': ' . (isset($GLOBALS['use_backquotes']) ? PMA_backquote($db) : '\'' . $db . '\''). $crlf
- . ' -->' . $crlf
- . ' <database name="' . htmlspecialchars($db) . '">' . $crlf;
-
return PMA_exportOutputHandler($head);
}
- else
- {
- return true;
- }
-}
-/**
- * Outputs database footer
- *
- * @param string $db Database name
- * @return bool Whether it suceeded
- *
- * @access public
- */
-function PMA_exportDBFooter($db) {
- global $crlf;
-
- if (isset($GLOBALS['xml_export_contents']) && $GLOBALS['xml_export_contents']) {
- return PMA_exportOutputHandler(' </database>' . $crlf);
- }
- else
- {
- return true;
+ /**
+ * Outputs database header
+ *
+ * @param string $db Database name
+ * @return bool Whether it suceeded
+ *
+ * @access public
+ */
+ function PMA_exportDBHeader($db) {
+ global $crlf;
+
+ if (isset($GLOBALS['xml_export_contents']) && $GLOBALS['xml_export_contents']) {
+ $head = ' <!--' . $crlf
+ . ' - ' . __('Database') . ': ' . (isset($GLOBALS['use_backquotes']) ? PMA_backquote($db) : '\'' . $db . '\''). $crlf
+ . ' -->' . $crlf
+ . ' <database name="' . htmlspecialchars($db) . '">' . $crlf;
+
+ return PMA_exportOutputHandler($head);
+ }
+ else
+ {
+ return true;
+ }
}
-}
-
-/**
- * Outputs CREATE DATABASE statement
- *
- * @param string $db Database name
- * @return bool Whether it suceeded
- *
- * @access public
- */
-function PMA_exportDBCreate($db) {
- return true;
-}
-/**
- * Outputs the content of a table in XML format
- *
- * @param string $db database name
- * @param string $table table name
- * @param string $crlf the end of line sequence
- * @param string $error_url the url to go back in case of error
- * @param string $sql_query SQL query for obtaining data
- * @return bool Whether it suceeded
- *
- * @access public
- */
-function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
-
- if (isset($GLOBALS['xml_export_contents']) && $GLOBALS['xml_export_contents']) {
- $result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
-
- $columns_cnt = PMA_DBI_num_fields($result);
- $columns = array();
- for ($i = 0; $i < $columns_cnt; $i++) {
- $columns[$i] = stripslashes(str_replace(' ', '_', PMA_DBI_field_name($result, $i)));
+ /**
+ * Outputs database footer
+ *
+ * @param string $db Database name
+ * @return bool Whether it suceeded
+ *
+ * @access public
+ */
+ function PMA_exportDBFooter($db) {
+ global $crlf;
+
+ if (isset($GLOBALS['xml_export_contents']) && $GLOBALS['xml_export_contents']) {
+ return PMA_exportOutputHandler(' </database>' . $crlf);
}
- unset($i);
-
- $buffer = ' <!-- ' . __('Table') . ' ' . $table . ' -->' . $crlf;
- if (!PMA_exportOutputHandler($buffer)) {
- return false;
+ else
+ {
+ return true;
}
+ }
+
+ /**
+ * Outputs CREATE DATABASE statement
+ *
+ * @param string $db Database name
+ * @return bool Whether it suceeded
+ *
+ * @access public
+ */
+ function PMA_exportDBCreate($db) {
+ return true;
+ }
- while ($record = PMA_DBI_fetch_row($result)) {
- $buffer = ' <table name="' . htmlspecialchars($table) . '">' . $crlf;
+ /**
+ * Outputs the content of a table in XML format
+ *
+ * @param string $db database name
+ * @param string $table table name
+ * @param string $crlf the end of line sequence
+ * @param string $error_url the url to go back in case of error
+ * @param string $sql_query SQL query for obtaining data
+ * @return bool Whether it suceeded
+ *
+ * @access public
+ */
+ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
+
+ if (isset($GLOBALS['xml_export_contents']) && $GLOBALS['xml_export_contents']) {
+ $result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
+
+ $columns_cnt = PMA_DBI_num_fields($result);
+ $columns = array();
for ($i = 0; $i < $columns_cnt; $i++) {
- // If a cell is NULL, still export it to preserve the XML structure
- if (!isset($record[$i]) || is_null($record[$i])) {
- $record[$i] = 'NULL';
- }
- $buffer .= ' <column name="' . htmlspecialchars($columns[$i]) . '">' . htmlspecialchars((string)$record[$i])
- . '</column>' . $crlf;
+ $columns[$i] = stripslashes(str_replace(' ', '_', PMA_DBI_field_name($result, $i)));
}
- $buffer .= ' </table>' . $crlf;
+ unset($i);
+ $buffer = ' <!-- ' . __('Table') . ' ' . $table . ' -->' . $crlf;
if (!PMA_exportOutputHandler($buffer)) {
return false;
}
+
+ while ($record = PMA_DBI_fetch_row($result)) {
+ $buffer = ' <table name="' . htmlspecialchars($table) . '">' . $crlf;
+ for ($i = 0; $i < $columns_cnt; $i++) {
+ // If a cell is NULL, still export it to preserve the XML structure
+ if (!isset($record[$i]) || is_null($record[$i])) {
+ $record[$i] = 'NULL';
+ }
+ $buffer .= ' <column name="' . htmlspecialchars($columns[$i]) . '">' . htmlspecialchars((string)$record[$i])
+ . '</column>' . $crlf;
+ }
+ $buffer .= ' </table>' . $crlf;
+
+ if (!PMA_exportOutputHandler($buffer)) {
+ return false;
+ }
+ }
+ PMA_DBI_free_result($result);
}
- PMA_DBI_free_result($result);
- }
- return true;
-} // end of the 'PMA_getTableXML()' function
-}
+ return true;
+ } // end of the 'PMA_getTableXML()' function
+ }
}
?>
diff --git a/libraries/export/yaml.php b/libraries/export/yaml.php
index 26b19a9..0ec1551 100644
--- a/libraries/export/yaml.php
+++ b/libraries/export/yaml.php
@@ -31,139 +31,139 @@ if (isset($plugin_list)) {
);
} else {
-/**
- * Set of functions used to build exports of tables
- */
-
-/**
- * Outputs export footer
- *
- * @return bool Whether it suceeded
- *
- * @access public
- */
-function PMA_exportFooter()
-{
- PMA_exportOutputHandler('...' . $GLOBALS['crlf']);
- return true;
-}
-
-/**
- * Outputs export header
- *
- * @return bool Whether it suceeded
- *
- * @access public
- */
-function PMA_exportHeader()
-{
- PMA_exportOutputHandler('%YAML 1.1' . $GLOBALS['crlf'] . '---' . $GLOBALS['crlf']);
- return true;
-}
-
-/**
- * Outputs database header
- *
- * @param string $db Database name
- * @return bool Whether it suceeded
- *
- * @access public
- */
-function PMA_exportDBHeader($db)
-{
- return true;
-}
+ /**
+ * Set of functions used to build exports of tables
+ */
+
+ /**
+ * Outputs export footer
+ *
+ * @return bool Whether it suceeded
+ *
+ * @access public
+ */
+ function PMA_exportFooter()
+ {
+ PMA_exportOutputHandler('...' . $GLOBALS['crlf']);
+ return true;
+ }
-/**
- * Outputs database footer
- *
- * @param string $db Database name
- * @return bool Whether it suceeded
- *
- * @access public
- */
-function PMA_exportDBFooter($db)
-{
- return true;
-}
+ /**
+ * Outputs export header
+ *
+ * @return bool Whether it suceeded
+ *
+ * @access public
+ */
+ function PMA_exportHeader()
+ {
+ PMA_exportOutputHandler('%YAML 1.1' . $GLOBALS['crlf'] . '---' . $GLOBALS['crlf']);
+ return true;
+ }
-/**
- * Outputs CREATE DATABASE statement
- *
- * @param string $db Database name
- * @return bool Whether it suceeded
- *
- * @access public
- */
-function PMA_exportDBCreate($db)
-{
- return true;
-}
+ /**
+ * Outputs database header
+ *
+ * @param string $db Database name
+ * @return bool Whether it suceeded
+ *
+ * @access public
+ */
+ function PMA_exportDBHeader($db)
+ {
+ return true;
+ }
-/**
- * Outputs the content of a table in YAML format
- *
- * @param string $db database name
- * @param string $table table name
- * @param string $crlf the end of line sequence
- * @param string $error_url the url to go back in case of error
- * @param string $sql_query SQL query for obtaining data
- * @return bool Whether it suceeded
- *
- * @access public
- */
-function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
-{
- $result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
+ /**
+ * Outputs database footer
+ *
+ * @param string $db Database name
+ * @return bool Whether it suceeded
+ *
+ * @access public
+ */
+ function PMA_exportDBFooter($db)
+ {
+ return true;
+ }
- $columns_cnt = PMA_DBI_num_fields($result);
- for ($i = 0; $i < $columns_cnt; $i++) {
- $columns[$i] = stripslashes(PMA_DBI_field_name($result, $i));
+ /**
+ * Outputs CREATE DATABASE statement
+ *
+ * @param string $db Database name
+ * @return bool Whether it suceeded
+ *
+ * @access public
+ */
+ function PMA_exportDBCreate($db)
+ {
+ return true;
}
- unset($i);
-
- $buffer = '';
- $record_cnt = 0;
- while ($record = PMA_DBI_fetch_row($result)) {
- $record_cnt++;
-
- // Output table name as comment if this is the first record of the table
- if ($record_cnt == 1) {
- $buffer = '# ' . $db . '.' . $table . $crlf;
- $buffer .= '-' . $crlf;
- } else {
- $buffer = '-' . $crlf;
- }
+ /**
+ * Outputs the content of a table in YAML format
+ *
+ * @param string $db database name
+ * @param string $table table name
+ * @param string $crlf the end of line sequence
+ * @param string $error_url the url to go back in case of error
+ * @param string $sql_query SQL query for obtaining data
+ * @return bool Whether it suceeded
+ *
+ * @access public
+ */
+ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
+ {
+ $result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
+
+ $columns_cnt = PMA_DBI_num_fields($result);
for ($i = 0; $i < $columns_cnt; $i++) {
- if (! isset($record[$i])) {
- continue;
+ $columns[$i] = stripslashes(PMA_DBI_field_name($result, $i));
+ }
+ unset($i);
+
+ $buffer = '';
+ $record_cnt = 0;
+ while ($record = PMA_DBI_fetch_row($result)) {
+ $record_cnt++;
+
+ // Output table name as comment if this is the first record of the table
+ if ($record_cnt == 1) {
+ $buffer = '# ' . $db . '.' . $table . $crlf;
+ $buffer .= '-' . $crlf;
+ } else {
+ $buffer = '-' . $crlf;
}
- $column = $columns[$i];
+ for ($i = 0; $i < $columns_cnt; $i++) {
+ if (! isset($record[$i])) {
+ continue;
+ }
- if (is_null($record[$i])) {
- $buffer .= ' ' . $column . ': null' . $crlf;
- continue;
- }
+ $column = $columns[$i];
+
+ if (is_null($record[$i])) {
+ $buffer .= ' ' . $column . ': null' . $crlf;
+ continue;
+ }
- if (is_numeric($record[$i])) {
- $buffer .= ' ' . $column . ': ' . $record[$i] . $crlf;
- continue;
+ if (is_numeric($record[$i])) {
+ $buffer .= ' ' . $column . ': ' . $record[$i] . $crlf;
+ continue;
+ }
+
+ $record[$i] = str_replace(array('\\', '"', "\n", "\r"), array('\\\\', '\"', '\n', '\r'), $record[$i]);
+ $buffer .= ' ' . $column . ': "' . $record[$i] . '"' . $crlf;
}
- $record[$i] = str_replace(array('\\', '"', "\n", "\r"), array('\\\\', '\"', '\n', '\r'), $record[$i]);
- $buffer .= ' ' . $column . ': "' . $record[$i] . '"' . $crlf;
+ if (! PMA_exportOutputHandler($buffer)) {
+ return false;
+ }
}
+ PMA_DBI_free_result($result);
- if (! PMA_exportOutputHandler($buffer)) {
- return false;
- }
+ return true;
}
- PMA_DBI_free_result($result);
-
- return true;
-}
}
?>
hooks/post-receive
--
phpMyAdmin
More information about the Git
mailing list