/** * This function will process the user defined pages * and tables which will be exported as Relational schema * you can set the table positions on the paper via scratchboard * for table positions, put the x,y co-ordinates * * $this->action tells what the Schema is supposed to do * create and select a page, generate schema etc * * @access public * @return void */ public function processUserChoice() { global $db, $cfgRelation; if (isset($this->action)) { switch ($this->action) { case 'selectpage': $this->chosenPage = $_REQUEST['chpage']; if ('1' == $_REQUEST['action_choose']) { $this->deleteCoordinates($db, $cfgRelation, $this->chosenPage); $this->deletePages($db, $cfgRelation, $this->chosenPage); $this->chosenPage = 0; } break; case 'createpage': $this->pageNumber = PMA_REL_createPage($_POST['newpage'], $cfgRelation, $db); $this->autoLayoutForeign = isset($_POST['auto_layout_foreign']) ? "1" : null; $this->autoLayoutInternal = isset($_POST['auto_layout_internal']) ? "1" : null; $this->processRelations($db, $this->pageNumber, $cfgRelation); break; case 'edcoord': $this->chosenPage = $_POST['chpage']; $this->c_table_rows = $_POST['c_table_rows']; $this->_editCoordinates($db, $cfgRelation); break; case 'delete_old_references': $this->_deleteTableRows($_POST['delrow'], $cfgRelation, $db, $_POST['chpage']); break; case 'process_export': $this->_processExportSchema(); break; } // end switch } // end if (isset($do)) }
/** * Creates a new page and returns its auto-incrementing id * * @param string $pageName name of the page * @param string $db name of the database * * @return int|null */ function PMA_createNewPage($pageName, $db) { $cfgRelation = PMA_getRelationsParam(); if ($cfgRelation['pdfwork']) { $pageNumber = PMA_REL_createPage($pageName, $cfgRelation, $db); return $pageNumber; } return null; }
include_once 'pmd_save_pos.php'; } if (isset($mode)) { if ('create_export' != $mode && empty($pdf_page_number)) { die("<script>alert('Pages not found!');history.go(-2);</script>"); } $pmd_table = $common_functions->backquote($GLOBALS['cfgRelation']['db']) . '.' . $common_functions->backquote($GLOBALS['cfgRelation']['designer_coords']); $pma_table = $common_functions->backquote($GLOBALS['cfgRelation']['db']) . '.' . $common_functions->backquote($cfgRelation['table_coords']); $scale_q = $common_functions->sqlAddSlashes($scale); if ('create_export' == $mode) { $pdf_page_number = PMA_REL_createPage($newpage, $cfgRelation, $db); if ($pdf_page_number > 0) { $message = PMA_Message::success(__('Page has been created')); $mode = 'export'; } else { $message = PMA_Message::error(__('Page creation failed')); } } $pdf_page_number_q = $common_functions->sqlAddSlashes($pdf_page_number); if ('export' == $mode) { $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"
} /** * If called directly from the designer, first save the positions */ if (!isset($_POST['scale'])) { include_once 'pmd_save_pos.php'; } if (isset($_POST['mode'])) { if ('create_export' != $_POST['mode'] && empty($_POST['pdf_page_number'])) { die("<script>alert('Pages not found!');history.go(-2);</script>"); } $pmd_table = PMA_Util::backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_Util::backquote($GLOBALS['cfgRelation']['designer_coords']); $pma_table = PMA_Util::backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_Util::backquote($cfgRelation['table_coords']); $scale_q = PMA_Util::sqlAddSlashes($_POST['scale']); if ('create_export' == $_POST['mode']) { $pdf_page_number = PMA_REL_createPage($_POST['newpage'], $cfgRelation, $db); if ($pdf_page_number > 0) { $message = PMA_Message::success(__('Page has been created.')); $_POST['mode'] = 'export'; } else { $message = PMA_Message::error(__('Page creation has failed!')); } } else { $pdf_page_number = $_POST['pdf_page_number']; } $pdf_page_number_q = PMA_Util::sqlAddSlashes($pdf_page_number); if ('export' == $_POST['mode']) { $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_Util::sqlAddSlashes($db) . "'"; PMA_queryAsControlUser($sql, true, PMA_DatabaseInterface::QUERY_STORE); } if ('import' == $_POST['mode']) {