2 /* vim: set expandtab sw=4 ts=4 sts=4: */
5 * @package PhpMyAdmin-Designer
8 require_once './libraries/common.inc.php';
9 require_once 'libraries/pmd_common.php';
12 * Sets globals from $_POST
22 foreach ($post_params as $one_post_param) {
23 if (isset($_POST[$one_post_param])) {
24 $GLOBALS[$one_post_param] = $_POST[$one_post_param];
29 * If called directly from the designer, first save the positions
31 if (! isset($scale)) {
33 include_once 'pmd_save_pos.php';
37 if ('create_export' != $mode && empty($pdf_page_number)) {
38 die("<script>alert('Pages not found!');history.go(-2);</script>");
41 $pmd_table = PMA_Util
::backquote($GLOBALS['cfgRelation']['db']) . '.'
42 . PMA_Util
::backquote($GLOBALS['cfgRelation']['designer_coords']);
43 $pma_table = PMA_Util
::backquote($GLOBALS['cfgRelation']['db']) . '.'
44 . PMA_Util
::backquote($cfgRelation['table_coords']);
45 $scale_q = PMA_Util
::sqlAddSlashes($scale);
47 if ('create_export' == $mode) {
48 $pdf_page_number = PMA_REL_createPage($newpage, $cfgRelation, $db);
49 if ($pdf_page_number > 0) {
50 $message = PMA_Message
::success(__('Page has been created'));
53 $message = PMA_Message
::error(__('Page creation failed'));
57 $pdf_page_number_q = PMA_Util
::sqlAddSlashes($pdf_page_number);
59 if ('export' == $mode) {
60 $sql = "REPLACE INTO " . $pma_table
61 . " (db_name, table_name, pdf_page_number, x, y)"
62 . " SELECT db_name, table_name, " . $pdf_page_number_q . ","
63 . " ROUND(x/" . $scale_q . ") , ROUND(y/" . $scale_q . ") y"
64 . " FROM " . $pmd_table
65 . " WHERE db_name = '" . PMA_Util
::sqlAddSlashes($db) . "'";
67 PMA_queryAsControlUser($sql, true, PMA_DBI_QUERY_STORE
);
70 if ('import' == $mode) {
71 PMA_queryAsControlUser(
72 'UPDATE ' . $pma_table . ',' . $pmd_table .
73 ' SET ' . $pmd_table . '.`x`= ' . $pma_table . '.`x` * '. $scale_q . ',
74 ' . $pmd_table . '.`y`= ' . $pma_table . '.`y` * '. $scale_q .'
76 ' . $pmd_table . '.`db_name`=' . $pma_table . '.`db_name`
78 ' . $pmd_table . '.`table_name` = ' . $pma_table . '.`table_name`
80 ' . $pmd_table . '.`db_name`=\''. PMA_Util
::sqlAddSlashes($db) . '\'
81 AND pdf_page_number = ' . $pdf_page_number_q . ';',
82 true, PMA_DBI_QUERY_STORE
87 $response = PMA_Response
::getInstance();
88 $response->getFooter()->setMinimal();
94 if (! empty($message)) {
98 <form name
="form1" method
="post" action
="pmd_pdf.php">
100 echo PMA_generate_common_hidden_inputs($db);
102 echo '<fieldset><legend>' . __('Import/Export coordinates for PDF schema') . '</legend>';
106 $table_info_result = PMA_queryAsControlUser(
107 'SELECT * FROM ' . PMA_Util
::backquote($GLOBALS['cfgRelation']['db'])
108 . '.' . PMA_Util
::backquote($cfgRelation['pdf_pages'])
109 . ' WHERE db_name = \'' . PMA_Util
::sqlAddSlashes($db) . '\''
112 if (PMA_DBI_num_rows($table_info_result) > 0) {
113 echo '<p>' . __('Page') . ':';
114 echo '<select name="pdf_page_number">';
116 while ($page = PMA_DBI_fetch_assoc($table_info_result)) {
117 echo '<option value="' . $page['page_nr'] . '">';
118 echo htmlspecialchars($page['page_descr']);
123 $choices['import'] = __('Import from selected page');
124 $choices['export'] = __('Export to selected page');
126 $choices['create_export'] = __('Create a page and export to it');
128 if (1 == count($choices)) {
129 echo $choices['create_export'];
130 echo '<input type="hidden" name="mode" value="create_export" />';
132 echo PMA_Util
::getRadioFields(
133 'mode', $choices, $checked_choice = '', $line_break = true,
134 $escape_label = false, $class = ''
138 echo '<label for="newpage">' . __('New page name: ') . '</label>';
139 echo '<input id="newpage" type="text" name="newpage" />';
141 echo '<p>' . __('Export/Import to scale') . ':';
143 <select name
="scale">
144 <option value
="1">1:1</option
>
145 <option value
="2">1:2</option
>
146 <option value
="3" selected
="selected">1:3 (<?php
echo __('recommended'); ?
>)</option
>
147 <option value
="4">1:4</option
>
148 <option value
="5">1:5</option
>
151 <input type
="submit" value
="<?php echo __('Go'); ?>"/>