Use plugins for extension and MIME type.
This commit is contained in:
@@ -22,6 +22,7 @@ $Source$
|
|||||||
plugins are independant piece of code (RFE #1325937).
|
plugins are independant piece of code (RFE #1325937).
|
||||||
* db_operations.php, tbl_properties_operations.php,
|
* db_operations.php, tbl_properties_operations.php,
|
||||||
libraries/Table.class.php: Adapt to changes in export.
|
libraries/Table.class.php: Adapt to changes in export.
|
||||||
|
* export.php, libraries/export/*: Use plugins for extension and MIME type.
|
||||||
|
|
||||||
2006-04-26 Sebastian Mendel <cybot_tm@users.sourceforge.net>
|
2006-04-26 Sebastian Mendel <cybot_tm@users.sourceforge.net>
|
||||||
* themes/*:
|
* themes/*:
|
||||||
|
55
export.php
55
export.php
@@ -7,14 +7,19 @@
|
|||||||
*/
|
*/
|
||||||
require_once('./libraries/common.lib.php');
|
require_once('./libraries/common.lib.php');
|
||||||
require_once('./libraries/zip.lib.php');
|
require_once('./libraries/zip.lib.php');
|
||||||
|
require_once('./libraries/plugin_interface.lib.php');
|
||||||
|
|
||||||
PMA_checkParameters(array('what', 'export_type'));
|
PMA_checkParameters(array('what', 'export_type'));
|
||||||
|
|
||||||
// What type of export are we doing?
|
// Scan plugins
|
||||||
if ($what == 'excel') {
|
$export_list = PMA_getPlugins('./libraries/export/', array('export_type' => $export_type, 'single_table' => isset($single_table)));
|
||||||
$type = 'csv';
|
|
||||||
} else {
|
// Backward compatbility
|
||||||
$type = $what;
|
$type = $what;
|
||||||
|
|
||||||
|
// Check export type
|
||||||
|
if (!isset($export_list[$type])) {
|
||||||
|
die('Bad type!');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the functions specific to the export type
|
// Get the functions specific to the export type
|
||||||
@@ -224,37 +229,9 @@ if ($asfile) {
|
|||||||
$filename = PMA_convert_string($convcharset, 'iso-8859-1', $filename);
|
$filename = PMA_convert_string($convcharset, 'iso-8859-1', $filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate basic dump extension
|
// Grab basic dump extension and mime type
|
||||||
if ($type == 'csv') {
|
$filename .= '.' . $export_list[$type]['extension'];
|
||||||
$filename .= '.csv';
|
$mime_type = $export_list[$type]['mime_type'];
|
||||||
$mime_type = 'text/comma-separated-values';
|
|
||||||
} elseif ($type == 'htmlexcel') {
|
|
||||||
$filename .= '.xls';
|
|
||||||
$mime_type = 'application/vnd.ms-excel';
|
|
||||||
} elseif ($type == 'htmlword') {
|
|
||||||
$filename .= '.doc';
|
|
||||||
$mime_type = 'application/vnd.ms-word';
|
|
||||||
} elseif ($type == 'xls') {
|
|
||||||
$filename .= '.xls';
|
|
||||||
$mime_type = 'application/vnd.ms-excel';
|
|
||||||
} elseif ($type == 'xml') {
|
|
||||||
$filename .= '.xml';
|
|
||||||
$mime_type = 'text/xml';
|
|
||||||
} elseif ($type == 'latex') {
|
|
||||||
$filename .= '.tex';
|
|
||||||
$mime_type = 'application/x-tex';
|
|
||||||
} elseif ($type == 'pdf') {
|
|
||||||
$filename .= '.pdf';
|
|
||||||
$mime_type = 'application/pdf';
|
|
||||||
} else {
|
|
||||||
$filename .= '.sql';
|
|
||||||
// text/x-sql is correct MIME type, however safari ignores further
|
|
||||||
// Content-Disposition header, so we must force it to download it this
|
|
||||||
// way...
|
|
||||||
$mime_type = PMA_USR_BROWSER_AGENT == 'SAFARI'
|
|
||||||
? 'application/octet-stream'
|
|
||||||
: 'text/x-sql';
|
|
||||||
}
|
|
||||||
|
|
||||||
// If dump is going to be compressed, set correct encoding or mime_type and add
|
// If dump is going to be compressed, set correct encoding or mime_type and add
|
||||||
// compression to extension
|
// compression to extension
|
||||||
@@ -429,7 +406,7 @@ if ($export_type == 'server') {
|
|||||||
break 2;
|
break 2;
|
||||||
}
|
}
|
||||||
$tables = PMA_DBI_get_tables($current_db);
|
$tables = PMA_DBI_get_tables($current_db);
|
||||||
$views = array();
|
$views = array();
|
||||||
foreach ($tables as $table) {
|
foreach ($tables as $table) {
|
||||||
// if this is a view, collect it for later; views must be exported
|
// if this is a view, collect it for later; views must be exported
|
||||||
// after the tables
|
// after the tables
|
||||||
@@ -472,7 +449,7 @@ if ($export_type == 'server') {
|
|||||||
$tmp_select = '|' . $tmp_select . '|';
|
$tmp_select = '|' . $tmp_select . '|';
|
||||||
}
|
}
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$views = array();
|
$views = array();
|
||||||
foreach ($tables as $table) {
|
foreach ($tables as $table) {
|
||||||
// if this is a view, collect it for later; views must be exported after
|
// if this is a view, collect it for later; views must be exported after
|
||||||
// the tables
|
// the tables
|
||||||
@@ -539,7 +516,7 @@ if ($export_type == 'server') {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// I think we have to export data for a single view; for example PDF report
|
// I think we have to export data for a single view; for example PDF report
|
||||||
//if (isset($GLOBALS[$what . '_data']) && ! PMA_table::isView($db, $table)) {
|
//if (isset($GLOBALS[$what . '_data']) && ! PMA_table::isView($db, $table)) {
|
||||||
if (isset($GLOBALS[$what . '_data'])) {
|
if (isset($GLOBALS[$what . '_data'])) {
|
||||||
if (!PMA_exportData($db, $table, $crlf, $err_url, $local_query)) {
|
if (!PMA_exportData($db, $table, $crlf, $err_url, $local_query)) {
|
||||||
|
@@ -10,14 +10,15 @@ if (isset($plugin_list)) {
|
|||||||
$plugin_list['csv'] = array(
|
$plugin_list['csv'] = array(
|
||||||
'text' => 'strStrucCSV',
|
'text' => 'strStrucCSV',
|
||||||
'extension' => 'csv',
|
'extension' => 'csv',
|
||||||
|
'mime_type' => 'text/comma-separated-values',
|
||||||
'options' => array(
|
'options' => array(
|
||||||
array('type' => 'text', 'name' => 'separator', 'text' => 'strFieldsTerminatedBy'),
|
array('type' => 'text', 'name' => 'separator', 'text' => 'strFieldsTerminatedBy'),
|
||||||
array('type' => 'text', 'name' => 'enclosed', 'text' => 'strFieldsEnclosedBy'),
|
array('type' => 'text', 'name' => 'enclosed', 'text' => 'strFieldsEnclosedBy'),
|
||||||
array('type' => 'text', 'name' => 'escaped', 'text' => 'strFieldsEscapedBy'),
|
array('type' => 'text', 'name' => 'escaped', 'text' => 'strFieldsEscapedBy'),
|
||||||
array('type' => 'text', 'name' => 'terminated', 'text' => 'strLinesTerminatedBy'),
|
array('type' => 'text', 'name' => 'terminated', 'text' => 'strLinesTerminatedBy'),
|
||||||
array('type' => 'text', 'name' => 'null', 'text' => 'strReplaceNULLBy'),
|
array('type' => 'text', 'name' => 'null', 'text' => 'strReplaceNULLBy'),
|
||||||
array('type' => 'bool', 'name' => 'columns', 'text' => 'strPutColNames'),
|
array('type' => 'bool', 'name' => 'columns', 'text' => 'strPutColNames'),
|
||||||
array('type' => 'hidden', 'name' => 'data'),
|
array('type' => 'hidden', 'name' => 'data'),
|
||||||
),
|
),
|
||||||
'options_text' => 'strCSVOptions',
|
'options_text' => 'strCSVOptions',
|
||||||
);
|
);
|
||||||
|
@@ -10,11 +10,12 @@ if (isset($plugin_list)) {
|
|||||||
$plugin_list['excel'] = array(
|
$plugin_list['excel'] = array(
|
||||||
'text' => 'strStrucExcelCSV',
|
'text' => 'strStrucExcelCSV',
|
||||||
'extension' => 'xls',
|
'extension' => 'xls',
|
||||||
|
'mime_type' => 'application/vnd.ms-excel',
|
||||||
'options' => array(
|
'options' => array(
|
||||||
array('type' => 'text', 'name' => 'null', 'text' => 'strReplaceNULLBy'),
|
array('type' => 'text', 'name' => 'null', 'text' => 'strReplaceNULLBy'),
|
||||||
array('type' => 'bool', 'name' => 'columns', 'text' => 'strPutColNames'),
|
array('type' => 'bool', 'name' => 'columns', 'text' => 'strPutColNames'),
|
||||||
array('type' => 'select', 'name' => 'edition', 'values' => array('win' => 'Windows', 'mac' => 'Excel 2003 / Macintosh'), 'text' => 'strExcelEdition'),
|
array('type' => 'select', 'name' => 'edition', 'values' => array('win' => 'Windows', 'mac' => 'Excel 2003 / Macintosh'), 'text' => 'strExcelEdition'),
|
||||||
array('type' => 'hidden', 'name' => 'data'),
|
array('type' => 'hidden', 'name' => 'data'),
|
||||||
),
|
),
|
||||||
'options_text' => 'strExcelOptions',
|
'options_text' => 'strExcelOptions',
|
||||||
);
|
);
|
||||||
|
@@ -10,10 +10,11 @@ if (isset($plugin_list)) {
|
|||||||
$plugin_list['htmlexcel'] = array(
|
$plugin_list['htmlexcel'] = array(
|
||||||
'text' => 'strHTMLExcel',
|
'text' => 'strHTMLExcel',
|
||||||
'extension' => 'xsl',
|
'extension' => 'xsl',
|
||||||
|
'mime_type' => 'application/vnd.ms-excel',
|
||||||
'options' => array(
|
'options' => array(
|
||||||
array('type' => 'text', 'name' => 'null', 'text' => 'strReplaceNULLBy'),
|
array('type' => 'text', 'name' => 'null', 'text' => 'strReplaceNULLBy'),
|
||||||
array('type' => 'bool', 'name' => 'columns', 'text' => 'strPutColNames'),
|
array('type' => 'bool', 'name' => 'columns', 'text' => 'strPutColNames'),
|
||||||
array('type' => 'hidden', 'name' => 'data'),
|
array('type' => 'hidden', 'name' => 'data'),
|
||||||
),
|
),
|
||||||
'options_text' => 'strHTMLExcelOptions',
|
'options_text' => 'strHTMLExcelOptions',
|
||||||
);
|
);
|
||||||
|
@@ -10,6 +10,7 @@ if (isset($plugin_list)) {
|
|||||||
$plugin_list['htmlword'] = array(
|
$plugin_list['htmlword'] = array(
|
||||||
'text' => 'strHTMLWord',
|
'text' => 'strHTMLWord',
|
||||||
'extension' => 'doc',
|
'extension' => 'doc',
|
||||||
|
'mime_type' => 'application/vnd.ms-word',
|
||||||
'options' => array(
|
'options' => array(
|
||||||
array('type' => 'bool', 'name' => 'structure', 'text' => 'strStructure', 'force' => 'data'),
|
array('type' => 'bool', 'name' => 'structure', 'text' => 'strStructure', 'force' => 'data'),
|
||||||
array('type' => 'bgroup', 'name' => 'data', 'text' => 'strData', 'force' => 'structure'),
|
array('type' => 'bgroup', 'name' => 'data', 'text' => 'strData', 'force' => 'structure'),
|
||||||
|
@@ -14,6 +14,7 @@ if (isset($plugin_list)) {
|
|||||||
$plugin_list['latex'] = array(
|
$plugin_list['latex'] = array(
|
||||||
'text' => 'strLaTeX',
|
'text' => 'strLaTeX',
|
||||||
'extension' => 'tex',
|
'extension' => 'tex',
|
||||||
|
'mime_type' => 'application/x-tex',
|
||||||
'options' => array(
|
'options' => array(
|
||||||
array('type' => 'bool', 'name' => 'caption', 'text' => 'strLatexIncludeCaption'),
|
array('type' => 'bool', 'name' => 'caption', 'text' => 'strLatexIncludeCaption'),
|
||||||
),
|
),
|
||||||
|
@@ -3,16 +3,17 @@
|
|||||||
// vim: expandtab sw=4 ts=4 sts=4:
|
// vim: expandtab sw=4 ts=4 sts=4:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Produce a PDF report (export) from a query
|
* Produce a PDF report (export) from a query
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (isset($plugin_list)) {
|
if (isset($plugin_list)) {
|
||||||
$plugin_list['pdf'] = array(
|
$plugin_list['pdf'] = array(
|
||||||
'text' => 'strPDF',
|
'text' => 'strPDF',
|
||||||
'extension' => 'pdf',
|
'extension' => 'pdf',
|
||||||
|
'mime_type' => 'application/pdf',
|
||||||
'options' => array(
|
'options' => array(
|
||||||
array('type' => 'text', 'name' => 'report_title', 'text' => 'strPDFReportTitle'),
|
array('type' => 'text', 'name' => 'report_title', 'text' => 'strPDFReportTitle'),
|
||||||
array('type' => 'hidden', 'name' => 'data'),
|
array('type' => 'hidden', 'name' => 'data'),
|
||||||
),
|
),
|
||||||
'options_text' => 'strPDFOptions',
|
'options_text' => 'strPDFOptions',
|
||||||
);
|
);
|
||||||
@@ -35,14 +36,14 @@ define('FPDF_FONTPATH', './libraries/fpdf/font/');
|
|||||||
|
|
||||||
// Adapted from a LGPL script by Philip Clarke
|
// Adapted from a LGPL script by Philip Clarke
|
||||||
|
|
||||||
class PMA_PDF extends PMA_FPDF
|
class PMA_PDF extends PMA_FPDF
|
||||||
{
|
{
|
||||||
var $tablewidths;
|
var $tablewidths;
|
||||||
var $headerset;
|
var $headerset;
|
||||||
var $footerset;
|
var $footerset;
|
||||||
|
|
||||||
// overloading of a fpdf function:
|
// overloading of a fpdf function:
|
||||||
function _beginpage($orientation)
|
function _beginpage($orientation)
|
||||||
{
|
{
|
||||||
$this->page++;
|
$this->page++;
|
||||||
// solved the problem of overwriting a page, if it already exists
|
// solved the problem of overwriting a page, if it already exists
|
||||||
@@ -54,7 +55,7 @@ class PMA_PDF extends PMA_FPDF
|
|||||||
$this->y = $this->tMargin;
|
$this->y = $this->tMargin;
|
||||||
$this->lasth = 0;
|
$this->lasth = 0;
|
||||||
$this->FontFamily = '';
|
$this->FontFamily = '';
|
||||||
|
|
||||||
//Page orientation
|
//Page orientation
|
||||||
if (!$orientation) {
|
if (!$orientation) {
|
||||||
$orientation = $this->DefOrientation;
|
$orientation = $this->DefOrientation;
|
||||||
@@ -82,7 +83,7 @@ class PMA_PDF extends PMA_FPDF
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function Header()
|
function Header()
|
||||||
{
|
{
|
||||||
global $maxY;
|
global $maxY;
|
||||||
|
|
||||||
@@ -122,7 +123,7 @@ class PMA_PDF extends PMA_FPDF
|
|||||||
$this->SetY($maxY);
|
$this->SetY($maxY);
|
||||||
}
|
}
|
||||||
|
|
||||||
function Footer()
|
function Footer()
|
||||||
{
|
{
|
||||||
// Check if footer for this page already exists
|
// Check if footer for this page already exists
|
||||||
if (!isset($this->footerset[$this->page])) {
|
if (!isset($this->footerset[$this->page])) {
|
||||||
@@ -135,7 +136,7 @@ class PMA_PDF extends PMA_FPDF
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function morepagestable($lineheight=8)
|
function morepagestable($lineheight=8)
|
||||||
{
|
{
|
||||||
// some things to set and 'remember'
|
// some things to set and 'remember'
|
||||||
$l = $this->lMargin;
|
$l = $this->lMargin;
|
||||||
@@ -290,7 +291,7 @@ class PMA_PDF extends PMA_FPDF
|
|||||||
$this->morepagestable($this->FontSizePt);
|
$this->morepagestable($this->FontSizePt);
|
||||||
PMA_DBI_free_result($this->results);
|
PMA_DBI_free_result($this->results);
|
||||||
|
|
||||||
} // end of mysql_report function
|
} // end of mysql_report function
|
||||||
|
|
||||||
} // end of PMA_PDF class
|
} // end of PMA_PDF class
|
||||||
|
|
||||||
@@ -301,7 +302,7 @@ class PMA_PDF extends PMA_FPDF
|
|||||||
*
|
*
|
||||||
* @return bool Whether it suceeded
|
* @return bool Whether it suceeded
|
||||||
*/
|
*/
|
||||||
function PMA_exportComment($text)
|
function PMA_exportComment($text)
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -313,7 +314,7 @@ function PMA_exportComment($text)
|
|||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function PMA_exportFooter()
|
function PMA_exportFooter()
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -325,7 +326,7 @@ function PMA_exportFooter()
|
|||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function PMA_exportHeader()
|
function PMA_exportHeader()
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -339,7 +340,7 @@ function PMA_exportHeader()
|
|||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function PMA_exportDBHeader($db)
|
function PMA_exportDBHeader($db)
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -353,7 +354,7 @@ function PMA_exportDBHeader($db)
|
|||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function PMA_exportDBFooter($db)
|
function PMA_exportDBFooter($db)
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -367,7 +368,7 @@ function PMA_exportDBFooter($db)
|
|||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function PMA_exportDBCreate($db)
|
function PMA_exportDBCreate($db)
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -385,7 +386,7 @@ function PMA_exportDBCreate($db)
|
|||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
|
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
|
||||||
{
|
{
|
||||||
global $what;
|
global $what;
|
||||||
global $pdf_report_title;
|
global $pdf_report_title;
|
||||||
|
@@ -16,6 +16,7 @@ if (isset($plugin_list)) {
|
|||||||
$plugin_list['sql'] = array(
|
$plugin_list['sql'] = array(
|
||||||
'text' => 'strSQL',
|
'text' => 'strSQL',
|
||||||
'extension' => 'sql',
|
'extension' => 'sql',
|
||||||
|
'mime_type' => 'text/x-sql',
|
||||||
'options' => array(
|
'options' => array(
|
||||||
array('type' => 'text', 'name' => 'header_comment', 'text' => 'strAddHeaderComment'),
|
array('type' => 'text', 'name' => 'header_comment', 'text' => 'strAddHeaderComment'),
|
||||||
array('type' => 'bool', 'name' => 'use_transaction', 'text' => 'strEncloseInTransaction'),
|
array('type' => 'bool', 'name' => 'use_transaction', 'text' => 'strEncloseInTransaction'),
|
||||||
|
@@ -20,10 +20,11 @@ if ($xls) {
|
|||||||
$plugin_list['xls'] = array(
|
$plugin_list['xls'] = array(
|
||||||
'text' => 'strStrucNativeExcel',
|
'text' => 'strStrucNativeExcel',
|
||||||
'extension' => 'xls',
|
'extension' => 'xls',
|
||||||
|
'mime_type' => 'application/vnd.ms-excel',
|
||||||
'options' => array(
|
'options' => array(
|
||||||
array('type' => 'text', 'name' => 'null', 'text' => 'strReplaceNULLBy'),
|
array('type' => 'text', 'name' => 'null', 'text' => 'strReplaceNULLBy'),
|
||||||
array('type' => 'text', 'name' => 'columns', 'text' => 'strPutColNames'),
|
array('type' => 'text', 'name' => 'columns', 'text' => 'strPutColNames'),
|
||||||
array('type' => 'hidden', 'name' => 'data'),
|
array('type' => 'hidden', 'name' => 'data'),
|
||||||
),
|
),
|
||||||
'options_text' => 'strStrucNativeExcelOptions',
|
'options_text' => 'strStrucNativeExcelOptions',
|
||||||
);
|
);
|
||||||
|
@@ -12,6 +12,7 @@ if (isset($plugin_list)) {
|
|||||||
$plugin_list['xml'] = array(
|
$plugin_list['xml'] = array(
|
||||||
'text' => 'strXML',
|
'text' => 'strXML',
|
||||||
'extension' => 'xml',
|
'extension' => 'xml',
|
||||||
|
'mime_type' => 'text/xml',
|
||||||
'options' => array(
|
'options' => array(
|
||||||
),
|
),
|
||||||
'options_text' => 'strXMLOptions',
|
'options_text' => 'strXMLOptions',
|
||||||
|
Reference in New Issue
Block a user