Convert export to plugin architecture, so that plugins are independant piece of code (RFE #1325937).
This commit is contained in:
@@ -17,6 +17,9 @@ $Source$
|
||||
* css/phpmyadmin.css.php, themes/darkblue_orange/css/theme_right.css.php,
|
||||
themes/original/css/theme_right.css.php: New style for non table forms
|
||||
used in plugins.
|
||||
* libraries/config.default.php, libraries/display_export.lib.php,
|
||||
libraries/export/*: Convert export to plugin architecture, so that
|
||||
plugins are independant piece of code (RFE #1325937).
|
||||
|
||||
2006-04-26 Sebastian Mendel <cybot_tm@users.sourceforge.net>
|
||||
* themes/*:
|
||||
|
@@ -271,7 +271,7 @@ $cfg['Export']['xls_null'] = 'NULL';
|
||||
$cfg['Export']['csv_columns'] = FALSE;
|
||||
$cfg['Export']['csv_null'] = 'NULL';
|
||||
$cfg['Export']['csv_separator'] = ';';
|
||||
$cfg['Export']['csv_enclosed'] = '"';
|
||||
$cfg['Export']['csv_enclosed'] = '"';
|
||||
$cfg['Export']['csv_escaped'] = '\\';
|
||||
$cfg['Export']['csv_terminated'] = 'AUTO';
|
||||
$cfg['Export']['excel_columns'] = FALSE;
|
||||
@@ -286,6 +286,10 @@ $cfg['Export']['latex_comments'] = TRUE;
|
||||
$cfg['Export']['latex_mime'] = TRUE;
|
||||
$cfg['Export']['latex_null'] = '\textit{NULL}';
|
||||
$cfg['Export']['latex_caption'] = TRUE;
|
||||
$cfg['Export']['latex_structure_caption'] = 'strLatexStructure';
|
||||
$cfg['Export']['latex_structure_continued_caption'] = 'strLatexStructure strLatexContinued';
|
||||
$cfg['Export']['latex_data_caption'] = 'strLatexContent';
|
||||
$cfg['Export']['latex_data_continued_caption'] = 'strLatexContent strLatexContinued';
|
||||
$cfg['Export']['latex_data_label'] = 'tab:__TABLE__-data';
|
||||
$cfg['Export']['latex_structure_label'] = 'tab:__TABLE__-structure';
|
||||
|
||||
|
@@ -8,17 +8,9 @@ require_once './libraries/Table.class.php';
|
||||
require_once('./libraries/relation.lib.php');
|
||||
$cfgRelation = PMA_getRelationsParam();
|
||||
|
||||
// Check if we have native MS Excel export using PEAR class Spreadsheet_Excel_Writer
|
||||
if (!empty($GLOBALS['cfg']['TempDir'])) {
|
||||
@include_once('Spreadsheet/Excel/Writer.php');
|
||||
if (class_exists('Spreadsheet_Excel_Writer')) {
|
||||
$xls = TRUE;
|
||||
} else {
|
||||
$xls = FALSE;
|
||||
}
|
||||
} else {
|
||||
$xls = FALSE;
|
||||
}
|
||||
|
||||
require_once('./libraries/file_listing.php');
|
||||
require_once('./libraries/plugin_interface.lib.php');
|
||||
|
||||
function PMA_exportCheckboxCheck($str) {
|
||||
if (isset($GLOBALS['cfg']['Export'][$str]) && $GLOBALS['cfg']['Export'][$str]) {
|
||||
@@ -32,93 +24,41 @@ function PMA_exportIsActive($what, $val) {
|
||||
}
|
||||
}
|
||||
|
||||
/* Scan for plugins */
|
||||
$export_list = PMA_getPlugins('./libraries/export/', array('export_type' => $export_type, 'single_table' => isset($single_table)));
|
||||
|
||||
/* Fail if we didn't find any plugin */
|
||||
if (empty($export_list)) {
|
||||
$GLOBALS['show_error_header'] = TRUE;
|
||||
PMA_showMessage($strCanNotLoadExportPlugins);
|
||||
unset($GLOBALS['show_error_header']);
|
||||
require('./libraries/footer.inc.php');
|
||||
}
|
||||
?>
|
||||
|
||||
<form method="post" action="export.php" name="dump">
|
||||
|
||||
<?php
|
||||
$hide_structure = false;
|
||||
$hide_sql = false;
|
||||
$hide_xml = (bool) (isset($db) && strlen($db));
|
||||
if ($export_type == 'server') {
|
||||
echo PMA_generate_common_hidden_inputs('', '', 1);
|
||||
} elseif ($export_type == 'database') {
|
||||
echo PMA_generate_common_hidden_inputs($db, '', 1);
|
||||
} else {
|
||||
echo PMA_generate_common_hidden_inputs($db, $table, 1);
|
||||
if (!isset($single_table)) {
|
||||
$hide_structure = true;
|
||||
$hide_sql = true;
|
||||
} else {
|
||||
// just to keep this value for possible next display of this form after saving on server
|
||||
echo '<input type="hidden" name="single_table" value="TRUE" />' . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// just to keep this value for possible next display of this form after saving on server
|
||||
if (isset($single_table)) {
|
||||
echo '<input type="hidden" name="single_table" value="TRUE" />' . "\n";
|
||||
}
|
||||
|
||||
echo '<input type="hidden" name="export_type" value="' . $export_type . '" />' . "\n";
|
||||
|
||||
if (isset($sql_query)) {
|
||||
echo '<input type="hidden" name="sql_query" value="' . htmlspecialchars($sql_query) . '" />' . "\n";
|
||||
}
|
||||
echo PMA_pluginGetJavascript($export_list);
|
||||
?>
|
||||
|
||||
<script type="text/javascript" language="javascript">
|
||||
//<![CDATA[
|
||||
function hide_them_all() {
|
||||
document.getElementById("csv_options").style.display = 'none';
|
||||
document.getElementById("excel_options").style.display = 'none';
|
||||
document.getElementById("latex_options").style.display = 'none';
|
||||
document.getElementById("htmlexcel_options").style.display = 'none';
|
||||
document.getElementById("htmlword_options").style.display = 'none';
|
||||
document.getElementById("pdf_options").style.display = 'none';
|
||||
<?php if ($xls) { ?>
|
||||
document.getElementById("xls_options").style.display = 'none';
|
||||
<?php } ?>
|
||||
<?php if (!$hide_sql) { ?>
|
||||
document.getElementById("sql_options").style.display = 'none';
|
||||
<?php } ?>
|
||||
document.getElementById("none_options").style.display = 'none';
|
||||
}
|
||||
|
||||
function show_checked_option() {
|
||||
hide_them_all();
|
||||
if (document.getElementById('radio_dump_latex').checked) {
|
||||
document.getElementById('latex_options').style.display = 'block';
|
||||
} else if (document.getElementById('radio_dump_htmlexcel').checked) {
|
||||
document.getElementById('htmlexcel_options').style.display = 'block';
|
||||
} else if (document.getElementById('radio_dump_pdf').checked) {
|
||||
document.getElementById('pdf_options').style.display = 'block';
|
||||
} else if (document.getElementById('radio_dump_htmlword').checked) {
|
||||
document.getElementById('htmlword_options').style.display = 'block';
|
||||
<?php if ($xls) { ?>
|
||||
} else if (document.getElementById('radio_dump_xls').checked) {
|
||||
document.getElementById('xls_options').style.display = 'block';
|
||||
<?php } ?>
|
||||
<?php if (!$hide_sql) { ?>
|
||||
} else if (document.getElementById('radio_dump_sql').checked) {
|
||||
document.getElementById('sql_options').style.display = 'block';
|
||||
<?php } ?>
|
||||
<?php if (!$hide_xml) { ?>
|
||||
} else if (document.getElementById('radio_dump_xml').checked) {
|
||||
document.getElementById('none_options').style.display = 'block';
|
||||
<?php } ?>
|
||||
} else if (document.getElementById('radio_dump_csv').checked) {
|
||||
document.getElementById('csv_options').style.display = 'block';
|
||||
} else if (document.getElementById('radio_dump_excel').checked) {
|
||||
document.getElementById('excel_options').style.display = 'block';
|
||||
} else {
|
||||
if (document.getElementById('radio_dump_sql')) {
|
||||
document.getElementById('radio_dump_sql').checked = true;
|
||||
document.getElementById('sql_options').style.display = 'block';
|
||||
} else if (document.getElementById('radio_dump_csv')) {
|
||||
document.getElementById('radio_dump_csv').checked = true;
|
||||
document.getElementById('csv_options').style.display = 'block';
|
||||
} else {
|
||||
document.getElementById('none_options').style.display = 'block';
|
||||
}
|
||||
}
|
||||
}
|
||||
//]]>
|
||||
</script>
|
||||
|
||||
<fieldset id="fieldsetexport">
|
||||
<legend><?php echo $export_page_title; ?></legend>
|
||||
|
||||
@@ -132,642 +72,20 @@ function show_checked_option() {
|
||||
|
||||
<div id="div_container_exportoptions">
|
||||
<fieldset id="exportoptions">
|
||||
<legend><?php echo $strExport; ?></legend>
|
||||
|
||||
<?php if ( ! empty( $multi_values ) ) { ?>
|
||||
<div class="formelementrow">
|
||||
<?php echo $multi_values; ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ( ! $hide_sql ) { /* SQL */ ?>
|
||||
<div class="formelementrow">
|
||||
<input type="radio" name="what" value="sql" id="radio_dump_sql"
|
||||
onclick="
|
||||
if (this.checked) {
|
||||
hide_them_all();
|
||||
document.getElementById('sql_options').style.display = 'block';
|
||||
}; return true"
|
||||
<?php PMA_exportIsActive('format', 'sql'); ?> />
|
||||
<label for="radio_dump_sql"><?php echo $strSQL; ?></label>
|
||||
</div>
|
||||
<?php } /* LaTeX table */ ?>
|
||||
<div class="formelementrow">
|
||||
<input type="radio" name="what" value="latex" id="radio_dump_latex"
|
||||
onclick="
|
||||
if (this.checked) {
|
||||
hide_them_all();
|
||||
document.getElementById('latex_options').style.display = 'block';
|
||||
}; return true"
|
||||
<?php PMA_exportIsActive('format', 'latex'); ?> />
|
||||
<label for="radio_dump_latex"><?php echo $strLaTeX; ?></label>
|
||||
</div>
|
||||
<?php /* PDF */ ?>
|
||||
<div class="formelementrow">
|
||||
<input type="radio" name="what" value="pdf" id="radio_dump_pdf"
|
||||
onclick="
|
||||
if (this.checked) {
|
||||
hide_them_all();
|
||||
document.getElementById('pdf_options').style.display = 'block';
|
||||
}; return true"
|
||||
<?php PMA_exportIsActive('format', 'pdf'); ?> />
|
||||
<label for="radio_dump_pdf"><?php echo $strPDF; ?></label>
|
||||
</div>
|
||||
<?php /* HTML Excel */ ?>
|
||||
<div class="formelementrow">
|
||||
<input type="radio" name="what" value="htmlexcel" id="radio_dump_htmlexcel"
|
||||
onclick="
|
||||
if (this.checked) {
|
||||
hide_them_all();
|
||||
document.getElementById('htmlexcel_options').style.display = 'block';
|
||||
document.getElementById('checkbox_dump_asfile').checked = true;
|
||||
}; return true"
|
||||
<?php PMA_exportIsActive('format', 'htmlexcel'); ?> />
|
||||
<label for="radio_dump_htmlexcel"><?php echo $strHTMLExcel; ?></label>
|
||||
</div>
|
||||
<?php /* HTML Word */ ?>
|
||||
<div class="formelementrow">
|
||||
<input type="radio" name="what" value="htmlword" id="radio_dump_htmlword"
|
||||
onclick="
|
||||
if (this.checked) {
|
||||
hide_them_all();
|
||||
document.getElementById('htmlword_options').style.display = 'block';
|
||||
document.getElementById('checkbox_dump_asfile').checked = true;
|
||||
}; return true"
|
||||
<?php PMA_exportIsActive('format', 'htmlword'); ?> />
|
||||
<label for="radio_dump_htmlword"><?php echo $strHTMLWord; ?></label>
|
||||
</div>
|
||||
<?php if ($xls) { /* Native Excel */ ?>
|
||||
<div class="formelementrow">
|
||||
<input type="radio" name="what" value="xls" id="radio_dump_xls"
|
||||
onclick="
|
||||
if (this.checked) {
|
||||
hide_them_all();
|
||||
document.getElementById('xls_options').style.display = 'block';
|
||||
document.getElementById('checkbox_dump_asfile').checked = true;
|
||||
}; return true"
|
||||
<?php PMA_exportIsActive('format', 'xls'); ?> />
|
||||
<label for="radio_dump_xls"><?php echo $strStrucNativeExcel; ?></label>
|
||||
</div>
|
||||
<?php } /* Excel CSV */ ?>
|
||||
<div class="formelementrow">
|
||||
<input type="radio" name="what" value="excel" id="radio_dump_excel"
|
||||
onclick="
|
||||
if (this.checked) {
|
||||
hide_them_all();
|
||||
document.getElementById('excel_options').style.display = 'block';
|
||||
}; return true"
|
||||
<?php PMA_exportIsActive('format', 'excel'); ?> />
|
||||
<label for="radio_dump_excel"><?php echo $strStrucExcelCSV; ?></label>
|
||||
</div>
|
||||
<?php /* General CSV */ ?>
|
||||
<div class="formelementrow">
|
||||
<input type="radio" name="what" value="csv" id="radio_dump_csv"
|
||||
onclick="if
|
||||
(this.checked) {
|
||||
hide_them_all();
|
||||
document.getElementById('csv_options').style.display = 'block';
|
||||
}; return true"
|
||||
<?php PMA_exportIsActive('format', 'csv'); ?> />
|
||||
<label for="radio_dump_csv"><?php echo $strStrucCSV;?></label>
|
||||
</div>
|
||||
<?php if (!$hide_xml) { /* XML */ ?>
|
||||
<div class="formelementrow">
|
||||
<input type="radio" name="what" value="xml" id="radio_dump_xml"
|
||||
onclick="
|
||||
if (this.checked) {
|
||||
hide_them_all();
|
||||
document.getElementById('none_options').style.display = 'block';
|
||||
}; return true"
|
||||
<?php PMA_exportIsActive('format', 'xml'); ?> />
|
||||
<label for="radio_dump_xml"><?php echo $strXML; ?></label>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php echo PMA_pluginGetChoice('Export', 'what', $export_list); ?>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
</td><td>
|
||||
|
||||
<div id="div_container_sub_exportoptions">
|
||||
<?php if ( ! $hide_sql ) { /* SQL options */ ?>
|
||||
<fieldset id="sql_options">
|
||||
<legend>
|
||||
<?php
|
||||
echo $strSQLOptions;
|
||||
$goto_documentation = '<a href="./Documentation.html#faqexport" target="documentation">';
|
||||
echo ( $cfg['ReplaceHelpImg'] ? '' : '(' )
|
||||
. $goto_documentation
|
||||
. ( $cfg['ReplaceHelpImg'] ?
|
||||
'<img class="icon" src="' . $pmaThemeImage . 'b_help.png" alt="'
|
||||
.$strDocu . '" width="11" height="11" />'
|
||||
: $strDocu )
|
||||
. '</a>' . ($cfg['ReplaceHelpImg'] ? '' : ')');
|
||||
?>
|
||||
</legend>
|
||||
<div class="formelementrow">
|
||||
<?php echo $strAddHeaderComment; ?>:<br />
|
||||
<input type="text" name="header_comment" size="30"
|
||||
value="<?php echo $cfg['Export']['sql_header_comment']; ?>" />
|
||||
</div>
|
||||
|
||||
<div class="formelementrow">
|
||||
<input type="checkbox" name="use_transaction" value="yes"
|
||||
id="checkbox_use_transaction"
|
||||
<?php PMA_exportCheckboxCheck('sql_use_transaction'); ?> />
|
||||
<label for="checkbox_use_transaction">
|
||||
<?php echo $strEncloseInTransaction; ?></label>
|
||||
</div>
|
||||
|
||||
<div class="formelementrow">
|
||||
<input type="checkbox" name="disable_fk" value="yes"
|
||||
id="checkbox_disable_fk"
|
||||
<?php PMA_exportCheckboxCheck('sql_disable_fk'); ?> />
|
||||
<label for="checkbox_disable_fk">
|
||||
<?php echo $strDisableForeignChecks; ?></label>
|
||||
</div>
|
||||
<?php
|
||||
$compats = PMA_DBI_getCompatibilities();
|
||||
if (count($compats) > 0) {
|
||||
?>
|
||||
<label for="select_sql_compat">
|
||||
<?php echo $strSQLExportCompatibility; ?>:</label>
|
||||
<select name="sql_compat" id="select_sql_compat">
|
||||
<?php
|
||||
foreach ($compats as $x) {
|
||||
echo '<option value="' . $x . '"'
|
||||
. ($cfg['Export']['sql_compat'] == $x ? ' selected="selected"' : '' )
|
||||
. '>' . $x . '</option>' . "\n";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<?php echo PMA_showMySQLDocu('manual_MySQL_Database_Administration',
|
||||
'Server_SQL_mode') . "\n";
|
||||
} ?>
|
||||
<?php if ( $export_type == 'server' ) { /* For databases */ ?>
|
||||
<fieldset>
|
||||
<legend><?php echo $strDatabaseExportOptions; ?></legend>
|
||||
<input type="checkbox" name="drop_database" value="yes"
|
||||
id="checkbox_drop_database"
|
||||
<?php PMA_exportCheckboxCheck('sql_drop_database'); ?> />
|
||||
<label for="checkbox_drop_database">
|
||||
<?php echo sprintf($strAddClause, 'DROP DATABASE'); ?></label>
|
||||
</fieldset>
|
||||
<?php } if ( ! $hide_structure ) { /* SQL structure */ ?>
|
||||
<fieldset>
|
||||
<legend>
|
||||
<input type="checkbox" name="sql_structure" value="structure"
|
||||
id="checkbox_sql_structure"
|
||||
<?php PMA_exportCheckboxCheck('sql_structure'); ?>
|
||||
onclick="
|
||||
if (!this.checked && !document.getElementById('checkbox_sql_data').checked)
|
||||
return false;
|
||||
else return true;" />
|
||||
<label for="checkbox_sql_structure">
|
||||
<?php echo $strStructure; ?></label>
|
||||
</legend>
|
||||
|
||||
<input type="checkbox" name="drop" value="1" id="checkbox_dump_drop"
|
||||
<?php PMA_exportCheckboxCheck('sql_drop_table'); ?> />
|
||||
<label for="checkbox_dump_drop">
|
||||
<?php if ($export_type == 'table') {
|
||||
if (PMA_Table::_isView($db,$table)) {
|
||||
$drop_clause = 'DROP VIEW';
|
||||
} else {
|
||||
$drop_clause = 'DROP TABLE';
|
||||
}
|
||||
} elseif (PMA_MYSQL_INT_VERSION >= 50000) {
|
||||
$drop_clause = 'DROP TABLE / DROP VIEW';
|
||||
} else {
|
||||
$drop_clause = 'DROP TABLE';
|
||||
}
|
||||
echo sprintf($strAddClause, $drop_clause); ?></label><br />
|
||||
|
||||
<input type="checkbox" name="if_not_exists" value="1"
|
||||
id="checkbox_dump_if_not_exists"
|
||||
<?php PMA_exportCheckboxCheck('sql_if_not_exists'); ?> />
|
||||
<label for="checkbox_dump_if_not_exists">
|
||||
<?php echo sprintf($strAddClause, 'IF NOT EXISTS'); ?></label><br />
|
||||
|
||||
<input type="checkbox" name="sql_auto_increment" value="1"
|
||||
id="checkbox_auto_increment"
|
||||
<?php PMA_exportCheckboxCheck('sql_auto_increment'); ?> />
|
||||
<label for="checkbox_auto_increment">
|
||||
<?php echo $strAddAutoIncrement; ?></label><br />
|
||||
|
||||
<input type="checkbox" name="use_backquotes" value="1"
|
||||
id="checkbox_dump_use_backquotes"
|
||||
<?php PMA_exportCheckboxCheck('sql_backquotes'); ?> />
|
||||
<label for="checkbox_dump_use_backquotes">
|
||||
<?php echo $strUseBackquotes; ?></label><br />
|
||||
|
||||
<b><?php echo $strAddIntoComments; ?>:</b><br />
|
||||
|
||||
<input type="checkbox" name="sql_dates" value="yes"
|
||||
id="checkbox_sql_dates"
|
||||
<?php PMA_exportCheckboxCheck('sql_dates'); ?> />
|
||||
<label for="checkbox_sql_dates">
|
||||
<?php echo $strCreationDates; ?></label><br />
|
||||
<?php if (!empty($cfgRelation['relation'])) { ?>
|
||||
<input type="checkbox" name="sql_relation" value="yes"
|
||||
id="checkbox_sql_use_relation"
|
||||
<?php PMA_exportCheckboxCheck('sql_relation'); ?> />
|
||||
<label for="checkbox_sql_use_relation"><?php echo $strRelations; ?></label><br />
|
||||
<?php } if (!empty($cfgRelation['commwork']) && PMA_MYSQL_INT_VERSION < 40100) { ?>
|
||||
<input type="checkbox" name="sql_comments" value="yes"
|
||||
id="checkbox_sql_use_comments"
|
||||
<?php PMA_exportCheckboxCheck('sql_comments'); ?> />
|
||||
<label for="checkbox_sql_use_comments"><?php echo $strComments; ?></label><br />
|
||||
<?php } if ($cfgRelation['mimework']) { ?>
|
||||
<input type="checkbox" name="sql_mime" value="yes"
|
||||
id="checkbox_sql_use_mime"
|
||||
<?php PMA_exportCheckboxCheck('sql_mime'); ?> />
|
||||
<label for="checkbox_sql_use_mime"><?php echo $strMIME_MIMEtype; ?></label><br />
|
||||
<?php } ?>
|
||||
</fieldset>
|
||||
<?php
|
||||
} /* end SQL STRUCTURE */
|
||||
/* SQL data */
|
||||
?>
|
||||
<fieldset>
|
||||
<legend>
|
||||
<input type="checkbox" name="sql_data" value="data"
|
||||
id="checkbox_sql_data" <?php PMA_exportCheckboxCheck('sql_data'); ?>
|
||||
onclick="
|
||||
if (!this.checked && (!document.getElementById('checkbox_sql_structure') || !document.getElementById('checkbox_sql_structure').checked))
|
||||
return false;
|
||||
else return true;" />
|
||||
<label for="checkbox_sql_data">
|
||||
<?php echo $strData; ?></label>
|
||||
</legend>
|
||||
<input type="checkbox" name="showcolumns" value="yes"
|
||||
id="checkbox_dump_showcolumns"
|
||||
<?php PMA_exportCheckboxCheck('sql_columns'); ?> />
|
||||
<label for="checkbox_dump_showcolumns">
|
||||
<?php echo $strCompleteInserts; ?></label><br />
|
||||
|
||||
<input type="checkbox" name="extended_ins" value="yes"
|
||||
id="checkbox_dump_extended_ins"
|
||||
<?php PMA_exportCheckboxCheck('sql_extended'); ?> />
|
||||
<label for="checkbox_dump_extended_ins">
|
||||
<?php echo $strExtendedInserts; ?></label><br />
|
||||
|
||||
<label for="input_max_query_size">
|
||||
<?php echo $strMaximalQueryLength; ?>:</label>
|
||||
<input type="text" name="max_query_size" id="input_max_query_size"
|
||||
value="<?php echo $cfg['Export']['sql_max_query_size'];?>" /><br />
|
||||
|
||||
<input type="checkbox" name="delayed" value="yes"
|
||||
id="checkbox_dump_delayed"
|
||||
<?php PMA_exportCheckboxCheck('sql_delayed'); ?> />
|
||||
<label for="checkbox_dump_delayed">
|
||||
<?php echo $strDelayedInserts; ?></label><br />
|
||||
|
||||
<input type="checkbox" name="sql_ignore" value="yes"
|
||||
id="checkbox_dump_ignore"
|
||||
<?php PMA_exportCheckboxCheck('sql_ignore'); ?> />
|
||||
<label for="checkbox_dump_ignore">
|
||||
<?php echo $strIgnoreInserts; ?></label><br />
|
||||
|
||||
<input type="checkbox" name="hexforbinary" value="yes"
|
||||
id="checkbox_hexforbinary"
|
||||
<?php PMA_exportCheckboxCheck('sql_hex_for_binary'); ?> />
|
||||
<label for="checkbox_hexforbinary">
|
||||
<?php echo $strHexForBinary; ?></label><br />
|
||||
|
||||
<label for="select_sql_type">
|
||||
<?php echo $strSQLExportType; ?>:</label>
|
||||
<select name="sql_type" id="select_sql_type">
|
||||
<option value="insert"<?php echo $cfg['Export']['sql_type'] == 'insert' ? ' selected="selected"' : ''; ?>>INSERT</option>
|
||||
<option value="update"<?php echo $cfg['Export']['sql_type'] == 'update' ? ' selected="selected"' : ''; ?>>UPDATE</option>
|
||||
<option value="replace"<?php echo $cfg['Export']['sql_type'] == 'replace' ? ' selected="selected"' : ''; ?>>REPLACE</option>
|
||||
</select>
|
||||
</fieldset>
|
||||
</fieldset>
|
||||
<?php
|
||||
} // end SQL-OPTIONS
|
||||
?>
|
||||
|
||||
<?php /* LaTeX options */ ?>
|
||||
<fieldset id="latex_options">
|
||||
<legend><?php echo $strLaTeXOptions; ?></legend>
|
||||
|
||||
<div class="formelementrow">
|
||||
<input type="checkbox" name="latex_caption" value="yes"
|
||||
id="checkbox_latex_show_caption"
|
||||
<?php PMA_exportCheckboxCheck('latex_caption'); ?> />
|
||||
<label for="checkbox_latex_show_caption">
|
||||
<?php echo $strLatexIncludeCaption; ?></label>
|
||||
</div>
|
||||
|
||||
<?php if ( ! $hide_structure ) { /* LaTeX structure */ ?>
|
||||
<fieldset>
|
||||
<legend>
|
||||
<input type="checkbox" name="latex_structure" value="structure"
|
||||
id="checkbox_latex_structure"
|
||||
<?php PMA_exportCheckboxCheck('latex_structure'); ?>
|
||||
onclick="
|
||||
if (!this.checked && !document.getElementById('checkbox_latex_data').checked)
|
||||
return false;
|
||||
else return true;" />
|
||||
<label for="checkbox_latex_structure">
|
||||
<?php echo $strStructure; ?></label>
|
||||
</legend>
|
||||
|
||||
<table>
|
||||
<tr><td><label for="latex_structure_caption">
|
||||
<?php echo $strLatexCaption; ?></label></td>
|
||||
<td><input type="text" name="latex_structure_caption" size="30"
|
||||
value="<?php echo $strLatexStructure; ?>"
|
||||
id="latex_structure_caption" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td><label for="latex_structure_continued_caption">
|
||||
<?php echo $strLatexContinuedCaption; ?></label></td>
|
||||
<td><input type="text" name="latex_structure_continued_caption"
|
||||
value="<?php echo $strLatexStructure . ' ' . $strLatexContinued; ?>"
|
||||
size="30" id="latex_structure_continued_caption" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td><label for="latex_structure_label">
|
||||
<?php echo $strLatexLabel; ?></label></td>
|
||||
<td><input type="text" name="latex_structure_label" size="30"
|
||||
value="<?php echo $cfg['Export']['latex_structure_label']; ?>"
|
||||
id="latex_structure_label" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<?php if ( ! empty( $cfgRelation['relation']) ) { ?>
|
||||
<input type="checkbox" name="latex_relation" value="yes"
|
||||
id="checkbox_latex_use_relation"
|
||||
<?php PMA_exportCheckboxCheck('latex_relation'); ?> />
|
||||
<label for="checkbox_latex_use_relation">
|
||||
<?php echo $strRelations; ?></label><br />
|
||||
<?php } if ( $cfgRelation['commwork'] ) { ?>
|
||||
<input type="checkbox" name="latex_comments" value="yes"
|
||||
id="checkbox_latex_use_comments"
|
||||
<?php PMA_exportCheckboxCheck('latex_comments'); ?> />
|
||||
<label for="checkbox_latex_use_comments">
|
||||
<?php echo $strComments; ?></label><br />
|
||||
<?php } if ( $cfgRelation['mimework'] ) { ?>
|
||||
<input type="checkbox" name="latex_mime" value="yes"
|
||||
id="checkbox_latex_use_mime"
|
||||
<?php PMA_exportCheckboxCheck('latex_mime'); ?> />
|
||||
<label for="checkbox_latex_use_mime">
|
||||
<?php echo $strMIME_MIMEtype; ?></label><br />
|
||||
<?php } ?>
|
||||
</fieldset>
|
||||
<?php
|
||||
} // end LaTeX STRUCTURE
|
||||
/* LaTeX data */
|
||||
?>
|
||||
<fieldset>
|
||||
<legend>
|
||||
<input type="checkbox" name="latex_data" value="data"
|
||||
id="checkbox_latex_data"
|
||||
<?php PMA_exportCheckboxCheck('latex_data'); ?>
|
||||
onclick="
|
||||
if (!this.checked && (!document.getElementById('checkbox_latex_structure') || !document.getElementById('checkbox_latex_structure').checked))
|
||||
return false;
|
||||
else return true;" />
|
||||
<label for="checkbox_latex_data">
|
||||
<?php echo $strData; ?></label>
|
||||
</legend>
|
||||
<input type="checkbox" name="latex_showcolumns" value="yes"
|
||||
id="ch_latex_showcolumns"
|
||||
<?php PMA_exportCheckboxCheck('latex_columns'); ?> />
|
||||
<label for="ch_latex_showcolumns">
|
||||
<?php echo $strColumnNames; ?></label><br />
|
||||
<table>
|
||||
<tr><td><label for="latex_data_caption">
|
||||
<?php echo $strLatexCaption; ?></label></td>
|
||||
<td><input type="text" name="latex_data_caption" size="30"
|
||||
value="<?php echo $strLatexContent; ?>"
|
||||
id="latex_data_caption" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td><label for="latex_data_continued_caption">
|
||||
<?php echo $strLatexContinuedCaption; ?></label></td>
|
||||
<td><input type="text" name="latex_data_continued_caption" size="30"
|
||||
value="<?php echo $strLatexContent . ' ' . $strLatexContinued; ?>"
|
||||
id="latex_data_continued_caption" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td><label for="latex_data_label">
|
||||
<?php echo $strLatexLabel; ?></label></td>
|
||||
<td><input type="text" name="latex_data_label" size="30"
|
||||
value="<?php echo $cfg['Export']['latex_data_label']; ?>"
|
||||
id="latex_data_label" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td><label for="latex_replace_null">
|
||||
<?php echo $strReplaceNULLBy; ?></label></td>
|
||||
<td><input type="text" name="latex_replace_null" size="20"
|
||||
value="<?php echo $cfg['Export']['latex_null']; ?>"
|
||||
id="latex_replace_null" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
</fieldset>
|
||||
|
||||
<?php /* CSV options */ ?>
|
||||
<fieldset id="csv_options">
|
||||
<input type="hidden" name="csv_data" value="csv_data" />
|
||||
<legend><?php echo $strCSVOptions; ?></legend>
|
||||
|
||||
<table>
|
||||
<tr><td><label for="export_separator">
|
||||
<?php echo $strFieldsTerminatedBy; ?></label></td>
|
||||
<td><input type="text" name="export_separator" size="2"
|
||||
id="export_separator"
|
||||
value="<?php echo $cfg['Export']['csv_separator']; ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td><label for="enclosed">
|
||||
<?php echo $strFieldsEnclosedBy; ?></label></td>
|
||||
<td><input type="text" name="enclosed" size="2"
|
||||
id="enclosed"
|
||||
value="<?php echo $cfg['Export']['csv_enclosed']; ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td><label for="escaped">
|
||||
<?php echo $strFieldsEscapedBy; ?></label></td>
|
||||
<td><input type="text" name="escaped" size="2"
|
||||
id="escaped"
|
||||
value="<?php echo $cfg['Export']['csv_escaped']; ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td><label for="add_character">
|
||||
<?php echo $strLinesTerminatedBy; ?></label></td>
|
||||
<td><input type="text" name="add_character" size="2"
|
||||
id="add_character"
|
||||
value="<?php if ($cfg['Export']['csv_terminated'] == 'AUTO') echo ((PMA_whichCrlf() == "\n") ? '\n' : '\r\n'); else echo $cfg['Export']['csv_terminated']; ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td><label for="csv_replace_null">
|
||||
<?php echo $strReplaceNULLBy; ?></label></td>
|
||||
<td><input type="text" name="csv_replace_null" size="20"
|
||||
id="csv_replace_null"
|
||||
value="<?php echo $cfg['Export']['csv_null']; ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<input type="checkbox" name="showcsvnames" value="yes"
|
||||
id="checkbox_dump_showcsvnames"
|
||||
<?php PMA_exportCheckboxCheck('csv_columns'); ?> />
|
||||
<label for="checkbox_dump_showcsvnames">
|
||||
<?php echo $strPutColNames; ?></label>
|
||||
</fieldset>
|
||||
|
||||
<?php /* Excel options */ ?>
|
||||
<fieldset id="excel_options">
|
||||
<input type="hidden" name="excel_data" value="excel_data" />
|
||||
<legend><?php echo $strExcelOptions; ?></legend>
|
||||
|
||||
<table>
|
||||
<tr><td><label for="excel_replace_null">
|
||||
<?php echo $strReplaceNULLBy; ?></label>
|
||||
</td>
|
||||
<td><input type="text" name="excel_replace_null" size="20"
|
||||
id="excel_replace_null"
|
||||
value="<?php echo $cfg['Export']['excel_null']; ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td><label for="select_excel_edition">
|
||||
<?php echo $strExcelEdition; ?>:
|
||||
</label>
|
||||
</td>
|
||||
<td><select name="excel_edition" id="select_excel_edition">
|
||||
<option value="win"<?php echo $cfg['Export']['excel_edition'] == 'win' ? ' selected="selected"' : ''; ?>>Windows</option>
|
||||
<option value="mac"<?php echo $cfg['Export']['excel_edition'] == 'mac' ? ' selected="selected"' : ''; ?>>Excel 2003 / Macintosh</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<input type="checkbox" name="showexcelnames" value="yes"
|
||||
id="checkbox_dump_showexcelnames"
|
||||
<?php PMA_exportCheckboxCheck('excel_columns'); ?> />
|
||||
<label for="checkbox_dump_showexcelnames">
|
||||
<?php echo $strPutColNames; ?></label>
|
||||
</fieldset>
|
||||
|
||||
<?php /* HTML Excel options */ ?>
|
||||
<fieldset id="htmlexcel_options">
|
||||
<input type="hidden" name="htmlexcel_data" value="htmlexcel_data" />
|
||||
<legend><?php echo $strHTMLExcelOptions; ?></legend>
|
||||
|
||||
<div class="formelementrow">
|
||||
<label for="htmlexcel_replace_null"><?php echo $strReplaceNULLBy; ?></label>
|
||||
<input type="text" name="htmlexcel_replace_null" size="20"
|
||||
value="<?php echo $cfg['Export']['htmlexcel_null']; ?>"
|
||||
id="htmlexcel_replace_null" />
|
||||
</div>
|
||||
|
||||
<div class="formelementrow">
|
||||
<input type="checkbox" name="htmlexcel_shownames" value="yes"
|
||||
id="checkbox_dump_htmlexcel_shownames"
|
||||
<?php PMA_exportCheckboxCheck('htmlexcel_columns'); ?> />
|
||||
<label for="checkbox_dump_htmlexcel_shownames">
|
||||
<?php echo $strPutColNames; ?></label>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<?php /* HTML Word options */ ?>
|
||||
<fieldset id="htmlword_options">
|
||||
<legend><?php echo $strHTMLWordOptions; ?></legend>
|
||||
|
||||
<div class="formelementrow">
|
||||
<input type="checkbox" name="htmlword_structure" value="structure"
|
||||
id="checkbox_htmlword_structure"
|
||||
<?php PMA_exportCheckboxCheck('htmlword_structure'); ?>
|
||||
onclick="
|
||||
if (!this.checked && (!document.getElementById('checkbox_htmlword_data') || !document.getElementById('checkbox_htmlword_data').checked))
|
||||
return false;
|
||||
else return true;" />
|
||||
<label for="checkbox_htmlword_structure">
|
||||
<?php echo $strStructure; ?></label>
|
||||
</div>
|
||||
|
||||
<fieldset>
|
||||
<legend>
|
||||
<input type="checkbox" name="htmlword_data" value="data"
|
||||
id="checkbox_htmlword_data"
|
||||
<?php PMA_exportCheckboxCheck('htmlword_data'); ?>
|
||||
onclick="
|
||||
if (!this.checked && (!document.getElementById('checkbox_htmlword_structure') || !document.getElementById('checkbox_htmlword_structure').checked))
|
||||
return false;
|
||||
else return true;" />
|
||||
<label for="checkbox_htmlword_data">
|
||||
<?php echo $strData; ?></label>
|
||||
</legend>
|
||||
|
||||
<div class="formelementrow">
|
||||
<label for="htmlword_replace_null">
|
||||
<?php echo $strReplaceNULLBy; ?></label>
|
||||
<input id="htmlword_replace_null" type="text" size="20"
|
||||
name="htmlword_replace_null"
|
||||
value="<?php echo $cfg['Export']['htmlword_null']; ?>" />
|
||||
</div>
|
||||
|
||||
<div class="formelementrow">
|
||||
<input type="checkbox" name="htmlword_shownames" value="yes"
|
||||
id="checkbox_dump_htmlword_shownames"
|
||||
<?php PMA_exportCheckboxCheck('htmlword_columns'); ?> />
|
||||
<label for="checkbox_dump_htmlword_shownames">
|
||||
<?php echo $strPutColNames; ?></label>
|
||||
</div>
|
||||
</fieldset>
|
||||
</fieldset>
|
||||
|
||||
<?php if ( $xls ) { /* Native Excel options */ ?>
|
||||
<fieldset id="xls_options">
|
||||
<input type="hidden" name="xls_data" value="xls_data" />
|
||||
<legend><?php echo $strExcelOptions; ?></legend>
|
||||
|
||||
<div class="formelementrow">
|
||||
<label for="xls_replace_null"><?php echo $strReplaceNULLBy; ?></label>
|
||||
<input type="text" name="xls_replace_null" size="20"
|
||||
value="<?php echo $cfg['Export']['xls_null']; ?>"
|
||||
id="xls_replace_null" />
|
||||
</div>
|
||||
|
||||
<div class="formelementrow">
|
||||
<input type="checkbox" name="xls_shownames" value="yes"
|
||||
id="checkbox_dump_xls_shownames"
|
||||
<?php PMA_exportCheckboxCheck('xls_columns'); ?> />
|
||||
<label for="checkbox_dump_xls_shownames">
|
||||
<?php echo $strPutColNames; ?></label>
|
||||
</div>
|
||||
</fieldset>
|
||||
<?php } /* end if ( $xls ) */ ?>
|
||||
|
||||
<?php /* PDF options */ ?>
|
||||
<fieldset id="pdf_options">
|
||||
<input type="hidden" name="pdf_data" value="pdf_data" />
|
||||
<legend><?php echo $strPDFOptions; ?></legend>
|
||||
|
||||
<div class="formelementrow">
|
||||
<label for="pdf_report_title"><?php echo $strPDFReportTitle; ?></label>
|
||||
<input type="text" name="pdf_report_title" size="50"
|
||||
value="<?php echo $cfg['Export']['pdf_report_title']; ?>"
|
||||
id="pdf_report_title" />
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset id="none_options">
|
||||
<legend><?php echo $strXML; ?></legend>
|
||||
<?php echo $strNoOptions; ?>
|
||||
<input type="hidden" name="xml_data" value="xml_data" />
|
||||
</fieldset>
|
||||
|
||||
<?php echo PMA_pluginGetOptions('Export', $export_list); ?>
|
||||
</div>
|
||||
</td></tr></table>
|
||||
|
||||
<script type="text/javascript" language="javascript">
|
||||
//<![CDATA[
|
||||
show_checked_option();
|
||||
init_options();
|
||||
//]]>
|
||||
</script>
|
||||
|
||||
|
@@ -6,6 +6,23 @@
|
||||
* Set of functions used to build CSV dumps of tables
|
||||
*/
|
||||
|
||||
if (isset($plugin_list)) {
|
||||
$plugin_list['csv'] = array(
|
||||
'text' => 'strStrucCSV',
|
||||
'extension' => 'csv',
|
||||
'options' => array(
|
||||
array('type' => 'text', 'name' => 'separator', 'text' => 'strFieldsTerminatedBy'),
|
||||
array('type' => 'text', 'name' => 'enclosed', 'text' => 'strFieldsEnclosedBy'),
|
||||
array('type' => 'text', 'name' => 'escaped', 'text' => 'strFieldsEscapedBy'),
|
||||
array('type' => 'text', 'name' => 'terminated', 'text' => 'strLinesTerminatedBy'),
|
||||
array('type' => 'text', 'name' => 'null', 'text' => 'strReplaceNULLBy'),
|
||||
array('type' => 'bool', 'name' => 'columns', 'text' => 'strPutColNames'),
|
||||
array('type' => 'hidden', 'name' => 'data'),
|
||||
),
|
||||
'options_text' => 'strCSVOptions',
|
||||
);
|
||||
} else {
|
||||
|
||||
/**
|
||||
* Outputs comment
|
||||
*
|
||||
@@ -37,29 +54,29 @@ function PMA_exportFooter() {
|
||||
*/
|
||||
function PMA_exportHeader() {
|
||||
global $what;
|
||||
global $add_character;
|
||||
global $export_separator;
|
||||
global $enclosed;
|
||||
global $escaped;
|
||||
global $csv_terminated;
|
||||
global $csv_separator;
|
||||
global $csv_enclosed;
|
||||
global $csv_escaped;
|
||||
|
||||
// Here we just prepare some values for export
|
||||
if ($what == 'excel') {
|
||||
$add_character = "\015\012";
|
||||
$export_separator = isset($GLOBALS['excel_edition']) && $GLOBALS['excel_edition'] == 'mac' ? ';' : ',';
|
||||
$enclosed = '"';
|
||||
$escaped = '"';
|
||||
if (isset($GLOBALS['showexcelnames']) && $GLOBALS['showexcelnames'] == 'yes') {
|
||||
$GLOBALS['showcsvnames'] = 'yes';
|
||||
$csv_terminated = "\015\012";
|
||||
$csv_separator = isset($GLOBALS['excel_edition']) && $GLOBALS['excel_edition'] == 'mac' ? ';' : ',';
|
||||
$csv_enclosed = '"';
|
||||
$csv_escaped = '"';
|
||||
if (isset($GLOBALS['excel_columns'])) {
|
||||
$GLOBALS['cvs_columns'] = 'yes';
|
||||
}
|
||||
} else {
|
||||
if (empty($add_character)) {
|
||||
$add_character = $GLOBALS['crlf'];
|
||||
if (empty($csv_terminated)) {
|
||||
$csv_terminated = $GLOBALS['crlf'];
|
||||
} else {
|
||||
$add_character = str_replace('\\r', "\015", $add_character);
|
||||
$add_character = str_replace('\\n', "\012", $add_character);
|
||||
$add_character = str_replace('\\t', "\011", $add_character);
|
||||
$csv_terminated = str_replace('\\r', "\015", $csv_terminated);
|
||||
$csv_terminated = str_replace('\\n', "\012", $csv_terminated);
|
||||
$csv_terminated = str_replace('\\t', "\011", $csv_terminated);
|
||||
} // end if
|
||||
$export_separator = str_replace('\\t', "\011", $export_separator);
|
||||
$csv_separator = str_replace('\\t', "\011", $csv_separator);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@@ -118,30 +135,30 @@ function PMA_exportDBCreate($db) {
|
||||
*/
|
||||
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
|
||||
global $what;
|
||||
global $add_character;
|
||||
global $export_separator;
|
||||
global $enclosed;
|
||||
global $escaped;
|
||||
global $csv_terminated;
|
||||
global $csv_separator;
|
||||
global $csv_enclosed;
|
||||
global $csv_escaped;
|
||||
|
||||
// Gets the data from the database
|
||||
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
|
||||
$fields_cnt = PMA_DBI_num_fields($result);
|
||||
|
||||
// If required, get fields name at the first line
|
||||
if (isset($GLOBALS['showcsvnames']) && $GLOBALS['showcsvnames'] == 'yes') {
|
||||
if (isset($GLOBALS['cvs_columns'])) {
|
||||
$schema_insert = '';
|
||||
for ($i = 0; $i < $fields_cnt; $i++) {
|
||||
if ($enclosed == '') {
|
||||
if ($csv_enclosed == '') {
|
||||
$schema_insert .= stripslashes(PMA_DBI_field_name($result, $i));
|
||||
} else {
|
||||
$schema_insert .= $enclosed
|
||||
. str_replace($enclosed, $escaped . $enclosed, stripslashes(PMA_DBI_field_name($result, $i)))
|
||||
. $enclosed;
|
||||
$schema_insert .= $csv_enclosed
|
||||
. str_replace($csv_enclosed, $csv_escaped . $csv_enclosed, stripslashes(PMA_DBI_field_name($result, $i)))
|
||||
. $csv_enclosed;
|
||||
}
|
||||
$schema_insert .= $export_separator;
|
||||
$schema_insert .= $csv_separator;
|
||||
} // end for
|
||||
$schema_insert =trim(substr($schema_insert, 0, -1));
|
||||
if (!PMA_exportOutputHandler($schema_insert . $add_character)) {
|
||||
if (!PMA_exportOutputHandler($schema_insert . $csv_terminated)) {
|
||||
return FALSE;
|
||||
}
|
||||
} // end if
|
||||
@@ -151,28 +168,28 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
|
||||
$schema_insert = '';
|
||||
for ($j = 0; $j < $fields_cnt; $j++) {
|
||||
if (!isset($row[$j]) || is_null($row[$j])) {
|
||||
$schema_insert .= $GLOBALS[$what . '_replace_null'];
|
||||
$schema_insert .= $GLOBALS[$what . '_null'];
|
||||
} elseif ($row[$j] == '0' || $row[$j] != '') {
|
||||
// loic1 : always enclose fields
|
||||
if ($what == 'excel') {
|
||||
$row[$j] = ereg_replace("\015(\012)?", "\012", $row[$j]);
|
||||
}
|
||||
if ($enclosed == '') {
|
||||
if ($csv_enclosed == '') {
|
||||
$schema_insert .= $row[$j];
|
||||
} else {
|
||||
$schema_insert .= $enclosed
|
||||
. str_replace($enclosed, $escaped . $enclosed, $row[$j])
|
||||
. $enclosed;
|
||||
$schema_insert .= $csv_enclosed
|
||||
. str_replace($csv_enclosed, $csv_escaped . $csv_enclosed, $row[$j])
|
||||
. $csv_enclosed;
|
||||
}
|
||||
} else {
|
||||
$schema_insert .= '';
|
||||
}
|
||||
if ($j < $fields_cnt-1) {
|
||||
$schema_insert .= $export_separator;
|
||||
$schema_insert .= $csv_separator;
|
||||
}
|
||||
} // end for
|
||||
|
||||
if (!PMA_exportOutputHandler($schema_insert . $add_character)) {
|
||||
if (!PMA_exportOutputHandler($schema_insert . $csv_terminated)) {
|
||||
return FALSE;
|
||||
}
|
||||
} // end while
|
||||
@@ -180,4 +197,6 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
|
||||
|
||||
return TRUE;
|
||||
} // end of the 'PMA_getTableCsv()' function
|
||||
|
||||
}
|
||||
?>
|
||||
|
25
libraries/export/excel.php
Normal file
25
libraries/export/excel.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/* $Id$ */
|
||||
// vim: expandtab sw=4 ts=4 sts=4:
|
||||
|
||||
/**
|
||||
* Set of functions used to build CSV dumps of tables
|
||||
*/
|
||||
|
||||
if (isset($plugin_list)) {
|
||||
$plugin_list['excel'] = array(
|
||||
'text' => 'strStrucExcelCSV',
|
||||
'extension' => 'xls',
|
||||
'options' => array(
|
||||
array('type' => 'text', 'name' => 'null', 'text' => 'strReplaceNULLBy'),
|
||||
array('type' => 'bool', 'name' => 'columns', 'text' => 'strPutColNames'),
|
||||
array('type' => 'select', 'name' => 'edition', 'values' => array('win' => 'Windows', 'mac' => 'Excel 2003 / Macintosh'), 'text' => 'strExcelEdition'),
|
||||
array('type' => 'hidden', 'name' => 'data'),
|
||||
),
|
||||
'options_text' => 'strExcelOptions',
|
||||
);
|
||||
} else {
|
||||
/* Everything rest is coded in csv plugin */
|
||||
require('./libraries/export/csv.php');
|
||||
}
|
||||
?>
|
@@ -6,6 +6,19 @@
|
||||
* Set of functions used to build CSV dumps of tables
|
||||
*/
|
||||
|
||||
if (isset($plugin_list)) {
|
||||
$plugin_list['htmlexcel'] = array(
|
||||
'text' => 'strHTMLExcel',
|
||||
'extension' => 'xsl',
|
||||
'options' => array(
|
||||
array('type' => 'text', 'name' => 'null', 'text' => 'strReplaceNULLBy'),
|
||||
array('type' => 'bool', 'name' => 'columns', 'text' => 'strPutColNames'),
|
||||
array('type' => 'hidden', 'name' => 'data'),
|
||||
),
|
||||
'options_text' => 'strHTMLExcelOptions',
|
||||
);
|
||||
} else {
|
||||
|
||||
/**
|
||||
* Outputs comment
|
||||
*
|
||||
@@ -130,7 +143,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
|
||||
$fields_cnt = PMA_DBI_num_fields($result);
|
||||
|
||||
// If required, get fields name at the first line
|
||||
if (isset($GLOBALS[$what . '_shownames']) && $GLOBALS[$what . '_shownames'] == 'yes') {
|
||||
if (isset($GLOBALS[$what . '_columns'])) {
|
||||
$schema_insert = '<tr>';
|
||||
for ($i = 0; $i < $fields_cnt; $i++) {
|
||||
$schema_insert .= '<td class=xl2216681 nowrap><b>' . htmlspecialchars(stripslashes(PMA_DBI_field_name($result, $i))) . '</b></td>';
|
||||
@@ -146,7 +159,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
|
||||
$schema_insert = '<tr>';
|
||||
for ($j = 0; $j < $fields_cnt; $j++) {
|
||||
if (!isset($row[$j]) || is_null($row[$j])) {
|
||||
$value = $GLOBALS[$what . '_replace_null'];
|
||||
$value = $GLOBALS[$what . '_null'];
|
||||
} elseif ($row[$j] == '0' || $row[$j] != '') {
|
||||
$value = $row[$j];
|
||||
} else {
|
||||
@@ -163,4 +176,6 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
@@ -6,6 +6,21 @@
|
||||
* Set of functions used to build CSV dumps of tables
|
||||
*/
|
||||
|
||||
if (isset($plugin_list)) {
|
||||
$plugin_list['htmlword'] = array(
|
||||
'text' => 'strHTMLWord',
|
||||
'extension' => 'doc',
|
||||
'options' => array(
|
||||
array('type' => 'bool', 'name' => 'structure', 'text' => 'strStructure', 'force' => 'data'),
|
||||
array('type' => 'bgroup', 'name' => 'data', 'text' => 'strData', 'force' => 'structure'),
|
||||
array('type' => 'text', 'name' => 'null', 'text' => 'strReplaceNULLBy'),
|
||||
array('type' => 'bool', 'name' => 'columns', 'text' => 'strPutColNames'),
|
||||
array('type' => 'egroup'),
|
||||
),
|
||||
'options_text' => 'strHTMLWordOptions',
|
||||
);
|
||||
} else {
|
||||
|
||||
/**
|
||||
* Outputs comment
|
||||
*
|
||||
@@ -133,7 +148,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
|
||||
$schema_insert = '<tr class="print-category">';
|
||||
for ($j = 0; $j < $fields_cnt; $j++) {
|
||||
if (!isset($row[$j]) || is_null($row[$j])) {
|
||||
$value = $GLOBALS[$what . '_replace_null'];
|
||||
$value = $GLOBALS[$what . '_null'];
|
||||
} elseif ($row[$j] == '0' || $row[$j] != '') {
|
||||
$value = $row[$j];
|
||||
} else {
|
||||
@@ -320,4 +335,6 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
|
||||
|
||||
return PMA_exportOutputHandler('</table>');
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
@@ -6,6 +6,62 @@
|
||||
* Set of functions used to build dumps of tables
|
||||
*/
|
||||
|
||||
if (isset($plugin_list)) {
|
||||
$hide_structure = false;
|
||||
if ($plugin_param['export_type'] == 'table' && !$plugin_param['single_table']) {
|
||||
$hide_structure = true;
|
||||
}
|
||||
$plugin_list['latex'] = array(
|
||||
'text' => 'strLaTeX',
|
||||
'extension' => 'tex',
|
||||
'options' => array(
|
||||
array('type' => 'bool', 'name' => 'caption', 'text' => 'strLatexIncludeCaption'),
|
||||
),
|
||||
'options_text' => 'strLaTeXOptions',
|
||||
);
|
||||
/* Structure options */
|
||||
if (!$hide_structure) {
|
||||
$plugin_list['latex']['options'][] =
|
||||
array('type' => 'bgroup', 'name' => 'structure', 'text' => 'strStructure', 'force' => 'data');
|
||||
$plugin_list['latex']['options'][] =
|
||||
array('type' => 'text', 'name' => 'structure_caption', 'text' => 'strLatexCaption');
|
||||
$plugin_list['latex']['options'][] =
|
||||
array('type' => 'text', 'name' => 'structure_continued_caption', 'text' => 'strLatexContinuedCaption');
|
||||
$plugin_list['latex']['options'][] =
|
||||
array('type' => 'text', 'name' => 'structure_label', 'text' => 'strLatexLabel');
|
||||
if (!empty($GLOBALS['cfgRelation']['relation'])) {
|
||||
$plugin_list['latex']['options'][] =
|
||||
array('type' => 'bool', 'name' => 'relation', 'text' => 'strRelations');
|
||||
}
|
||||
if (!empty($GLOBALS['cfgRelation']['commwork']) && PMA_MYSQL_INT_VERSION < 40100) {
|
||||
$plugin_list['latex']['options'][] =
|
||||
array('type' => 'bool', 'name' => 'comments', 'text' => 'strComments');
|
||||
}
|
||||
if (!empty($GLOBALS['cfgRelation']['mimework'])) {
|
||||
$plugin_list['latex']['options'][] =
|
||||
array('type' => 'bool', 'name' => 'mime', 'text' => 'strMIME_MIMEtype');
|
||||
}
|
||||
$plugin_list['latex']['options'][] =
|
||||
array('type' => 'egroup');
|
||||
}
|
||||
/* Data */
|
||||
$plugin_list['latex']['options'][] =
|
||||
array('type' => 'bgroup', 'name' => 'data', 'text' => 'strData', 'force' => 'structure');
|
||||
$plugin_list['latex']['options'][] =
|
||||
array('type' => 'bool', 'name' => 'columns', 'text' => 'strPutColNames');
|
||||
$plugin_list['latex']['options'][] =
|
||||
array('type' => 'text', 'name' => 'data_caption', 'text' => 'strLatexCaption');
|
||||
$plugin_list['latex']['options'][] =
|
||||
array('type' => 'text', 'name' => 'data_continued_caption', 'text' => 'strLatexContinuedCaption');
|
||||
$plugin_list['latex']['options'][] =
|
||||
array('type' => 'text', 'name' => 'data_label', 'text' => 'strLatexLabel');
|
||||
$plugin_list['latex']['options'][] =
|
||||
array('type' => 'text', 'name' => 'null', 'text' => 'strReplaceNULLBy');
|
||||
$plugin_list['latex']['options'][] =
|
||||
array('type' => 'egroup');
|
||||
/* FIXME: force either data or structure */
|
||||
} else {
|
||||
|
||||
/**
|
||||
* Escapes some special characters for use in TeX/LaTeX
|
||||
*
|
||||
@@ -155,7 +211,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
|
||||
}
|
||||
|
||||
// show column names
|
||||
if (isset($GLOBALS['latex_showcolumns'])) {
|
||||
if (isset($GLOBALS['latex_columns'])) {
|
||||
$buffer = '\\hline ';
|
||||
for ($i = 0; $i < $columns_cnt; $i++) {
|
||||
$buffer .= '\\multicolumn{1}{|c|}{\\textbf{' . PMA_texEscape(stripslashes($columns[$i])) . '}} & ';
|
||||
@@ -186,7 +242,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
|
||||
if ( isset($record[$columns[$i]]) && (!function_exists('is_null') || !is_null($record[$columns[$i]]))) {
|
||||
$column_value = PMA_texEscape(stripslashes($record[$columns[$i]]));
|
||||
} else {
|
||||
$column_value = $GLOBALS['latex_replace_null'];
|
||||
$column_value = $GLOBALS['latex_null'];
|
||||
}
|
||||
|
||||
// last column ... no need for & character
|
||||
@@ -244,7 +300,7 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
|
||||
}
|
||||
}
|
||||
PMA_DBI_free_result($keys_result);
|
||||
|
||||
|
||||
/**
|
||||
* Gets fields properties
|
||||
*/
|
||||
@@ -414,4 +470,6 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
|
||||
$buffer = ' \\end{longtable}' . $crlf;
|
||||
return PMA_exportOutputHandler($buffer);
|
||||
} // end of the 'PMA_getTableStructureLaTeX()' function
|
||||
|
||||
}
|
||||
?>
|
||||
|
@@ -6,6 +6,17 @@
|
||||
* Produce a PDF report (export) from a query
|
||||
*/
|
||||
|
||||
if (isset($plugin_list)) {
|
||||
$plugin_list['pdf'] = array(
|
||||
'text' => 'strPDF',
|
||||
'extension' => 'pdf',
|
||||
'options' => array(
|
||||
array('type' => 'text', 'name' => 'report_title', 'text' => 'strPDFReportTitle'),
|
||||
array('type' => 'hidden', 'name' => 'data'),
|
||||
),
|
||||
'options_text' => 'strPDFOptions',
|
||||
);
|
||||
} else {
|
||||
|
||||
define('FPDF_FONTPATH', './libraries/fpdf/font/');
|
||||
//if ($charset == 'utf-8') {
|
||||
@@ -399,4 +410,5 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
|
||||
|
||||
return TRUE;
|
||||
} // end of the 'PMA_exportData()' function
|
||||
}
|
||||
?>
|
||||
|
@@ -5,6 +5,116 @@
|
||||
* Set of functions used to build SQL dumps of tables
|
||||
*/
|
||||
|
||||
if (isset($plugin_list)) {
|
||||
$hide_sql = false;
|
||||
$hide_structure = false;
|
||||
if ($plugin_param['export_type'] == 'table' && !$plugin_param['single_table']) {
|
||||
$hide_structure = true;
|
||||
$hide_sql = true;
|
||||
}
|
||||
if (!$hide_sql) {
|
||||
$plugin_list['sql'] = array(
|
||||
'text' => 'strSQL',
|
||||
'extension' => 'sql',
|
||||
'options' => array(
|
||||
array('type' => 'text', 'name' => 'header_comment', 'text' => 'strAddHeaderComment'),
|
||||
array('type' => 'bool', 'name' => 'use_transaction', 'text' => 'strEncloseInTransaction'),
|
||||
array('type' => 'bool', 'name' => 'disable_fk', 'text' => 'strDisableForeignChecks'),
|
||||
),
|
||||
'options_text' => 'strSQLOptions',
|
||||
);
|
||||
$compats = PMA_DBI_getCompatibilities();
|
||||
if (count($compats) > 0) {
|
||||
$values = array();
|
||||
foreach($compats as $val) {
|
||||
$values[$val] = $val;
|
||||
}
|
||||
$plugin_list['sql']['options'][] =
|
||||
array('type' => 'select', 'name' => 'compatibility', 'text' => 'strSQLCompatibility', 'values' => $values, 'doc' => array('manual_MySQL_Database_Administration', 'Server_SQL_mode'));
|
||||
unset($values);
|
||||
}
|
||||
|
||||
/* Server export options */
|
||||
if ($plugin_param['export_type'] == 'server') {
|
||||
$plugin_list['sql']['options'][] =
|
||||
array('type' => 'bgroup', 'text' => 'strDatabaseExportOptions');
|
||||
$plugin_list['sql']['options'][] =
|
||||
array('type' => 'bool', 'name' => 'drop_database', 'text' => sprintf($GLOBALS['strAddClause'], 'DROP DATABASE'));
|
||||
$plugin_list['sql']['options'][] =
|
||||
array('type' => 'egroup');
|
||||
}
|
||||
|
||||
/* Structure options */
|
||||
if (!$hide_structure) {
|
||||
$plugin_list['sql']['options'][] =
|
||||
array('type' => 'bgroup', 'name' => 'structure', 'text' => 'strStructure', 'force' => 'data');
|
||||
if ($plugin_param['export_type'] == 'table') {
|
||||
if (PMA_Table::_isView($GLOBALS['db'], $GLOBALS['table'])) {
|
||||
$drop_clause = 'DROP VIEW';
|
||||
} else {
|
||||
$drop_clause = 'DROP TABLE';
|
||||
}
|
||||
} elseif (PMA_MYSQL_INT_VERSION >= 50000) {
|
||||
$drop_clause = 'DROP TABLE / DROP VIEW';
|
||||
} else {
|
||||
$drop_clause = 'DROP TABLE';
|
||||
}
|
||||
$plugin_list['sql']['options'][] =
|
||||
array('type' => 'bool', 'name' => 'drop', 'text' => sprintf($GLOBALS['strAddClause'], $drop_clause));
|
||||
$plugin_list['sql']['options'][] =
|
||||
array('type' => 'bool', 'name' => 'if_not_exists', 'text' => sprintf($GLOBALS['strAddClause'], 'IF NOT EXISTS'));
|
||||
$plugin_list['sql']['options'][] =
|
||||
array('type' => 'bool', 'name' => 'auto_increment', 'text' => 'strAddAutoIncrement');
|
||||
$plugin_list['sql']['options'][] =
|
||||
array('type' => 'bool', 'name' => 'use_backquotes', 'text' => 'strUseBackquotes');
|
||||
|
||||
/* MIME stuff etc. */
|
||||
$plugin_list['sql']['options'][] =
|
||||
array('type' => 'bgroup', 'text' => 'strAddIntoComments');
|
||||
$plugin_list['sql']['options'][] =
|
||||
array('type' => 'bool', 'name' => 'dates', 'text' => 'strCreationDates');
|
||||
if (!empty($GLOBALS['cfgRelation']['relation'])) {
|
||||
$plugin_list['sql']['options'][] =
|
||||
array('type' => 'bool', 'name' => 'relation', 'text' => 'strRelations');
|
||||
}
|
||||
if (!empty($GLOBALS['cfgRelation']['commwork']) && PMA_MYSQL_INT_VERSION < 40100) {
|
||||
$plugin_list['sql']['options'][] =
|
||||
array('type' => 'bool', 'name' => 'comments', 'text' => 'strComments');
|
||||
}
|
||||
if (!empty($GLOBALS['cfgRelation']['mimework'])) {
|
||||
$plugin_list['sql']['options'][] =
|
||||
array('type' => 'bool', 'name' => 'mime', 'text' => 'strMIME_MIMEtype');
|
||||
}
|
||||
$plugin_list['sql']['options'][] =
|
||||
array('type' => 'egroup');
|
||||
|
||||
$plugin_list['sql']['options'][] =
|
||||
array('type' => 'egroup');
|
||||
}
|
||||
|
||||
/* Data */
|
||||
$plugin_list['sql']['options'][] =
|
||||
array('type' => 'bgroup', 'name' => 'data', 'text' => 'strData', 'force' => 'structure');
|
||||
$plugin_list['sql']['options'][] =
|
||||
array('type' => 'bool', 'name' => 'columns', 'text' => 'strCompleteInserts');
|
||||
$plugin_list['sql']['options'][] =
|
||||
array('type' => 'bool', 'name' => 'extended', 'text' => 'strExtendedInserts');
|
||||
$plugin_list['sql']['options'][] =
|
||||
array('type' => 'text', 'name' => 'max_query_size', 'text' => 'strMaximalQueryLength');
|
||||
$plugin_list['sql']['options'][] =
|
||||
array('type' => 'bool', 'name' => 'delayed', 'text' => 'strDelayedInserts');
|
||||
$plugin_list['sql']['options'][] =
|
||||
array('type' => 'bool', 'name' => 'ignore', 'text' => 'strIgnoreInserts');
|
||||
$plugin_list['sql']['options'][] =
|
||||
array('type' => 'bool', 'name' => 'hex_for_binary', 'text' => 'strHexForBinary');
|
||||
$plugin_list['sql']['options'][] =
|
||||
array('type' => 'select', 'name' => 'type', 'text' => 'strSQLExportType', 'values' => array('INSERT', 'UPDATE', 'REPLACE'));
|
||||
$plugin_list['sql']['options'][] =
|
||||
array('type' => 'egroup');
|
||||
/* FIXME: force either data or structure */
|
||||
}
|
||||
} else {
|
||||
|
||||
/**
|
||||
* Marker for comments, -- is needed for ANSI SQL.
|
||||
*/
|
||||
@@ -13,8 +123,8 @@ $GLOBALS['comment_marker'] = '-- ';
|
||||
/**
|
||||
* Avoids undefined variables, use NULL so isset() returns false
|
||||
*/
|
||||
if ( ! isset( $use_backquotes ) ) {
|
||||
$use_backquotes = null;
|
||||
if ( ! isset( $sql_use_backquotes ) ) {
|
||||
$sql_use_backquotes = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,11 +152,11 @@ function PMA_exportFooter()
|
||||
|
||||
$foot = '';
|
||||
|
||||
if (isset($GLOBALS['disable_fk'])) {
|
||||
if (isset($GLOBALS['sql_disable_fk'])) {
|
||||
$foot .= $crlf . 'SET FOREIGN_KEY_CHECKS=1;' . $crlf;
|
||||
}
|
||||
|
||||
if (isset($GLOBALS['use_transaction'])) {
|
||||
if (isset($GLOBALS['sql_use_transaction'])) {
|
||||
$foot .= $crlf . 'COMMIT;' . $crlf;
|
||||
}
|
||||
|
||||
@@ -82,18 +192,18 @@ function PMA_exportHeader()
|
||||
. $GLOBALS['comment_marker'] . $GLOBALS['strServerVersion'] . ': ' . substr(PMA_MYSQL_INT_VERSION, 0, 1) . '.' . (int) substr(PMA_MYSQL_INT_VERSION, 1, 2) . '.' . (int) substr(PMA_MYSQL_INT_VERSION, 3) . $crlf
|
||||
. $GLOBALS['comment_marker'] . $GLOBALS['strPHPVersion'] . ': ' . phpversion() . $crlf;
|
||||
|
||||
if (isset($GLOBALS['header_comment']) && !empty($GLOBALS['header_comment'])) {
|
||||
$lines = explode('\n', $GLOBALS['header_comment']);
|
||||
if (isset($GLOBALS['sql_header_comment']) && !empty($GLOBALS['sql_header_comment'])) {
|
||||
$lines = explode('\n', $GLOBALS['sql_header_comment']);
|
||||
$head .= $GLOBALS['comment_marker'] . $crlf
|
||||
. $GLOBALS['comment_marker'] . implode($crlf . $GLOBALS['comment_marker'], $lines) . $crlf
|
||||
. $GLOBALS['comment_marker'] . $crlf;
|
||||
}
|
||||
|
||||
if (isset($GLOBALS['disable_fk'])) {
|
||||
if (isset($GLOBALS['sql_disable_fk'])) {
|
||||
$head .= $crlf . 'SET FOREIGN_KEY_CHECKS=0;' . $crlf;
|
||||
}
|
||||
|
||||
if (isset($GLOBALS['use_transaction'])) {
|
||||
if (isset($GLOBALS['sql_use_transaction'])) {
|
||||
$head .= $crlf .'SET AUTOCOMMIT=0;' . $crlf
|
||||
. 'START TRANSACTION;' . $crlf . $crlf;
|
||||
}
|
||||
@@ -113,12 +223,12 @@ function PMA_exportHeader()
|
||||
function PMA_exportDBCreate($db)
|
||||
{
|
||||
global $crlf;
|
||||
if (isset($GLOBALS['drop_database'])) {
|
||||
if (!PMA_exportOutputHandler('DROP DATABASE ' . (isset($GLOBALS['use_backquotes']) ? PMA_backquote($db) : $db) . ';' . $crlf)) {
|
||||
if (isset($GLOBALS['sql_drop_database'])) {
|
||||
if (!PMA_exportOutputHandler('DROP DATABASE ' . (isset($GLOBALS['sql_use_backquotes']) ? PMA_backquote($db) : $db) . ';' . $crlf)) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
$create_query = 'CREATE DATABASE ' . (isset($GLOBALS['use_backquotes']) ? PMA_backquote($db) : $db);
|
||||
$create_query = 'CREATE DATABASE ' . (isset($GLOBALS['sql_use_backquotes']) ? PMA_backquote($db) : $db);
|
||||
if (PMA_MYSQL_INT_VERSION >= 40101) {
|
||||
$collation = PMA_getDbCollation($db);
|
||||
if (strpos($collation, '_')) {
|
||||
@@ -131,7 +241,7 @@ function PMA_exportDBCreate($db)
|
||||
if (!PMA_exportOutputHandler($create_query)) {
|
||||
return FALSE;
|
||||
}
|
||||
if (isset($GLOBALS['use_backquotes']) && PMA_MYSQL_INT_VERSION >= 40100 && isset($GLOBALS['sql_compat']) && $GLOBALS['sql_compat'] == 'NONE') {
|
||||
if (isset($GLOBALS['sql_use_backquotes']) && PMA_MYSQL_INT_VERSION >= 40100 && isset($GLOBALS['sql_compat']) && $GLOBALS['sql_compat'] == 'NONE') {
|
||||
return PMA_exportOutputHandler('USE ' . PMA_backquote($db) . ';' . $crlf);
|
||||
}
|
||||
return PMA_exportOutputHandler('USE ' . $db . ';' . $crlf);
|
||||
@@ -150,7 +260,7 @@ function PMA_exportDBHeader($db)
|
||||
{
|
||||
global $crlf;
|
||||
$head = $GLOBALS['comment_marker'] . $crlf
|
||||
. $GLOBALS['comment_marker'] . $GLOBALS['strDatabase'] . ': ' . (isset($GLOBALS['use_backquotes']) ? PMA_backquote($db) : '\'' . $db . '\''). $crlf
|
||||
. $GLOBALS['comment_marker'] . $GLOBALS['strDatabase'] . ': ' . (isset($GLOBALS['sql_use_backquotes']) ? PMA_backquote($db) : '\'' . $db . '\''). $crlf
|
||||
. $GLOBALS['comment_marker'] . $crlf;
|
||||
return PMA_exportOutputHandler($head);
|
||||
}
|
||||
@@ -193,8 +303,8 @@ function PMA_exportDBFooter($db)
|
||||
*/
|
||||
function PMA_getTableDef($db, $table, $crlf, $error_url, $show_dates = false)
|
||||
{
|
||||
global $drop;
|
||||
global $use_backquotes;
|
||||
global $sql_drop;
|
||||
global $sql_use_backquotes;
|
||||
global $cfgRelation;
|
||||
global $sql_constraints;
|
||||
|
||||
@@ -231,19 +341,19 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $show_dates = false)
|
||||
|
||||
$schema_create .= $new_crlf;
|
||||
|
||||
if (!empty($drop)) {
|
||||
if (!empty($sql_drop)) {
|
||||
if (PMA_Table::_isView($db,$table)) {
|
||||
$drop_clause = 'DROP VIEW';
|
||||
} else {
|
||||
$drop_clause = 'DROP TABLE';
|
||||
}
|
||||
$schema_create .= $drop_clause . ' IF EXISTS ' . PMA_backquote($table, $use_backquotes) . ';' . $crlf;
|
||||
$schema_create .= $drop_clause . ' IF EXISTS ' . PMA_backquote($table, $sql_use_backquotes) . ';' . $crlf;
|
||||
unset($drop_clause);
|
||||
}
|
||||
|
||||
// Steve Alberty's patch for complete table dump,
|
||||
// Whether to quote table and fields names or not
|
||||
if ($use_backquotes) {
|
||||
if ($sql_use_backquotes) {
|
||||
PMA_DBI_query('SET SQL_QUOTE_SHOW_CREATE = 1');
|
||||
} else {
|
||||
PMA_DBI_query('SET SQL_QUOTE_SHOW_CREATE = 0');
|
||||
@@ -264,7 +374,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $show_dates = false)
|
||||
}
|
||||
|
||||
// Should we use IF NOT EXISTS?
|
||||
if (isset($GLOBALS['if_not_exists'])) {
|
||||
if (isset($GLOBALS['sql_if_not_exists'])) {
|
||||
$create_query = preg_replace('/^CREATE TABLE/', 'CREATE TABLE IF NOT EXISTS', $create_query);
|
||||
}
|
||||
|
||||
@@ -357,7 +467,7 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $show_dates = false)
|
||||
function PMA_getTableComments($db, $table, $crlf, $do_relation = false, $do_comments = false, $do_mime = false)
|
||||
{
|
||||
global $cfgRelation;
|
||||
global $use_backquotes;
|
||||
global $sql_use_backquotes;
|
||||
global $sql_constraints;
|
||||
|
||||
$schema_create = '';
|
||||
@@ -392,32 +502,32 @@ function PMA_getTableComments($db, $table, $crlf, $do_relation = false, $do_comm
|
||||
|
||||
if (isset($comments_map) && count($comments_map) > 0) {
|
||||
$schema_create .= $crlf . $GLOBALS['comment_marker'] . $crlf
|
||||
. $GLOBALS['comment_marker'] . $GLOBALS['strCommentsForTable']. ' ' . PMA_backquote($table, $use_backquotes) . ':' . $crlf;
|
||||
. $GLOBALS['comment_marker'] . $GLOBALS['strCommentsForTable']. ' ' . PMA_backquote($table, $sql_use_backquotes) . ':' . $crlf;
|
||||
foreach ($comments_map AS $comment_field => $comment) {
|
||||
$schema_create .= $GLOBALS['comment_marker'] . ' ' . PMA_backquote($comment_field, $use_backquotes) . $crlf
|
||||
. $GLOBALS['comment_marker'] . ' ' . PMA_backquote($comment, $use_backquotes) . $crlf;
|
||||
$schema_create .= $GLOBALS['comment_marker'] . ' ' . PMA_backquote($comment_field, $sql_use_backquotes) . $crlf
|
||||
. $GLOBALS['comment_marker'] . ' ' . PMA_backquote($comment, $sql_use_backquotes) . $crlf;
|
||||
}
|
||||
$schema_create .= $GLOBALS['comment_marker'] . $crlf;
|
||||
}
|
||||
|
||||
if (isset($mime_map) && count($mime_map) > 0) {
|
||||
$schema_create .= $crlf . $GLOBALS['comment_marker'] . $crlf
|
||||
. $GLOBALS['comment_marker'] . $GLOBALS['strMIMETypesForTable']. ' ' . PMA_backquote($table, $use_backquotes) . ':' . $crlf;
|
||||
. $GLOBALS['comment_marker'] . $GLOBALS['strMIMETypesForTable']. ' ' . PMA_backquote($table, $sql_use_backquotes) . ':' . $crlf;
|
||||
@reset($mime_map);
|
||||
foreach ($mime_map AS $mime_field => $mime) {
|
||||
$schema_create .= $GLOBALS['comment_marker'] . ' ' . PMA_backquote($mime_field, $use_backquotes) . $crlf
|
||||
. $GLOBALS['comment_marker'] . ' ' . PMA_backquote($mime['mimetype'], $use_backquotes) . $crlf;
|
||||
$schema_create .= $GLOBALS['comment_marker'] . ' ' . PMA_backquote($mime_field, $sql_use_backquotes) . $crlf
|
||||
. $GLOBALS['comment_marker'] . ' ' . PMA_backquote($mime['mimetype'], $sql_use_backquotes) . $crlf;
|
||||
}
|
||||
$schema_create .= $GLOBALS['comment_marker'] . $crlf;
|
||||
}
|
||||
|
||||
if ($have_rel) {
|
||||
$schema_create .= $crlf . $GLOBALS['comment_marker'] . $crlf
|
||||
. $GLOBALS['comment_marker'] . $GLOBALS['strRelationsForTable']. ' ' . PMA_backquote($table, $use_backquotes) . ':' . $crlf;
|
||||
. $GLOBALS['comment_marker'] . $GLOBALS['strRelationsForTable']. ' ' . PMA_backquote($table, $sql_use_backquotes) . ':' . $crlf;
|
||||
foreach ($res_rel AS $rel_field => $rel) {
|
||||
$schema_create .= $GLOBALS['comment_marker'] . ' ' . PMA_backquote($rel_field, $use_backquotes) . $crlf
|
||||
. $GLOBALS['comment_marker'] . ' ' . PMA_backquote($rel['foreign_table'], $use_backquotes)
|
||||
. ' -> ' . PMA_backquote($rel['foreign_field'], $use_backquotes) . $crlf;
|
||||
$schema_create .= $GLOBALS['comment_marker'] . ' ' . PMA_backquote($rel_field, $sql_use_backquotes) . $crlf
|
||||
. $GLOBALS['comment_marker'] . ' ' . PMA_backquote($rel['foreign_table'], $sql_use_backquotes)
|
||||
. ' -> ' . PMA_backquote($rel['foreign_field'], $sql_use_backquotes) . $crlf;
|
||||
}
|
||||
$schema_create .= $GLOBALS['comment_marker'] . $crlf;
|
||||
}
|
||||
@@ -443,7 +553,7 @@ function PMA_getTableComments($db, $table, $crlf, $do_relation = false, $do_comm
|
||||
*/
|
||||
function PMA_exportStructure($db, $table, $crlf, $error_url, $relation = FALSE, $comments = FALSE, $mime = FALSE, $dates = FALSE)
|
||||
{
|
||||
$formatted_table_name = (isset($GLOBALS['use_backquotes']))
|
||||
$formatted_table_name = (isset($GLOBALS['sql_use_backquotes']))
|
||||
? PMA_backquote($table)
|
||||
: '\'' . $table . '\'';
|
||||
$dump = $crlf
|
||||
@@ -483,11 +593,11 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $relation = FALSE,
|
||||
*/
|
||||
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
|
||||
{
|
||||
global $use_backquotes;
|
||||
global $sql_use_backquotes;
|
||||
global $rows_cnt;
|
||||
global $current_row;
|
||||
|
||||
$formatted_table_name = (isset($GLOBALS['use_backquotes']))
|
||||
$formatted_table_name = (isset($GLOBALS['sql_use_backquotes']))
|
||||
? PMA_backquote($table)
|
||||
: '\'' . $table . '\'';
|
||||
$head = $crlf
|
||||
@@ -519,9 +629,9 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
|
||||
|
||||
for ($j = 0; $j < $fields_cnt; $j++) {
|
||||
if (isset($analyzed_sql[0]['select_expr'][$j]['column'])) {
|
||||
$field_set[$j] = PMA_backquote($analyzed_sql[0]['select_expr'][$j]['column'], $use_backquotes);
|
||||
$field_set[$j] = PMA_backquote($analyzed_sql[0]['select_expr'][$j]['column'], $sql_use_backquotes);
|
||||
} else {
|
||||
$field_set[$j] = PMA_backquote($fields_meta[$j]->name, $use_backquotes);
|
||||
$field_set[$j] = PMA_backquote($fields_meta[$j]->name, $sql_use_backquotes);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -531,7 +641,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
|
||||
if (isset($GLOBALS['sql_ignore'])) {
|
||||
$schema_insert .= 'IGNORE ';
|
||||
}
|
||||
$schema_insert .= PMA_backquote($table, $use_backquotes) . ' SET ';
|
||||
$schema_insert .= PMA_backquote($table, $sql_use_backquotes) . ' SET ';
|
||||
} else {
|
||||
// insert or replace
|
||||
if (isset($GLOBALS['sql_type']) && $GLOBALS['sql_type'] == 'replace') {
|
||||
@@ -541,7 +651,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
|
||||
}
|
||||
|
||||
// delayed inserts?
|
||||
if (isset($GLOBALS['delayed'])) {
|
||||
if (isset($GLOBALS['sql_delayed'])) {
|
||||
$insert_delayed = ' DELAYED';
|
||||
} else {
|
||||
$insert_delayed = '';
|
||||
@@ -553,12 +663,12 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
|
||||
}
|
||||
|
||||
// scheme for inserting fields
|
||||
if (isset($GLOBALS['showcolumns'])) {
|
||||
if (isset($GLOBALS['sql_columns'])) {
|
||||
$fields = implode(', ', $field_set);
|
||||
$schema_insert = $sql_command . $insert_delayed .' INTO ' . PMA_backquote($table, $use_backquotes)
|
||||
$schema_insert = $sql_command . $insert_delayed .' INTO ' . PMA_backquote($table, $sql_use_backquotes)
|
||||
. ' (' . $fields . ') VALUES ';
|
||||
} else {
|
||||
$schema_insert = $sql_command . $insert_delayed .' INTO ' . PMA_backquote($table, $use_backquotes)
|
||||
$schema_insert = $sql_command . $insert_delayed .' INTO ' . PMA_backquote($table, $sql_use_backquotes)
|
||||
. ' VALUES ';
|
||||
}
|
||||
}
|
||||
@@ -567,7 +677,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
|
||||
$replace = array('\0', '\n', '\r', '\Z');
|
||||
$current_row = 0;
|
||||
$query_size = 0;
|
||||
if (isset($GLOBALS['extended_ins'])) {
|
||||
if (isset($GLOBALS['sql_extended'])) {
|
||||
$separator = ',';
|
||||
$schema_insert .= $crlf;
|
||||
} else {
|
||||
@@ -589,7 +699,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
|
||||
// Note: with mysqli, under MySQL 4.1.3, we get the flag
|
||||
// "binary" for those field types (I don't know why)
|
||||
} elseif (stristr($field_flags[$j], 'BINARY')
|
||||
&& isset($GLOBALS['hexforbinary'])
|
||||
&& isset($GLOBALS['sql_hex_for_binary'])
|
||||
&& $fields_meta[$j]->type != 'datetime'
|
||||
&& $fields_meta[$j]->type != 'date'
|
||||
&& $fields_meta[$j]->type != 'time'
|
||||
@@ -623,12 +733,12 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
|
||||
} else {
|
||||
|
||||
// Extended inserts case
|
||||
if (isset($GLOBALS['extended_ins'])) {
|
||||
if (isset($GLOBALS['sql_extended'])) {
|
||||
if ($current_row == 1) {
|
||||
$insert_line = $schema_insert . '(' . implode(', ', $values) . ')';
|
||||
} else {
|
||||
$insert_line = '(' . implode(', ', $values) . ')';
|
||||
if (isset($GLOBALS['max_query_size']) && $GLOBALS['max_query_size'] > 0 && $query_size + strlen($insert_line) > $GLOBALS['max_query_size']) {
|
||||
if (isset($GLOBALS['sql_max_query_size']) && $GLOBALS['sql_max_query_size'] > 0 && $query_size + strlen($insert_line) > $GLOBALS['sql_max_query_size']) {
|
||||
if (!PMA_exportOutputHandler(';' . $crlf)) {
|
||||
return FALSE;
|
||||
}
|
||||
@@ -661,4 +771,5 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
|
||||
|
||||
return TRUE;
|
||||
} // end of the 'PMA_exportData()' function
|
||||
}
|
||||
?>
|
||||
|
@@ -2,7 +2,32 @@
|
||||
/* $Id$ */
|
||||
// vim: expandtab sw=4 ts=4 sts=4:
|
||||
|
||||
require_once('Spreadsheet/Excel/Writer.php');
|
||||
// Check if we have native MS Excel export using PEAR class Spreadsheet_Excel_Writer
|
||||
if (!empty($GLOBALS['cfg']['TempDir'])) {
|
||||
@include_once('Spreadsheet/Excel/Writer.php');
|
||||
if (class_exists('Spreadsheet_Excel_Writer')) {
|
||||
$xls = TRUE;
|
||||
} else {
|
||||
$xls = FALSE;
|
||||
}
|
||||
} else {
|
||||
$xls = FALSE;
|
||||
}
|
||||
|
||||
if ($xls) {
|
||||
|
||||
if (isset($plugin_list)) {
|
||||
$plugin_list['xls'] = array(
|
||||
'text' => 'strStrucNativeExcel',
|
||||
'extension' => 'xls',
|
||||
'options' => array(
|
||||
array('type' => 'text', 'name' => 'null', 'text' => 'strReplaceNULLBy'),
|
||||
array('type' => 'text', 'name' => 'columns', 'text' => 'strPutColNames'),
|
||||
array('type' => 'hidden', 'name' => 'data'),
|
||||
),
|
||||
'options_text' => 'strStrucNativeExcelOptions',
|
||||
);
|
||||
} else {
|
||||
|
||||
/**
|
||||
* Set of functions used to build MS Excel dumps of tables
|
||||
@@ -135,7 +160,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
|
||||
$col = 0;
|
||||
|
||||
// If required, get fields name at the first line
|
||||
if (isset($GLOBALS['xls_shownames']) && $GLOBALS['xls_shownames'] == 'yes') {
|
||||
if (isset($GLOBALS['xls_columns']) && $GLOBALS['xls_columns'] == 'yes') {
|
||||
$schema_insert = '';
|
||||
for ($i = 0; $i < $fields_cnt; $i++) {
|
||||
$worksheet->write(0, $i, stripslashes(PMA_DBI_field_name($result, $i)));
|
||||
@@ -148,7 +173,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
|
||||
$schema_insert = '';
|
||||
for ($j = 0; $j < $fields_cnt; $j++) {
|
||||
if (!isset($row[$j]) || is_null($row[$j])) {
|
||||
$worksheet->write($col, $j, $GLOBALS['xls_replace_null']);
|
||||
$worksheet->write($col, $j, $GLOBALS['xls_null']);
|
||||
} elseif ($row[$j] == '0' || $row[$j] != '') {
|
||||
// FIXME: we should somehow handle character set here!
|
||||
$worksheet->write($col, $j, $row[$j]);
|
||||
@@ -162,4 +187,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@@ -6,6 +6,18 @@
|
||||
* Set of functions used to build XML dumps of tables
|
||||
*/
|
||||
|
||||
if (isset($db) && strlen($db)) { /* Can't do server export */
|
||||
|
||||
if (isset($plugin_list)) {
|
||||
$plugin_list['xml'] = array(
|
||||
'text' => 'strXML',
|
||||
'extension' => 'xml',
|
||||
'options' => array(
|
||||
),
|
||||
'options_text' => 'strXMLOptions',
|
||||
);
|
||||
} else {
|
||||
|
||||
/**
|
||||
* Outputs comment
|
||||
*
|
||||
@@ -155,4 +167,6 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
|
||||
|
||||
return TRUE;
|
||||
} // end of the 'PMA_getTableXML()' function
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Reference in New Issue
Block a user