Use template for getHtmlForImport

Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
This commit is contained in:
Maurício Meneghini Fauth 2017-11-25 17:36:15 -02:00
parent ec3591fe60
commit 4b51f335de
4 changed files with 69 additions and 51 deletions

View File

@ -60,77 +60,31 @@ class Import
$compressions[] = 'zip';
}
$html = '';
$html .= '<iframe id="import_upload_iframe" name="import_upload_iframe" '
. 'width="1" height="1" class="hide"></iframe>';
$html .= '<div id="import_form_status" class="hide"></div>';
$html .= '<div id="importmain">';
$html .= ' <img src="' . $GLOBALS['pmaThemeImage'] . 'ajax_clock_small.gif" '
. 'width="16" height="16" alt="ajax clock" class="hide" />';
$html .= Template::get('display/import/javascript')->render([
return Template::get('display/import/import')->render([
'upload_id' => $upload_id,
'handler' => $_SESSION[$SESSION_KEY]["handler"],
'id_key' => $_SESSION[$SESSION_KEY]['handler']::getIdKey(),
'pma_theme_image' => $GLOBALS['pmaThemeImage'],
]);
$html .= ' <form id="import_file_form" action="import.php" method="post" '
. 'enctype="multipart/form-data"';
$html .= ' name="import"';
if ($_SESSION[$SESSION_KEY]["handler"] != 'PhpMyAdmin\Plugins\Import\Upload\UploadNoplugin') {
$html .= ' target="import_upload_iframe"';
}
$html .= ' class="ajax"';
$html .= '>';
$html .= ' <input type="hidden" name="';
$html .= $_SESSION[$SESSION_KEY]['handler']::getIdKey();
$html .= '" value="' . $upload_id . '" />';
$html .= Template::get('display/import/hidden_inputs')->render([
'import_type' => $import_type,
'db' => $db,
'table' => $table,
]);
$html .= Template::get('display/import/options')->render([
'import_type' => $import_type,
'db' => $db,
'table' => $table,
]);
$html .= Template::get('display/import/file_option')->render([
'max_upload_size' => $max_upload_size,
'import_list' => $import_list,
'local_import_file' => $local_import_file,
'is_upload' => $GLOBALS['is_upload'],
'upload_dir' => isset($cfg['UploadDir']) ? $cfg['UploadDir'] : null,
'timeout_passed' => isset($GLOBALS['timeout_passed']) ? $GLOBALS['timeout_passed'] : null,
'timeout_passed_global' => isset($GLOBALS['timeout_passed']) ? $GLOBALS['timeout_passed'] : null,
'compressions' => $compressions,
'is_encoding_supported' => Encoding::isSupported(),
'encodings' => Encoding::listEncodings(),
'import_charset' => isset($cfg['Import']['charset']) ? $cfg['Import']['charset'] : null,
'dbi' => $GLOBALS['dbi'],
'disable_is' => $cfg['Server']['DisableIS'],
]);
$html .= Template::get('display/import/partial_import_option')->render([
'timeout_passed' => isset($timeout_passed) ? $timeout_passed : null,
'offset' => $offset,
]);
$html .= Template::get('display/import/other_option')->render();
$html .= Template::get('display/import/format_option')->render([
'import_list' => $import_list,
'can_convert_kanji' => Encoding::canConvertKanji(),
]);
$html .= Template::get('display/import/submit_option')->render();
$html .= '</form>';
$html .= '</div>';
return $html;
}
/**

View File

@ -13,7 +13,7 @@
</li>
<li>
<input type="radio" name="file_location" id="radio_local_import_file"
{%- if timeout_passed is not empty and local_import_file is not empty %}
{%- if timeout_passed_global is not empty and local_import_file is not empty %}
checked="checked"
{%- endif %} />
{{ Util_getSelectUploadFileBlock(

View File

@ -0,0 +1,64 @@
<iframe id="import_upload_iframe" name="import_upload_iframe" width="1" height="1" class="hide"></iframe>
<div id="import_form_status" class="hide"></div>
<div id="importmain">
<img src="{{ pma_theme_image }}ajax_clock_small.gif" width="16" height="16" alt="ajax clock" class="hide" />
{% include 'display/import/javascript.twig' with {
'upload_id': upload_id,
'handler': handler,
'pma_theme_image': pma_theme_image
} only %}
<form id="import_file_form"
action="import.php"
method="post"
enctype="multipart/form-data"
name="import"
class="ajax"
{%- if handler != 'PhpMyAdmin\\Plugins\\Import\\Upload\\UploadNoplugin' %}
target="import_upload_iframe"
{%- endif %}>
<input type="hidden" name="{{ id_key }}" value="{{ upload_id }}" />
{% include 'display/import/hidden_inputs.twig' with {
'import_type': import_type,
'db': db,
'table': table
} only %}
{% include 'display/import/options.twig' with {
'import_type': import_type,
'db': db,
'table': table
} only %}
{% include 'display/import/file_option.twig' with {
'max_upload_size': max_upload_size,
'import_list': import_list,
'local_import_file': local_import_file,
'is_upload': is_upload,
'upload_dir': upload_dir,
'timeout_passed_global': timeout_passed_global,
'compressions': compressions,
'is_encoding_supported': is_encoding_supported,
'encodings': encodings,
'import_charset': import_charset,
'dbi': dbi,
'disable_is': disable_is
} only %}
{% include 'display/import/partial_import_option.twig' with {
'timeout_passed': timeout_passed,
'offset': offset
} only %}
{% include 'display/import/other_option.twig' only %}
{% include 'display/import/format_option.twig' with {
'import_list': import_list,
'can_convert_kanji': can_convert_kanji
} only %}
{% include 'display/import/submit_option.twig' only %}
</form>
</div>

View File

@ -6,7 +6,7 @@
{# Hide form #}
$("#upload_form_form").css("display", "none");
{% if handler != 'PhpMyAdmin\Plugins\Import\Upload\UploadNoplugin' %}
{% if handler != 'PhpMyAdmin\\Plugins\\Import\\Upload\\UploadNoplugin' %}
{% include 'display/import/with_plugin.twig' with {
'upload_id': upload_id,
'pma_theme_image': pma_theme_image