From 4a4ddeadcf85f11edf580894d754ade80cb975be Mon Sep 17 00:00:00 2001 From: Adnan Date: Wed, 18 Aug 2010 18:05:01 +0500 Subject: [PATCH] Fixed mime types and improve comments --- .../schema/Dia_Relation_Schema.class.php | 14 +-- .../schema/Eps_Relation_Schema.class.php | 16 ++-- .../schema/Pdf_Relation_Schema.class.php | 94 ++++++++++--------- .../schema/Svg_Relation_Schema.class.php | 51 ++++++---- libraries/schema/User_Schema.class.php | 5 +- .../schema/Visio_Relation_Schema.class.php | 6 +- 6 files changed, 106 insertions(+), 80 deletions(-) diff --git a/libraries/schema/Dia_Relation_Schema.class.php b/libraries/schema/Dia_Relation_Schema.class.php index af9ce2066..97ac28a19 100644 --- a/libraries/schema/Dia_Relation_Schema.class.php +++ b/libraries/schema/Dia_Relation_Schema.class.php @@ -175,7 +175,7 @@ class PMA_DIA extends XMLWriter if(ob_get_clean()){ ob_end_clean(); } - //header('Content-type: text/xml'); + header('Content-type: application/x-dia-diagram'); header('Content-Disposition: attachment; filename="'.$fileName.'.dia"'); $output = $this->flush(); print $output; @@ -227,7 +227,7 @@ class Table_Stats $sql = 'DESCRIBE ' . PMA_backquote($tableName); $result = PMA_DBI_try_query($sql, null, PMA_DBI_QUERY_STORE); 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 @@ -253,7 +253,7 @@ class Table_Stats . ' AND pdf_page_number = ' . $pageNumber; $result = PMA_query_as_controluser($sql, false, PMA_DBI_QUERY_STORE); 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); $this->x = (double) $this->x; @@ -713,10 +713,10 @@ class PMA_Dia_Relation_Schema extends PMA_Export_Relation_Schema $dia->endDiaDoc(); $dia->showOutput($db.'-'.$this->pageNumber); exit(); - print '
';
-        print_r(get_object_vars($dia));
-        print_r(get_object_vars($this));
-        print '
'; + // print '
';
+        //print_r(get_object_vars($dia));
+        //print_r(get_object_vars($this));
+        //print '
'; } /** diff --git a/libraries/schema/Eps_Relation_Schema.class.php b/libraries/schema/Eps_Relation_Schema.class.php index d22e43ce1..07c3417d2 100644 --- a/libraries/schema/Eps_Relation_Schema.class.php +++ b/libraries/schema/Eps_Relation_Schema.class.php @@ -338,7 +338,7 @@ class PMA_EPS // if(ob_get_clean()){ //ob_end_clean(); //} - //header('Content-type: text/xml'); + header('Content-type: image/x-eps'); header('Content-Disposition: attachment; filename="'.$fileName.'.eps"'); $output = $this->stringCommands; print $output; @@ -400,7 +400,7 @@ class Table_Stats $sql = 'DESCRIBE ' . PMA_backquote($tableName); $result = PMA_DBI_try_query($sql, null, PMA_DBI_QUERY_STORE); 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); 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); $this->x = (double) $this->x; @@ -797,11 +797,11 @@ class PMA_Eps_Relation_Schema extends PMA_Export_Relation_Schema $eps->endEpsDoc(); $eps->showOutput($db.'-'.$this->pageNumber); exit(); - print '
';
-        print_r(get_object_vars($eps));
-        print_r($alltables);
-        print_r(get_object_vars($this));
-        print '
'; + //print '
';
+        //print_r(get_object_vars($eps));
+        //print_r($alltables);
+        //print_r(get_object_vars($this));
+        //print '
'; } diff --git a/libraries/schema/Pdf_Relation_Schema.class.php b/libraries/schema/Pdf_Relation_Schema.class.php index 28424bffa..829798137 100644 --- a/libraries/schema/Pdf_Relation_Schema.class.php +++ b/libraries/schema/Pdf_Relation_Schema.class.php @@ -75,6 +75,17 @@ class PMA_PDF extends TCPDF 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 * @@ -196,44 +207,6 @@ class PMA_PDF extends TCPDF * Displays an error message * * @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 '

PDF - ' . __('Error') . '

' . "\n"; - if (!empty($error_message)) { - $error_message = htmlspecialchars($error_message); - } - echo '

' . "\n"; - echo ' ' . $error_message . "\n"; - echo '

' . "\n"; - - echo '' . __('Back') . ''; - 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 * @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 + * @copyright + * @license + * @see PMA_PDF */ 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 - * @see PMA_PDF + * @name Relation_Stats + * @author Muhammad Adnan + * @copyright + * @license + * @see PMA_PDF::SetDrawColor,PMA_PDF::PMA_PDF_setLineWidthScale,PMA_PDF::PMA_PDF_lineScale */ 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 + * @copyright + * @license + */ 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)) { $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) diff --git a/libraries/schema/Svg_Relation_Schema.class.php b/libraries/schema/Svg_Relation_Schema.class.php index a6b809531..8714abcaf 100644 --- a/libraries/schema/Svg_Relation_Schema.class.php +++ b/libraries/schema/Svg_Relation_Schema.class.php @@ -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 + * @copyright + * @license + * @see PMA_SVG */ class Table_Stats { @@ -360,7 +369,7 @@ class Table_Stats $sql = 'DESCRIBE ' . PMA_backquote($tableName); $result = PMA_DBI_try_query($sql, null, PMA_DBI_QUERY_STORE); 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); 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); $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 - * @see PMA_SVG,PMA_SVG::printElementLine + * @name Relation_Stats + * @author Muhammad Adnan + * @copyright + * @license + * @see PMA_SVG::printElementLine */ class Relation_Stats { @@ -671,16 +688,16 @@ class Relation_Stats /** * Svg Relation Schema Class * - * Purpose of this class is to generate the SVG XML Document - * which is used for representing the database diagrams as image in Dia IDE - * This class uses Database Table and Reference Objects of Dia and with - * the combination of these objects actually helps in preparing Dia XML. + * Purpose of this class is to generate the SVG XML Document because + * SVG defines the graphics in XML format which is used for representing + * the database diagrams as vector image. This class actually helps + * 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 * to this class * - * @name Dia_Relation_Schema + * @name Svg_Relation_Schema * @author Muhammad Adnan * @copyright * @license @@ -726,7 +743,7 @@ class PMA_Svg_Relation_Schema extends PMA_Export_Relation_Schema $svg->SetAuthor('phpMyAdmin ' . PMA_VERSION); $svg->setFont('Arial'); $svg->setFontSize('16px'); - $svg->startSvgDoc('1000px','600px'); + $svg->startSvgDoc('1000px','1000px'); $alltables = $this->getAllTables($db,$this->pageNumber); foreach ($alltables AS $table) { @@ -764,11 +781,11 @@ class PMA_Svg_Relation_Schema extends PMA_Export_Relation_Schema $svg->endSvgDoc(); $svg->showOutput($db.'-'.$this->pageNumber); exit(); - print '
';
-        print_r(get_object_vars($svg));
+        //print '
';
+       // print_r(get_object_vars($svg));
         //print_r($alltables);
-        print_r($this);
-        print '
'; + // print_r($this); + // print '
'; } diff --git a/libraries/schema/User_Schema.class.php b/libraries/schema/User_Schema.class.php index 63020a206..93b5c9dad 100644 --- a/libraries/schema/User_Schema.class.php +++ b/libraries/schema/User_Schema.class.php @@ -92,7 +92,7 @@ class PMA_User_Schema
- + @@ -147,7 +147,7 @@ class PMA_User_Schema
- + @@ -379,6 +379,7 @@ class PMA_User_Schema +
diff --git a/libraries/schema/Visio_Relation_Schema.class.php b/libraries/schema/Visio_Relation_Schema.class.php index e41cdcc4c..472785c71 100644 --- a/libraries/schema/Visio_Relation_Schema.class.php +++ b/libraries/schema/Visio_Relation_Schema.class.php @@ -160,7 +160,7 @@ class PMA_VISIO extends XMLWriter //if(ob_get_clean()){ //ob_end_clean(); //} - //header('Content-type: text/xml'); + header('Content-type: application/visio'); header('Content-Disposition: attachment; filename="'.$fileName.'.vdx"'); $output = $this->flush(); print $output; @@ -212,7 +212,7 @@ class Table_Stats $sql = 'DESCRIBE ' . PMA_backquote($tableName); $result = PMA_DBI_try_query($sql, null, PMA_DBI_QUERY_STORE); 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); 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); $this->x = (double) $this->x;