Translated using Weblate (Indonesian)
[phpmyadmin.git] / pmd_pdf.php
blobc45eaa28921100d14248bb1769f677d2b007e48f
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @package PhpMyAdmin-Designer
6 */
8 require_once './libraries/common.inc.php';
9 require_once 'libraries/pmd_common.php';
11 /**
12 * Sets globals from $_POST
14 $post_params = array(
15 'db',
16 'mode',
17 'newpage',
18 'pdf_page_number',
19 'scale'
22 foreach ($post_params as $one_post_param) {
23 if (isset($_POST[$one_post_param])) {
24 $GLOBALS[$one_post_param] = $_POST[$one_post_param];
28 /**
29 * If called directly from the designer, first save the positions
31 if (! isset($scale)) {
32 $no_die_save_pos = 1;
33 include_once 'pmd_save_pos.php';
36 if (isset($mode)) {
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'));
51 $mode = 'export';
52 } else {
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 .'
75 WHERE
76 ' . $pmd_table . '.`db_name`=' . $pma_table . '.`db_name`
77 AND
78 ' . $pmd_table . '.`table_name` = ' . $pma_table . '.`table_name`
79 AND
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();
91 <br/>
92 <div>
93 <?php
94 if (! empty($message)) {
95 $message->display();
98 <form name="form1" method="post" action="pmd_pdf.php">
99 <?php
100 echo PMA_generate_common_hidden_inputs($db);
101 echo '<div>';
102 echo '<fieldset><legend>' . __('Import/Export coordinates for PDF schema') . '</legend>';
104 $choices = array();
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']);
119 echo '</option>';
121 echo '</select>';
122 echo '</p>';
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" />';
131 } else {
132 echo PMA_Util::getRadioFields(
133 'mode', $choices, $checked_choice = '', $line_break = true,
134 $escape_label = false, $class = ''
137 echo '<br />';
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>
149 </select>
150 </p>
151 <input type="submit" value="<?php echo __('Go'); ?>"/>
152 </fieldset>
153 </div>
154 </form>
155 </div>