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 * $this->action tells what the Schema is supposed to do
35 * create and select a page, generate schema etc
40 public function processUserChoice()
42 global $action_choose, $db, $cfgRelation;
44 if (isset($this->action
)) {
45 switch ($this->action
) {
47 $this->chosenPage
= $_REQUEST['chpage'];
48 if ($action_choose=="1") {
49 $this->deleteCoordinates(
59 $this->chosenPage
= 0;
63 $this->pageNumber
= PMA_REL_create_page(
68 $this->autoLayoutForeign
= isset($_POST['auto_layout_foreign'])
71 $this->autoLayoutInternal
= isset($_POST['auto_layout_internal'])
74 $this->processRelations(
81 $this->chosenPage
= $_POST['chpage'];
82 $this->c_table_rows
= $_POST['c_table_rows'];
83 $this->_editCoordinates($db, $cfgRelation);
85 case 'delete_old_references':
86 $this->_deleteTableRows(
93 case 'process_export':
94 $this->_processExportSchema();
98 } // end if (isset($do))
103 * shows/displays the HTML FORM to create the page
105 * @param string $db name of the selected database
110 public function showCreatePageDialog($db)
113 <form method
="post" action
="schema_edit.php" name
="frm_create_page">
116 <?php
echo __('Create a page') . "\n"; ?
>
118 <?php
echo PMA_generate_common_hidden_inputs($db); ?
>
119 <input type
="hidden" name
="do" value
="createpage" />
122 <td
><label
for="id_newpage"><?php
echo __('Page name'); ?
></label
></td
>
123 <td
><input type
="text" name
="newpage" id
="id_newpage" size
="20" maxlength
="50" /></td
>
126 <td
><?php
echo __('Automatic layout based on'); ?
></td
>
128 <input type
="checkbox" name
="auto_layout_internal" id
="id_auto_layout_internal" /><label
for="id_auto_layout_internal">
129 <?php
echo __('Internal relations'); ?
></label
><br
/>
132 * Check to see whether INNODB and PBXT storage engines are Available in MYSQL PACKAGE
133 * If available, then provide AutoLayout for Foreign Keys in Schema View
136 if (PMA_StorageEngine
::isValid('InnoDB') || PMA_StorageEngine
::isValid('PBXT')) {
138 <input type
="checkbox" name
="auto_layout_foreign" id
="id_auto_layout_foreign" /><label
for="id_auto_layout_foreign">
139 <?php
echo __('FOREIGN KEY'); ?
></label
><br
/>
146 <fieldset
class="tblFooters">
147 <input type
="submit" value
="<?php echo __('Go'); ?>" />
154 * shows/displays the created page names in a drop down list
155 * User can select any page number and edit it using dashboard etc
160 public function selectPage()
162 global $db,$table,$cfgRelation;
163 $page_query = 'SELECT * FROM '
164 . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
165 . PMA_backquote($cfgRelation['pdf_pages'])
166 . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'';
167 $page_rs = PMA_query_as_controluser($page_query, false, PMA_DBI_QUERY_STORE
);
168 if ($page_rs && PMA_DBI_num_rows($page_rs) > 0) {
170 <form method
="get" action
="schema_edit.php" name
="frm_select_page">
173 <?php
echo __('Please choose a page to edit') . "\n"; ?
>
175 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
176 <input type
="hidden" name
="do" value
="selectpage" />
177 <select name
="chpage" id
="chpage" class="autosubmit">
178 <option value
="0"><?php
echo __('Select page'); ?
></option
>
180 while ($curr_page = PMA_DBI_fetch_assoc($page_rs)) {
182 . '<option value="' . $curr_page['page_nr'] . '"';
183 if (isset($this->chosenPage
)
184 && $this->chosenPage
== $curr_page['page_nr']
186 echo ' selected="selected"';
188 echo '>' . $curr_page['page_nr'] . ': '
189 . htmlspecialchars($curr_page['page_descr']) . '</option>';
199 PMA_display_html_radio('action_choose', $choices, '0', false);
203 <fieldset
class="tblFooters">
204 <input type
="submit" value
="<?php echo __('Go'); ?>" /><br
/>
213 * A dashboard is displayed to AutoLayout the position of tables
214 * users can drag n drop the tables and change their positions
219 public function showTableDashBoard()
221 global $db, $cfgRelation, $table, $with_field_names;
223 * We will need an array of all tables in this db
225 $selectboxall = array('--');
226 $alltab_rs = PMA_DBI_query(
227 'SHOW TABLES FROM ' . PMA_backquote($db) . ';',
231 while ($val = @PMA_DBI_fetch_row
($alltab_rs)) {
232 $selectboxall[] = $val[0];
238 * Now if we already have chosen a page number then we should
239 * show the tables involved
241 if (isset($this->chosenPage
) && $this->chosenPage
> 0) {
244 <h2
><?php
echo __('Select Tables'); ?
></h2
>
246 $page_query = 'SELECT * FROM '
247 . PMA_backquote($GLOBALS['cfgRelation']['db'])
248 . '.' . PMA_backquote($cfgRelation['table_coords'])
249 . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
250 . ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($this->chosenPage
) . '\'';
251 $page_rs = PMA_query_as_controluser($page_query, false);
252 $array_sh_page = array();
253 while ($temp_sh_page = @PMA_DBI_fetch_assoc
($page_rs)) {
254 $array_sh_page[] = $temp_sh_page;
257 * Display WYSIWYG parts
260 if (! isset($_POST['with_field_names']) && ! isset($_POST['showwysiwyg'])) {
261 $with_field_names = true;
263 $this->_displayScratchboardTables($array_sh_page);
266 <form method
="post" action
="schema_edit.php" name
="edcoord">
267 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
268 <input type
="hidden" name
="chpage" value
="<?php echo htmlspecialchars($this->chosenPage); ?>" />
269 <input type
="hidden" name
="do" value
="edcoord" />
272 <th
><?php
echo __('Table'); ?
></th
>
273 <th
><?php
echo __('Delete'); ?
></th
>
278 if (isset($ctable)) {
284 foreach ($array_sh_page as $dummy_sh_page => $sh_page) {
285 $_mtab = $sh_page['table_name'];
286 $tabExist[$_mtab] = false;
287 echo "\n" . ' <tr class="noclick ';
294 $odd_row != $odd_row;
296 . "\n" . ' <select name="c_table_' . $i . '[name]">';
297 foreach ($selectboxall as $key => $value) {
298 echo "\n" . ' <option value="' . htmlspecialchars($value) . '"';
299 if ($value == $sh_page['table_name']) {
300 echo ' selected="selected"';
301 $tabExist[$_mtab] = true;
303 echo '>' . htmlspecialchars($value) . '</option>';
305 echo "\n" . ' </select>'
308 . "\n" . ' <input type="checkbox" id="id_c_table_' . $i .'" name="c_table_' . $i . '[delete]" value="y" /><label for="id_c_table_' . $i .'">' . __('Delete') . '</label>';
309 echo "\n" . ' </td>';
311 . "\n" . ' <input type="text" onchange="dragPlace(' . $i . ', \'x\', this.value)" name="c_table_' . $i . '[x]" value="' . $sh_page['x'] . '" />';
312 echo "\n" . ' </td>';
314 . "\n" . ' <input type="text" onchange="dragPlace(' . $i . ', \'y\', this.value)" name="c_table_' . $i . '[y]" value="' . $sh_page['y'] . '" />';
315 echo "\n" . ' </td>';
316 echo "\n" . ' </tr>';
320 * Add one more empty row
322 echo "\n" . ' <tr class="noclick ';
328 $odd_row != $odd_row;
331 . "\n" . ' <select name="c_table_' . $i . '[name]">';
332 foreach ($selectboxall as $key => $value) {
333 echo "\n" . ' <option value="' . htmlspecialchars($value) . '">' . htmlspecialchars($value) . '</option>';
335 echo "\n" . ' </select>'
338 . "\n" . ' <input type="checkbox" id="id_c_table_' . $i .'" name="c_table_' . $i . '[delete]" value="y" /><label for="id_c_table_' . $i .'">' . __('Delete') . '</label>';
339 echo "\n" . ' </td>';
341 . "\n" . ' <input type="text" name="c_table_' . $i . '[x]" value="' . (isset($sh_page['x'])?
$sh_page['x']:'') . '" />';
342 echo "\n" . ' </td>';
344 . "\n" . ' <input type="text" name="c_table_' . $i . '[y]" value="' . (isset($sh_page['y'])?
$sh_page['y']:'') . '" />';
345 echo "\n" . ' </td>';
346 echo "\n" . ' </tr>';
347 echo "\n" . ' </table>' . "\n";
349 echo "\n" . ' <input type="hidden" name="c_table_rows" value="' . ($i +
1) . '" />';
350 echo "\n" . ' <input type="hidden" id="showwysiwyg" name="showwysiwyg" value="' . ((isset($showwysiwyg) && $showwysiwyg == '1') ?
'1' : '0') . '" />';
351 echo "\n" . ' <input type="checkbox" name="with_field_names" ' . (isset($with_field_names) ?
'checked="checked"' : ''). ' />' . __('Column names') . '<br />';
352 echo "\n" . ' <input type="submit" value="' . __('Save') . '" />';
353 echo "\n" . '</form>' . "\n\n";
356 if (isset($tabExist)) {
357 $this->_deleteTables($db, $this->chosenPage
, $tabExist);
362 * show Export relational schema generation options
363 * user can select export type of his own choice
364 * and the attributes related to it
370 public function displaySchemaGenerationOptions()
372 global $cfg,$pmaThemeImage,$db,$test_rs,$chpage;
374 <form method
="post" action
="schema_export.php">
378 echo PMA_generate_common_hidden_inputs($db);
379 if ($cfg['PropertiesIconic']) {
380 echo PMA_getImage('b_views.png');
382 echo __('Display relational schema');
385 <select name
="export_type" id
="export_type">
386 <option value
="pdf" selected
="selected">PDF
</option
>
387 <option value
="svg">SVG
</option
>
388 <option value
="dia">DIA
</option
>
389 <option value
="visio">Visio
</option
>
390 <option value
="eps">EPS
</option
>
392 <label
><?php
echo __('Select Export Relational Type');?
></label
><br
/>
394 if (isset($test_rs)) {
396 <label
for="pdf_page_number_opt"><?php
echo __('Page number:'); ?
></label
>
397 <select name
="pdf_page_number" id
="pdf_page_number_opt">
399 while ($pages = @PMA_DBI_fetch_assoc
($test_rs)) {
400 echo ' <option value="' . $pages['page_nr'] . '">'
401 . $pages['page_nr'] . ': ' . htmlspecialchars($pages['page_descr']) . '</option>' . "\n";
403 PMA_DBI_free_result($test_rs);
408 <input type
="hidden" name
="pdf_page_number" value
="<?php echo htmlspecialchars($this->chosenPage); ?>" />
410 <input type
="hidden" name
="do" value
="process_export" />
411 <input type
="hidden" name
="chpage" value
="<?php echo $chpage; ?>" />
412 <input type
="checkbox" name
="show_grid" id
="show_grid_opt" />
413 <label
for="show_grid_opt"><?php
echo __('Show grid'); ?
></label
><br
/>
414 <input type
="checkbox" name
="show_color" id
="show_color_opt" checked
="checked" />
415 <label
for="show_color_opt"><?php
echo __('Show color'); ?
></label
><br
/>
416 <input type
="checkbox" name
="show_table_dimension" id
="show_table_dim_opt" />
417 <label
for="show_table_dim_opt"><?php
echo __('Show dimension of tables'); ?
>
419 <input type
="checkbox" name
="all_table_same_wide" id
="all_table_same_wide" />
420 <label
for="all_table_same_wide"><?php
echo __('Display all tables with the same width'); ?
>
422 <input type
="checkbox" name
="with_doc" id
="with_doc" checked
="checked" />
423 <label
for="with_doc"><?php
echo __('Data Dictionary'); ?
></label
><br
/>
424 <input type
="checkbox" name
="show_keys" id
="show_keys" />
425 <label
for="show_keys"><?php
echo __('Only show keys'); ?
></label
><br
/>
426 <select name
="orientation" id
="orientation_opt" onchange
="refreshDragOption('pdflayout');" >
427 <option value
="L"><?php
echo __('Landscape');?
></option
>
428 <option value
="P"><?php
echo __('Portrait');?
></option
>
430 <label
for="orientation_opt"><?php
echo __('Orientation'); ?
></label
>
432 <select name
="paper" id
="paper_opt" onchange
="refreshDragOption('pdflayout');">
434 foreach ($cfg['PDFPageSizes'] as $key => $val) {
435 echo '<option value="' . $val . '"';
436 if ($val == $cfg['PDFDefaultPageSize']) {
437 echo ' selected="selected"';
439 echo ' >' . $val . '</option>' . "\n";
443 <label
for="paper_opt"><?php
echo __('Paper size'); ?
></label
>
445 <fieldset
class="tblFooters">
446 <input type
="submit" value
="<?php echo __('Go'); ?>" />
453 * Check if there are tables that need to be deleted in dashboard,
454 * if there are, ask the user for allowance
456 * @param string $db name of database selected
457 * @param integer $chpage selected page
458 * @param array $tabExist
463 private function _deleteTables($db, $chpage, $tabExist)
469 if (! empty($tabExist) && is_array($tabExist)) {
470 foreach ($tabExist as $key => $value) {
472 $_strtrans .= '<input type="hidden" name="delrow[]" value="' . htmlspecialchars($key) . '" />' . "\n";
473 $_strname .= '<li>' . htmlspecialchars($key) . '</li>' . "\n";
478 echo '<form action="schema_edit.php" method="post">' . "\n"
479 . PMA_generate_common_hidden_inputs($db)
480 . '<input type="hidden" name="do" value="delete_old_references" />' . "\n"
481 . '<input type="hidden" name="chpage" value="' . htmlspecialchars($chpage) . '" />' . "\n"
482 . __('The current page has references to tables that no longer exist. Would you like to delete those references?')
487 . '<input type="submit" value="' . __('Go') . '" />' . "\n"
495 * Check if there are tables that need to be deleted in dashboard,
496 * if there are, ask the user for allowance
501 private function _displayScratchboardTables($array_sh_page)
503 global $with_field_names, $db;
505 <script type
="text/javascript" src
="./js/dom-drag.js"></script
>
506 <form method
="post" action
="schema_edit.php" name
="dragdrop">
507 <input type
="button" name
="dragdrop" value
="<?php echo __('Toggle scratchboard'); ?>" onclick
="ToggleDragDrop('pdflayout');" />
508 <input type
="button" name
="dragdropreset" value
="<?php echo __('Reset'); ?>" onclick
="resetDrag();" />
510 <div id
="pdflayout" class="pdflayout" style
="visibility: hidden;">
514 $reset_draginit = '';
516 foreach ($array_sh_page as $key => $temp_sh_page) {
517 $drag_x = $temp_sh_page['x'];
518 $drag_y = $temp_sh_page['y'];
520 $draginit2 .= ' Drag.init($("#table_' . $i . '")[0], null, 0, parseInt(myid.style.width)-2, 0, parseInt(myid.style.height)-5);' . "\n";
521 $draginit2 .= ' $("#table_' . $i . '")[0].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";
522 $draginit .= ' $("#table_' . $i . '")[0].style.left = "' . $drag_x . 'px";' . "\n";
523 $draginit .= ' $("#table_' . $i . '")[0].style.top = "' . $drag_y . 'px";' . "\n";
524 $reset_draginit .= ' $("#table_' . $i . '")[0].style.left = "2px";' . "\n";
525 $reset_draginit .= ' $("#table_' . $i . '")[0].style.top = "' . (15 * $i) . 'px";' . "\n";
526 $reset_draginit .= ' document.edcoord.elements["c_table_' . $i . '[x]"].value = "2"' . "\n";
527 $reset_draginit .= ' document.edcoord.elements["c_table_' . $i . '[y]"].value = "' . (15 * $i) . '"' . "\n";
529 echo '<div id="table_' . $i . '" class="pdflayout_table"><u>' . $temp_sh_page['table_name'] . '</u>';
530 if (isset($with_field_names)) {
531 $fields = PMA_DBI_get_columns($db, $temp_sh_page['table_name']);
532 // if the table has been dropped from outside phpMyAdmin,
533 // we can no longer obtain its columns list
535 foreach ($fields as $row) {
536 echo '<br />' . htmlspecialchars($row['Field']) . "\n";
540 echo '</div>' . "\n";
545 <script type
="text/javascript">
549 myid
= $
('#pdflayout')[0];
550 <?php
echo $draginit; ?
>
554 function TableDragInit() {
555 myid
= $
('#pdflayout')[0];
556 <?php
echo $draginit2; ?
>
559 function resetDrag() {
560 <?php
echo $reset_draginit; ?
>
568 * delete the table rows with table co-ordinates
570 * @param int $delrow delete selected table from list of tables
571 * @param array $cfgRelation relation settings
572 * @param string $db database name
573 * @param integer $chpage selected page for adding relations etc
578 private function _deleteTableRows($delrow,$cfgRelation,$db,$chpage)
580 foreach ($delrow as $current_row) {
581 $del_query = 'DELETE FROM '
582 . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
583 . PMA_backquote($cfgRelation['table_coords']) . ' ' . "\n"
584 . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'' . "\n"
585 . ' AND table_name = \'' . PMA_sqlAddSlashes($current_row) . '\'' . "\n"
586 . ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($chpage) . '\'';
588 PMA_query_as_controluser($del_query, false);
593 * get all the export options and verify
594 * call and include the appropriate Schema Class depending on $export_type
599 private function _processExportSchema()
602 * Settings for relation stuff
604 include_once './libraries/transformations.lib.php';
605 include_once './libraries/Index.class.php';
607 * default is PDF, otherwise validate it's only letters a-z
609 global $db,$export_type;
610 if (!isset($export_type) ||
!preg_match('/^[a-zA-Z]+$/', $export_type)) {
611 $export_type = 'pdf';
614 PMA_DBI_select_db($db);
616 include "./libraries/schema/" . ucfirst($export_type) . "_Relation_Schema.class.php";
617 $obj_schema = eval("new PMA_" . ucfirst($export_type) . "_Relation_Schema();");
621 * delete X and Y coordinates
623 * @param string $db The database name
624 * @param array $cfgRelation relation settings
625 * @param integer $choosePage selected page for adding relations etc
630 public function deleteCoordinates($db, $cfgRelation, $choosePage)
632 $query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
633 . PMA_backquote($cfgRelation['table_coords'])
634 . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
635 . ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($choosePage) . '\'';
636 PMA_query_as_controluser($query, false);
642 * @param string $db The database name
643 * @param array $cfgRelation relation settings
644 * @param integer $choosePage selected page for adding relations etc
649 public function deletePages($db, $cfgRelation, $choosePage)
651 $query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
652 . PMA_backquote($cfgRelation['pdf_pages'])
653 . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
654 . ' AND page_nr = \'' . PMA_sqlAddSlashes($choosePage) . '\'';
655 PMA_query_as_controluser($query, false);
659 * process internal and foreign key relations
661 * @param string $db The database name
662 * @param integer $pageNumber document number/Id
663 * @param array $cfgRelation relation settings
668 public function processRelations($db, $pageNumber, $cfgRelation)
671 * A u t o m a t i c l a y o u t
673 * There are 2 kinds of relations in PMA
674 * 1) Internal Relations 2) Foreign Key Relations
676 if (isset($this->autoLayoutInternal
) ||
isset($this->autoLayoutForeign
)) {
677 $all_tables = array();
680 if (isset($this->autoLayoutForeign
)) {
682 * get the tables list
683 * who support FOREIGN KEY, it's not
684 * important that we group together InnoDB tables
685 * and PBXT tables, as this logic is just to put
686 * the tables on the layout, not to determine relations
688 $tables = PMA_DBI_get_tables_full($db);
689 $foreignkey_tables = array();
690 foreach ($tables as $table_name => $table_properties) {
691 if (PMA_foreignkey_supported($table_properties['ENGINE'])) {
692 $foreignkey_tables[] = $table_name;
695 $all_tables = $foreignkey_tables;
697 * could be improved by finding the tables which have the
698 * most references keys and placing them at the beginning
699 * of the array (so that they are all center of schema)
701 unset($tables, $foreignkey_tables);
704 if (isset($this->autoLayoutInternal
)) {
706 * get the tables list who support Internal Relations;
707 * This type of relations will be created when
708 * you setup the PMA tables correctly
710 $master_tables = 'SELECT COUNT(master_table), master_table'
711 . ' FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
712 . PMA_backquote($cfgRelation['relation'])
713 . ' WHERE master_db = \'' . PMA_sqlAddSlashes($db) . '\''
714 . ' GROUP BY master_table'
715 . ' ORDER BY COUNT(master_table) DESC';
716 $master_tables_rs = PMA_query_as_controluser(
717 $master_tables, false, PMA_DBI_QUERY_STORE
719 if ($master_tables_rs && PMA_DBI_num_rows($master_tables_rs) > 0) {
720 /* first put all the master tables at beginning
721 * of the list, so they are near the center of
724 while (list(, $master_table) = PMA_DBI_fetch_row($master_tables_rs)) {
725 $all_tables[] = $master_table;
728 /* Now for each master, add its foreigns into an array
729 * of foreign tables, if not already there
730 * (a foreign might be foreign for more than
731 * one table, and might be a master itself)
734 $foreign_tables = array();
735 foreach ($all_tables as $master_table) {
736 $foreigners = PMA_getForeigners($db, $master_table);
737 foreach ($foreigners as $foreigner) {
738 if (! in_array($foreigner['foreign_table'], $foreign_tables)) {
739 $foreign_tables[] = $foreigner['foreign_table'];
745 * Now merge the master and foreign arrays/tables
747 foreach ($foreign_tables as $foreign_table) {
748 if (! in_array($foreign_table, $all_tables)) {
749 $all_tables[] = $foreign_table;
755 if (isset($this->autoLayoutInternal
) ||
isset($this->autoLayoutForeign
)) {
756 $this->addRelationCoordinates(
757 $all_tables, $pageNumber, $db, $cfgRelation
761 $this->chosenPage
= $pageNumber;
765 * Add X and Y coordinates for a table
767 * @param array $all_tables A list of all tables involved
768 * @param integer $pageNumber document number/Id
769 * @param string $db The database name
770 * @param array $cfgRelation relation settings
775 public function addRelationCoordinates($all_tables, $pageNumber, $db, $cfgRelation)
778 * Now generate the coordinates for the schema
779 * in a clockwise spiral and add to co-ordinates table
785 $direction = "right";
786 foreach ($all_tables as $current_table) {
788 * save current table's coordinates
790 $insert_query = 'INSERT INTO '
791 . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
792 . PMA_backquote($cfgRelation['table_coords']) . ' '
793 . '(db_name, table_name, pdf_page_number, x, y) '
794 . 'VALUES (\'' . PMA_sqlAddSlashes($db) . '\', \''
795 . PMA_sqlAddSlashes($current_table) . '\',' . $pageNumber
796 . ',' . $pos_x . ',' . $pos_y . ')';
797 PMA_query_as_controluser($insert_query, false);
800 * compute for the next table
802 switch ($direction) {
806 $delta *= $delta_mult;
811 $delta *= $delta_mult;
816 $delta *= $delta_mult;
820 $direction = "right";
821 $delta *= $delta_mult;
828 * update X and Y coordinates for a table
830 * @param string $db The database name
831 * @param array $cfgRelation relation settings
836 private function _editCoordinates($db, $cfgRelation)
838 for ($i = 0; $i < $this->c_table_rows
; $i++
) {
839 $arrvalue = 'c_table_' . $i;
841 $arrvalue = $
$arrvalue;
842 if (! isset($arrvalue['x']) ||
$arrvalue['x'] == '') {
845 if (! isset($arrvalue['y']) ||
$arrvalue['y'] == '') {
848 if (isset($arrvalue['name']) && $arrvalue['name'] != '--') {
849 $test_query = 'SELECT * FROM '
850 . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
851 . PMA_backquote($cfgRelation['table_coords'])
852 . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
853 . ' AND table_name = \'' . PMA_sqlAddSlashes($arrvalue['name']) . '\''
854 . ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($this->chosenPage
) . '\'';
855 $test_rs = PMA_query_as_controluser($test_query, false, PMA_DBI_QUERY_STORE
);
857 if ($test_rs && PMA_DBI_num_rows($test_rs) > 0) {
858 if (isset($arrvalue['delete']) && $arrvalue['delete'] == 'y') {
859 $ch_query = 'DELETE FROM '
860 . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
861 . PMA_backquote($cfgRelation['table_coords'])
862 . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
863 . ' AND table_name = \'' . PMA_sqlAddSlashes($arrvalue['name']) . '\''
864 . ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($this->chosenPage
) . '\'';
866 $ch_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db'])
867 . '.' . PMA_backquote($cfgRelation['table_coords']) . ' '
868 . 'SET x = ' . $arrvalue['x'] . ', y= ' . $arrvalue['y']
869 . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
870 . ' AND table_name = \'' . PMA_sqlAddSlashes($arrvalue['name']) . '\''
871 . ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($this->chosenPage
) . '\'';
874 $ch_query = 'INSERT INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db'])
875 . '.' . PMA_backquote($cfgRelation['table_coords']) . ' '
876 . '(db_name, table_name, pdf_page_number, x, y) '
877 . 'VALUES (\'' . PMA_sqlAddSlashes($db) . '\', \''
878 . PMA_sqlAddSlashes($arrvalue['name']) . '\', \''
879 . PMA_sqlAddSlashes($this->chosenPage
) . '\','
880 . $arrvalue['x'] . ',' . $arrvalue['y'] . ')';
883 PMA_query_as_controluser($ch_query, false);