From 9cf71d9169800953b210dadfeeee5ce2b23cb520 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Thu, 13 Aug 2015 10:17:24 +0530 Subject: [PATCH] Fix #11394 Export/import Designer view Signed-off-by: Madhura Jayaratne --- ChangeLog | 1 + libraries/plugins/export/ExportSql.class.php | 70 +++++++++++++++++++- 2 files changed, 69 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index ea4d544f9c..80dd6a3ef6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -89,6 +89,7 @@ phpMyAdmin - ChangeLog - issue #10250 Displayed git revision info is not set + Improved schema SVG export - issue #10726 Do not try to set port 80 for https requests ++ issue #11394 Export/import Designer view 4.4.14.0 (not yet released) - issue #11367 Export after search, missing WHERE clause diff --git a/libraries/plugins/export/ExportSql.class.php b/libraries/plugins/export/ExportSql.class.php index 2a3c2fcf25..48cd63e22d 100644 --- a/libraries/plugins/export/ExportSql.class.php +++ b/libraries/plugins/export/ExportSql.class.php @@ -1036,8 +1036,7 @@ class ExportSql extends ExportPlugin $types = array( 'bookmark' => 'dbase', 'relation' => 'master_db', - //'pdf_pages' => 'db_name', - //'table_coords' => 'db_name', + 'pdf_pages' => 'db_name', 'savedsearches' => 'db_name', 'central_columns' => 'db_name', ); @@ -1071,6 +1070,69 @@ class ExportSql extends ExportPlugin foreach ($types as $type => $dbNameColumn) { if (in_array($type, $metadataTypes) && isset($cfgRelation[$type])) { + // special case, designer pages and their coordinates + if ($type == 'pdf_pages') { + + $sql_query = "SELECT `page_nr`, `page_descr` FROM " + . PMA_Util::backquote($cfgRelation['db']) + . "." . PMA_Util::backquote($cfgRelation[$type]) + . " WHERE " . PMA_Util::backquote($dbNameColumn) + . " = '" . PMA_Util::sqlAddSlashes($db) . "'"; + + $result = $GLOBALS['dbi']->fetchResult( + $sql_query, 'page_nr', 'page_descr' + ); + + foreach ($result as $page => $name) { + // insert row for pdf_page + $sql_query_row = "SELECT `db_name`, `page_descr` FROM " + . PMA_Util::backquote($cfgRelation['db']) + . "." . PMA_Util::backquote($cfgRelation[$type]) + . " WHERE " . PMA_Util::backquote($dbNameColumn) + . " = '" . PMA_Util::sqlAddSlashes($db) . "'" + . " AND `page_nr` = '" . $page . "'"; + + if (! $this->exportData( + $cfgRelation['db'], + $cfgRelation[$type], + $GLOBALS['crlf'], + '', + $sql_query_row, + $aliases + )) { + return false; + } + + $lastPage = $GLOBALS['crlf'] + . "SET @LAST_PAGE = LAST_INSERT_ID();" + . $GLOBALS['crlf'] ; + if (! PMA_exportOutputHandler($lastPage)) { + return false; + } + + $sql_query_coords = "SELECT `db_name`, `table_name`, " + . "'@LAST_PAGE' AS `pdf_page_number`, `x`, `y` FROM " + . PMA_Util::backquote($cfgRelation['db']) + . "." . PMA_Util::backquote($cfgRelation['table_coords']) + . " WHERE `pdf_page_number` = '" . $page . "'"; + + $GLOBALS['exporting_metadata'] = true; + if (! $this->exportData( + $cfgRelation['db'], + $cfgRelation['table_coords'], + $GLOBALS['crlf'], + '', + $sql_query_coords, + $aliases + )) { + $GLOBALS['exporting_metadata'] = false; + return false; + } + $GLOBALS['exporting_metadata'] = false; + } + continue; + } + // remove auto_incrementing id field for some tables if ($type == 'bookmark') { $sql_query = "SELECT `dbase`, `user`, `label`, `query` FROM "; @@ -2224,6 +2286,10 @@ class ExportSql extends ExportPlugin ) ) . "'"; + } elseif (! empty($GLOBALS['exporting_metadata']) + && $row[$j] == '@LAST_PAGE' + ) { + $values[] = '@LAST_PAGE'; } else { // something else -> treat as a string $values[] = '\''