Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2018-01-13 03:26:08 +01:00
commit f40ce94a96
16 changed files with 432 additions and 409 deletions

View File

@ -32,15 +32,12 @@ class Export
*
* @param string $str option name
*
* @return string
* @return boolean
*/
public static function exportCheckboxCheck($str)
private static function checkboxCheck($str)
{
if (isset($GLOBALS['cfg']['Export'][$str]) && $GLOBALS['cfg']['Export'][$str]) {
return ' checked="checked"';
}
return null;
return isset($GLOBALS['cfg']['Export'][$str])
&& $GLOBALS['cfg']['Export'][$str];
}
/**
@ -165,16 +162,14 @@ class Export
}
/**
* Returns HTML for the options in teplate dropdown
* Returns HTML for the options in template dropdown
*
* @param string $export_type export type - server, database, or table
* @param string $exportType export type - server, database, or table
*
* @return string HTML for the options in teplate dropdown
*/
public static function getOptionsForExportTemplates($export_type)
private static function getOptionsForExportTemplates($exportType)
{
$ret = '<option value="">-- ' . __('Select a template') . ' --</option>';
// Get the relation settings
$cfgRelation = Relation::getRelationsParam();
@ -183,24 +178,25 @@ class Export
. Util::backquote($cfgRelation['export_templates'])
. " WHERE `username` = "
. "'" . $GLOBALS['dbi']->escapeString($GLOBALS['cfg']['Server']['user'])
. "' AND `export_type` = '" . $GLOBALS['dbi']->escapeString($export_type) . "'"
. "' AND `export_type` = '" . $GLOBALS['dbi']->escapeString($exportType) . "'"
. " ORDER BY `template_name`;";
$result = Relation::queryAsControlUser($query);
if (!$result) {
return $ret;
}
while ($row = $GLOBALS['dbi']->fetchAssoc($result, DatabaseInterface::CONNECT_CONTROL)) {
$ret .= '<option value="' . htmlspecialchars($row['id']) . '"';
if (!empty($_GET['template_id']) && $_GET['template_id'] == $row['id']) {
$ret .= ' selected="selected"';
$templates = [];
if ($result !== false) {
while ($row = $GLOBALS['dbi']->fetchAssoc($result, DatabaseInterface::CONNECT_CONTROL)) {
$templates[] = [
'name' => $row['template_name'],
'id' => $row['id'],
];
}
$ret .= '>';
$ret .= htmlspecialchars($row['template_name']) . '</option>';
}
return $ret;
return Template::get('display/export/template_options')->render([
'templates' => $templates,
'selected_template' => !empty($_GET['template_id']) ? $_GET['template_id'] : null,
]);
}
/**
@ -212,194 +208,87 @@ class Export
{
global $cfg;
if (isset($_GET['quick_or_custom'])) {
$export_method = $_GET['quick_or_custom'];
$exportMethod = $_GET['quick_or_custom'];
} else {
$export_method = $cfg['Export']['method'];
$exportMethod = $cfg['Export']['method'];
}
if ($export_method == 'custom-no-form') {
return '';
}
$html = '<div class="exportoptions" id="quick_or_custom">';
$html .= '<h3>' . __('Export method:') . '</h3>';
$html .= '<ul>';
$html .= '<li>';
$html .= '<input type="radio" name="quick_or_custom" value="quick" '
. ' id="radio_quick_export"';
if ($export_method == 'quick') {
$html .= ' checked="checked"';
}
$html .= ' />';
$html .= '<label for ="radio_quick_export">';
$html .= __('Quick - display only the minimal options');
$html .= '</label>';
$html .= '</li>';
$html .= '<li>';
$html .= '<input type="radio" name="quick_or_custom" value="custom" '
. ' id="radio_custom_export"';
if ($export_method == 'custom') {
$html .= ' checked="checked"';
}
$html .= ' />';
$html .= '<label for="radio_custom_export">';
$html .= __('Custom - display all possible options');
$html .= '</label>';
$html .= '</li>';
$html .= '</ul>';
$html .= '</div>';
return $html;
return Template::get('display/export/method')->render([
'export_method' => $exportMethod,
]);
}
/**
* Prints Html For Export Options Selection
*
* @param String $export_type Selected Export Type
* @param String $multi_values Export Options
* @param string $exportType Selected Export Type
* @param string $multiValues Export Options
*
* @return string
*/
public static function getHtmlForExportOptionsSelection($export_type, $multi_values)
public static function getHtmlForExportOptionsSelection($exportType, $multiValues)
{
$html = '<div class="exportoptions" id="databases_and_tables">';
if ($export_type == 'server') {
$html .= '<h3>' . __('Databases:') . '</h3>';
} elseif ($export_type == 'database') {
$html .= '<h3>' . __('Tables:') . '</h3>';
}
if (! empty($multi_values)) {
$html .= $multi_values;
}
$html .= '</div>';
return $html;
return Template::get('display/export/selection')->render([
'export_type' => $exportType,
'multi_values' => $multiValues,
]);
}
/**
* Prints Html For Export Options Format dropdown
*
* @param ExportPlugin[] $export_list Export List
* @param ExportPlugin[] $exportList Export List
*
* @return string
*/
public static function getHtmlForExportOptionsFormatDropdown($export_list)
public static function getHtmlForExportOptionsFormatDropdown($exportList)
{
$html = '<div class="exportoptions" id="format">';
$html .= '<h3>' . __('Format:') . '</h3>';
$html .= Plugins::getChoice('Export', 'what', $export_list, 'format');
$html .= '</div>';
return $html;
$dropdown = Plugins::getChoice('Export', 'what', $exportList, 'format');
return Template::get('display/export/format_dropdown')->render([
'dropdown' => $dropdown,
]);
}
/**
* Prints Html For Export Options Format-specific options
*
* @param ExportPlugin[] $export_list Export List
* @param ExportPlugin[] $exportList Export List
*
* @return string
*/
public static function getHtmlForExportOptionsFormat($export_list)
public static function getHtmlForExportOptionsFormat($exportList)
{
$html = '<div class="exportoptions" id="format_specific_opts">';
$html .= '<h3>' . __('Format-specific options:') . '</h3>';
$html .= '<p class="no_js_msg" id="scroll_to_options_msg">';
$html .= __(
'Scroll down to fill in the options for the selected format '
. 'and ignore the options for other formats.'
);
$html .= '</p>';
$html .= Plugins::getOptions('Export', $export_list);
$html .= '</div>';
if (Encoding::canConvertKanji()) {
// Japanese encoding setting
$html .= '<div class="exportoptions" id="kanji_encoding">';
$html .= '<h3>' . __('Encoding Conversion:') . '</h3>';
$html .= Encoding::kanjiEncodingForm();
$html .= '</div>';
}
$html .= '<div class="exportoptions" id="submit">';
$html .= Util::getExternalBug(
__('SQL compatibility mode'), 'mysql', '50027', '14515'
);
global $cfg;
if ($cfg['ExecTimeLimit'] > 0) {
$html .= '<input type="submit" value="' . __('Go')
. '" id="buttonGo" onclick="check_time_out('
. $cfg['ExecTimeLimit'] . ')"/>';
} else {
// if the time limit set is zero, then time out won't occur
// So no need to check for time out.
$html .= '<input type="submit" value="' . __('Go') . '" id="buttonGo" />';
}
$html .= '</div>';
$options = Plugins::getOptions('Export', $exportList);
return $html;
return Template::get('display/export/options_format')->render([
'options' => $options,
'can_convert_kanji' => Encoding::canConvertKanji(),
'exec_time_limit' => $cfg['ExecTimeLimit'],
]);
}
/**
* Prints Html For Export Options Rows
*
* @param String $db Selected DB
* @param String $table Selected Table
* @param String $unlim_num_rows Num of Rows
* @param string $db Selected DB
* @param string $table Selected Table
* @param string $unlimNumRows Num of Rows
*
* @return string
*/
public static function getHtmlForExportOptionsRows($db, $table, $unlim_num_rows)
public static function getHtmlForExportOptionsRows($db, $table, $unlimNumRows)
{
$html = '<div class="exportoptions" id="rows">';
$html .= '<h3>' . __('Rows:') . '</h3>';
$html .= '<ul>';
$html .= '<li>';
$html .= '<input type="radio" name="allrows" value="0" id="radio_allrows_0"';
if (isset($_GET['allrows']) && $_GET['allrows'] == 0) {
$html .= ' checked="checked"';
}
$html .= '/>';
$html .= '<label for ="radio_allrows_0">' . __('Dump some row(s)') . '</label>';
$html .= '<ul>';
$html .= '<li>';
$html .= '<label for="limit_to">' . __('Number of rows:') . '</label>';
$html .= '<input type="text" id="limit_to" name="limit_to" size="5" value="';
if (isset($_GET['limit_to'])) {
$html .= htmlspecialchars($_GET['limit_to']);
} elseif (!empty($unlim_num_rows)) {
$html .= $unlim_num_rows;
} else {
$_table = new Table($table, $db);
$html .= $_table->countRecords();
}
$html .= '" onfocus="this.select()" />';
$html .= '</li>';
$html .= '<li>';
$html .= '<label for="limit_from">' . __('Row to begin at:') . '</label>';
$html .= '<input type="text" id="limit_from" name="limit_from" value="';
if (isset($_GET['limit_from'])) {
$html .= htmlspecialchars($_GET['limit_from']);
} else {
$html .= '0';
}
$html .= '" size="5" onfocus="this.select()" />';
$html .= '</li>';
$html .= '</ul>';
$html .= '</li>';
$html .= '<li>';
$html .= '<input type="radio" name="allrows" value="1" id="radio_allrows_1"';
if (! isset($_GET['allrows']) || $_GET['allrows'] == 1) {
$html .= ' checked="checked"';
}
$html .= '/>';
$html .= ' <label for="radio_allrows_1">' . __('Dump all rows') . '</label>';
$html .= '</li>';
$html .= '</ul>';
$html .= '</div>';
return $html;
$tableObject = new Table($table, $db);
$numberOfRows = $tableObject->countRecords();
return Template::get('display/export/options_rows')->render([
'allrows' => isset($_GET['allrows']) ? $_GET['allrows'] : null,
'limit_to' => isset($_GET['limit_to']) ? $_GET['limit_to'] : null,
'limit_from' => isset($_GET['limit_from']) ? $_GET['limit_from'] : null,
'unlim_num_rows' => $unlimNumRows,
'number_of_rows' => $numberOfRows,
]);
}
/**
@ -410,34 +299,19 @@ class Export
public static function getHtmlForExportOptionsQuickExport()
{
global $cfg;
$html = '<div class="exportoptions" id="output_quick_export">';
$html .= '<h3>' . __('Output:') . '</h3>';
$html .= '<ul>';
$html .= '<li>';
$html .= '<input type="checkbox" name="quick_export_onserver" value="saveit" ';
$html .= 'id="checkbox_quick_dump_onserver" ';
$html .= self::exportCheckboxCheck('quick_export_onserver');
$html .= '/>';
$html .= '<label for="checkbox_quick_dump_onserver">';
$html .= sprintf(
__('Save on server in the directory <b>%s</b>'),
htmlspecialchars(Util::userDir($cfg['SaveDir']))
$saveDir = Util::userDir($cfg['SaveDir']);
$exportIsChecked = self::checkboxCheck(
'quick_export_onserver'
);
$exportOverwriteIsChecked = self::checkboxCheck(
'quick_export_onserver_overwrite'
);
$html .= '</label>';
$html .= '</li>';
$html .= '<li>';
$html .= '<input type="checkbox" name="quick_export_onserver_overwrite" ';
$html .= 'value="saveitover" id="checkbox_quick_dump_onserver_overwrite" ';
$html .= self::exportCheckboxCheck('quick_export_onserver_overwrite');
$html .= '/>';
$html .= '<label for="checkbox_quick_dump_onserver_overwrite">';
$html .= __('Overwrite existing file(s)');
$html .= '</label>';
$html .= '</li>';
$html .= '</ul>';
$html .= '</div>';
return $html;
return Template::get('display/export/options_quick_export')->render([
'save_dir' => $saveDir,
'export_is_checked' => $exportIsChecked,
'export_overwrite_is_checked' => $exportOverwriteIsChecked,
]);
}
/**
@ -448,49 +322,36 @@ class Export
public static function getHtmlForExportOptionsOutputSaveDir()
{
global $cfg;
$html = '<li>';
$html .= '<input type="checkbox" name="onserver" value="saveit" ';
$html .= 'id="checkbox_dump_onserver" ';
$html .= self::exportCheckboxCheck('onserver');
$html .= '/>';
$html .= '<label for="checkbox_dump_onserver">';
$html .= sprintf(
__('Save on server in the directory <b>%s</b>'),
htmlspecialchars(Util::userDir($cfg['SaveDir']))
$saveDir = Util::userDir($cfg['SaveDir']);
$exportIsChecked = self::checkboxCheck(
'onserver'
);
$exportOverwriteIsChecked = self::checkboxCheck(
'onserver_overwrite'
);
$html .= '</label>';
$html .= '</li>';
$html .= '<li>';
$html .= '<input type="checkbox" name="onserver_overwrite" value="saveitover"';
$html .= ' id="checkbox_dump_onserver_overwrite" ';
$html .= self::exportCheckboxCheck('onserver_overwrite');
$html .= '/>';
$html .= '<label for="checkbox_dump_onserver_overwrite">';
$html .= __('Overwrite existing file(s)');
$html .= '</label>';
$html .= '</li>';
return $html;
return Template::get('display/export/options_output_save_dir')->render([
'save_dir' => $saveDir,
'export_is_checked' => $exportIsChecked,
'export_overwrite_is_checked' => $exportOverwriteIsChecked,
]);
}
/**
* Prints Html For Export Options
*
* @param String $export_type Selected Export Type
* @param string $exportType Selected Export Type
*
* @return string
*/
public static function getHtmlForExportOptionsOutputFormat($export_type)
public static function getHtmlForExportOptionsOutputFormat($exportType)
{
$html = '<li>';
$html .= '<label for="filename_template" class="desc">';
$html .= __('File name template:');
$trans = new Message;
$trans->addText(__('@SERVER@ will become the server name'));
if ($export_type == 'database' || $export_type == 'table') {
if ($exportType == 'database' || $exportType == 'table') {
$trans->addText(__(', @DATABASE@ will become the database name'));
if ($export_type == 'table') {
if ($exportType == 'table') {
$trans->addText(__(', @TABLE@ will become the table name'));
}
}
@ -509,53 +370,38 @@ class Export
);
$msg->addParamHtml('</a>');
$msg->addParam($trans);
$doc_url = Util::getDocuLink('faq', 'faq6-27');
$docUrl = Util::getDocuLink('faq', 'faq6-27');
$msg->addParamHtml(
'<a href="' . $doc_url . '" target="documentation">'
'<a href="' . $docUrl . '" target="documentation">'
);
$msg->addParamHtml('</a>');
$html .= Util::showHint($msg);
$html .= '</label>';
$html .= '<input type="text" name="filename_template" id="filename_template" ';
$html .= ' value="';
if (isset($_GET['filename_template'])) {
$html .= htmlspecialchars($_GET['filename_template']);
$filenameTemplate = $_GET['filename_template'];
} else {
if ($export_type == 'database') {
$html .= htmlspecialchars(
$GLOBALS['PMA_Config']->getUserValue(
'pma_db_filename_template',
$GLOBALS['cfg']['Export']['file_template_database']
)
if ($exportType == 'database') {
$filenameTemplate = $GLOBALS['PMA_Config']->getUserValue(
'pma_db_filename_template',
$GLOBALS['cfg']['Export']['file_template_database']
);
} elseif ($export_type == 'table') {
$html .= htmlspecialchars(
$GLOBALS['PMA_Config']->getUserValue(
'pma_table_filename_template',
$GLOBALS['cfg']['Export']['file_template_table']
)
} elseif ($exportType == 'table') {
$filenameTemplate = $GLOBALS['PMA_Config']->getUserValue(
'pma_table_filename_template',
$GLOBALS['cfg']['Export']['file_template_table']
);
} else {
$html .= htmlspecialchars(
$GLOBALS['PMA_Config']->getUserValue(
'pma_server_filename_template',
$GLOBALS['cfg']['Export']['file_template_server']
)
$filenameTemplate = $GLOBALS['PMA_Config']->getUserValue(
'pma_server_filename_template',
$GLOBALS['cfg']['Export']['file_template_server']
);
}
}
$html .= '"';
$html .= '/>';
$html .= '<input type="checkbox" name="remember_template" ';
$html .= 'id="checkbox_remember_template" ';
$html .= self::exportCheckboxCheck('remember_file_template');
$html .= '/>';
$html .= '<label for="checkbox_remember_template">';
$html .= __('use this for future exports');
$html .= '</label>';
$html .= '</li>';
return $html;
return Template::get('display/export/options_output_format')->render([
'message' => $msg->getMessage(),
'filename_template' => $filenameTemplate,
'is_checked' => self::checkboxCheck('remember_file_template'),
]);
}
/**
@ -566,25 +412,11 @@ class Export
public static function getHtmlForExportOptionsOutputCharset()
{
global $cfg;
$html = ' <li><label for="select_charset" class="desc">'
. __('Character set of the file:') . '</label>' . "\n";
$html .= '<select id="select_charset" name="charset" size="1">';
foreach (Encoding::listEncodings() as $temp_charset) {
$html .= '<option value="' . $temp_charset . '"';
if (isset($_GET['charset'])
&& ($_GET['charset'] != $temp_charset)
) {
$html .= '';
} elseif ((empty($cfg['Export']['charset']) && $temp_charset == 'utf-8')
|| $temp_charset == $cfg['Export']['charset']
) {
$html .= ' selected="selected"';
}
$html .= '>' . $temp_charset . '</option>';
} // end foreach
$html .= '</select></li>';
return $html;
return Template::get('display/export/options_output_charset')->render([
'encodings' => Encoding::listEncodings(),
'export_charset' => $cfg['Export']['charset'],
]);
}
/**
@ -596,52 +428,29 @@ class Export
{
global $cfg;
if (isset($_GET['compression'])) {
$selected_compression = $_GET['compression'];
$selectedCompression = $_GET['compression'];
} elseif (isset($cfg['Export']['compression'])) {
$selected_compression = $cfg['Export']['compression'];
$selectedCompression = $cfg['Export']['compression'];
} else {
$selected_compression = "none";
$selectedCompression = 'none';
}
// Since separate files export works with ZIP only
if (isset($cfg['Export']['as_separate_files'])
&& $cfg['Export']['as_separate_files']
) {
$selected_compression = "zip";
$selectedCompression = 'zip';
}
$html = "";
// zip and gzip encode features
$is_zip = ($cfg['ZipDump'] && @function_exists('gzcompress'));
$is_gzip = ($cfg['GZipDump'] && @function_exists('gzencode'));
if ($is_zip || $is_gzip) {
$html .= '<li>';
$html .= '<label for="compression" class="desc">'
. __('Compression:') . '</label>';
$html .= '<select id="compression" name="compression">';
$html .= '<option value="none">' . __('None') . '</option>';
if ($is_zip) {
$html .= '<option value="zip" ';
if ($selected_compression == "zip") {
$html .= 'selected="selected"';
}
$html .= '>' . __('zipped') . '</option>';
}
if ($is_gzip) {
$html .= '<option value="gzip" ';
if ($selected_compression == "gzip") {
$html .= 'selected="selected"';
}
$html .= '>' . __('gzipped') . '</option>';
}
$html .= '</select>';
$html .= '</li>';
} else {
$html .= '<input type="hidden" name="compression" value="'
. htmlspecialchars($selected_compression) . '" />';
}
$isZip = ($cfg['ZipDump'] && @function_exists('gzcompress'));
$isGzip = ($cfg['GZipDump'] && @function_exists('gzencode'));
return $html;
return Template::get('display/export/options_output_compression')->render([
'is_zip' => $isZip,
'is_gzip' => $isGzip,
'selected_compression' => $selectedCompression,
]);
}
/**
@ -651,130 +460,81 @@ class Export
*/
public static function getHtmlForExportOptionsOutputRadio()
{
$html = '<li>';
$html .= '<input type="radio" id="radio_view_as_text" '
. ' name="output_format" value="astext" ';
if (isset($_GET['repopulate']) || $GLOBALS['cfg']['Export']['asfile'] == false) {
$html .= 'checked="checked"';
}
$html .= '/>';
$html .= '<label for="radio_view_as_text">'
. __('View output as text') . '</label></li>';
return $html;
return Template::get('display/export/options_output_radio')->render([
'has_repopulate' => isset($_GET['repopulate']),
'export_asfile' => $GLOBALS['cfg']['Export']['asfile'],
]);
}
/**
* Prints Html For Export Options Checkbox - Separate files
*
* @param String $export_type Selected Export Type
* @param string $exportType Selected Export Type
*
* @return string
*/
public static function getHtmlForExportOptionsOutputSeparateFiles($export_type)
public static function getHtmlForExportOptionsOutputSeparateFiles($exportType)
{
$html = '<li>';
$html .= '<input type="checkbox" id="checkbox_as_separate_files" '
. self::exportCheckboxCheck('as_separate_files')
. ' name="as_separate_files" value="' . $export_type . '" />';
$html .= '<label for="checkbox_as_separate_files">';
$isChecked = self::checkboxCheck('as_separate_files');
if ($export_type == 'server') {
$html .= __('Export databases as separate files');
} elseif ($export_type == 'database') {
$html .= __('Export tables as separate files');
}
$html .= '</label></li>';
return $html;
return Template::get('display/export/options_output_separate_files')->render([
'is_checked' => $isChecked,
'export_type' => $exportType,
]);
}
/**
* Prints Html For Export Options
*
* @param String $export_type Selected Export Type
* @param string $exportType Selected Export Type
*
* @return string
*/
public static function getHtmlForExportOptionsOutput($export_type)
public static function getHtmlForExportOptionsOutput($exportType)
{
global $cfg;
$html = '<div class="exportoptions" id="output">';
$html .= '<h3>' . __('Output:') . '</h3>';
$html .= '<ul id="ul_output">';
$html .= '<li><input type="checkbox" id="btn_alias_config" ';
if (isset($_SESSION['tmpval']['aliases'])
&& !Core::emptyRecursive($_SESSION['tmpval']['aliases'])
) {
$html .= 'checked="checked"';
}
$hasAliases = isset($_SESSION['tmpval']['aliases'])
&& !Core::emptyRecursive($_SESSION['tmpval']['aliases']);
unset($_SESSION['tmpval']['aliases']);
$html .= '/>';
$html .= '<label for="btn_alias_config">';
$html .= __('Rename exported databases/tables/columns');
$html .= '</label></li>';
if ($export_type != 'server') {
$html .= '<li>';
$html .= '<input type="checkbox" name="lock_tables"';
$html .= ' value="something" id="checkbox_lock_tables"';
if (! isset($_GET['repopulate'])) {
$html .= self::exportCheckboxCheck('lock_tables') . '/>';
} elseif (isset($_GET['lock_tables'])) {
$html .= ' checked="checked"';
}
$html .= '<label for="checkbox_lock_tables">';
$html .= sprintf(__('Use %s statement'), '<code>LOCK TABLES</code>');
$html .= '</label></li>';
}
$isCheckedLockTables = self::checkboxCheck('lock_tables');
$isCheckedAsfile = self::checkboxCheck('asfile');
$html .= '<li>';
$html .= '<input type="radio" name="output_format" value="sendit" ';
$html .= 'id="radio_dump_asfile" ';
if (!isset($_GET['repopulate'])) {
$html .= self::exportCheckboxCheck('asfile');
}
$html .= '/>';
$html .= '<label for="radio_dump_asfile">'
. __('Save output to a file') . '</label>';
$html .= '<ul id="ul_save_asfile">';
$optionsOutputSaveDir = '';
if (isset($cfg['SaveDir']) && !empty($cfg['SaveDir'])) {
$html .= self::getHtmlForExportOptionsOutputSaveDir();
$optionsOutputSaveDir = self::getHtmlForExportOptionsOutputSaveDir();
}
$html .= self::getHtmlForExportOptionsOutputFormat($export_type);
// charset of file
$optionsOutputFormat = self::getHtmlForExportOptionsOutputFormat($exportType);
$optionsOutputCharset = '';
if (Encoding::isSupported()) {
$html .= self::getHtmlForExportOptionsOutputCharset();
} // end if
$html .= self::getHtmlForExportOptionsOutputCompression();
if ($export_type == 'server'
|| $export_type == 'database'
) {
$html .= self::getHtmlForExportOptionsOutputSeparateFiles($export_type);
$optionsOutputCharset = self::getHtmlForExportOptionsOutputCharset();
}
$optionsOutputCompression = self::getHtmlForExportOptionsOutputCompression();
$optionsOutputSeparateFiles = '';
if ($exportType == 'server' || $exportType == 'database') {
$optionsOutputSeparateFiles = self::getHtmlForExportOptionsOutputSeparateFiles(
$exportType
);
}
$optionsOutputRadio = self::getHtmlForExportOptionsOutputRadio();
$html .= '</ul>';
$html .= '</li>';
$html .= self::getHtmlForExportOptionsOutputRadio();
$html .= '</ul>';
/*
* @todo use sprintf() for better translatability, while keeping the
* <label></label> principle (for screen readers)
*/
$html .= '<label for="maxsize">'
. __('Skip tables larger than') . '</label>';
$html .= '<input type="text" id="maxsize" name="maxsize" size="4">' . __('MiB');
$html .= '</div>';
return $html;
return Template::get('display/export/options_output')->render([
'has_aliases' => $hasAliases,
'export_type' => $exportType,
'is_checked_lock_tables' => $isCheckedLockTables,
'is_checked_asfile' => $isCheckedAsfile,
'repopulate' => isset($_GET['repopulate']),
'lock_tables' => isset($_GET['lock_tables']),
'save_dir' => isset($cfg['SaveDir']) ? $cfg['SaveDir'] : null,
'is_encoding_supported' => Encoding::isSupported(),
'options_output_save_dir' => $optionsOutputSaveDir,
'options_output_format' => $optionsOutputFormat,
'options_output_charset' => $optionsOutputCharset,
'options_output_compression' => $optionsOutputCompression,
'options_output_separate_files' => $optionsOutputSeparateFiles,
'options_output_radio' => $optionsOutputRadio,
]);
}
/**

View File

@ -0,0 +1,4 @@
<div class="exportoptions" id="format">
<h3>{% trans 'Format:' %}</h3>
{{ dropdown|raw }}
</div>

View File

@ -0,0 +1,22 @@
{% if export_method != 'custom-no-form' %}
<div class="exportoptions" id="quick_or_custom">
<h3>{% trans 'Export method:' %}</h3>
<ul>
<li>
<input type="radio" name="quick_or_custom" value="quick" id="radio_quick_export"
{{- export_method == 'quick' ? ' checked' }}>
<label for="radio_quick_export">
{% trans 'Quick - display only the minimal options' %}
</label>
</li>
<li>
<input type="radio" name="quick_or_custom" value="custom" id="radio_custom_export"
{{- export_method == 'custom' ? ' checked' }}>
<label for="radio_custom_export">
{% trans 'Custom - display all possible options' %}
</label>
</li>
</ul>
</div>
{% endif %}

View File

@ -0,0 +1,24 @@
<div class="exportoptions" id="format_specific_opts">
<h3>{% trans 'Format-specific options:' %}</h3>
<p class="no_js_msg" id="scroll_to_options_msg">
{% trans 'Scroll down to fill in the options for the selected format and ignore the options for other formats.' %}
</p>
{{ options|raw }}
</div>
{% if can_convert_kanji %}
{# Japanese encoding setting #}
<div class="exportoptions" id="kanji_encoding">
<h3>{% trans 'Encoding Conversion:' %}</h3>
{% include 'encoding/kanji_encoding_form.twig' %}
</div>
{% endif %}
<div class="exportoptions" id="submit">
<input type="submit" value="{% trans 'Go' %}" id="buttonGo"
{#- If the time limit set is zero, then time out won't occur so no need
to check for time out. -#}
{%- if exec_time_limit > 0 %}
onclick="check_time_out({{ exec_time_limit }})"
{%- endif %}>
</div>

View File

@ -0,0 +1,54 @@
<div class="exportoptions" id="output">
<h3>{% trans 'Output:' %}</h3>
<ul id="ul_output">
<li>
<input type="checkbox" id="btn_alias_config"{{ has_aliases ? ' checked' }}>
<label for="btn_alias_config">
{% trans 'Rename exported databases/tables/columns' %}
</label>
</li>
{% if export_type != 'server' %}
<li>
<input type="checkbox" name="lock_tables"
value="something" id="checkbox_lock_tables"
{{- (not repopulate and is_checked_lock_tables) or lock_tables ? ' checked' }}>
<label for="checkbox_lock_tables">
{{ 'Use %s statement'|trans|format('<code>LOCK TABLES</code>')|raw }}
</label>
</li>
{% endif %}
<li>
<input type="radio" name="output_format" value="sendit" id="radio_dump_asfile"
{{- not repopulate and is_checked_asfile ? ' checked' }}>
<label for="radio_dump_asfile">
{% trans 'Save output to a file' %}
</label>
<ul id="ul_save_asfile">
{% if save_dir is not empty %}
{{ options_output_save_dir|raw }}
{% endif %}
{{ options_output_format|raw }}
{% if is_encoding_supported %}
{{ options_output_charset|raw }}
{% endif %}
{{ options_output_compression|raw }}
{% if export_type == 'server' or export_type == 'database' %}
{{ options_output_separate_files|raw }}
{% endif %}
</ul>
</li>
{{ options_output_radio|raw }}
</ul>
<label for="maxsize">
{{- 'Skip tables larger than %s MiB'|trans|format(
'</label><input type="text" id="maxsize" name="maxsize" size="4">'
)|raw }}
</div>

View File

@ -0,0 +1,16 @@
<li>
<label for="select_charset" class="desc">
{% trans 'Character set of the file:' %}
</label>
<select id="select_charset" name="charset" size="1">
{% for charset in encodings %}
<option value="{{ charset }}"
{%- if (export_charset is empty and charset == 'utf-8')
or charset == export_charset %}
selected
{%- endif %}>
{{- charset -}}
</option>
{% endfor %}
</select>
</li>

View File

@ -0,0 +1,24 @@
{% if is_zip or is_gzip %}
<li>
<label for="compression" class="desc">
{% trans 'Compression:' %}
</label>
<select id="compression" name="compression">
<option value="none">{% trans 'None' %}</option>
{% if is_zip %}
<option value="zip"
{{- selected_compression == 'zip' ? ' selected' }}>
{% trans 'zipped' %}
</option>
{% endif %}
{% if is_gzip %}
<option value="gzip"
{{- selected_compression == 'gzip' ? ' selected' }}>
{% trans 'gzipped' %}
</option>
{% endif %}
</select>
</li>
{% else %}
<input type="hidden" name="compression" value="{{ selected_compression }}">
{% endif %}

View File

@ -0,0 +1,13 @@
<li>
<label for="filename_template" class="desc">
{% trans 'File name template:' %}
{{ Util_showHint(message) }}
</label>
<input type="text" name="filename_template" id="filename_template" value="
{{- filename_template }}">
<input type="checkbox" name="remember_template" id="checkbox_remember_template"
{{- is_checked ? ' checked' }}>
<label for="checkbox_remember_template">
{% trans 'use this for future exports' %}
</label>
</li>

View File

@ -0,0 +1,7 @@
<li>
<input type="radio" id="radio_view_as_text" name="output_format" value="astext"
{{- has_repopulate or export_asfile == false ? ' checked' }}>
<label for="radio_view_as_text">
{% trans 'View output as text' %}
</label>
</li>

View File

@ -0,0 +1,15 @@
<li>
<input type="checkbox" name="onserver" value="saveit"
id="checkbox_dump_onserver"{{ export_is_checked ? ' checked' }}>
<label for="checkbox_dump_onserver">
{{ 'Save on server in the directory <strong>%s</strong>'|trans|format(save_dir|e)|raw }}
</label>
</li>
<li>
<input type="checkbox" name="onserver_overwrite"
value="saveitover" id="checkbox_dump_onserver_overwrite"
{{- export_overwrite_is_checked ? ' checked' }}>
<label for="checkbox_dump_onserver_overwrite">
{% trans 'Overwrite existing file(s)' %}
</label>
</li>

View File

@ -0,0 +1,12 @@
<li>
<input type="checkbox" id="checkbox_as_separate_files"
name="as_separate_files" value="{{ export_type }}"
{{- is_checked ? ' checked' }}>
<label for="checkbox_as_separate_files">
{% if export_type == 'server' %}
{% trans 'Export databases as separate files' %}
{% elseif export_type == 'database' %}
{% trans 'Export tables as separate files' %}
{% endif %}
</label>
</li>

View File

@ -0,0 +1,20 @@
<div class="exportoptions" id="output_quick_export">
<h3>{% trans 'Output:' %}</h3>
<ul>
<li>
<input type="checkbox" name="quick_export_onserver" value="saveit"
id="checkbox_quick_dump_onserver"{{ export_is_checked ? ' checked' }}>
<label for="checkbox_quick_dump_onserver">
{{ 'Save on server in the directory <strong>%s</strong>'|trans|format(save_dir|e)|raw }}
</label>
</li>
<li>
<input type="checkbox" name="quick_export_onserver_overwrite"
value="saveitover" id="checkbox_quick_dump_onserver_overwrite"
{{- export_overwrite_is_checked ? ' checked' }}>
<label for="checkbox_quick_dump_onserver_overwrite">
{% trans 'Overwrite existing file(s)' %}
</label>
</li>
</ul>
</div>

View File

@ -0,0 +1,35 @@
<div class="exportoptions" id="rows">
<h3>{% trans 'Rows:' %}</h3>
<ul>
<li>
<input type="radio" name="allrows" value="0" id="radio_allrows_0"
{{- allrows is not null and allrows == 0 ? ' checked' }}>
<label for="radio_allrows_0">{% trans 'Dump some row(s)' %}</label>
<ul>
<li>
<label for="limit_to">{% trans 'Number of rows:' %}</label>
<input type="text" id="limit_to" name="limit_to" size="5" value="
{%- spaceless %}
{% if limit_to is not null %}
{{ limit_to }}
{% elseif unlim_num_rows is not empty and unlim_num_rows != 0 %}
{{ unlim_num_rows }}
{% else %}
{{ number_of_rows }}
{% endif %}
{% endspaceless %}" onfocus="this.select()">
</li>
<li>
<label for="limit_from">{% trans 'Row to begin at:' %}</label>
<input type="text" id="limit_from" name="limit_from" size="5" value="
{{- limit_from is not null ? limit_from : 0 }}" onfocus="this.select()">
</li>
</ul>
</li>
<li>
<input type="radio" name="allrows" value="1" id="radio_allrows_1"
{{- allrows is null or allrows == 1 ? ' checked' }}>
<label for="radio_allrows_1">{% trans 'Dump all rows' %}</label>
</li>
</ul>
</div>

View File

@ -0,0 +1,10 @@
<div class="exportoptions" id="databases_and_tables">
{% if export_type == 'server' %}
<h3>{% trans 'Databases:' %}</h3>
{% elseif export_type == 'database' %}
<h3>{% trans 'Tables:' %}</h3>
{% endif %}
{% if multi_values is not empty %}
{{ multi_values|raw }}
{% endif %}
</div>

View File

@ -0,0 +1,7 @@
<option value="">-- {% trans 'Select a template' %} --</option>
{% for template in templates %}
<option value="{{ template.id }}"{{ template.id == selected_template ? ' selected' }}>
{{ template.name }}
</option>
{% endfor %}

View File

@ -203,12 +203,12 @@ class ExportTest extends TestCase
//validate 4: Export::getHtmlForExportOptionsQuickExport
$this->assertContains(
'<input type="checkbox" name="onserver" value="saveit" ',
'<input type="checkbox" name="onserver" value="saveit"',
$html
);
$dir = htmlspecialchars(Util::userDir($cfg['SaveDir']));
$this->assertContains(
'Save on server in the directory <b>' . $dir . '</b>',
'Save on server in the directory <strong>' . $dir . '</strong>',
$html
);