OpenStreetMaps.js merged into OpenLayers.js
[phpmyadmin.git] / pmd_pdf.php
blobf8102dae1d02f96af074abeeca19a5afa92c00cd
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @package phpMyAdmin-Designer
6 */
8 require_once './libraries/pmd_common.php';
10 /**
11 * If called directly from the designer, first save the positions
13 if (! isset($scale)) {
14 $no_die_save_pos = 1;
15 include_once 'pmd_save_pos.php';
18 if (isset($mode)) {
19 if ('create_export' != $mode && empty($pdf_page_number)) {
20 die("<script>alert('Pages not found!');history.go(-2);</script>");
23 $pmd_table = PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['designer_coords']);
24 $pma_table = PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']);
25 $scale_q = PMA_sqlAddSlashes($scale);
27 if ('create_export' == $mode) {
28 $pdf_page_number = PMA_REL_create_page($newpage, $cfgRelation, $db);
29 if ($pdf_page_number > 0) {
30 $message = PMA_Message::success(__('Page has been created'));
31 $mode = 'export';
32 } else {
33 $message = PMA_Message::error(__('Page creation failed'));
37 $pdf_page_number_q = PMA_sqlAddSlashes($pdf_page_number);
39 if ('export' == $mode) {
40 $sql = "REPLACE INTO " . $pma_table . " (db_name, table_name, pdf_page_number, x, y) SELECT db_name, table_name, " . $pdf_page_number_q . ", ROUND(x/" . $scale_q . ") , ROUND(y/" . $scale_q . ") y FROM " . $pmd_table . " WHERE db_name = '" . PMA_sqlAddSlashes($db) . "'";
42 PMA_query_as_controluser($sql,true,PMA_DBI_QUERY_STORE);
45 if ('import' == $mode) {
46 PMA_query_as_controluser(
47 'UPDATE ' . $pma_table . ',' . $pmd_table .
48 ' SET ' . $pmd_table . '.`x`= ' . $pma_table . '.`x` * '. $scale_q . ',
49 ' . $pmd_table . '.`y`= ' . $pma_table . '.`y` * '. $scale_q .'
50 WHERE
51 ' . $pmd_table . '.`db_name`=' . $pma_table . '.`db_name`
52 AND
53 ' . $pmd_table . '.`table_name` = ' . $pma_table . '.`table_name`
54 AND
55 ' . $pmd_table . '.`db_name`=\''. PMA_sqlAddSlashes($db) .'\'
56 AND pdf_page_number = ' . $pdf_page_number_q . ';', true, PMA_DBI_QUERY_STORE);
60 // no need to use pmd/styles
61 require_once './libraries/header_meta_style.inc.php';
63 </head>
64 <body>
65 <br>
66 <div>
67 <?php
68 if (!empty($message)) {
69 $message->display();
72 <form name="form1" method="post" action="pmd_pdf.php">
73 <?php
74 echo PMA_generate_common_hidden_inputs($db);
75 echo '<div>';
76 echo '<fieldset><legend>' . __('Import/Export coordinates for PDF schema') . '</legend>';
78 $choices = array();
80 $table_info_result = PMA_query_as_controluser('SELECT * FROM '
81 . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages'])
82 . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'');
84 if (PMA_DBI_num_rows($table_info_result) > 0) {
85 echo '<p>' . __('Page') . ':';
86 echo '<select name="pdf_page_number">';
88 while($page = PMA_DBI_fetch_assoc($table_info_result)) {
89 echo '<option value="' . $page['page_nr'] . '">';
90 echo htmlspecialchars($page['page_descr']);
91 echo '</option>';
93 echo '</select>';
94 echo '</p>';
95 $choices['import'] = __('Import from selected page');
96 $choices['export'] = __('Export to selected page');
98 $choices['create_export'] = __('Create a page and export to it');
100 if (1 == count($choices)) {
101 echo $choices['create_export'];
102 echo '<input type="hidden" name="mode" value="create_export" />';
103 } else {
104 PMA_display_html_radio('mode', $choices, $checked_choice = '', $line_break = true, $escape_label = false, $class='');
106 echo '<br />';
107 echo '<label for="newpage">' . __('New page name: ') . '</label>';
108 echo '<input id="newpage" type="text" name="newpage" />';
110 echo '<p>' . __('Export/Import to scale') . ':';
112 <select name="scale">
113 <option value="1">1:1</option>
114 <option value="2">1:2</option>
115 <option value="3" selected>1:3 (<?php echo __('recommended'); ?>)</option>
116 <option value="4">1:4</option>
117 <option value="5">1:5</option>
118 </select>
119 </p>
120 <input type="submit" value="<?php echo __('Go'); ?>">
121 </fieldset>
122 </div>
123 </form>
124 </div>
125 </body>
126 </html>