The branch, master has been updated
via 5675555d5a67800ca86888a733bd050175bc975f (commit)
from b2a55f1ef25e88a24e4dcc31302890be380154fe (commit)
- Log -----------------------------------------------------------------
commit 5675555d5a67800ca86888a733bd050175bc975f
Author: Hauke Henningsen <blubberkeks152(a)users.sourceforge.net>
Date: Tue Aug 3 13:08:21 2010 -0400
patch #3038312 [export] JSON export
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 2 +
libraries/export/{php_array.php => json.php} | 44 ++++++++++++--------------
2 files changed, 22 insertions(+), 24 deletions(-)
copy libraries/export/{php_array.php => json.php} (72%)
diff --git a/ChangeLog b/ChangeLog
index e27a334..4242ca5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -102,6 +102,8 @@ $Id$
- [interface] Fixed rendering of error/notice/info titles background.
- patch #3038293 [doc] Language and grammar fixes,
thanks to Isaac Bennetch - ibennetch
+- patch #3038312 [export] JSON export,
+ thanks to Hauke Henningsen - blubberkeks152
3.3.6.0 (not yet released)
- bug #3033063 [core] Navi gets wrong db name
diff --git a/libraries/export/php_array.php b/libraries/export/json.php
similarity index 72%
copy from libraries/export/php_array.php
copy to libraries/export/json.php
index 7d1fb5e..0355d9a 100644
--- a/libraries/export/php_array.php
+++ b/libraries/export/json.php
@@ -1,8 +1,7 @@
<?php
/**
- * Set of functions used to build dumps of tables as PHP Arrays
+ * Set of functions used to build dumps of tables as JSON
*
- * @version 0.2b (20090704)
*/
if (! defined('PHPMYADMIN')) {
exit;
@@ -12,8 +11,8 @@ if (! defined('PHPMYADMIN')) {
*
*/
if (isset($plugin_list)) {
- $plugin_list['php_array'] = array(
- 'text' => __('PHP array'),
+ $plugin_list['json'] = array(
+ 'text' => 'JSON',
'extension' => 'php',
'mime_type' => 'text/plain',
'options' => array(
@@ -22,7 +21,7 @@ if (isset($plugin_list)) {
'name' => 'data',
),
),
- 'options_text' => __('Options'),
+ 'options_text' => 'strOptions',
);
} else {
@@ -39,7 +38,7 @@ if (isset($plugin_list)) {
*/
function PMA_exportComment($text)
{
- PMA_exportOutputHandler('// ' . $text . $GLOBALS['crlf']);
+ PMA_exportOutputHandler('/* ' . $text . ' */' . $GLOBALS['crlf']);
return true;
}
@@ -65,10 +64,9 @@ function PMA_exportFooter()
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']
+ . ' Export to JSON plugin for PHPMyAdmin' . $GLOBALS['crlf']
+ . ' @version 0.1' . $GLOBALS['crlf']
. ' */' . $GLOBALS['crlf'] . $GLOBALS['crlf']
);
return true;
@@ -85,7 +83,7 @@ function PMA_exportHeader()
*/
function PMA_exportDBHeader($db)
{
- PMA_exportOutputHandler('//' . $GLOBALS['crlf'] . '// Database "' . $db . '"' . $GLOBALS['crlf'] . '//' . $GLOBALS['crlf']);
+ PMA_exportOutputHandler('/* Database \'' . $db . '\' */ ' . $GLOBALS['crlf'] );
return true;
}
@@ -145,17 +143,15 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
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 .= $crlf . '// ' . $db . '.' . $table . $crlf;
- $buffer .= '$' . $table . ' = array(' . $crlf;
- $buffer .= ' array(';
+ $buffer .= '/* ' . $db . '.' . $table . ' */' . $crlf . $crlf;
+ $buffer .= '[{';
} else {
- $buffer .= ',' . $crlf . ' array(';
+ $buffer .= ', {';
}
-
for ($i = 0; $i < $columns_cnt; $i++) {
$isLastLine = ($i + 1 >= $columns_cnt);
@@ -163,22 +159,22 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
$column = $columns[$i];
if (is_null($record[$i])) {
- $buffer .= "'" . $column . "'=>null" . (! $isLastLine ? ',' : '');
+ $buffer .= '"' . $column . '": null' . (! $isLastLine ? ',' : '');
} elseif (is_numeric($record[$i])) {
- $buffer .= "'" . $column . "'=>" . $record[$i] . (! $isLastLine ? ',' : '');
+ $buffer .= '"' . $column . '": ' . $record[$i] . (! $isLastLine ? ',' : '');
} else {
- $buffer .= "'" . $column . "'=>'" . addslashes($record[$i]) . "'" . (! $isLastLine ? ',' : '');
+ $buffer .= '"' . $column . '": "' . addslashes($record[$i]) . '"' . (! $isLastLine ? ',' : '');
}
}
- $buffer .= ')';
+ $buffer .= '}';
}
-
- $buffer .= $crlf . ');' . $crlf;
+
+ $buffer .= ']';
if (! PMA_exportOutputHandler($buffer)) {
return FALSE;
}
-
+
PMA_DBI_free_result($result);
return true;
hooks/post-receive
--
phpMyAdmin