diff --git a/js/messages.php b/js/messages.php index dec9992e01..7bc0d97b4e 100644 --- a/js/messages.php +++ b/js/messages.php @@ -372,6 +372,7 @@ $js_messages['strSelectPage'] = __('Please select a page to continue'); $js_messages['strEnterValidPageName'] = __('Please enter a valid page name'); $js_messages['strLeavingPage'] = __('Do you want to save the changes to the current page?'); $js_messages['strSuccessfulPageDelete'] = __('Successfully deleted the page'); +$js_messages['strExportRelationalSchema'] = __('Export relational schema'); /* Visual query builder (js/pmd/move.js) */ $js_messages['strAddOption'] = __('Add an option for column "%s".'); diff --git a/js/pmd/move.js b/js/pmd/move.js index 0e354f6bc6..9fa344904e 100644 --- a/js/pmd/move.js +++ b/js/pmd/move.js @@ -821,6 +821,63 @@ function Prompt_to_save_current_page(callback) } } +//------------------------------ EXPORT PAGES --------------------------------------- +function Export_pages() +{ + var button_options = {}; + button_options[PMA_messages.strGo] = function () { + var $form = $("#id_export_pages"); + var $msgbox = PMA_ajaxShowMessage(PMA_messages.strProcessingRequest); + location.href = $form.attr('action') + '?' + getParamsForExport($form) + Get_url_pos(); + $msgbox.remove(); + $(this).dialog('close'); + }; + button_options[PMA_messages.strCancel] = function () { + $(this).dialog('close'); + }; + var $msgbox = PMA_ajaxShowMessage(); + var params = 'ajax_request=true&dialog=export&token=' + token + '&db=' + db + '&selected_page=' + selected_page; + $.get("pmd_general.php", params, function (data) { + if (data.success === false) { + PMA_ajaxShowMessage(data.error, false); + } else { + PMA_ajaxRemoveMessage($msgbox); + $('
') + .append(data.message) + .dialog({ + title: PMA_messages.strExportRelationalSchema, + width: 400, + modal: true, + buttons: button_options, + close: function () { + $(this).remove(); + } + }); + } + }); // end $.get() +}// end export pages + +function getParamsForExport($from) +{ + var url = ""; + url += "&db=" + $from.find('input[name="db"]').val(); + url += "&token=" + $from.find('input[name="token"]').val(); + url += "&do=" + $from.find('input[name="do"]').val(); + url += "&export_type=" + $from.find("#export_type").val(); + url += "&chpage=" + $from.find('input[name="chpage"]').val(); + url += "&orientation=" + $from.find('select[name="orientation"]').val(); + url += "&paper=" + $from.find('select[name="paper"]').val(); + url += "&show_color=" + ($from.find('input[name="show_color"]').is(":checked") ? "on" : "off"); + url += "&with_doc=" + ($from.find('input[name="with_doc"]').is(":checked") ? "on" : "off"); + url += "&all_tables_same_width=" + ($from.find('input[name="all_tables_same_width"]').is(":checked") ? "on" : "off"); + url += "&show_grid=" + ($from.find('input[name="show_grid"]').is(":checked") ? "on" : "off"); + url += "&show_keys=" + ($from.find('input[name="show_keys"]').is(":checked") ? "on" : "off"); + url += "&show_table_dimension=" + ($from.find('input[name="show_table_dimension"]').is(":checked") ? "on" : "off"); + + return url; +} + + function Load_page(page) { var param_page = ''; if (page != null) { diff --git a/libraries/designer.lib.php b/libraries/designer.lib.php index 663eed004c..fe9b9d23e0 100644 --- a/libraries/designer.lib.php +++ b/libraries/designer.lib.php @@ -126,4 +126,77 @@ function PMA_getPageIdsAndNames($db) } return $result; } + +/** + * Function to get html for displaying the schema export + * + * @param string $db database name + * @param int $page the page to be exported + * + * @return string + */ +function PMA_getHtmlForSchemaExport($db, $page) +{ + $htmlString = ''; + + return $htmlString; +} ?> \ No newline at end of file diff --git a/libraries/schema/Pdf_Relation_Schema.class.php b/libraries/schema/Pdf_Relation_Schema.class.php index b667502ca8..a1d4811c19 100644 --- a/libraries/schema/Pdf_Relation_Schema.class.php +++ b/libraries/schema/Pdf_Relation_Schema.class.php @@ -1146,17 +1146,18 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema global $pdf, $cfgRelation; // Get the name of this pdfpage to use as filename + $editingPage = $_POST['chpage'] != '-1' ? $_POST['chpage'] : $pageNumber; $_name_sql = 'SELECT page_descr FROM ' . PMA_Util::backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_Util::backquote($cfgRelation['pdf_pages']) - . ' WHERE page_nr = ' . $pageNumber; + . ' WHERE page_nr = ' . $editingPage; $_name_rs = PMA_queryAsControlUser($_name_sql); if ($_name_rs) { $_name_row = $GLOBALS['dbi']->fetchRow($_name_rs); $filename = $_name_row[0] . '.pdf'; } if (empty($filename)) { - $filename = $pageNumber . '.pdf'; + $filename = $editingPage . '.pdf'; } $pdf->Download($filename); } diff --git a/libraries/schema/User_Schema.class.php b/libraries/schema/User_Schema.class.php index 380823e15e..9abff8ab24 100644 --- a/libraries/schema/User_Schema.class.php +++ b/libraries/schema/User_Schema.class.php @@ -87,12 +87,6 @@ class PMA_User_Schema $this->autoLayoutInternal = isset($_POST['auto_layout_internal']) ? "1" : null; -// $this->processRelations( -// $db, -// $this->pageNumber, -// $cfgRelation -// ); -// break; $this->saveTablePositions( $db, $this->pageNumber, diff --git a/pmd_general.php b/pmd_general.php index 29666a348b..e5f9836751 100644 --- a/pmd_general.php +++ b/pmd_general.php @@ -30,6 +30,8 @@ if (isset($_REQUEST['dialog'])) { $html = PMA_getHtmlForEditOrDeletePages($GLOBALS['db'], 'delete'); } else if ($_REQUEST['dialog'] == 'save_as') { $html = PMA_getHtmlForPageSaveAs($GLOBALS['db']); + } else if ($_REQUEST['dialog'] == 'export') { + $html = PMA_getHtmlForSchemaExport($GLOBALS['db'], $_REQUEST['selected_page']); } $response->addHTML($html); @@ -213,6 +215,13 @@ echo '';
+
+
+
+
+
setAction($_REQUEST['do']);
- $user_schema->processUserChoice();
+ $temp_page = PMA_createNewPage("_temp" . rand());
+ try {
+ PMA_saveTablePositions($temp_page);
+ $_POST['pdf_page_number'] = $temp_page;
+ $user_schema->setAction($_REQUEST['do']);
+ $user_schema->processUserChoice();
+ PMA_deletePage($temp_page);
+ } catch (Exception $e) {
+ PMA_deletePage($temp_page); // delete temp page even if an exception occured
+ throw $e;
+ }
}
?>
diff --git a/themes/pmahomme/img/pmd/export.png b/themes/pmahomme/img/pmd/export.png
new file mode 100644
index 0000000000..bbead21512
Binary files /dev/null and b/themes/pmahomme/img/pmd/export.png differ