Schema Classes structure, PDF and SVG
This commit is contained in:
124
export_relation_schema.php
Normal file
124
export_relation_schema.php
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
<?php
|
||||||
|
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @version $Id$
|
||||||
|
* @package phpMyAdmin
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets some core libraries
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once './libraries/common.inc.php';
|
||||||
|
require_once './libraries/db_common.inc.php';
|
||||||
|
require './libraries/StorageEngine.class.php';
|
||||||
|
|
||||||
|
$active_page = 'db_operations.php';
|
||||||
|
require_once './libraries/db_common.inc.php';
|
||||||
|
$url_query .= '&goto=export_relation_schema.php';
|
||||||
|
require_once './libraries/db_info.inc.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Settings for relation stuff
|
||||||
|
*/
|
||||||
|
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.
|
||||||
|
$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.
|
||||||
|
* 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['relwork']) {
|
||||||
|
echo sprintf(__('<b>%s</b> table not found or not set in %s'), 'relation', 'config.inc.php') . '<br />' . "\n"
|
||||||
|
. PMA_showDocu('relation') . "\n";
|
||||||
|
require_once './libraries/footer.inc.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$cfgRelation['displaywork']) {
|
||||||
|
echo sprintf(__('<b>%s</b> table not found or not set in %s'), 'table_info', 'config.inc.php') . '<br />' . "\n"
|
||||||
|
. PMA_showDocu('table_info') . "\n";
|
||||||
|
require_once './libraries/footer.inc.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($cfgRelation['table_coords'])){
|
||||||
|
echo sprintf(__('<b>%s</b> table not found or not set in %s'), 'table_coords', 'config.inc.php') . '<br />' . "\n"
|
||||||
|
. PMA_showDocu('table_coords') . "\n";
|
||||||
|
require_once './libraries/footer.inc.php';
|
||||||
|
}
|
||||||
|
if (!isset($cfgRelation['pdf_pages'])) {
|
||||||
|
echo sprintf(__('<b>%s</b> table not found or not set in %s'), 'pdf_page', 'config.inc.php') . '<br />' . "\n"
|
||||||
|
. PMA_showDocu('pdf_pages') . "\n";
|
||||||
|
require_once './libraries/footer.inc.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($cfgRelation['pdfwork']) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User Object Created for displaying the HTML options
|
||||||
|
* so, user can play with it and perform export of relations schema
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once './libraries/schema/user_schema.php';
|
||||||
|
$user_schema = new PMA_USER_SCHEMA();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function will process the user input
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
$user_schema->userInputProcess($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();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* After selection of page or creating a page
|
||||||
|
* 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)))) {
|
||||||
|
/**
|
||||||
|
* show Export schema generation options
|
||||||
|
*/
|
||||||
|
$user_schema->displaySchemaGenerationOptions();
|
||||||
|
|
||||||
|
if ((isset($showwysiwyg) && $showwysiwyg == '1')) {
|
||||||
|
?>
|
||||||
|
<script type="text/javascript">
|
||||||
|
//<![CDATA[
|
||||||
|
ToggleDragDrop('pdflayout');
|
||||||
|
//]]>
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
} // end if
|
||||||
|
} // end if ($cfgRelation['pdfwork'])
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays the footer
|
||||||
|
*/
|
||||||
|
echo "\n";
|
||||||
|
require_once './libraries/footer.inc.php';
|
||||||
|
?>
|
7
libraries/schema/dia_relation_schema.php
Normal file
7
libraries/schema/dia_relation_schema.php
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
include_once("relationSchema.abstract.class.php");
|
||||||
|
class PMA_DIA_RELAION_SCHEMA extends PMA_Relation_Schema
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
7
libraries/schema/eps_relation_chema.php
Normal file
7
libraries/schema/eps_relation_chema.php
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
include_once("relationSchema.abstract.class.php");
|
||||||
|
class PMA_PDF_RELAION_SCHEMA extends PMA_Relation_Schema
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
1338
libraries/schema/pdf_relation_schema.php
Normal file
1338
libraries/schema/pdf_relation_schema.php
Normal file
File diff suppressed because it is too large
Load Diff
71
libraries/schema/relation_schema.php
Normal file
71
libraries/schema/relation_schema.php
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
// Using Abstract Factory Pattern for exporting relational Schema in different Formats !
|
||||||
|
abstract class PMA_Relation_Schema
|
||||||
|
{
|
||||||
|
private $_pageTitle; // Title of the page
|
||||||
|
private $_autoLayoutType; // Internal or Foreign Key Relations;
|
||||||
|
protected $same_wide;
|
||||||
|
|
||||||
|
public function setPageTitle($title)
|
||||||
|
{
|
||||||
|
$this->_pageTitle=$title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setExportType($type)
|
||||||
|
{
|
||||||
|
$this->_pageTitle=$title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setSameWidthTables($width)
|
||||||
|
{
|
||||||
|
$this->same_wide=$width;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAllTables($db,$page_number)
|
||||||
|
{
|
||||||
|
global $cfgRelation;
|
||||||
|
// Get All tables
|
||||||
|
$tab_sql = 'SELECT table_name FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
|
||||||
|
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
|
||||||
|
. ' AND pdf_page_number = ' . $page_number;
|
||||||
|
// echo $tab_sql;
|
||||||
|
$tab_rs = PMA_query_as_controluser($tab_sql, null, PMA_DBI_QUERY_STORE);
|
||||||
|
if (!$tab_rs || !PMA_DBI_num_rows($tab_rs) > 0) {
|
||||||
|
$this->PMA_SCHEMA_die('',__('No tables'));
|
||||||
|
} while ($curr_table = @PMA_DBI_fetch_assoc($tab_rs)) {
|
||||||
|
$alltables[] = PMA_sqlAddslashes($curr_table['table_name']);
|
||||||
|
}
|
||||||
|
return $alltables;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function initTable()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays an error message
|
||||||
|
*/
|
||||||
|
function PMA_Schema_die($type = '',$error_message = '')
|
||||||
|
{
|
||||||
|
global $db;
|
||||||
|
|
||||||
|
require_once './libraries/header.inc.php';
|
||||||
|
|
||||||
|
echo "<p><strong> {$type} " . __("SCHEMA ERROR") . "</strong></p>" . "\n";
|
||||||
|
if (!empty($error_message)) {
|
||||||
|
$error_message = htmlspecialchars($error_message);
|
||||||
|
}
|
||||||
|
echo '<p>' . "\n";
|
||||||
|
echo ' ' . $error_message . "\n";
|
||||||
|
echo '</p>' . "\n";
|
||||||
|
|
||||||
|
echo '<a href="export_relation_schema.php?' . PMA_generate_common_url($db)
|
||||||
|
. '">' . __('Back') . '</a>';
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
require_once './libraries/footer.inc.php';
|
||||||
|
} // end of the "PMA_PDF_die()" function
|
||||||
|
}
|
||||||
|
?>
|
127
libraries/schema/svg_relation_schema.php
Normal file
127
libraries/schema/svg_relation_schema.php
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
<?php
|
||||||
|
include_once("relation_schema.php");
|
||||||
|
class PMA_SVG extends XMLWriter
|
||||||
|
{
|
||||||
|
public $title;
|
||||||
|
public $author;
|
||||||
|
public $font;
|
||||||
|
public $fontSize;
|
||||||
|
|
||||||
|
function __construct()
|
||||||
|
{
|
||||||
|
//$writer = new XMLWriter();
|
||||||
|
$this->openMemory();
|
||||||
|
/* Set indenting using three spaces, so output is formatted */
|
||||||
|
$this->setIndent(TRUE);
|
||||||
|
$this->setIndentString(' ');
|
||||||
|
/* Create the XML document */
|
||||||
|
$this->startDocument('1.0','UTF-8');
|
||||||
|
$this->startDtd('svg','-//W3C//DTD SVG 1.1//EN','http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd');
|
||||||
|
$this->endDtd();
|
||||||
|
}
|
||||||
|
|
||||||
|
function setTitle($title)
|
||||||
|
{
|
||||||
|
$this->title=$title;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setAuthor($author)
|
||||||
|
{
|
||||||
|
$this->author=$author;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setFont($font)
|
||||||
|
{
|
||||||
|
$this->font=$font;
|
||||||
|
}
|
||||||
|
function setFontSize($fontSize)
|
||||||
|
{
|
||||||
|
$this->fontSize=$fontSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
function startSvgDoc($width,$height)
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->startElement('svg');
|
||||||
|
$this->writeAttribute('width', $width);
|
||||||
|
$this->writeAttribute('height', $height);
|
||||||
|
$this->writeAttribute('xmlns', 'http://www.w3.org/2000/svg');
|
||||||
|
$this->writeAttribute('version', '1.1');
|
||||||
|
}
|
||||||
|
|
||||||
|
function endSvgDoc()
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->endElement();
|
||||||
|
$this->endDocument();
|
||||||
|
}
|
||||||
|
|
||||||
|
function showOutput()
|
||||||
|
{
|
||||||
|
|
||||||
|
header('Content-type: image/svg+xml');
|
||||||
|
$output = $this->flush();
|
||||||
|
print $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
function printElement($name,$x,$y,$width='',$height='',$text='',$styles='')
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->startElement($name);
|
||||||
|
$this->writeAttribute('width',$width);
|
||||||
|
$this->writeAttribute('height',$height);
|
||||||
|
$this->writeAttribute('x', $x);
|
||||||
|
$this->writeAttribute('y', $y);
|
||||||
|
$this->writeAttribute('style', $styles);
|
||||||
|
if(isset($text)){
|
||||||
|
$this->writeAttribute('font-family', $this->font);
|
||||||
|
$this->writeAttribute('font-size', $this->fontSize);
|
||||||
|
$this->text($text);
|
||||||
|
}
|
||||||
|
$this->endElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class PMA_SVG_RELAION_SCHEMA extends PMA_Relation_Schema
|
||||||
|
{
|
||||||
|
|
||||||
|
function __construct($page_number, $show_info = 0, $change_color = 0, $all_table_same_wide = 0, $show_keys = 0)
|
||||||
|
{
|
||||||
|
//global $pdf, $db, $cfgRelation, $with_doc;
|
||||||
|
global $db,$writer;
|
||||||
|
|
||||||
|
$svg = new PMA_SVG();
|
||||||
|
$this->setSameWidthTables($all_table_same_wide);
|
||||||
|
|
||||||
|
$svg->setTitle(sprintf(__('Schema of the %s database - Page %s'), $db, $page_number));
|
||||||
|
$svg->SetAuthor('phpMyAdmin ' . PMA_VERSION);
|
||||||
|
$svg->setFont('Arial');
|
||||||
|
$svg->setFontSize('16px');
|
||||||
|
$svg->startSvgDoc('500px','500px');
|
||||||
|
$svg->printElement('rect',0,0,'100','100',NULL,'fill:none;stroke:black;');
|
||||||
|
$svg->printElement('text',100,100,'100','100','this is just a test');
|
||||||
|
$svg->endSvgDoc();
|
||||||
|
$svg->showOutput();
|
||||||
|
//echo $svg->getTitle();
|
||||||
|
/* $alltables=$this->getAllTables($db,$page_number);
|
||||||
|
foreach ($alltables AS $table) {
|
||||||
|
if (!isset($this->tables[$table])) {
|
||||||
|
$this->tables[$table] = new PMA_RT_Table($table, $this->ff, $this->_tablewidth, $show_keys, $show_info);
|
||||||
|
// $this->tables[$table]=$table;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->same_wide) {
|
||||||
|
$this->tables[$table]->width = $this->_tablewidth;
|
||||||
|
}
|
||||||
|
$this->PMA_RT_setMinMax($this->tables[$table]);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
/* print '<pre>';
|
||||||
|
print_r(get_object_vars($svg));
|
||||||
|
print_r($this);
|
||||||
|
print '</pre>';
|
||||||
|
exit();*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
636
libraries/schema/user_schema.php
Normal file
636
libraries/schema/user_schema.php
Normal file
@@ -0,0 +1,636 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This Class will interact with the user to gather the information
|
||||||
|
* about their tables for which they want to export the relational schema
|
||||||
|
*/
|
||||||
|
|
||||||
|
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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function userInputProcess($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':
|
||||||
|
if ($action_choose=="1") {
|
||||||
|
$ch_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
|
||||||
|
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
|
||||||
|
. ' AND pdf_page_number = \'' . PMA_sqlAddslashes($chpage) . '\'';
|
||||||
|
PMA_query_as_controluser($ch_query, FALSE, $query_default_option);
|
||||||
|
|
||||||
|
$ch_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages'])
|
||||||
|
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
|
||||||
|
. ' AND page_nr = \'' . PMA_sqlAddslashes($chpage) . '\'';
|
||||||
|
PMA_query_as_controluser($ch_query, FALSE, $query_default_option);
|
||||||
|
|
||||||
|
unset($chpage);
|
||||||
|
}
|
||||||
|
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
|
||||||
|
// ================================
|
||||||
|
if (isset($auto_layout_internal) || isset($auto_layout_foreign)) {
|
||||||
|
$all_tables = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($auto_layout_foreign)) {
|
||||||
|
// get the tables list
|
||||||
|
$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'])) {
|
||||||
|
$foreignkey_tables[] = $table_name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$all_tables = $foreignkey_tables;
|
||||||
|
// could be improved by finding the tables which have the
|
||||||
|
// 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
|
||||||
|
$master_tables = 'SELECT COUNT(master_table), master_table'
|
||||||
|
. ' FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation'])
|
||||||
|
. ' WHERE master_db = \'' . $db . '\''
|
||||||
|
. ' GROUP BY master_table'
|
||||||
|
. ' 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
|
||||||
|
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)
|
||||||
|
|
||||||
|
$foreign_tables = array();
|
||||||
|
foreach ($all_tables as $master_table) {
|
||||||
|
$foreigners = PMA_getForeigners($db, $master_table);
|
||||||
|
foreach ($foreigners as $foreigner) {
|
||||||
|
if (!in_array($foreigner['foreign_table'], $foreign_tables)) {
|
||||||
|
$foreign_tables[] = $foreigner['foreign_table'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// then merge the arrays
|
||||||
|
foreach ($foreign_tables as $foreign_table) {
|
||||||
|
if (!in_array($foreign_table, $all_tables)) {
|
||||||
|
$all_tables[] = $foreign_table;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // endif there are master tables
|
||||||
|
} // endif auto_layout_internal
|
||||||
|
|
||||||
|
if (isset($auto_layout_internal) || isset($auto_layout_foreign)) {
|
||||||
|
// 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
|
||||||
|
$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
|
||||||
|
switch ($direction) {
|
||||||
|
case 'right':
|
||||||
|
$pos_x += $delta;
|
||||||
|
$direction = "down";
|
||||||
|
$delta *= $delta_mult;
|
||||||
|
break;
|
||||||
|
case 'down':
|
||||||
|
$pos_y += $delta;
|
||||||
|
$direction = "left";
|
||||||
|
$delta *= $delta_mult;
|
||||||
|
break;
|
||||||
|
case 'left':
|
||||||
|
$pos_x -= $delta;
|
||||||
|
$direction = "up";
|
||||||
|
$delta *= $delta_mult;
|
||||||
|
break;
|
||||||
|
case 'up':
|
||||||
|
$pos_y -= $delta;
|
||||||
|
$direction = "right";
|
||||||
|
$delta *= $delta_mult;
|
||||||
|
break;
|
||||||
|
} // end switch
|
||||||
|
} // end foreach
|
||||||
|
} // end if some auto-layout to do
|
||||||
|
|
||||||
|
$chpage = $pdf_page_number;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'edcoord':
|
||||||
|
for ($i = 0; $i < $c_table_rows; $i++) {
|
||||||
|
$arrvalue = 'c_table_' . $i;
|
||||||
|
global $$arrvalue;
|
||||||
|
$arrvalue = $$arrvalue;
|
||||||
|
if (!isset($arrvalue['x']) || $arrvalue['x'] == '') {
|
||||||
|
$arrvalue['x'] = 0;
|
||||||
|
}
|
||||||
|
if (!isset($arrvalue['y']) || $arrvalue['y'] == '') {
|
||||||
|
$arrvalue['y'] = 0;
|
||||||
|
}
|
||||||
|
if (isset($arrvalue['name']) && $arrvalue['name'] != '--') {
|
||||||
|
$test_query = 'SELECT * FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
|
||||||
|
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
|
||||||
|
. ' AND table_name = \'' . PMA_sqlAddslashes($arrvalue['name']) . '\''
|
||||||
|
. ' AND pdf_page_number = \'' . PMA_sqlAddslashes($chpage) . '\'';
|
||||||
|
// echo $test_query;
|
||||||
|
$test_rs = PMA_query_as_controluser($test_query, FALSE, $query_default_option);
|
||||||
|
if ($test_rs && PMA_DBI_num_rows($test_rs) > 0) {
|
||||||
|
if (isset($arrvalue['delete']) && $arrvalue['delete'] == 'y') {
|
||||||
|
$ch_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
|
||||||
|
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
|
||||||
|
. ' AND table_name = \'' . PMA_sqlAddslashes($arrvalue['name']) . '\''
|
||||||
|
. ' AND pdf_page_number = \'' . PMA_sqlAddslashes($chpage) . '\'';
|
||||||
|
} else {
|
||||||
|
$ch_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']) . ' '
|
||||||
|
. 'SET x = ' . $arrvalue['x'] . ', y= ' . $arrvalue['y']
|
||||||
|
. ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
|
||||||
|
. ' AND table_name = \'' . PMA_sqlAddslashes($arrvalue['name']) . '\''
|
||||||
|
. ' AND pdf_page_number = \'' . PMA_sqlAddslashes($chpage) . '\'';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$ch_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($arrvalue['name']) . '\', \'' . PMA_sqlAddslashes($chpage) . '\',' . $arrvalue['x'] . ',' . $arrvalue['y'] . ')';
|
||||||
|
}
|
||||||
|
//echo $ch_query;
|
||||||
|
PMA_query_as_controluser($ch_query, FALSE, $query_default_option);
|
||||||
|
} // 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);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
} // end switch
|
||||||
|
} // end if (isset($do))
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function shows/displays the HTML FORM to create the page
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function createPage()
|
||||||
|
{
|
||||||
|
global $db,$table;
|
||||||
|
?>
|
||||||
|
<form method="post" action="export_relation_schema.php" name="frm_create_page">
|
||||||
|
<fieldset>
|
||||||
|
<legend>
|
||||||
|
<?php echo __('Create a page !') . "\n"; ?>
|
||||||
|
</legend>
|
||||||
|
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
|
||||||
|
<input type="hidden" name="do" value="createpage" />
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td><label for="id_newpage"><?php echo __('Page name'); ?></label></td>
|
||||||
|
<td><input type="text" name="newpage" id="id_newpage" size="20" maxlength="50" /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo __('Automatic layout based on'); ?></td>
|
||||||
|
<td>
|
||||||
|
<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">
|
||||||
|
<?php echo __('FOREIGN KEY'); ?></label><br />
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</td></tr>
|
||||||
|
</table>
|
||||||
|
</fieldset>
|
||||||
|
<fieldset class="tblFooters">
|
||||||
|
<input type="submit" value="<?php echo __('Go'); ?>" />
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function shows/displays the created page names
|
||||||
|
* All page names in a list
|
||||||
|
* User can select any page number and edit it using dashboard etc
|
||||||
|
*/
|
||||||
|
public function selectPage()
|
||||||
|
{
|
||||||
|
global $db,$table,$query_default_option,$cfgRelation;
|
||||||
|
$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) {
|
||||||
|
?>
|
||||||
|
<form method="get" action="export_relation_schema.php" name="frm_select_page">
|
||||||
|
<fieldset>
|
||||||
|
<legend>
|
||||||
|
<?php echo __('Please select a page to edit') . "\n"; ?>
|
||||||
|
</legend>
|
||||||
|
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
|
||||||
|
<input type="hidden" name="do" value="selectpage" />
|
||||||
|
<select name="chpage" onchange="this.form.submit()">
|
||||||
|
<?php
|
||||||
|
while ($curr_page = PMA_DBI_fetch_assoc($page_rs)) {
|
||||||
|
echo "\n" . ' '
|
||||||
|
. '<option value="' . $curr_page['page_nr'] . '"';
|
||||||
|
if (isset($chpage) && $chpage == $curr_page['page_nr']) {
|
||||||
|
echo ' selected="selected"';
|
||||||
|
}
|
||||||
|
echo '>' . $curr_page['page_nr'] . ': ' . htmlspecialchars($curr_page['page_descr']) . '</option>';
|
||||||
|
} // end while
|
||||||
|
echo "\n";
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
<?php
|
||||||
|
$choices = array(
|
||||||
|
'0' => __('Edit'),
|
||||||
|
'1' => __('Delete'));
|
||||||
|
PMA_display_html_radio('action_choose', $choices, '0', false);
|
||||||
|
unset($choices);
|
||||||
|
?>
|
||||||
|
</fieldset>
|
||||||
|
<fieldset class="tblFooters">
|
||||||
|
<input type="submit" value="<?php echo __('Go'); ?>" /><br />
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
<?php
|
||||||
|
} // end IF
|
||||||
|
echo "\n";
|
||||||
|
} // end function
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A dashboard will also be shown where you can position the tables
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
$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
|
||||||
|
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) . '\''
|
||||||
|
. ' AND pdf_page_number = \'' . PMA_sqlAddslashes($chpage) . '\'';
|
||||||
|
$page_rs = PMA_query_as_controluser($page_query, FALSE, $query_default_option);
|
||||||
|
$array_sh_page = array();
|
||||||
|
$draginit = '';
|
||||||
|
$reset_draginit = '';
|
||||||
|
$i = 0;
|
||||||
|
while ($temp_sh_page = @PMA_DBI_fetch_assoc($page_rs)) {
|
||||||
|
$array_sh_page[] = $temp_sh_page;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Display WYSIWYG-PDF parts?
|
||||||
|
if ($cfg['WYSIWYG-PDF']) {
|
||||||
|
if (!isset($_POST['with_field_names']) && !isset($_POST['showwysiwyg'])) {
|
||||||
|
$with_field_names = TRUE;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<script type="text/javascript" src="./js/dom-drag.js"></script>
|
||||||
|
<form method="post" action="export_relation_schema.php" name="dragdrop">
|
||||||
|
<input type="button" name="dragdrop" value="<?php echo __('Toggle scratchboard'); ?>" onclick="ToggleDragDrop('pdflayout');" />
|
||||||
|
<input type="button" name="dragdropreset" value="<?php echo __('Reset'); ?>" onclick="resetDrag();" />
|
||||||
|
</form>
|
||||||
|
<div id="pdflayout" class="pdflayout" style="visibility: hidden;">
|
||||||
|
<?php
|
||||||
|
foreach ($array_sh_page as $key => $temp_sh_page) {
|
||||||
|
$drag_x = $temp_sh_page['x'];
|
||||||
|
$drag_y = $temp_sh_page['y'];
|
||||||
|
|
||||||
|
$draginit .= ' Drag.init(getElement("table_' . $i . '"), null, 0, parseInt(myid.style.width)-2, 0, parseInt(myid.style.height)-5);' . "\n";
|
||||||
|
$draginit .= ' 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";
|
||||||
|
$draginit .= ' getElement("table_' . $i . '").style.left = "' . $drag_x . 'px";' . "\n";
|
||||||
|
$draginit .= ' getElement("table_' . $i . '").style.top = "' . $drag_y . 'px";' . "\n";
|
||||||
|
$reset_draginit .= ' getElement("table_' . $i . '").style.left = "2px";' . "\n";
|
||||||
|
$reset_draginit .= ' getElement("table_' . $i . '").style.top = "' . (15 * $i) . 'px";' . "\n";
|
||||||
|
$reset_draginit .= ' document.edcoord.elements["c_table_' . $i . '[x]"].value = "2"' . "\n";
|
||||||
|
$reset_draginit .= ' document.edcoord.elements["c_table_' . $i . '[y]"].value = "' . (15 * $i) . '"' . "\n";
|
||||||
|
|
||||||
|
$local_query = 'SHOW FIELDS FROM '
|
||||||
|
. PMA_backquote($temp_sh_page['table_name'])
|
||||||
|
. ' FROM ' . PMA_backquote($db);
|
||||||
|
$fields_rs = PMA_DBI_query($local_query);
|
||||||
|
unset($local_query);
|
||||||
|
$fields_cnt = PMA_DBI_num_rows($fields_rs);
|
||||||
|
|
||||||
|
echo '<div id="table_' . $i . '" class="pdflayout_table"><u>' . $temp_sh_page['table_name'] . '</u>';
|
||||||
|
if (isset($with_field_names)) {
|
||||||
|
while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
|
||||||
|
echo '<br />' . htmlspecialchars($row['Field']) . "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo '</div>' . "\n";
|
||||||
|
PMA_DBI_free_result($fields_rs);
|
||||||
|
unset($fields_rs);
|
||||||
|
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
//<![CDATA[
|
||||||
|
function PDFinit() {
|
||||||
|
refreshLayout();
|
||||||
|
myid = getElement('pdflayout');
|
||||||
|
<?php echo $draginit; ?>
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetDrag() {
|
||||||
|
<?php echo $reset_draginit; ?>
|
||||||
|
}
|
||||||
|
//]]>
|
||||||
|
</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
|
||||||
|
*/
|
||||||
|
public function displaySchemaGenerationOptions()
|
||||||
|
{
|
||||||
|
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" />';
|
||||||
|
}
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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
|
||||||
|
}
|
||||||
|
?>
|
7
libraries/schema/visio_relation_schema.php
Normal file
7
libraries/schema/visio_relation_schema.php
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
include_once("relationSchema.abstract.class.php");
|
||||||
|
class PMA_PDF_RELAION_SCHEMA extends PMA_Relation_Schema
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
82
process_relation_schema.php
Normal file
82
process_relation_schema.php
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
<?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.php");
|
||||||
|
$obj_schema=new PMA_PDF_RELAION_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.php");
|
||||||
|
$obj_schema=new PMA_SVG_RELAION_SCHEMA($pdf_page_number, $show_table_dimension, $show_color,
|
||||||
|
$all_table_same_wide,$show_keys);
|
||||||
|
break;
|
||||||
|
case 'dia';
|
||||||
|
include_once("./libraries/schema/diaSchema.class.php");
|
||||||
|
$obj_schema=new diaSchema();
|
||||||
|
break;
|
||||||
|
case 'visio';
|
||||||
|
include_once("./libraries/schema/visioSchema.class.php");
|
||||||
|
$obj_schema=new visioSchema();
|
||||||
|
break;
|
||||||
|
case 'eps';
|
||||||
|
include_once("./libraries/schema/epsSchema.class.php");
|
||||||
|
$obj_schema=new epsSchema();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception $e)
|
||||||
|
{
|
||||||
|
print('<pre>');
|
||||||
|
print_r($e);
|
||||||
|
print('</pre>');
|
||||||
|
}
|
||||||
|
?>
|
Reference in New Issue
Block a user