Export schema from designer
Signed-off-by: Bimal Yashodha <kb.yashodha@gmail.com>
This commit is contained in:
parent
d6d6e31d7a
commit
6a243cfe3c
@ -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".');
|
||||
|
||||
@ -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);
|
||||
$('<div id="page_export_dialog"></div>')
|
||||
.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) {
|
||||
|
||||
@ -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 = '<form method="post" action="schema_export.php"'
|
||||
. ' class="disableAjax" id="id_export_pages">'
|
||||
. '<fieldset>'
|
||||
. PMA_URL_getHiddenInputs($db)
|
||||
. '<select name="export_type" id="export_type">';
|
||||
|
||||
if (file_exists(TCPDF_INC)) {
|
||||
$htmlString .= '<option value="pdf" selected="selected">PDF</option>';
|
||||
}
|
||||
|
||||
$htmlString .=' <option value="svg">SVG</option>'
|
||||
. '<option value="dia">DIA</option>'
|
||||
. '<option value="eps">EPS</option>'
|
||||
. '</select>'
|
||||
. '<label>' . __('Select Export Relational Type') . '</label><br />';
|
||||
|
||||
$htmlString .= '<input type="hidden" name="do" value="process_export" />'
|
||||
. '<input type="hidden" name="chpage" value="' . htmlspecialchars($page) . '" />'
|
||||
. '<input type="checkbox" name="show_grid" id="show_grid_opt" />'
|
||||
. '<label for="show_grid_opt">' . __('Show grid') . '</label><br />'
|
||||
. '<input type="checkbox" name="show_color"'
|
||||
. ' id="show_color_opt" checked="checked" />'
|
||||
. '<label for="show_color_opt">' . __('Show color') . '</label>'
|
||||
. '<br />'
|
||||
. '<input type="checkbox" name="show_table_dimension"'
|
||||
. ' id="show_table_dim_opt" />'
|
||||
. '<label for="show_table_dim_opt">'
|
||||
. __('Show dimension of tables')
|
||||
. '</label><br />'
|
||||
. '<input type="checkbox" name="all_tables_same_width"'
|
||||
. ' id="all_tables_same_width" />'
|
||||
. '<label for="all_tables_same_width">'
|
||||
. __('Same width for all tables')
|
||||
. '</label><br />'
|
||||
. '<input type="checkbox" name="with_doc"'
|
||||
. ' id="with_doc" checked="checked" />'
|
||||
. '<label for="with_doc">' . __('Data Dictionary') . '</label><br />'
|
||||
. '<input type="checkbox" name="show_keys" id="show_keys" />'
|
||||
. '<label for="show_keys">' . __('Only show keys') . '</label><br />'
|
||||
. '<select name="orientation" id="orientation_opt" class="paper-change">'
|
||||
. '<option value="L">' . __('Landscape') . '</option>'
|
||||
. '<option value="P">' . __('Portrait') . '</option>'
|
||||
. '</select>'
|
||||
. '<label for="orientation_opt">' . __('Orientation') . '</label>'
|
||||
. '<br />'
|
||||
. '<select name="paper" id="paper_opt" class="paper-change">';
|
||||
|
||||
foreach ($GLOBALS['cfg']['PDFPageSizes'] as $val) {
|
||||
$htmlString .= '<option value="' . htmlspecialchars($val) . '"';
|
||||
if ($val == $GLOBALS['cfg']['PDFDefaultPageSize']) {
|
||||
$htmlString .= ' selected="selected"';
|
||||
}
|
||||
$htmlString .= ' >' . htmlspecialchars($val) . '</option>' . "\n";
|
||||
}
|
||||
|
||||
$htmlString .= '</select>'
|
||||
. '<label for="paper_opt">' . __('Paper size') . '</label>'
|
||||
. '</fieldset>'
|
||||
. '</form>';
|
||||
|
||||
return $htmlString;
|
||||
}
|
||||
?>
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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 '</div>';
|
||||
</a>
|
||||
<img class="M_bord" src="<?php echo $_SESSION['PMA_Theme']->getImgPath('pmd/bord.png'); ?>" alt="" />
|
||||
<span id="page_name"><?php echo htmlspecialchars($selected_page) ?></span>
|
||||
<img class="M_bord" src="<?php echo $_SESSION['PMA_Theme']->getImgPath('pmd/bord.png'); ?>" alt="" />
|
||||
<a href="#" onclick="Export_pages(); return false"
|
||||
class="M_butt" target="_self" >
|
||||
<img title="<?php echo __('Export schema'); ?>" alt="key"
|
||||
src="<?php echo $_SESSION['PMA_Theme']->getImgPath('pmd/export.png'); ?>" />
|
||||
</a>
|
||||
<img class="M_bord" src="<?php echo $_SESSION['PMA_Theme']->getImgPath('pmd/bord.png'); ?>" alt="" />
|
||||
<?php
|
||||
if (isset($_REQUEST['query'])) {
|
||||
echo '<a href="#" onclick="build_query(\'SQL Query on Database\', 0)" onmousedown="return false;"
|
||||
|
||||
@ -12,13 +12,6 @@
|
||||
require_once 'libraries/common.inc.php';
|
||||
require 'libraries/StorageEngine.class.php';
|
||||
|
||||
/**
|
||||
* Validate vulnerable POST parameters
|
||||
*/
|
||||
if (! PMA_isValid($_POST['pdf_page_number'], 'numeric')) {
|
||||
die('Attack stopped');
|
||||
}
|
||||
|
||||
/**
|
||||
* get all variables needed for exporting relational schema
|
||||
* in $cfgRelation
|
||||
@ -27,6 +20,7 @@ $cfgRelation = PMA_getRelationsParam();
|
||||
|
||||
require_once 'libraries/transformations.lib.php';
|
||||
require_once 'libraries/Index.class.php';
|
||||
require_once 'libraries/pmd_common.php';
|
||||
require_once 'libraries/schema/User_Schema.class.php';
|
||||
|
||||
/**
|
||||
@ -44,7 +38,6 @@ $post_params = array(
|
||||
'orientation',
|
||||
'paper',
|
||||
'names',
|
||||
'pdf_page_number',
|
||||
'show_color',
|
||||
'show_grid',
|
||||
'show_keys',
|
||||
@ -52,8 +45,9 @@ $post_params = array(
|
||||
'with_doc'
|
||||
);
|
||||
foreach ($post_params as $one_post_param) {
|
||||
if (isset($_POST[$one_post_param])) {
|
||||
$GLOBALS[$one_post_param] = $_POST[$one_post_param];
|
||||
if (isset($_REQUEST[$one_post_param])) {
|
||||
$GLOBALS[$one_post_param] = $_REQUEST[$one_post_param];
|
||||
$_POST[$one_post_param] = $_REQUEST[$one_post_param];
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,7 +63,16 @@ $user_schema = new PMA_User_Schema();
|
||||
* create and select a page, generate schema etc
|
||||
*/
|
||||
if (isset($_REQUEST['do'])) {
|
||||
$user_schema->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;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
BIN
themes/pmahomme/img/pmd/export.png
Normal file
BIN
themes/pmahomme/img/pmd/export.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 865 B |
Loading…
Reference in New Issue
Block a user