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).
|
||||
* db_operations.php, tbl_properties_operations.php,
|
||||
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>
|
||||
* themes/*:
|
||||
|
49
export.php
49
export.php
@@ -7,14 +7,19 @@
|
||||
*/
|
||||
require_once('./libraries/common.lib.php');
|
||||
require_once('./libraries/zip.lib.php');
|
||||
require_once('./libraries/plugin_interface.lib.php');
|
||||
|
||||
PMA_checkParameters(array('what', 'export_type'));
|
||||
|
||||
// What type of export are we doing?
|
||||
if ($what == 'excel') {
|
||||
$type = 'csv';
|
||||
} else {
|
||||
$type = $what;
|
||||
// Scan plugins
|
||||
$export_list = PMA_getPlugins('./libraries/export/', array('export_type' => $export_type, 'single_table' => isset($single_table)));
|
||||
|
||||
// Backward compatbility
|
||||
$type = $what;
|
||||
|
||||
// Check export type
|
||||
if (!isset($export_list[$type])) {
|
||||
die('Bad type!');
|
||||
}
|
||||
|
||||
// Get the functions specific to the export type
|
||||
@@ -224,37 +229,9 @@ if ($asfile) {
|
||||
$filename = PMA_convert_string($convcharset, 'iso-8859-1', $filename);
|
||||
}
|
||||
|
||||
// Generate basic dump extension
|
||||
if ($type == 'csv') {
|
||||
$filename .= '.csv';
|
||||
$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';
|
||||
}
|
||||
// Grab basic dump extension and mime type
|
||||
$filename .= '.' . $export_list[$type]['extension'];
|
||||
$mime_type = $export_list[$type]['mime_type'];
|
||||
|
||||
// If dump is going to be compressed, set correct encoding or mime_type and add
|
||||
// compression to extension
|
||||
|
@@ -10,6 +10,7 @@ if (isset($plugin_list)) {
|
||||
$plugin_list['csv'] = array(
|
||||
'text' => 'strStrucCSV',
|
||||
'extension' => 'csv',
|
||||
'mime_type' => 'text/comma-separated-values',
|
||||
'options' => array(
|
||||
array('type' => 'text', 'name' => 'separator', 'text' => 'strFieldsTerminatedBy'),
|
||||
array('type' => 'text', 'name' => 'enclosed', 'text' => 'strFieldsEnclosedBy'),
|
||||
|
@@ -10,6 +10,7 @@ if (isset($plugin_list)) {
|
||||
$plugin_list['excel'] = array(
|
||||
'text' => 'strStrucExcelCSV',
|
||||
'extension' => 'xls',
|
||||
'mime_type' => 'application/vnd.ms-excel',
|
||||
'options' => array(
|
||||
array('type' => 'text', 'name' => 'null', 'text' => 'strReplaceNULLBy'),
|
||||
array('type' => 'bool', 'name' => 'columns', 'text' => 'strPutColNames'),
|
||||
|
@@ -10,6 +10,7 @@ if (isset($plugin_list)) {
|
||||
$plugin_list['htmlexcel'] = array(
|
||||
'text' => 'strHTMLExcel',
|
||||
'extension' => 'xsl',
|
||||
'mime_type' => 'application/vnd.ms-excel',
|
||||
'options' => array(
|
||||
array('type' => 'text', 'name' => 'null', 'text' => 'strReplaceNULLBy'),
|
||||
array('type' => 'bool', 'name' => 'columns', 'text' => 'strPutColNames'),
|
||||
|
@@ -10,6 +10,7 @@ if (isset($plugin_list)) {
|
||||
$plugin_list['htmlword'] = array(
|
||||
'text' => 'strHTMLWord',
|
||||
'extension' => 'doc',
|
||||
'mime_type' => 'application/vnd.ms-word',
|
||||
'options' => array(
|
||||
array('type' => 'bool', 'name' => 'structure', 'text' => 'strStructure', 'force' => 'data'),
|
||||
array('type' => 'bgroup', 'name' => 'data', 'text' => 'strData', 'force' => 'structure'),
|
||||
|
@@ -14,6 +14,7 @@ if (isset($plugin_list)) {
|
||||
$plugin_list['latex'] = array(
|
||||
'text' => 'strLaTeX',
|
||||
'extension' => 'tex',
|
||||
'mime_type' => 'application/x-tex',
|
||||
'options' => array(
|
||||
array('type' => 'bool', 'name' => 'caption', 'text' => 'strLatexIncludeCaption'),
|
||||
),
|
||||
|
@@ -10,6 +10,7 @@ if (isset($plugin_list)) {
|
||||
$plugin_list['pdf'] = array(
|
||||
'text' => 'strPDF',
|
||||
'extension' => 'pdf',
|
||||
'mime_type' => 'application/pdf',
|
||||
'options' => array(
|
||||
array('type' => 'text', 'name' => 'report_title', 'text' => 'strPDFReportTitle'),
|
||||
array('type' => 'hidden', 'name' => 'data'),
|
||||
|
@@ -16,6 +16,7 @@ if (isset($plugin_list)) {
|
||||
$plugin_list['sql'] = array(
|
||||
'text' => 'strSQL',
|
||||
'extension' => 'sql',
|
||||
'mime_type' => 'text/x-sql',
|
||||
'options' => array(
|
||||
array('type' => 'text', 'name' => 'header_comment', 'text' => 'strAddHeaderComment'),
|
||||
array('type' => 'bool', 'name' => 'use_transaction', 'text' => 'strEncloseInTransaction'),
|
||||
|
@@ -20,6 +20,7 @@ if ($xls) {
|
||||
$plugin_list['xls'] = array(
|
||||
'text' => 'strStrucNativeExcel',
|
||||
'extension' => 'xls',
|
||||
'mime_type' => 'application/vnd.ms-excel',
|
||||
'options' => array(
|
||||
array('type' => 'text', 'name' => 'null', 'text' => 'strReplaceNULLBy'),
|
||||
array('type' => 'text', 'name' => 'columns', 'text' => 'strPutColNames'),
|
||||
|
@@ -12,6 +12,7 @@ if (isset($plugin_list)) {
|
||||
$plugin_list['xml'] = array(
|
||||
'text' => 'strXML',
|
||||
'extension' => 'xml',
|
||||
'mime_type' => 'text/xml',
|
||||
'options' => array(
|
||||
),
|
||||
'options_text' => 'strXMLOptions',
|
||||
|
Reference in New Issue
Block a user