Skip to content

Commit

Permalink
Use template for getHtmlForExportOptionsOutputFormat
Browse files Browse the repository at this point in the history
Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
  • Loading branch information
MauricioFauth committed Jan 10, 2018
1 parent 11c43ef commit bcb67cb
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 42 deletions.
66 changes: 24 additions & 42 deletions libraries/classes/Display/Export.php
Expand Up @@ -344,20 +344,17 @@ public static function getHtmlForExportOptionsOutputSaveDir()
/**
* 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'));
}
}
Expand All @@ -376,53 +373,38 @@ public static function getHtmlForExportOptionsOutputFormat($export_type)
);
$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' => (bool) self::exportCheckboxCheck('remember_file_template'),
]);
}

/**
Expand Down
13 changes: 13 additions & 0 deletions templates/display/export/options_output_format.twig
@@ -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>

0 comments on commit bcb67cb

Please sign in to comment.