fixed: bugID = 3112614
[phpmyadmin/adnan.git] / pmd_pdf.php
blobbeec1e022ad4df8842302169dedd551547397804
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @package phpMyAdmin-Designer
6 */
8 include_once '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($scale) && ! isset($createpage)) {
19 if (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);
26 $pdf_page_number_q = PMA_sqlAddslashes($pdf_page_number);
28 if (isset($exp)) {
30 $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) . "'";
32 PMA_query_as_controluser($sql,TRUE,PMA_DBI_QUERY_STORE);
35 if (isset($imp)) {
36 PMA_query_as_controluser(
37 'UPDATE ' . $pma_table . ',' . $pmd_table .
38 ' SET ' . $pmd_table . '.`x`= ' . $pma_table . '.`x` * '. $scale_q . ',
39 ' . $pmd_table . '.`y`= ' . $pma_table . '.`y` * '. $scale_q .'
40 WHERE
41 ' . $pmd_table . '.`db_name`=' . $pma_table . '.`db_name`
42 AND
43 ' . $pmd_table . '.`table_name` = ' . $pma_table . '.`table_name`
44 AND
45 ' . $pmd_table . '.`db_name`=\''. PMA_sqlAddslashes($db) .'\'
46 AND pdf_page_number = ' . $pdf_page_number_q . ';', TRUE, PMA_DBI_QUERY_STORE);
49 die("<script>alert('__('Modifications have been saved')');history.go(-2);</script>");
52 if (isset($createpage)) {
54 * @see pdf_pages.php
56 $query_default_option = PMA_DBI_QUERY_STORE;
58 $pdf_page_number = PMA_REL_create_page($newpage, $cfgRelation, $db, $query_default_option);
59 if ($pdf_page_number > 0) {
60 $message = PMA_Message::success(__('Page has been created'));
61 } else {
62 $message = PMA_Message::error(__('Page creation failed'));
66 // no need to use pmd/styles
67 require_once './libraries/header_meta_style.inc.php';
69 </head>
70 <body>
71 <br>
72 <div>
73 <?php
74 if (!empty($message)) {
75 $message->display();
78 <form name="form1" method="post" action="pmd_pdf.php">
79 <?php echo PMA_generate_common_hidden_inputs($db); ?>
80 <div>
81 <fieldset><legend><?php echo __('Export') . '/' . __('Import'); ?></legend>
82 <p><?php echo __('Export/Import to scale'); ?>:
83 <select name="scale">
84 <option value="1">1:1</option>
85 <option value="2">1:2</option>
86 <option value="3" selected>1:3 (<?php echo __('recommended'); ?>)</option>
87 <option value="4">1:4</option>
88 <option value="5">1:5</option>
89 </select>
90 </p>
91 <p><?php echo __('to/from page'); ?>:
93 <select name="pdf_page_number">
94 <?php
95 $table_info_result = PMA_query_as_controluser('SELECT * FROM '
96 . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages'])
97 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'');
98 while($page = PMA_DBI_fetch_assoc($table_info_result))
101 <option value="<?php echo $page['page_nr'] ?>"><?php echo htmlspecialchars($page['page_descr']) ?></option>
102 <?php
105 </select>
106 <input type="submit" name="exp" value="<?php echo __('Export'); ?>">
107 <input type="submit" name="imp" value="<?php echo __('Import'); ?>">
108 </fieldset>
109 </div>
110 <div>
111 <fieldset><legend><?php echo __('Create a page'); ?></legend>
112 <input type="text" name="newpage" />
113 <input type="submit" name="createpage" value="<?php echo __('Go'); ?>">
114 </fieldset>
115 </div>
116 </form>
117 </div>
118 </body>
119 </html>