added japanese language
[openemr.git] / phpmyadmin / pmd_pdf.php
blob11982528c079e517e94f741b4eba6038c054bb5e
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * PDF export for PMD
6 * @package PhpMyAdmin-Designer
7 */
9 require_once './libraries/common.inc.php';
10 require_once 'libraries/pmd_common.php';
12 /**
13 * Validate vulnerable POST parameters
15 if (isset($_POST['scale']) && ! PMA_isValid($_POST['scale'], 'numeric')) {
16 die('Attack stopped');
19 /**
20 * Sets globals from $_POST
22 $post_params = array(
23 'db'
26 foreach ($post_params as $one_post_param) {
27 if (isset($_POST[$one_post_param])) {
28 $GLOBALS[$one_post_param] = $_POST[$one_post_param];
32 /**
33 * If called directly from the designer, first save the positions
35 if (! isset($_POST['scale'])) {
36 include_once 'pmd_save_pos.php';
39 if (isset($_POST['mode'])) {
40 if ('create_export' != $_POST['mode'] && empty($_POST['pdf_page_number'])) {
41 die("<script>alert('Pages not found!');history.go(-2);</script>");
44 $pmd_table = PMA_Util::backquote($GLOBALS['cfgRelation']['db']) . '.'
45 . PMA_Util::backquote($GLOBALS['cfgRelation']['designer_coords']);
46 $pma_table = PMA_Util::backquote($GLOBALS['cfgRelation']['db']) . '.'
47 . PMA_Util::backquote($cfgRelation['table_coords']);
48 $scale_q = PMA_Util::sqlAddSlashes($_POST['scale']);
50 if ('create_export' == $_POST['mode']) {
51 $pdf_page_number = PMA_REL_createPage($_POST['newpage'], $cfgRelation, $db);
52 if ($pdf_page_number > 0) {
53 $message = PMA_Message::success(__('Page has been created.'));
54 $_POST['mode'] = 'export';
55 } else {
56 $message = PMA_Message::error(__('Page creation has failed!'));
58 } else {
59 $pdf_page_number = $_POST['pdf_page_number'];
62 $pdf_page_number_q = PMA_Util::sqlAddSlashes($pdf_page_number);
64 if ('export' == $_POST['mode']) {
65 $sql = "REPLACE INTO " . $pma_table
66 . " (db_name, table_name, pdf_page_number, x, y)"
67 . " SELECT db_name, table_name, " . $pdf_page_number_q . ","
68 . " ROUND(x/" . $scale_q . ") , ROUND(y/" . $scale_q . ") y"
69 . " FROM " . $pmd_table
70 . " WHERE db_name = '" . PMA_Util::sqlAddSlashes($db) . "'";
72 PMA_queryAsControlUser($sql, true, PMA_DatabaseInterface::QUERY_STORE);
75 if ('import' == $_POST['mode']) {
76 PMA_queryAsControlUser(
77 'UPDATE ' . $pma_table . ',' . $pmd_table .
78 ' SET ' . $pmd_table . '.`x`= ' . $pma_table . '.`x` * ' . $scale_q . ',
79 ' . $pmd_table . '.`y`= ' . $pma_table . '.`y` * ' . $scale_q . '
80 WHERE
81 ' . $pmd_table . '.`db_name`=' . $pma_table . '.`db_name`
82 AND
83 ' . $pmd_table . '.`table_name` = ' . $pma_table . '.`table_name`
84 AND
85 ' . $pmd_table . '.`db_name`=\'' . PMA_Util::sqlAddSlashes($db) . '\'
86 AND pdf_page_number = ' . $pdf_page_number_q . ';',
87 true, PMA_DatabaseInterface::QUERY_STORE
92 $response = PMA_Response::getInstance();
93 $response->getFooter()->setMinimal();
95 echo '<br/>';
96 echo '<div>';
97 if (! empty($message)) {
98 $message->display();
100 echo '<form name="form1" method="post" action="pmd_pdf.php">';
101 echo PMA_URL_getHiddenInputs($db);
102 echo '<div>';
103 echo '<fieldset><legend>' . __('Import/Export coordinates for relational schema') . '</legend>';
105 $choices = array();
107 $table_info_result = PMA_queryAsControlUser(
108 'SELECT * FROM ' . PMA_Util::backquote($GLOBALS['cfgRelation']['db'])
109 . '.' . PMA_Util::backquote($cfgRelation['pdf_pages'])
110 . ' WHERE db_name = \'' . PMA_Util::sqlAddSlashes($db) . '\''
113 if ($GLOBALS['dbi']->numRows($table_info_result) > 0) {
114 echo '<p>' . __('Page:');
115 echo '<select name="pdf_page_number">';
117 while ($page = $GLOBALS['dbi']->fetchAssoc($table_info_result)) {
118 echo '<option value="' . $page['page_nr'] . '">';
119 echo htmlspecialchars($page['page_descr']);
120 echo '</option>';
122 echo '</select>';
123 echo '</p>';
124 $choices['import'] = __('Import from selected page.');
125 $choices['export'] = __('Export to selected page.');
127 $choices['create_export'] = __('Create a page and export to it.');
129 if (1 == count($choices)) {
130 echo $choices['create_export'];
131 echo '<input type="hidden" name="mode" value="create_export" />';
132 } else {
133 echo PMA_Util::getRadioFields(
134 'mode', $choices, $checked_choice = '', $line_break = true,
135 $escape_label = false, $class = ''
138 echo '<br />';
139 echo '<label for="newpage">' . __('New page name: ') . '</label>';
140 echo '<input id="newpage" type="text" name="newpage" />';
142 echo '<p>' . __('Export/Import to scale:');
143 echo '<select name="scale">';
144 echo '<option value="1">1:1</option>';
145 echo '<option value="2">1:2</option>';
146 echo '<option value="3" selected="selected">1:3 ('
147 . __('recommended') . ')</option>';
148 echo '<option value="4">1:4</option>';
149 echo '<option value="5">1:5</option>';
150 echo '</select>';
151 echo '</p>';
153 echo '<input type="submit" value="' . __('Go') . '"/>';
155 echo '</fieldset>';
156 echo '</div>';
157 echo '</form>';
158 echo '</div>';