User_Schema class : removed tabs + commented code + organized structure, Delete listing of schema classes in process relation schema file

This commit is contained in:
Adnan
2010-07-02 16:31:32 +05:00
parent 1ef5f8564e
commit 188c7b8d38
5 changed files with 682 additions and 658 deletions

View File

@@ -20,20 +20,24 @@ $url_query .= '&goto=export_relation_schema.php';
require_once './libraries/db_info.inc.php';
/**
* Settings for relation stuff
* Includ settings for relation stuff
* get all variables needed for exporting relational schema
* in $cfgRelation
*/
require_once './libraries/relation.lib.php';
$cfgRelation = PMA_getRelationsParam();
// This is to avoid "Command out of sync" errors. Before switching this to
// a value of 0 (for MYSQLI_USE_RESULT), please check the logic
// to free results wherever needed.
/**
* This is to avoid "Command out of sync" errors. Before switching this to
* a value of 0 (for MYSQLI_USE_RESULT), please check the logic
* to free results wherever needed.
*/
$query_default_option = PMA_DBI_QUERY_STORE;
/**
* Now in ./libraries/relation.lib.php we check for all tables
* that we need, but if we don't find them we are quiet about it
* so people can work without.
* so people can't work without relational variables.
* This page is absolutely useless if you didn't set up your tables
* correctly, so it is a good place to see which tables we can and
* complain ;-)
@@ -64,27 +68,29 @@ if (!isset($cfgRelation['pdf_pages'])) {
if ($cfgRelation['pdfwork']) {
/**
* User Object Created for displaying the HTML options
* so, user can play with it and perform export of relations schema
* User object created for presenting the HTML options
* so, user can interact with it and perform export of relations schema
*/
require_once './libraries/schema/user_schema.php';
require_once './libraries/schema/User_Schema.class.php';
$user_schema = new PMA_User_Schema();
/**
* This function will process the user input
*
*/
$user_schema->userInputProcess($do);
$user_schema->processUserPreferences($do);
/**
* Now first show some possibility to select a page for the export of relation schema
*/
$user_schema->selectPage();
/**
* Possibility to create a new page:
*/
$user_schema->createPage();
/**
@@ -92,12 +98,14 @@ if ($cfgRelation['pdfwork']) {
* It will show you the list of tables
* A dashboard will also be shown where you can position the tables
*/
$user_schema->showTableDashBoard();
if (isset($do)
&& ($do == 'edcoord'
|| ($do == 'selectpage' && isset($chpage))
|| ($do == 'createpage' && isset($chpage)))) {
|| ($do == 'selectpage' && isset($chpage) && $chpage != 0)
|| ($do == 'createpage' && isset($chpage) && $chpage != 0))) {
/**
* show Export schema generation options
*/

View File

@@ -1,5 +1,16 @@
<?php
include_once("Export_Relation_Schema.class.php");
class PMA_DIA extends XMLWriter
{
public $title;
public $author;
public $font;
public $fontSize;
}
class PMA_Dia_Relation_Schema extends PMA_Export_Relation_Schema
{

View File

@@ -325,7 +325,7 @@ class PMA_PDF extends TCPDF {
$this->_out('/First ' . ($this->n + 1) . ' 0 R');
$this->_out('/Last ' . ($this->n + $last - $i) . ' 0 R');
$this->_out('/Count -' . $kids);
}tur
}
$this->_out('>>');
$this->_out('endobj');
}

View File

@@ -1,36 +1,38 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* This Class will interact with the user to gather the information
*
* @version $Id$
* @package phpMyAdmin
*/
/**
* This Class interacts with the user to gather the information
* about their tables for which they want to export the relational schema
* export options are shown to user from they can choose
*
* @name
* @author Muhammad Adnan <hiddenpearls@gmail.com>
* @copyright
* @license
*/
class PMA_User_Schema
{
/* private $_exportType;
public function __construct()
{
$this->_exportType='pdf'; // default export type
}
public function setExportType($type)
{
$this->_exportType=$type;
}
public function getExportType()
{
return $this->_exportType;
}*/
/**
* This function will process the user input
* 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
*
* @param string $do It is hidden value
* @access public
*/
public function userInputProcess($do)
public function processUserPreferences($do)
{
global $action_choose,$chpage,$db,$cfgRelation,$cfg,$auto_layout_foreign,$auto_layout_internal,$newpage,$c_table_rows,$query_default_option;
// Now is the time to work on all changes
//echo $do;
if (isset($do)) {
switch ($do) {
case 'selectpage':
@@ -49,22 +51,27 @@ class PMA_User_Schema
}
break;
case 'createpage':
$pdf_page_number = PMA_REL_create_page($newpage, $cfgRelation, $db, $query_default_option);
// A u t o m a t i c l a y o u t
// ================================
/*
* A u t o m a t i c l a y o u t
*
* There are 2 kinds of relations in PMA
* 1) Internal Relations 2) Foreign Key Relations
*/
if (isset($auto_layout_internal) || isset($auto_layout_foreign)) {
$all_tables = array();
}
if (isset($auto_layout_foreign)) {
// get the tables list
/*
* get the tables list
* who support FOREIGN KEY, it's not
* important that we group together InnoDB tables
* and PBXT tables, as this logic is just to put
* the tables on the layout, not to determine relations
*/
$tables = PMA_DBI_get_tables_full($db);
// find the ones who support FOREIGN KEY; it's not
// important that we group together InnoDB tables
// and PBXT tables, as this logic is just to put
// the tables on the layout, not to determine relations
$foreignkey_tables = array();
foreach($tables as $table_name => $table_properties) {
if (PMA_foreignkey_supported($table_properties['ENGINE'])) {
@@ -76,11 +83,14 @@ class PMA_User_Schema
// most references keys and placing them at the beginning
// of the array (so that they are all center of schema)
unset($tables, $foreignkey_tables);
} // endif auto_layout_foreign
}
if (isset($auto_layout_internal)) {
// get the tables that have relations, by descending
// number of links
/*
* get the tables list who support Internal Relations;
* This type of relations will be created when
* you setup the PMA tables correctly
*/
$master_tables = 'SELECT COUNT(master_table), master_table'
. ' FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation'])
. ' WHERE master_db = \'' . $db . '\''
@@ -88,17 +98,19 @@ class PMA_User_Schema
. ' ORDER BY ' . PMA_backquote('COUNT(master_table)') . ' DESC ';
$master_tables_rs = PMA_query_as_controluser($master_tables, FALSE, $query_default_option);
if ($master_tables_rs && PMA_DBI_num_rows($master_tables_rs) > 0) {
// first put all the master tables at beginning
// of the list, so they are near the center of
// the schema
/* first put all the master tables at beginning
* of the list, so they are near the center of
* the schema
*/
while (list(, $master_table) = PMA_DBI_fetch_row($master_tables_rs)) {
$all_tables[] = $master_table;
}
// then for each master, add its foreigns into an array
// of foreign tables, if not already there
// (a foreign might be foreign for more than
// one table, and might be a master itself)
/* Now for each master, add its foreigns into an array
* of foreign tables, if not already there
* (a foreign might be foreign for more than
* one table, and might be a master itself)
*/
$foreign_tables = array();
foreach ($all_tables as $master_table) {
@@ -110,7 +122,9 @@ class PMA_User_Schema
}
}
// then merge the arrays
/*
* Now merge the master and foreign arrays/tables
*/
foreach ($foreign_tables as $foreign_table) {
if (!in_array($foreign_table, $all_tables)) {
$all_tables[] = $foreign_table;
@@ -120,23 +134,27 @@ class PMA_User_Schema
} // endif auto_layout_internal
if (isset($auto_layout_internal) || isset($auto_layout_foreign)) {
// now generate the coordinates for the schema,
// in a clockwise spiral
/*
* Now generate the coordinates for the schema
* in a clockwise spiral
*/
$pos_x = 300;
$pos_y = 300;
$delta = 110;
$delta_mult = 1.10;
$direction = "right";
foreach ($all_tables as $current_table) {
// save current table's coordinates
/*
* save current table's coordinates
*/
$insert_query = 'INSERT INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) . ' '
. '(db_name, table_name, pdf_page_number, x, y) '
. 'VALUES (\'' . PMA_sqlAddslashes($db) . '\', \'' . PMA_sqlAddslashes($current_table) . '\',' . $pdf_page_number . ',' . $pos_x . ',' . $pos_y . ')';
PMA_query_as_controluser($insert_query, FALSE, $query_default_option);
// compute for the next table
/*
* compute for the next table
*/
switch ($direction) {
case 'right':
$pos_x += $delta;
@@ -163,7 +181,6 @@ class PMA_User_Schema
} // end if some auto-layout to do
$chpage = $pdf_page_number;
break;
case 'edcoord':
@@ -207,24 +224,26 @@ class PMA_User_Schema
} // end if
} // end for
break;
case 'deleteCrap':
foreach ($delrow as $current_row) {
$d_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) . ' ' . "\n"
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' . "\n"
. ' AND table_name = \'' . PMA_sqlAddslashes($current_row) . '\'' . "\n"
. ' AND pdf_page_number = \'' . PMA_sqlAddslashes($chpage) . '\'';
PMA_query_as_controluser($d_query, FALSE, $query_default_option);
}
$this->_deleteTableRows();
break;
case 'process_export':
$this->_processExportSchema();
break;
} // end switch
} // end if (isset($do))
}
/**
* This function shows/displays the HTML FORM to create the page
* shows/displays the HTML FORM to create the page
*
* @access public
*/
public function createPage()
{
global $db,$table;
@@ -247,10 +266,11 @@ class PMA_User_Schema
<input type="checkbox" name="auto_layout_internal" id="id_auto_layout_internal" /><label for="id_auto_layout_internal">
<?php echo __('Internal relations'); ?></label><br />
<?php
/**
/*
* Check to see whether INNODB and PBXT storage engines are Available in MYSQL PACKAGE
* If available, then provide AutoLayout for Foreign Keys in Schema View
*/
if (PMA_StorageEngine::isValid('InnoDB') || PMA_StorageEngine::isValid('PBXT')) {
?>
<input type="checkbox" name="auto_layout_foreign" id="id_auto_layout_foreign" /><label for="id_auto_layout_foreign">
@@ -269,16 +289,17 @@ class PMA_User_Schema
}
/**
* This function shows/displays the created page names
* All page names in a list
* shows/displays the created page names in a drop down list
* User can select any page number and edit it using dashboard etc
*
* @access public
*/
public function selectPage()
{
global $db,$table,$query_default_option,$cfgRelation;
global $db,$table,$query_default_option,$cfgRelation,$chpage;
$page_query = 'SELECT * FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
//echo $page_query;
$page_rs = PMA_query_as_controluser($page_query, FALSE, $query_default_option);
if ($page_rs && PMA_DBI_num_rows($page_rs) > 0) {
?>
@@ -290,6 +311,7 @@ class PMA_User_Schema
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
<input type="hidden" name="do" value="selectpage" />
<select name="chpage" onchange="this.form.submit()">
<option value='0'><?php echo __('Select page'); ?></option>
<?php
while ($curr_page = PMA_DBI_fetch_assoc($page_rs)) {
echo "\n" . ' '
@@ -305,7 +327,8 @@ class PMA_User_Schema
<?php
$choices = array(
'0' => __('Edit'),
'1' => __('Delete'));
'1' => __('Delete')
);
PMA_display_html_radio('action_choose', $choices, '0', false);
unset($choices);
?>
@@ -320,25 +343,32 @@ class PMA_User_Schema
} // end function
/**
* A dashboard will also be shown where you can position the tables
* A dashboard is displayed to AutoLayout the position of tables
* users can drag n drop the tables and change their positions
*
*/
public function showTableDashBoard()
{
global $db,$cfgRelation,$table,$cfg,$with_field_names,$with_field_names,$chpage;
// We will need an array of all tables in this db
global $db,$cfgRelation,$table,$cfg,$with_field_names,$chpage;
/*
* We will need an array of all tables in this db
*/
$selectboxall = array('--');
$alltab_rs = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', null, PMA_DBI_QUERY_STORE);
while ($val = @PMA_DBI_fetch_row($alltab_rs)) {
$selectboxall[] = $val[0];
}
// Now if we already have chosen a page number then we should show the
// tables involved
/*
* Now if we already have chosen a page number then we should
* show the tables involved
*/
if (isset($chpage) && $chpage > 0) {
echo "\n";
?>
<h2><?php echo __('Select Tables') ;?></h2>
<?php
$page_query = 'SELECT * FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
@@ -352,11 +382,245 @@ class PMA_User_Schema
$array_sh_page[] = $temp_sh_page;
}
// Display WYSIWYG-PDF parts?
/*
* Display WYSIWYG-PDF parts?
*/
if ($cfg['WYSIWYG-PDF']) {
if (!isset($_POST['with_field_names']) && !isset($_POST['showwysiwyg'])) {
$with_field_names = TRUE;
}
$this->_displayScratchboardTables($array_sh_page,$draginit,$reset_draginit);
}
?>
<form method="post" action="export_relation_schema.php" name="edcoord">
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
<input type="hidden" name="chpage" value="<?php echo htmlspecialchars($chpage); ?>" />
<input type="hidden" name="do" value="edcoord" />
<table border="0">
<tr>
<th><?php echo __('Table'); ?></th>
<th><?php echo __('Delete'); ?></th>
<th>X</th>
<th>Y</th>
</tr>
<?php
if (isset($ctable)) {
unset($ctable);
}
$i = 0;
$odd_row = true;
foreach ($array_sh_page as $dummy_sh_page => $sh_page) {
$_mtab = $sh_page['table_name'];
$tabExist[$_mtab] = FALSE;
echo "\n" . ' <tr class="';
if ($odd_row) {
echo 'odd';
} else {
echo 'even';
}
echo '">';
$odd_row != $odd_row;
echo "\n" . ' <td>'
. "\n" . ' <select name="c_table_' . $i . '[name]">';
foreach ($selectboxall as $key => $value) {
echo "\n" . ' <option value="' . htmlspecialchars($value) . '"';
if ($value == $sh_page['table_name']) {
echo ' selected="selected"';
$tabExist[$_mtab] = TRUE;
}
echo '>' . htmlspecialchars($value) . '</option>';
}
echo "\n" . ' </select>'
. "\n" . ' </td>';
echo "\n" . ' <td>'
. "\n" . ' <input type="checkbox" name="c_table_' . $i . '[delete]" value="y" />' . __('Delete');
echo "\n" . ' </td>';
echo "\n" . ' <td>'
. "\n" . ' <input type="text" ' . ($cfg['WYSIWYG-PDF'] ? 'onchange="dragPlace(' . $i . ', \'x\', this.value)"' : '') . ' name="c_table_' . $i . '[x]" value="' . $sh_page['x'] . '" />';
echo "\n" . ' </td>';
echo "\n" . ' <td>'
. "\n" . ' <input type="text" ' . ($cfg['WYSIWYG-PDF'] ? 'onchange="dragPlace(' . $i . ', \'y\', this.value)"' : '') . ' name="c_table_' . $i . '[y]" value="' . $sh_page['y'] . '" />';
echo "\n" . ' </td>';
echo "\n" . ' </tr>';
$i++;
}
/*
* Add one more empty row
*/
echo "\n" . ' <tr class="';
if ($odd_row) {
echo 'odd';
} else {
echo 'even';
}
$odd_row != $odd_row;
echo '">';
echo "\n" . ' <td>'
. "\n" . ' <select name="c_table_' . $i . '[name]">';
foreach ($selectboxall as $key => $value) {
echo "\n" . ' <option value="' . htmlspecialchars($value) . '">' . htmlspecialchars($value) . '</option>';
}
echo "\n" . ' </select>'
. "\n" . ' </td>';
echo "\n" . ' <td>'
. "\n" . ' <input type="checkbox" name="c_table_' . $i . '[delete]" value="y" />' . __('Delete');
echo "\n" . ' </td>';
echo "\n" . ' <td>'
. "\n" . ' <input type="text" name="c_table_' . $i . '[x]" value="' . (isset($sh_page['x'])?$sh_page['x']:'') . '" />';
echo "\n" . ' </td>';
echo "\n" . ' <td>'
. "\n" . ' <input type="text" name="c_table_' . $i . '[y]" value="' . (isset($sh_page['y'])?$sh_page['y']:'') . '" />';
echo "\n" . ' </td>';
echo "\n" . ' </tr>';
echo "\n" . ' </table>' . "\n";
echo "\n" . ' <input type="hidden" name="c_table_rows" value="' . ($i + 1) . '" />';
echo ($cfg['WYSIWYG-PDF'] ? "\n" . ' <input type="hidden" id="showwysiwyg" name="showwysiwyg" value="' . ((isset($showwysiwyg) && $showwysiwyg == '1') ? '1' : '0') . '" />' : '');
echo "\n" . ' <input type="checkbox" name="with_field_names" ' . (isset($with_field_names) ? 'checked="checked"' : ''). ' />' . __('Column names') . '<br />';
echo "\n" . ' <input type="submit" value="' . __('Save') . '" />';
echo "\n" . '</form>' . "\n\n";
} // end if
$this->_deleteTables($chpage);
}
/**
* show Export relational schema generation options
* user can select export type of his own choice
* and the attributes related to it
*/
public function displaySchemaGenerationOptions()
{
global $cfg,$pmaThemeImage,$db,$test_rs,$chpage;
?>
<form method="post" action="export_relation_schema.php">
<fieldset>
<legend>
<?php
echo PMA_generate_common_hidden_inputs($db);
if ($cfg['PropertiesIconic']) {
echo '<img class="icon" src="' . $pmaThemeImage . 'b_view.png"'
.' alt="" width="16" height="16" />';
}
echo __('Display Relational Schema');
?>:
</legend>
<select name="export_type" id="export_type">
<option value="pdf" selected="selected"><?php echo __('PDF');?></option>
<option value="svg"><?php echo __('SVG');?></option>
<option value="dia"><?php echo __('DIA');?></option>
<option value="visio"><?php echo __('VISIO');?></option>
<option value="eps"><?php echo __('EPS');?></option>
</select>
<label><?php echo __('Select Export Relational Type');?></label><br />
<?php
if (isset($test_rs)) {
?>
<label for="pdf_page_number_opt"><?php echo __('Page number:'); ?></label>
<select name="pdf_page_number" id="pdf_page_number_opt">
<?php
while ($pages = @PMA_DBI_fetch_assoc($test_rs)) {
echo ' <option value="' . $pages['page_nr'] . '">'
. $pages['page_nr'] . ': ' . htmlspecialchars($pages['page_descr']) . '</option>' . "\n";
} // end while
PMA_DBI_free_result($test_rs);
unset($test_rs);
?>
</select><br />
<?php } else { ?>
<input type="hidden" name="pdf_page_number" value="<?php echo htmlspecialchars($chpage); ?>" />
<?php } ?>
<input type="hidden" name="do" value="process_export" />
<input type="checkbox" name="show_grid" id="show_grid_opt" />
<label for="show_grid_opt"><?php echo __('Show grid'); ?></label><br />
<input type="checkbox" name="show_color" id="show_color_opt" checked="checked" />
<label for="show_color_opt"><?php echo __('Show color'); ?></label><br />
<input type="checkbox" name="show_table_dimension" id="show_table_dim_opt" />
<label for="show_table_dim_opt"><?php echo __('Show dimension of tables'); ?>
</label><br />
<input type="checkbox" name="all_tab_same_wide" id="all_tab_same_wide" />
<label for="all_tab_same_wide"><?php echo __('Display all tables with the same width'); ?>
</label><br />
<input type="checkbox" name="with_doc" id="with_doc" checked="checked" />
<label for="with_doc"><?php echo __('Data Dictionary'); ?></label><br />
<input type="checkbox" name="show_keys" id="show_keys" />
<label for="show_keys"><?php echo __('Only show keys'); ?></label><br />
<label for="orientation_opt"><?php echo __('Data Dictionary Format'); ?></label>
<select name="orientation" id="orientation_opt">
<option value="L"><?php echo __('Landscape');?></option>
<option value="P"><?php echo __('Portrait');?></option>
</select>
<br />
<label for="paper_opt"><?php echo __('Paper size'); ?></label>
<select name="paper" id="paper_opt">
<?php
foreach ($cfg['PDFPageSizes'] as $key => $val) {
echo '<option value="' . $val . '"';
if ($val == $cfg['PDFDefaultPageSize']) {
echo ' selected="selected"';
}
echo ' >' . $val . '</option>' . "\n";
}
?>
</select>
</fieldset>
<fieldset class="tblFooters">
<input type="submit" value="<?php echo __('Go'); ?>" />
</fieldset>
</form>
<?php
}// end function
/**
* Check if there are tables that need to be deleted in dashboard,
* if there are, ask the user for allowance
* @param string $chpage selected page
* @access private
*/
private function _deleteTables($chpage)
{
global $db, $table,$tabExist;
$_strtrans = '';
$_strname = '';
$shoot = FALSE;
if (!empty($tabExist) && is_array($tabExist)) {
foreach ($tabExist as $key => $value) {
if (!$value) {
$_strtrans .= '<input type="hidden" name="delrow[]" value="' . htmlspecialchars($key) . '" />' . "\n";
$_strname .= '<li>' . htmlspecialchars($key) . '</li>' . "\n";
$shoot = TRUE;
}
}
if ($shoot) {
echo '<form action="export_relation_schema.php" method="post">' . "\n"
. PMA_generate_common_hidden_inputs($db, $table)
. '<input type="hidden" name="do" value="deleteCrap" />' . "\n"
. '<input type="hidden" name="chpage" value="' . htmlspecialchars($chpage) . '" />' . "\n"
. __('The current page has references to tables that no longer exist. Would you like to delete those references?')
. '<ul>' . "\n"
. $_strname
. '</ul>' . "\n"
. $_strtrans
. '<input type="submit" value="' . __('Go') . '" />' . "\n"
. '</form>';
}
}
} // end function
/**
* Check if there are tables that need to be deleted in dashboard,
* if there are, ask the user for allowance
*/
private function _displayScratchboardTables($array_sh_page,$draginit,$reset_draginit)
{
global $with_field_names,$cfg,$db;
?>
<script type="text/javascript" src="./js/dom-drag.js"></script>
<form method="post" action="export_relation_schema.php" name="dragdrop">
@@ -394,7 +658,6 @@ class PMA_User_Schema
echo '</div>' . "\n";
PMA_DBI_free_result($fields_rs);
unset($fields_rs);
$i++;
}
?>
@@ -413,224 +676,48 @@ class PMA_User_Schema
//]]>
</script>
<?php
} // end if WYSIWYG-PDF
?>
<form method="post" action="export_relation_schema.php" name="edcoord">
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
<input type="hidden" name="chpage" value="<?php echo htmlspecialchars($chpage); ?>" />
<input type="hidden" name="do" value="edcoord" />
<table border="0">
<tr>
<th><?php echo __('Table'); ?></th>
<th><?php echo __('Delete'); ?></th>
<th>X</th>
<th>Y</th>
</tr>
<?php
if (isset($ctable)) {
unset($ctable);
}
$i = 0;
$odd_row = true;
foreach ($array_sh_page as $dummy_sh_page => $sh_page) {
$_mtab = $sh_page['table_name'];
$tabExist[$_mtab] = FALSE;
echo "\n" . ' <tr class="';
if ($odd_row) {
echo 'odd';
} else {
echo 'even';
}
echo '">';
$odd_row != $odd_row;
echo "\n" . ' <td>'
. "\n" . ' <select name="c_table_' . $i . '[name]">';
foreach ($selectboxall as $key => $value) {
echo "\n" . ' <option value="' . htmlspecialchars($value) . '"';
if ($value == $sh_page['table_name']) {
echo ' selected="selected"';
$tabExist[$_mtab] = TRUE;
}
echo '>' . htmlspecialchars($value) . '</option>';
} // end while
echo "\n" . ' </select>'
. "\n" . ' </td>';
echo "\n" . ' <td>'
. "\n" . ' <input type="checkbox" name="c_table_' . $i . '[delete]" value="y" />' . __('Delete');
echo "\n" . ' </td>';
echo "\n" . ' <td>'
. "\n" . ' <input type="text" ' . ($cfg['WYSIWYG-PDF'] ? 'onchange="dragPlace(' . $i . ', \'x\', this.value)"' : '') . ' name="c_table_' . $i . '[x]" value="' . $sh_page['x'] . '" />';
echo "\n" . ' </td>';
echo "\n" . ' <td>'
. "\n" . ' <input type="text" ' . ($cfg['WYSIWYG-PDF'] ? 'onchange="dragPlace(' . $i . ', \'y\', this.value)"' : '') . ' name="c_table_' . $i . '[y]" value="' . $sh_page['y'] . '" />';
echo "\n" . ' </td>';
echo "\n" . ' </tr>';
$i++;
} // end while
// Do one more empty row
echo "\n" . ' <tr class="';
if ($odd_row) {
echo 'odd';
} else {
echo 'even';
}
$odd_row != $odd_row;
echo '">';
echo "\n" . ' <td>'
. "\n" . ' <select name="c_table_' . $i . '[name]">';
foreach ($selectboxall as $key => $value) {
echo "\n" . ' <option value="' . htmlspecialchars($value) . '">' . htmlspecialchars($value) . '</option>';
}
echo "\n" . ' </select>'
. "\n" . ' </td>';
echo "\n" . ' <td>'
. "\n" . ' <input type="checkbox" name="c_table_' . $i . '[delete]" value="y" />' . __('Delete');
echo "\n" . ' </td>';
echo "\n" . ' <td>'
. "\n" . ' <input type="text" name="c_table_' . $i . '[x]" value="' . (isset($sh_page['x'])?$sh_page['x']:'') . '" />';
echo "\n" . ' </td>';
echo "\n" . ' <td>'
. "\n" . ' <input type="text" name="c_table_' . $i . '[y]" value="' . (isset($sh_page['y'])?$sh_page['y']:'') . '" />';
echo "\n" . ' </td>';
echo "\n" . ' </tr>';
echo "\n" . ' </table>' . "\n";
echo "\n" . ' <input type="hidden" name="c_table_rows" value="' . ($i + 1) . '" />';
echo ($cfg['WYSIWYG-PDF'] ? "\n" . ' <input type="hidden" id="showwysiwyg" name="showwysiwyg" value="' . ((isset($showwysiwyg) && $showwysiwyg == '1') ? '1' : '0') . '" />' : '');
echo "\n" . ' <input type="checkbox" name="with_field_names" ' . (isset($with_field_names) ? 'checked="checked"' : ''). ' />' . __('Column names') . '<br />';
echo "\n" . ' <input type="submit" value="' . __('Save') . '" />';
echo "\n" . '</form>' . "\n\n";
} // end if
$this->deleteTables($chpage);
}// end function
/**
* show Export relational schema generation options
* delete the table rows with table co-ordinates
*
* @access private
*/
public function displaySchemaGenerationOptions()
private function _deleteTableRows()
{
global $cfg,$pmaThemeImage,$db,$test_rs,$chpage;
?>
<!-- Export relational schema -->
<form method="post" action="process_relation_schema.php">
<fieldset>
<legend>
<?php
echo PMA_generate_common_hidden_inputs($db);
if ($cfg['PropertiesIconic']) {
echo '<img class="icon" src="' . $pmaThemeImage . 'b_view.png"'
.' alt="" width="16" height="16" />';
foreach ($delrow as $current_row) {
$del_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) . ' ' . "\n"
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'' . "\n"
. ' AND table_name = \'' . PMA_sqlAddslashes($current_row) . '\'' . "\n"
. ' AND pdf_page_number = \'' . PMA_sqlAddslashes($chpage) . '\'';
PMA_query_as_controluser($del_query, FALSE, $query_default_option);
}
echo __('Display Relational Schema');
?>:
</legend>
<select name="export_type" id="export_type">
<option value="pdf" selected="selected"><?php echo __('PDF');?></option>
<option value="svg"><?php echo __('SVG');?></option>
<option value="dia"><?php echo __('DIA');?></option>
<option value="visio"><?php echo __('VISIO');?></option>
<option value="eps"><?php echo __('EPS');?></option>
</select>
<label><?php echo __('Select Export Relational Type');?></label><br />
<?php
if (isset($test_rs)) {
?>
<label for="pdf_page_number_opt"><?php echo __('Page number:'); ?></label>
<select name="pdf_page_number" id="pdf_page_number_opt">
<?php
while ($pages = @PMA_DBI_fetch_assoc($test_rs)) {
echo ' <option value="' . $pages['page_nr'] . '">'
. $pages['page_nr'] . ': ' . htmlspecialchars($pages['page_descr']) . '</option>' . "\n";
} // end while
PMA_DBI_free_result($test_rs);
unset($test_rs);
?>
</select><br />
<?php } else { ?>
<input type="hidden" name="pdf_page_number" value="<?php echo htmlspecialchars($chpage); ?>" />
<?php } ?>
<input type="checkbox" name="show_grid" id="show_grid_opt" />
<label for="show_grid_opt"><?php echo __('Show grid'); ?></label><br />
<input type="checkbox" name="show_color" id="show_color_opt"
checked="checked" />
<label for="show_color_opt"><?php echo __('Show color'); ?></label><br />
<input type="checkbox" name="show_table_dimension" id="show_table_dim_opt" />
<label for="show_table_dim_opt"><?php echo __('Show dimension of tables'); ?>
</label><br />
<input type="checkbox" name="all_tab_same_wide" id="all_tab_same_wide" />
<label for="all_tab_same_wide"><?php echo __('Display all tables with the same width'); ?>
</label><br />
<input type="checkbox" name="with_doc" id="with_doc" checked="checked" />
<label for="with_doc"><?php echo __('Data Dictionary'); ?></label><br />
<input type="checkbox" name="show_keys" id="show_keys" />
<label for="show_keys"><?php echo __('Only show keys'); ?></label><br />
<label for="orientation_opt"><?php echo __('Data Dictionary Format'); ?></label>
<select name="orientation" id="orientation_opt">
<option value="L"><?php echo __('Landscape');?></option>
<option value="P"><?php echo __('Portrait');?></option>
</select><br />
<label for="paper_opt"><?php echo __('Paper size'); ?></label>
<select name="paper" id="paper_opt">
<?php
foreach ($cfg['PDFPageSizes'] as $key => $val) {
echo '<option value="' . $val . '"';
if ($val == $cfg['PDFDefaultPageSize']) {
echo ' selected="selected"';
}
echo ' >' . $val . '</option>' . "\n";
}
?>
</select>
</fieldset>
<fieldset class="tblFooters">
<input type="submit" value="<?php echo __('Go'); ?>" />
</fieldset>
</form>
<?php
}// end function
/**
* Check if there are tables that need to be deleted in dashboard,
* if there are, ask the user for allowance
* get all the export options and verify
* call and include the appropriate Schema Class depending on $export_type
*
* @access private
*/
public function deleteTables($chpage)
{
global $db, $table,$tabExist;
$_strtrans = '';
$_strname = '';
$shoot = FALSE;
if (!empty($tabExist) && is_array($tabExist)) {
foreach ($tabExist as $key => $value) {
if (!$value) {
$_strtrans .= '<input type="hidden" name="delrow[]" value="' . htmlspecialchars($key) . '" />' . "\n";
$_strname .= '<li>' . htmlspecialchars($key) . '</li>' . "\n";
$shoot = TRUE;
private function _processExportSchema()
{
$pdf_page_number = isset($pdf_page_number) ? $pdf_page_number : 1;
$show_grid = (isset($show_grid) && $show_grid == 'on') ? 1 : 0;
$show_color = (isset($show_color) && $show_color == 'on') ? 1 : 0;
$show_table_dimension = (isset($show_table_dimension) && $show_table_dimension == 'on') ? 1 : 0;
$all_table_same_wide = (isset($all_table_same_wide) && $all_table_same_wide == 'on') ? 1 : 0;
$with_doc = (isset($with_doc) && $with_doc == 'on') ? 1 : 0;
$orientation = (isset($orientation) && $orientation == 'P') ? 'P' : 'L';
$paper = isset($paper) ? $paper : 'A4';
$show_keys = (isset($show_keys) && $show_keys == 'on') ? 1 : 0;
$export_type = isset($export_type) ? $export_type : 'pdf'; // default is PDF
PMA_DBI_select_db($db);
include("./libraries/schema/".ucfirst($export_type)."_Relation_Schema.class.php");
$obj_schema = eval("new PMA_".ucfirst($export_type)."_Relation_Schema();");
}
}
if ($shoot) {
echo '<form action="export_relation_schema.php" method="post">' . "\n"
. PMA_generate_common_hidden_inputs($db, $table)
. '<input type="hidden" name="do" value="deleteCrap" />' . "\n"
. '<input type="hidden" name="chpage" value="' . htmlspecialchars($chpage) . '" />' . "\n"
. __('The current page has references to tables that no longer exist. Would you like to delete those references?')
. '<ul>' . "\n"
. $_strname
. '</ul>' . "\n"
. $_strtrans
. '<input type="submit" value="' . __('Go') . '" />' . "\n"
. '</form>';
}
}
} // end function
}
?>

View File

@@ -1,82 +0,0 @@
<?php
error_reporting(E_ALL | E_WARNING);
/**
* Gets some core scripts
*/
require_once './libraries/common.inc.php';
/**
* Settings for relation stuff
*/
require_once './libraries/relation.lib.php';
require_once './libraries/transformations.lib.php';
require_once './libraries/Index.class.php';
$cfgRelation = PMA_getRelationsParam();
/**
* Now in ./libraries/relation.lib.php we check for all tables
* that we need, but if we don't find them we are quiet about it
* so people can work without.
* This page is absolutely useless if you didn't set up your tables
* correctly, so it is a good place to see which tables we can and
* complain ;-)
*/
if (!$cfgRelation['pdfwork']) {
echo '<font color="red">' . __('Error') . '</font><br />' . "\n";
$url_to_goto = '<a href="' . $cfg['PmaAbsoluteUri'] . 'chk_rel.php?' . $url_query . '">';
echo sprintf(__('The additional features for working with linked tables have been deactivated. To find out why click %shere%s.'), $url_to_goto, '</a>') . "\n";
}
/**
* Main logic
*/
try
{
$pdf_page_number = isset($pdf_page_number) ? $pdf_page_number : 1;
$show_grid = (isset($show_grid) && $show_grid == 'on') ? 1 : 0;
$show_color = (isset($show_color) && $show_color == 'on') ? 1 : 0;
$show_table_dimension = (isset($show_table_dimension) && $show_table_dimension == 'on') ? 1 : 0;
$all_table_same_wide = (isset($all_table_same_wide) && $all_table_same_wide == 'on') ? 1 : 0;
$with_doc = (isset($with_doc) && $with_doc == 'on') ? 1 : 0;
$orientation = (isset($orientation) && $orientation == 'P') ? 'P' : 'L';
$paper = isset($paper) ? $paper : 'A4';
$show_keys = (isset($show_keys) && $show_keys == 'on') ? 1 : 0;
$export_type = isset($export_type) ? $export_type : 'pdf'; // default is PDF
PMA_DBI_select_db($db);
switch($export_type)
{
case 'pdf';
include_once("./libraries/schema/Pdf_Relation_Schema.class.php");
$obj_schema=new PMA_Pdf_Relation_Schema($pdf_page_number, $show_table_dimension, $show_color,
$show_grid, $all_table_same_wide, $orientation, $paper,
$show_keys
);
break;
case 'svg';
include_once("./libraries/schema/Svg_Relation_Schema.class.php");
$obj_schema=new PMA_Svg_Relation_Schema($pdf_page_number, $show_table_dimension, $show_color,
$all_table_same_wide,$show_keys);
break;
case 'dia';
include_once("./libraries/schema/Dia_Relation_Schema.class.php");
$obj_schema=new diaSchema();
break;
case 'visio';
include_once("./libraries/schema/Visio_Relation_Schema.class.php");
$obj_schema=new visioSchema();
break;
case 'eps';
include_once("./libraries/schema/Eps_Relation_Schema.class.php");
$obj_schema=new epsSchema();
break;
}
}
catch (Exception $e)
{
print('<pre>');
print_r($e);
print('</pre>');
}
?>