2 /* vim: set expandtab sw=4 ts=4 sts=4: */
9 * This Class interacts with the user to gather the information
10 * about their tables for which they want to export the relational schema
11 * export options are shown to user from they can choose
18 public $autoLayoutForeign;
19 public $autoLayoutInternal;
24 public function setAction($value)
26 $this->action
= $value;
29 * This function will process the user defined pages
30 * and tables which will be exported as Relational schema
31 * you can set the table positions on the paper via scratchboard
32 * for table positions, put the x,y co-ordinates
34 * @param string $this->action It tells what the Schema is supposed to do
35 * create and select a page, generate schema etc
39 public function processUserChoice()
41 global $action_choose,$db,$cfgRelation,$cfg;
43 if (isset($this->action
)) {
44 switch ($this->action
) {
46 $this->chosenPage
= $_REQUEST['chpage'];
47 if ($action_choose=="1") {
48 $this->deleteCoordinates(
58 $this->chosenPage
= 0;
62 $this->pageNumber
= PMA_REL_create_page(
67 $this->autoLayoutForeign
= isset($_POST['auto_layout_foreign']) ?
"1":NULL;
68 $this->autoLayoutInternal
= isset($_POST['auto_layout_internal']) ?
"1":NULL;
69 $this->processRelations(
76 $this->chosenPage
= $_POST['chpage'];
77 $this->c_table_rows
= $_POST['c_table_rows'];
78 $this->_editCoordinates($db, $cfgRelation);
80 case 'delete_old_references':
81 $this->_deleteTableRows(
88 case 'process_export':
89 $this->_processExportSchema();
93 } // end if (isset($do))
98 * shows/displays the HTML FORM to create the page
100 * @param string db name of the selected database
104 public function showCreatePageDialog($db)
107 <form method
="post" action
="schema_edit.php" name
="frm_create_page">
110 <?php
echo __('Create a page') . "\n"; ?
>
112 <?php
echo PMA_generate_common_hidden_inputs($db); ?
>
113 <input type
="hidden" name
="do" value
="createpage" />
116 <td
><label
for="id_newpage"><?php
echo __('Page name'); ?
></label
></td
>
117 <td
><input type
="text" name
="newpage" id
="id_newpage" size
="20" maxlength
="50" /></td
>
120 <td
><?php
echo __('Automatic layout based on'); ?
></td
>
122 <input type
="checkbox" name
="auto_layout_internal" id
="id_auto_layout_internal" /><label
for="id_auto_layout_internal">
123 <?php
echo __('Internal relations'); ?
></label
><br
/>
126 * Check to see whether INNODB and PBXT storage engines are Available in MYSQL PACKAGE
127 * If available, then provide AutoLayout for Foreign Keys in Schema View
130 if (PMA_StorageEngine
::isValid('InnoDB') || PMA_StorageEngine
::isValid('PBXT')) {
132 <input type
="checkbox" name
="auto_layout_foreign" id
="id_auto_layout_foreign" /><label
for="id_auto_layout_foreign">
133 <?php
echo __('FOREIGN KEY'); ?
></label
><br
/>
140 <fieldset
class="tblFooters">
141 <input type
="submit" value
="<?php echo __('Go'); ?>" />
148 * shows/displays the created page names in a drop down list
149 * User can select any page number and edit it using dashboard etc
154 public function selectPage()
156 global $db,$table,$cfgRelation;
157 $page_query = 'SELECT * FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages'])
158 . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'';
159 $page_rs = PMA_query_as_controluser($page_query, false, PMA_DBI_QUERY_STORE
);
160 if ($page_rs && PMA_DBI_num_rows($page_rs) > 0) {
162 <form method
="get" action
="schema_edit.php" name
="frm_select_page">
165 <?php
echo __('Please choose a page to edit') . "\n"; ?
>
167 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
168 <input type
="hidden" name
="do" value
="selectpage" />
169 <select name
="chpage" id
="chpage" class="autosubmit">
170 <option value
="0"><?php
echo __('Select page'); ?
></option
>
172 while ($curr_page = PMA_DBI_fetch_assoc($page_rs)) {
174 . '<option value="' . $curr_page['page_nr'] . '"';
175 if (isset($this->chosenPage
) && $this->chosenPage
== $curr_page['page_nr']) {
176 echo ' selected="selected"';
178 echo '>' . $curr_page['page_nr'] . ': ' . htmlspecialchars($curr_page['page_descr']) . '</option>';
188 PMA_display_html_radio('action_choose', $choices, '0', false);
192 <fieldset
class="tblFooters">
193 <input type
="submit" value
="<?php echo __('Go'); ?>" /><br
/>
202 * A dashboard is displayed to AutoLayout the position of tables
203 * users can drag n drop the tables and change their positions
208 public function showTableDashBoard()
210 global $db,$cfgRelation,$table,$cfg,$with_field_names;
212 * We will need an array of all tables in this db
214 $selectboxall = array('--');
215 $alltab_rs = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', null, PMA_DBI_QUERY_STORE
);
216 while ($val = @PMA_DBI_fetch_row
($alltab_rs)) {
217 $selectboxall[] = $val[0];
221 * Now if we already have chosen a page number then we should
222 * show the tables involved
225 if (isset($this->chosenPage
) && $this->chosenPage
> 0) {
228 <h2
><?php
echo __('Select Tables') ;?
></h2
>
230 $page_query = 'SELECT * FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
231 . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
232 . ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($this->chosenPage
) . '\'';
233 $page_rs = PMA_query_as_controluser($page_query, false);
234 $array_sh_page = array();
235 while ($temp_sh_page = @PMA_DBI_fetch_assoc
($page_rs)) {
236 $array_sh_page[] = $temp_sh_page;
239 * Display WYSIWYG parts
242 if (! isset($_POST['with_field_names']) && ! isset($_POST['showwysiwyg'])) {
243 $with_field_names = true;
245 $this->_displayScratchboardTables($array_sh_page);
248 <form method
="post" action
="schema_edit.php" name
="edcoord">
249 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
250 <input type
="hidden" name
="chpage" value
="<?php echo htmlspecialchars($this->chosenPage); ?>" />
251 <input type
="hidden" name
="do" value
="edcoord" />
254 <th
><?php
echo __('Table'); ?
></th
>
255 <th
><?php
echo __('Delete'); ?
></th
>
260 if (isset($ctable)) {
266 foreach ($array_sh_page as $dummy_sh_page => $sh_page) {
267 $_mtab = $sh_page['table_name'];
268 $tabExist[$_mtab] = false;
269 echo "\n" . ' <tr class="noclick ';
276 $odd_row != $odd_row;
278 . "\n" . ' <select name="c_table_' . $i . '[name]">';
279 foreach ($selectboxall as $key => $value) {
280 echo "\n" . ' <option value="' . htmlspecialchars($value) . '"';
281 if ($value == $sh_page['table_name']) {
282 echo ' selected="selected"';
283 $tabExist[$_mtab] = true;
285 echo '>' . htmlspecialchars($value) . '</option>';
287 echo "\n" . ' </select>'
290 . "\n" . ' <input type="checkbox" id="id_c_table_' . $i .'" name="c_table_' . $i . '[delete]" value="y" /><label for="id_c_table_' . $i .'">' . __('Delete') . '</label>';
291 echo "\n" . ' </td>';
293 . "\n" . ' <input type="text" onchange="dragPlace(' . $i . ', \'x\', this.value)" name="c_table_' . $i . '[x]" value="' . $sh_page['x'] . '" />';
294 echo "\n" . ' </td>';
296 . "\n" . ' <input type="text" onchange="dragPlace(' . $i . ', \'y\', this.value)" name="c_table_' . $i . '[y]" value="' . $sh_page['y'] . '" />';
297 echo "\n" . ' </td>';
298 echo "\n" . ' </tr>';
302 * Add one more empty row
304 echo "\n" . ' <tr class="noclick ';
310 $odd_row != $odd_row;
313 . "\n" . ' <select name="c_table_' . $i . '[name]">';
314 foreach ($selectboxall as $key => $value) {
315 echo "\n" . ' <option value="' . htmlspecialchars($value) . '">' . htmlspecialchars($value) . '</option>';
317 echo "\n" . ' </select>'
320 . "\n" . ' <input type="checkbox" id="id_c_table_' . $i .'" name="c_table_' . $i . '[delete]" value="y" /><label for="id_c_table_' . $i .'">' . __('Delete') . '</label>';
321 echo "\n" . ' </td>';
323 . "\n" . ' <input type="text" name="c_table_' . $i . '[x]" value="' . (isset($sh_page['x'])?
$sh_page['x']:'') . '" />';
324 echo "\n" . ' </td>';
326 . "\n" . ' <input type="text" name="c_table_' . $i . '[y]" value="' . (isset($sh_page['y'])?
$sh_page['y']:'') . '" />';
327 echo "\n" . ' </td>';
328 echo "\n" . ' </tr>';
329 echo "\n" . ' </table>' . "\n";
331 echo "\n" . ' <input type="hidden" name="c_table_rows" value="' . ($i +
1) . '" />';
332 echo "\n" . ' <input type="hidden" id="showwysiwyg" name="showwysiwyg" value="' . ((isset($showwysiwyg) && $showwysiwyg == '1') ?
'1' : '0') . '" />';
333 echo "\n" . ' <input type="checkbox" name="with_field_names" ' . (isset($with_field_names) ?
'checked="checked"' : ''). ' />' . __('Column names') . '<br />';
334 echo "\n" . ' <input type="submit" value="' . __('Save') . '" />';
335 echo "\n" . '</form>' . "\n\n";
338 $this->_deleteTables($db, $this->chosenPage
, isset($tabExist));
342 * show Export relational schema generation options
343 * user can select export type of his own choice
344 * and the attributes related to it
350 public function displaySchemaGenerationOptions()
352 global $cfg,$pmaThemeImage,$db,$test_rs,$chpage;
354 <form method
="post" action
="schema_export.php">
358 echo PMA_generate_common_hidden_inputs($db);
359 if ($cfg['PropertiesIconic']) {
360 echo '<img class="icon ic_b_views" src="themes/dot.gif" />';
362 echo __('Display relational schema');
365 <select name
="export_type" id
="export_type">
366 <option value
="pdf" selected
="selected">PDF
</option
>
367 <option value
="svg">SVG
</option
>
368 <option value
="dia">DIA
</option
>
369 <option value
="visio">Visio
</option
>
370 <option value
="eps">EPS
</option
>
372 <label
><?php
echo __('Select Export Relational Type');?
></label
><br
/>
374 if (isset($test_rs)) {
376 <label
for="pdf_page_number_opt"><?php
echo __('Page number:'); ?
></label
>
377 <select name
="pdf_page_number" id
="pdf_page_number_opt">
379 while ($pages = @PMA_DBI_fetch_assoc
($test_rs)) {
380 echo ' <option value="' . $pages['page_nr'] . '">'
381 . $pages['page_nr'] . ': ' . htmlspecialchars($pages['page_descr']) . '</option>' . "\n";
383 PMA_DBI_free_result($test_rs);
388 <input type
="hidden" name
="pdf_page_number" value
="<?php echo htmlspecialchars($this->chosenPage); ?>" />
390 <input type
="hidden" name
="do" value
="process_export" />
391 <input type
="hidden" name
="chpage" value
="<?php echo $chpage; ?>" />
392 <input type
="checkbox" name
="show_grid" id
="show_grid_opt" />
393 <label
for="show_grid_opt"><?php
echo __('Show grid'); ?
></label
><br
/>
394 <input type
="checkbox" name
="show_color" id
="show_color_opt" checked
="checked" />
395 <label
for="show_color_opt"><?php
echo __('Show color'); ?
></label
><br
/>
396 <input type
="checkbox" name
="show_table_dimension" id
="show_table_dim_opt" />
397 <label
for="show_table_dim_opt"><?php
echo __('Show dimension of tables'); ?
>
399 <input type
="checkbox" name
="all_table_same_wide" id
="all_table_same_wide" />
400 <label
for="all_table_same_wide"><?php
echo __('Display all tables with the same width'); ?
>
402 <input type
="checkbox" name
="with_doc" id
="with_doc" checked
="checked" />
403 <label
for="with_doc"><?php
echo __('Data Dictionary'); ?
></label
><br
/>
404 <input type
="checkbox" name
="show_keys" id
="show_keys" />
405 <label
for="show_keys"><?php
echo __('Only show keys'); ?
></label
><br
/>
406 <select name
="orientation" id
="orientation_opt" onchange
="refreshDragOption('pdflayout');" >
407 <option value
="L"><?php
echo __('Landscape');?
></option
>
408 <option value
="P"><?php
echo __('Portrait');?
></option
>
410 <label
for="orientation_opt"><?php
echo __('Orientation'); ?
></label
>
412 <select name
="paper" id
="paper_opt" onchange
="refreshDragOption('pdflayout');">
414 foreach ($cfg['PDFPageSizes'] as $key => $val) {
415 echo '<option value="' . $val . '"';
416 if ($val == $cfg['PDFDefaultPageSize']) {
417 echo ' selected="selected"';
419 echo ' >' . $val . '</option>' . "\n";
423 <label
for="paper_opt"><?php
echo __('Paper size'); ?
></label
>
425 <fieldset
class="tblFooters">
426 <input type
="submit" value
="<?php echo __('Go'); ?>" />
433 * Check if there are tables that need to be deleted in dashboard,
434 * if there are, ask the user for allowance
436 * @param string db name of database selected
437 * @param integer chpage selected page
438 * @param array tabExist
442 private function _deleteTables($db, $chpage, $tabExist)
447 if (!empty($tabExist) && is_array($tabExist)) {
448 foreach ($tabExist as $key => $value) {
450 $_strtrans .= '<input type="hidden" name="delrow[]" value="' . htmlspecialchars($key) . '" />' . "\n";
451 $_strname .= '<li>' . htmlspecialchars($key) . '</li>' . "\n";
456 echo '<form action="schema_edit.php" method="post">' . "\n"
457 . PMA_generate_common_hidden_inputs($db, $table)
458 . '<input type="hidden" name="do" value="delete_old_references" />' . "\n"
459 . '<input type="hidden" name="chpage" value="' . htmlspecialchars($chpage) . '" />' . "\n"
460 . __('The current page has references to tables that no longer exist. Would you like to delete those references?')
465 . '<input type="submit" value="' . __('Go') . '" />' . "\n"
473 * Check if there are tables that need to be deleted in dashboard,
474 * if there are, ask the user for allowance
479 private function _displayScratchboardTables($array_sh_page)
481 global $with_field_names,$cfg,$db;
483 <script type
="text/javascript" src
="./js/dom-drag.js"></script
>
484 <form method
="post" action
="schema_edit.php" name
="dragdrop">
485 <input type
="button" name
="dragdrop" value
="<?php echo __('Toggle scratchboard'); ?>" onclick
="ToggleDragDrop('pdflayout');" />
486 <input type
="button" name
="dragdropreset" value
="<?php echo __('Reset'); ?>" onclick
="resetDrag();" />
488 <div id
="pdflayout" class="pdflayout" style
="visibility: hidden;">
492 $reset_draginit = '';
494 foreach ($array_sh_page as $key => $temp_sh_page) {
495 $drag_x = $temp_sh_page['x'];
496 $drag_y = $temp_sh_page['y'];
498 $draginit2 .= ' Drag.init(getElement("table_' . $i . '"), null, 0, parseInt(myid.style.width)-2, 0, parseInt(myid.style.height)-5);' . "\n";
499 $draginit2 .= ' getElement("table_' . $i . '").onDrag = function (x, y) { document.edcoord.elements["c_table_' . $i . '[x]"].value = parseInt(x); document.edcoord.elements["c_table_' . $i . '[y]"].value = parseInt(y) }' . "\n";
500 $draginit .= ' getElement("table_' . $i . '").style.left = "' . $drag_x . 'px";' . "\n";
501 $draginit .= ' getElement("table_' . $i . '").style.top = "' . $drag_y . 'px";' . "\n";
502 $reset_draginit .= ' getElement("table_' . $i . '").style.left = "2px";' . "\n";
503 $reset_draginit .= ' getElement("table_' . $i . '").style.top = "' . (15 * $i) . 'px";' . "\n";
504 $reset_draginit .= ' document.edcoord.elements["c_table_' . $i . '[x]"].value = "2"' . "\n";
505 $reset_draginit .= ' document.edcoord.elements["c_table_' . $i . '[y]"].value = "' . (15 * $i) . '"' . "\n";
507 $local_query = PMA_DBI_get_columns_sql($db, $temp_sh_page['table_name']);
508 $fields_rs = PMA_DBI_query($local_query);
510 $fields_cnt = PMA_DBI_num_rows($fields_rs);
512 echo '<div id="table_' . $i . '" class="pdflayout_table"><u>' . $temp_sh_page['table_name'] . '</u>';
513 if (isset($with_field_names)) {
514 while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
515 echo '<br />' . htmlspecialchars($row['Field']) . "\n";
518 echo '</div>' . "\n";
519 PMA_DBI_free_result($fields_rs);
525 <script type
="text/javascript">
529 myid
= getElement('pdflayout');
530 <?php
echo $draginit; ?
>
534 function TableDragInit() {
535 myid
= getElement('pdflayout');
536 <?php
echo $draginit2; ?
>
539 function resetDrag() {
540 <?php
echo $reset_draginit; ?
>
548 * delete the table rows with table co-ordinates
550 * @param int delrow delete selected table from list of tables
551 * @param array cfgRelation relation settings
552 * @param string db database name
553 * @param integer chpage selected page for adding relations etc
557 private function _deleteTableRows($delrow,$cfgRelation,$db,$chpage)
559 foreach ($delrow as $current_row) {
560 $del_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) . ' ' . "\n"
561 . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'' . "\n"
562 . ' AND table_name = \'' . PMA_sqlAddSlashes($current_row) . '\'' . "\n"
563 . ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($chpage) . '\'';
565 PMA_query_as_controluser($del_query, false);
570 * get all the export options and verify
571 * call and include the appropriate Schema Class depending on $export_type
576 private function _processExportSchema()
579 * Settings for relation stuff
581 require_once './libraries/transformations.lib.php';
582 require_once './libraries/Index.class.php';
584 * default is PDF, otherwise validate it's only letters a-z
586 global $db,$export_type;
587 if (!isset($export_type) ||
!preg_match('/^[a-zA-Z]+$/', $export_type)) {
588 $export_type = 'pdf';
591 PMA_DBI_select_db($db);
593 include("./libraries/schema/".ucfirst($export_type)."_Relation_Schema.class.php");
594 $obj_schema = eval("new PMA_".ucfirst($export_type)."_Relation_Schema();");
598 * delete X and Y coordinates
600 * @param string db The database name
601 * @param array cfgRelation relation settings
602 * @param integer choosePage selected page for adding relations etc
606 public function deleteCoordinates($db, $cfgRelation, $choosePage)
608 $query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
609 . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
610 . ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($choosePage) . '\'';
611 PMA_query_as_controluser($query, false);
617 * @param string db The database name
618 * @param array cfgRelation relation settings
619 * @param integer choosePage selected page for adding relations etc
623 public function deletePages($db, $cfgRelation, $choosePage)
625 $query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages'])
626 . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
627 . ' AND page_nr = \'' . PMA_sqlAddSlashes($choosePage) . '\'';
628 PMA_query_as_controluser($query, false);
632 * process internal and foreign key relations
634 * @param string db The database name
635 * @param array cfgRelation relation settings
636 * @param integer pageNumber document number/Id
640 public function processRelations($db, $pageNumber, $cfgRelation)
643 * A u t o m a t i c l a y o u t
645 * There are 2 kinds of relations in PMA
646 * 1) Internal Relations 2) Foreign Key Relations
648 if (isset($this->autoLayoutInternal
) ||
isset($this->autoLayoutForeign
)) {
649 $all_tables = array();
652 if (isset($this->autoLayoutForeign
)) {
654 * get the tables list
655 * who support FOREIGN KEY, it's not
656 * important that we group together InnoDB tables
657 * and PBXT tables, as this logic is just to put
658 * the tables on the layout, not to determine relations
660 $tables = PMA_DBI_get_tables_full($db);
661 $foreignkey_tables = array();
662 foreach ($tables as $table_name => $table_properties) {
663 if (PMA_foreignkey_supported($table_properties['ENGINE'])) {
664 $foreignkey_tables[] = $table_name;
667 $all_tables = $foreignkey_tables;
669 * could be improved by finding the tables which have the
670 * most references keys and placing them at the beginning
671 * of the array (so that they are all center of schema)
673 unset($tables, $foreignkey_tables);
676 if (isset($this->autoLayoutInternal
)) {
678 * get the tables list who support Internal Relations;
679 * This type of relations will be created when
680 * you setup the PMA tables correctly
682 $master_tables = 'SELECT COUNT(master_table), master_table'
683 . ' FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation'])
684 . ' WHERE master_db = \'' . $db . '\''
685 . ' GROUP BY master_table'
686 . ' ORDER BY ' . PMA_backquote('COUNT(master_table)') . ' DESC ';
687 $master_tables_rs = PMA_query_as_controluser($master_tables, false, PMA_DBI_QUERY_STORE
);
688 if ($master_tables_rs && PMA_DBI_num_rows($master_tables_rs) > 0) {
689 /* first put all the master tables at beginning
690 * of the list, so they are near the center of
693 while (list(, $master_table) = PMA_DBI_fetch_row($master_tables_rs)) {
694 $all_tables[] = $master_table;
697 /* Now for each master, add its foreigns into an array
698 * of foreign tables, if not already there
699 * (a foreign might be foreign for more than
700 * one table, and might be a master itself)
703 $foreign_tables = array();
704 foreach ($all_tables as $master_table) {
705 $foreigners = PMA_getForeigners($db, $master_table);
706 foreach ($foreigners as $foreigner) {
707 if (!in_array($foreigner['foreign_table'], $foreign_tables)) {
708 $foreign_tables[] = $foreigner['foreign_table'];
714 * Now merge the master and foreign arrays/tables
716 foreach ($foreign_tables as $foreign_table) {
717 if (!in_array($foreign_table, $all_tables)) {
718 $all_tables[] = $foreign_table;
724 if (isset($this->autoLayoutInternal
) ||
isset($this->autoLayoutForeign
)) {
725 $this->addRelationCoordinates($all_tables,$pageNumber,$db, $cfgRelation);
728 $this->chosenPage
= $pageNumber;
732 * Add X and Y coordinates for a table
734 * @param string db The database name
735 * @param array cfgRelation relation settings
736 * @param integer pageNumber document number/Id
737 * @param array all_tables A list of all tables involved
741 public function addRelationCoordinates($all_tables,$pageNumber,$db, $cfgRelation)
744 * Now generate the coordinates for the schema
745 * in a clockwise spiral and add to co-ordinates table
751 $direction = "right";
752 foreach ($all_tables as $current_table) {
754 * save current table's coordinates
756 $insert_query = 'INSERT INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) . ' '
757 . '(db_name, table_name, pdf_page_number, x, y) '
758 . 'VALUES (\'' . PMA_sqlAddSlashes($db) . '\', \'' . PMA_sqlAddSlashes($current_table) . '\',' . $pageNumber . ',' . $pos_x . ',' . $pos_y . ')';
759 PMA_query_as_controluser($insert_query, false);
762 * compute for the next table
764 switch ($direction) {
768 $delta *= $delta_mult;
773 $delta *= $delta_mult;
778 $delta *= $delta_mult;
782 $direction = "right";
783 $delta *= $delta_mult;
790 * update X and Y coordinates for a table
792 * @param string db The database name
793 * @param array cfgRelation relation settings
797 private function _editCoordinates($db, $cfgRelation)
799 for ($i = 0; $i < $this->c_table_rows
; $i++
) {
800 $arrvalue = 'c_table_' . $i;
802 $arrvalue = $
$arrvalue;
803 if (! isset($arrvalue['x']) ||
$arrvalue['x'] == '') {
806 if (! isset($arrvalue['y']) ||
$arrvalue['y'] == '') {
809 if (isset($arrvalue['name']) && $arrvalue['name'] != '--') {
810 $test_query = 'SELECT * FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
811 . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
812 . ' AND table_name = \'' . PMA_sqlAddSlashes($arrvalue['name']) . '\''
813 . ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($this->chosenPage
) . '\'';
814 $test_rs = PMA_query_as_controluser($test_query, false, PMA_DBI_QUERY_STORE
);
816 if ($test_rs && PMA_DBI_num_rows($test_rs) > 0) {
817 if (isset($arrvalue['delete']) && $arrvalue['delete'] == 'y') {
818 $ch_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
819 . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
820 . ' AND table_name = \'' . PMA_sqlAddSlashes($arrvalue['name']) . '\''
821 . ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($this->chosenPage
) . '\'';
823 $ch_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) . ' '
824 . 'SET x = ' . $arrvalue['x'] . ', y= ' . $arrvalue['y']
825 . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
826 . ' AND table_name = \'' . PMA_sqlAddSlashes($arrvalue['name']) . '\''
827 . ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($this->chosenPage
) . '\'';
830 $ch_query = 'INSERT INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) . ' '
831 . '(db_name, table_name, pdf_page_number, x, y) '
832 . 'VALUES (\'' . PMA_sqlAddSlashes($db) . '\', \'' . PMA_sqlAddSlashes($arrvalue['name']) . '\', \'' . PMA_sqlAddSlashes($this->chosenPage
) . '\',' . $arrvalue['x'] . ',' . $arrvalue['y'] . ')';
835 PMA_query_as_controluser($ch_query, false);