Fixed mime types and improve comments

This commit is contained in:
Adnan
2010-08-18 18:05:01 +05:00
parent 381ba1be0f
commit 4a4ddeadcf
6 changed files with 106 additions and 80 deletions

View File

@@ -175,7 +175,7 @@ class PMA_DIA extends XMLWriter
if(ob_get_clean()){ if(ob_get_clean()){
ob_end_clean(); ob_end_clean();
} }
//header('Content-type: text/xml'); header('Content-type: application/x-dia-diagram');
header('Content-Disposition: attachment; filename="'.$fileName.'.dia"'); header('Content-Disposition: attachment; filename="'.$fileName.'.dia"');
$output = $this->flush(); $output = $this->flush();
print $output; print $output;
@@ -227,7 +227,7 @@ class Table_Stats
$sql = 'DESCRIBE ' . PMA_backquote($tableName); $sql = 'DESCRIBE ' . PMA_backquote($tableName);
$result = PMA_DBI_try_query($sql, null, PMA_DBI_QUERY_STORE); $result = PMA_DBI_try_query($sql, null, PMA_DBI_QUERY_STORE);
if (!$result || !PMA_DBI_num_rows($result)) { if (!$result || !PMA_DBI_num_rows($result)) {
//$dia->Error(sprintf(__('The %s table doesn\'t exist!'), $tableName)); $dia->dieSchema($pageNumber,"DIA",sprintf(__('The %s table doesn\'t exist!'), $tableName));
} }
/* /*
* load fields * load fields
@@ -253,7 +253,7 @@ class Table_Stats
. ' AND pdf_page_number = ' . $pageNumber; . ' AND pdf_page_number = ' . $pageNumber;
$result = PMA_query_as_controluser($sql, false, PMA_DBI_QUERY_STORE); $result = PMA_query_as_controluser($sql, false, PMA_DBI_QUERY_STORE);
if (!$result || !PMA_DBI_num_rows($result)) { if (!$result || !PMA_DBI_num_rows($result)) {
// $dia->Error(sprintf(__('Please configure the coordinates for table %s'), $tableName)); $dia->dieSchema($pageNumber,"DIA",sprintf(__('Please configure the coordinates for table %s'), $tableName));
} }
list($this->x, $this->y) = PMA_DBI_fetch_row($result); list($this->x, $this->y) = PMA_DBI_fetch_row($result);
$this->x = (double) $this->x; $this->x = (double) $this->x;
@@ -713,10 +713,10 @@ class PMA_Dia_Relation_Schema extends PMA_Export_Relation_Schema
$dia->endDiaDoc(); $dia->endDiaDoc();
$dia->showOutput($db.'-'.$this->pageNumber); $dia->showOutput($db.'-'.$this->pageNumber);
exit(); exit();
print '<pre>'; // print '<pre>';
print_r(get_object_vars($dia)); //print_r(get_object_vars($dia));
print_r(get_object_vars($this)); //print_r(get_object_vars($this));
print '</pre>'; //print '</pre>';
} }
/** /**

View File

@@ -338,7 +338,7 @@ class PMA_EPS
// if(ob_get_clean()){ // if(ob_get_clean()){
//ob_end_clean(); //ob_end_clean();
//} //}
//header('Content-type: text/xml'); header('Content-type: image/x-eps');
header('Content-Disposition: attachment; filename="'.$fileName.'.eps"'); header('Content-Disposition: attachment; filename="'.$fileName.'.eps"');
$output = $this->stringCommands; $output = $this->stringCommands;
print $output; print $output;
@@ -400,7 +400,7 @@ class Table_Stats
$sql = 'DESCRIBE ' . PMA_backquote($tableName); $sql = 'DESCRIBE ' . PMA_backquote($tableName);
$result = PMA_DBI_try_query($sql, null, PMA_DBI_QUERY_STORE); $result = PMA_DBI_try_query($sql, null, PMA_DBI_QUERY_STORE);
if (!$result || !PMA_DBI_num_rows($result)) { if (!$result || !PMA_DBI_num_rows($result)) {
$eps->dieSchema(sprintf(__('The %s table doesn\'t exist!'), $tableName)); $eps->dieSchema($pageNumber,"EPS",sprintf(__('The %s table doesn\'t exist!'), $tableName));
} }
/* /*
@@ -441,7 +441,7 @@ class Table_Stats
$result = PMA_query_as_controluser($sql, false, PMA_DBI_QUERY_STORE); $result = PMA_query_as_controluser($sql, false, PMA_DBI_QUERY_STORE);
if (!$result || !PMA_DBI_num_rows($result)) { if (!$result || !PMA_DBI_num_rows($result)) {
//$eps->dieSchema(sprintf(__('Please configure the coordinates for table %s'), $tableName)); $eps->dieSchema($pageNumber,"EPS",sprintf(__('Please configure the coordinates for table %s'), $tableName));
} }
list($this->x, $this->y) = PMA_DBI_fetch_row($result); list($this->x, $this->y) = PMA_DBI_fetch_row($result);
$this->x = (double) $this->x; $this->x = (double) $this->x;
@@ -797,11 +797,11 @@ class PMA_Eps_Relation_Schema extends PMA_Export_Relation_Schema
$eps->endEpsDoc(); $eps->endEpsDoc();
$eps->showOutput($db.'-'.$this->pageNumber); $eps->showOutput($db.'-'.$this->pageNumber);
exit(); exit();
print '<pre>'; //print '<pre>';
print_r(get_object_vars($eps)); //print_r(get_object_vars($eps));
print_r($alltables); //print_r($alltables);
print_r(get_object_vars($this)); //print_r(get_object_vars($this));
print '</pre>'; //print '</pre>';
} }

View File

@@ -75,6 +75,17 @@ class PMA_PDF extends TCPDF
parent::_putpages(); parent::_putpages();
} }
// added because tcpdf for PHP 5 has a protected $buffer
public function getBuffer()
{
return $this->buffer;
}
public function getState()
{
return $this->state;
}
/** /**
* Sets the scaling factor, defines minimum coordinates and margins * Sets the scaling factor, defines minimum coordinates and margins
* *
@@ -196,44 +207,6 @@ class PMA_PDF extends TCPDF
* Displays an error message * Displays an error message
* *
* @param string error_message the error mesage * @param string error_message the error mesage
* @global array the PMA configuration array
* @global integer the current server id
* @global string the current language
* @global string the charset to convert to
* @global string the current database name
* @global string the current charset
* @global string the current text direction
* @global string a localized string
* @global string an other localized string
* @access public
*/
/* function PMA_PDF_die($error_message = '')
{
global $cfg;
global $server, $lang, $convcharset, $db;
global $charset, $text_dir;
require_once './libraries/header.inc.php';
echo '<p><strong>PDF - ' . __('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="db_structure.php?' . PMA_generate_common_url($db)
. '">' . __('Back') . '</a>';
echo "\n";
require_once './libraries/footer.inc.php';
}*/ // end of the "PMA_PDF_die()" function
/**
* Aliases the "Error()" function from the TCPDF class to the
* "PMA_PDF_die()" one
*
* @param string error_message the error mesage
* @access public * @access public
* @see PMA_Export_Relation_Schema::dieSchema * @see PMA_Export_Relation_Schema::dieSchema
*/ */
@@ -480,8 +453,16 @@ class PMA_PDF extends TCPDF
} }
/** /**
* Draws tables schema * Table preferences/statistics
*
* This class preserves the table co-ordinates,fields
* and helps in drawing/generating the Tables in PDF document.
* *
* @name Table_Stats
* @author Muhammad Adnan <hiddenpearls@gmail.com>
* @copyright
* @license
* @see PMA_PDF
*/ */
class Table_Stats class Table_Stats
{ {
@@ -684,10 +665,18 @@ class Table_Stats
} }
/** /**
* Draws relation links * Relation preferences/statistics
*
* This class fetches the table master and foreign fields positions
* and helps in generating the Table references and then connects
* master table's master field to foreign table's foreign key
* in PDF document.
* *
* @access public * @name Relation_Stats
* @see PMA_PDF * @author Muhammad Adnan <hiddenpearls@gmail.com>
* @copyright
* @license
* @see PMA_PDF::SetDrawColor,PMA_PDF::PMA_PDF_setLineWidthScale,PMA_PDF::PMA_PDF_lineScale
*/ */
class Relation_Stats class Relation_Stats
{ {
@@ -820,6 +809,20 @@ class Relation_Stats
} }
} }
/**
* Pdf Relation Schema Class
*
* Purpose of this class is to generate the PDF Document. PDF is widely
* used format for documenting text,fonts,images and 3d vector graphics.
*
* This class inherits Export_Relation_Schema class has common functionality added
* to this class
*
* @name Pdf_Relation_Schema
* @author Muhammad Adnan <hiddenpearls@gmail.com>
* @copyright
* @license
*/
class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
{ {
/** /**
@@ -1085,7 +1088,12 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
if (empty($filename)) { if (empty($filename)) {
$filename = $pageNumber . '.pdf'; $filename = $pageNumber . '.pdf';
} }
$pdf->Output($db . '_' . $filename, 'D'); // destination: download // instead of $pdf->Output():
$pdfData = $pdf->getPDFData();
header('Content-Type: application/pdf');
header('Content-Length: '.strlen($pdfData).'');
header('Content-disposition: attachment; filename="'.$filename.'"');
echo $pdfData;
} }
public function dataDictionaryDoc($alltables) public function dataDictionaryDoc($alltables)

View File

@@ -316,7 +316,16 @@ class PMA_SVG extends XMLWriter
} }
/** /**
* Draws tables schema * Table preferences/statistics
*
* This class preserves the table co-ordinates,fields
* and helps in drawing/generating the Tables in SVG XML document.
*
* @name Table_Stats
* @author Muhammad Adnan <hiddenpearls@gmail.com>
* @copyright
* @license
* @see PMA_SVG
*/ */
class Table_Stats class Table_Stats
{ {
@@ -360,7 +369,7 @@ class Table_Stats
$sql = 'DESCRIBE ' . PMA_backquote($tableName); $sql = 'DESCRIBE ' . PMA_backquote($tableName);
$result = PMA_DBI_try_query($sql, null, PMA_DBI_QUERY_STORE); $result = PMA_DBI_try_query($sql, null, PMA_DBI_QUERY_STORE);
if (!$result || !PMA_DBI_num_rows($result)) { if (!$result || !PMA_DBI_num_rows($result)) {
$svg->dieSchema(sprintf(__('The %s table doesn\'t exist!'), $tableName)); $svg->dieSchema($pageNumber,"SVG",sprintf(__('The %s table doesn\'t exist!'), $tableName));
} }
/* /*
@@ -402,7 +411,7 @@ class Table_Stats
$result = PMA_query_as_controluser($sql, false, PMA_DBI_QUERY_STORE); $result = PMA_query_as_controluser($sql, false, PMA_DBI_QUERY_STORE);
if (!$result || !PMA_DBI_num_rows($result)) { if (!$result || !PMA_DBI_num_rows($result)) {
//$svg->dieSchema(sprintf(__('Please configure the coordinates for table %s'), $tableName)); $svg->dieSchema($pageNumber,"SVG",sprintf(__('Please configure the coordinates for table %s'), $tableName));
} }
list($this->x, $this->y) = PMA_DBI_fetch_row($result); list($this->x, $this->y) = PMA_DBI_fetch_row($result);
$this->x = (double) $this->x; $this->x = (double) $this->x;
@@ -516,10 +525,18 @@ class Table_Stats
/** /**
* Draws relation links * Relation preferences/statistics
*
* This class fetches the table master and foreign fields positions
* and helps in generating the Table references and then connects
* master table's master field to foreign table's foreign key
* in SVG XML document.
* *
* @access public * @name Relation_Stats
* @see PMA_SVG,PMA_SVG::printElementLine * @author Muhammad Adnan <hiddenpearls@gmail.com>
* @copyright
* @license
* @see PMA_SVG::printElementLine
*/ */
class Relation_Stats class Relation_Stats
{ {
@@ -671,16 +688,16 @@ class Relation_Stats
/** /**
* Svg Relation Schema Class * Svg Relation Schema Class
* *
* Purpose of this class is to generate the SVG XML Document * Purpose of this class is to generate the SVG XML Document because
* which is used for representing the database diagrams as image in Dia IDE * SVG defines the graphics in XML format which is used for representing
* This class uses Database Table and Reference Objects of Dia and with * the database diagrams as vector image. This class actually helps
* the combination of these objects actually helps in preparing Dia XML. * in preparing SVG XML format.
* *
* Dia XML is generated by using XMLWriter php extension and this class * SVG XML is generated by using XMLWriter php extension and this class
* inherits Export_Relation_Schema class has common functionality added * inherits Export_Relation_Schema class has common functionality added
* to this class * to this class
* *
* @name Dia_Relation_Schema * @name Svg_Relation_Schema
* @author Muhammad Adnan <hiddenpearls@gmail.com> * @author Muhammad Adnan <hiddenpearls@gmail.com>
* @copyright * @copyright
* @license * @license
@@ -726,7 +743,7 @@ class PMA_Svg_Relation_Schema extends PMA_Export_Relation_Schema
$svg->SetAuthor('phpMyAdmin ' . PMA_VERSION); $svg->SetAuthor('phpMyAdmin ' . PMA_VERSION);
$svg->setFont('Arial'); $svg->setFont('Arial');
$svg->setFontSize('16px'); $svg->setFontSize('16px');
$svg->startSvgDoc('1000px','600px'); $svg->startSvgDoc('1000px','1000px');
$alltables = $this->getAllTables($db,$this->pageNumber); $alltables = $this->getAllTables($db,$this->pageNumber);
foreach ($alltables AS $table) { foreach ($alltables AS $table) {
@@ -764,11 +781,11 @@ class PMA_Svg_Relation_Schema extends PMA_Export_Relation_Schema
$svg->endSvgDoc(); $svg->endSvgDoc();
$svg->showOutput($db.'-'.$this->pageNumber); $svg->showOutput($db.'-'.$this->pageNumber);
exit(); exit();
print '<pre>'; //print '<pre>';
print_r(get_object_vars($svg)); // print_r(get_object_vars($svg));
//print_r($alltables); //print_r($alltables);
print_r($this); // print_r($this);
print '</pre>'; // print '</pre>';
} }

View File

@@ -92,7 +92,7 @@ class PMA_User_Schema
<form method="post" action="export_relation_schema.php" name="frm_create_page"> <form method="post" action="export_relation_schema.php" name="frm_create_page">
<fieldset> <fieldset>
<legend> <legend>
<?php echo __('Create a page !') . "\n"; ?> <?php echo __('Create a page') . "\n"; ?>
</legend> </legend>
<?php echo PMA_generate_common_hidden_inputs($db); ?> <?php echo PMA_generate_common_hidden_inputs($db); ?>
<input type="hidden" name="do" value="createpage" /> <input type="hidden" name="do" value="createpage" />
@@ -147,7 +147,7 @@ class PMA_User_Schema
<form method="get" action="export_relation_schema.php" name="frm_select_page"> <form method="get" action="export_relation_schema.php" name="frm_select_page">
<fieldset> <fieldset>
<legend> <legend>
<?php echo __('Please select a page to edit') . "\n"; ?> <?php echo __('Please choose a page to edit') . "\n"; ?>
</legend> </legend>
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?> <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
<input type="hidden" name="do" value="selectpage" /> <input type="hidden" name="do" value="selectpage" />
@@ -379,6 +379,7 @@ class PMA_User_Schema
<input type="hidden" name="pdf_page_number" value="<?php echo htmlspecialchars($this->choosenPage); ?>" /> <input type="hidden" name="pdf_page_number" value="<?php echo htmlspecialchars($this->choosenPage); ?>" />
<?php } ?> <?php } ?>
<input type="hidden" name="do" value="process_export" /> <input type="hidden" name="do" value="process_export" />
<input type="hidden" name="chpage" value="<?php echo $chpage; ?>" />
<input type="checkbox" name="show_grid" id="show_grid_opt" /> <input type="checkbox" name="show_grid" id="show_grid_opt" />
<label for="show_grid_opt"><?php echo __('Show grid'); ?></label><br /> <label for="show_grid_opt"><?php echo __('Show grid'); ?></label><br />
<input type="checkbox" name="show_color" id="show_color_opt" checked="checked" /> <input type="checkbox" name="show_color" id="show_color_opt" checked="checked" />

View File

@@ -160,7 +160,7 @@ class PMA_VISIO extends XMLWriter
//if(ob_get_clean()){ //if(ob_get_clean()){
//ob_end_clean(); //ob_end_clean();
//} //}
//header('Content-type: text/xml'); header('Content-type: application/visio');
header('Content-Disposition: attachment; filename="'.$fileName.'.vdx"'); header('Content-Disposition: attachment; filename="'.$fileName.'.vdx"');
$output = $this->flush(); $output = $this->flush();
print $output; print $output;
@@ -212,7 +212,7 @@ class Table_Stats
$sql = 'DESCRIBE ' . PMA_backquote($tableName); $sql = 'DESCRIBE ' . PMA_backquote($tableName);
$result = PMA_DBI_try_query($sql, null, PMA_DBI_QUERY_STORE); $result = PMA_DBI_try_query($sql, null, PMA_DBI_QUERY_STORE);
if (!$result || !PMA_DBI_num_rows($result)) { if (!$result || !PMA_DBI_num_rows($result)) {
$visio->dieSchema(sprintf(__('The %s table doesn\'t exist!'), $tableName)); $visio->dieSchema($pageNumber,"VISIO",sprintf(__('The %s table doesn\'t exist!'), $tableName));
} }
/* /*
@@ -254,7 +254,7 @@ class Table_Stats
$result = PMA_query_as_controluser($sql, false, PMA_DBI_QUERY_STORE); $result = PMA_query_as_controluser($sql, false, PMA_DBI_QUERY_STORE);
if (!$result || !PMA_DBI_num_rows($result)) { if (!$result || !PMA_DBI_num_rows($result)) {
//$visio->dieSchema(sprintf(__('Please configure the coordinates for table %s'), $tableName)); $visio->dieSchema($pageNumber,"VISIO",sprintf(__('Please configure the coordinates for table %s'), $tableName));
} }
list($this->x, $this->y) = PMA_DBI_fetch_row($result); list($this->x, $this->y) = PMA_DBI_fetch_row($result);
$this->x = (double) $this->x; $this->x = (double) $this->x;