diff options
Diffstat (limited to 'srcs/phpmyadmin/templates/display/import')
| -rw-r--r-- | srcs/phpmyadmin/templates/display/import/import.twig | 195 | ||||
| -rw-r--r-- | srcs/phpmyadmin/templates/display/import/javascript.twig | 162 |
2 files changed, 357 insertions, 0 deletions
diff --git a/srcs/phpmyadmin/templates/display/import/import.twig b/srcs/phpmyadmin/templates/display/import/import.twig new file mode 100644 index 0000000..dab14a3 --- /dev/null +++ b/srcs/phpmyadmin/templates/display/import/import.twig @@ -0,0 +1,195 @@ +<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"> + + <script type="text/javascript"> + //<![CDATA[ + {% include 'display/import/javascript.twig' with { + 'upload_id': upload_id, + 'handler': handler, + 'pma_theme_image': pma_theme_image + } only %} + //]]> + </script> + + <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 }}"> + {% if import_type == 'server' %} + {{ get_hidden_inputs('', '', 1) }} + {% elseif import_type == 'database' %} + {{ get_hidden_inputs(db, '', 1) }} + {% else %} + {{ get_hidden_inputs(db, table, 1) }} + {% endif %} + <input type="hidden" name="import_type" value="{{ import_type }}"> + + <div class="exportoptions" id="header"> + <h2> + {{ get_image('b_import', 'Import'|trans) }} + {% if import_type == 'server' %} + {% trans 'Importing into the current server' %} + {% elseif import_type == 'database' %} + {{ 'Importing into the database "%s"'|trans|format(db) }} + {% else %} + {{ 'Importing into the table "%s"'|trans|format(table) }} + {% endif %} + </h2> + </div> + + <div class="importoptions"> + <h3>{% trans 'File to import:' %}</h3> + + {# We don't have show anything about compression, when no supported #} + {% if compressions is not empty %} + <div class="formelementrow" id="compression_info"> + <p> + {{ 'File may be compressed (%s) or uncompressed.'|trans|format(compressions|join(', ')) }} + <br> + {% trans 'A compressed file\'s name must end in <strong>.[format].[compression]</strong>. Example: <strong>.sql.zip</strong>' %} + </p> + </div> + {% endif %} + + <div class="formelementrow" id="upload_form"> + {% if is_upload and upload_dir is not empty %} + <ul> + <li> + <input type="radio" name="file_location" id="radio_import_file" required="required"> + {{ get_browse_upload_file_block(max_upload_size) }} + {% trans 'You may also drag and drop a file on any page.' %} + </li> + <li> + <input type="radio" name="file_location" id="radio_local_import_file" + {%- if timeout_passed_global is not empty and local_import_file is not empty %} + checked="checked" + {%- endif %}> + {{ get_select_upload_file_block( + import_list, + upload_dir + ) }} + </li> + </ul> + {% elseif is_upload %} + {{ get_browse_upload_file_block(max_upload_size) }} + <p>{% trans 'You may also drag and drop a file on any page.' %}</p> + {% elseif not is_upload %} + {{ 'File uploads are not allowed on this server.'|trans|notice }} + {% elseif upload_dir is not empty %} + {{ get_select_upload_file_block( + import_list, + upload_dir + ) }} + {% endif %} + </div> + + <div class="formelementrow" id="charaset_of_file"> + {# Charset of file #} + <label for="charset_of_file">{% trans 'Character set of the file:' %}</label> + {% if is_encoding_supported %} + <select id="charset_of_file" name="charset_of_file" size="1"> + {% for charset in encodings %} + <option value="{{ charset }}" + {% if (import_charset is empty and charset == 'utf-8') + or charset == import_charset %} + selected="selected" + {% endif %}> + {{ charset }} + </option> + {% endfor %} + </select> + {% else %} + <select lang="en" dir="ltr" name="charset_of_file" id="charset_of_file"> + <option value=""></option> + {% for charset in charsets %} + <option value="{{ charset.name }}" title="{{ charset.description }}" + {{- charset.name == 'utf8' ? ' selected' }}> + {{- charset.name -}} + </option> + {% endfor %} + </select> + {% endif %} + </div> + </div> + + <div class="importoptions"> + <h3>{% trans 'Partial import:' %}</h3> + + {% if timeout_passed is defined and timeout_passed %} + <div class="formelementrow"> + <input type="hidden" name="skip" value="{{ offset }}"> + {{ 'Previous import timed out, after resubmitting will continue from position %d.'|trans|format(offset) }} + </div> + {% endif %} + + <div class="formelementrow"> + <input type="checkbox" name="allow_interrupt" value="yes" id="checkbox_allow_interrupt" + {{ checkbox_check('Import', 'allow_interrupt') }}> + <label for="checkbox_allow_interrupt"> + {% trans 'Allow the interruption of an import in case the script detects it is close to the PHP timeout limit. <em>(This might be a good way to import large files, however it can break transactions.)</em>' %} + </label> + </div> + + {% if not (timeout_passed is defined and timeout_passed) %} + <div class="formelementrow"> + <label for="text_skip_queries"> + {% trans 'Skip this number of queries (for SQL) starting from the first one:' %} + </label> + <input type="number" name="skip_queries" value=" + {{- get_default_plugin('Import', 'skip_queries') -}} + " id="text_skip_queries" min="0"> + </div> + {% else %} + {# If timeout has passed, + do not show the Skip dialog to avoid the risk of someone + entering a value here that would interfere with "skip" #} + <input type="hidden" name="skip_queries" value=" + {{- get_default_plugin('Import', 'skip_queries') -}} + " id="text_skip_queries"> + {% endif %} + </div> + + <div class="importoptions"> + <h3>{% trans 'Other options:' %}</h3> + <div class="formelementrow"> + {{ get_fk_checkbox() }} + </div> + </div> + + <div class="importoptions"> + <h3>{% trans 'Format:' %}</h3> + {{ get_choice('Import', 'format', import_list) }} + <div id="import_notification"></div> + </div> + + <div class="importoptions" 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> + {{ get_options('Import', import_list) }} + </div> + <div class="clearfloat"></div> + + {# Japanese encoding setting #} + {% if can_convert_kanji %} + <div class="importoptions" id="kanji_encoding"> + <h3>{% trans 'Encoding Conversion:' %}</h3> + {% include 'encoding/kanji_encoding_form.twig' %} + </div> + {% endif %} + + <div class="importoptions" id="submit"> + <input id="buttonGo" class="btn btn-primary" type="submit" value="{% trans 'Go' %}"> + </div> + </form> +</div> diff --git a/srcs/phpmyadmin/templates/display/import/javascript.twig b/srcs/phpmyadmin/templates/display/import/javascript.twig new file mode 100644 index 0000000..ec91e3c --- /dev/null +++ b/srcs/phpmyadmin/templates/display/import/javascript.twig @@ -0,0 +1,162 @@ +$( function() { + {# Add event when user click on "Go" button #} + $("#buttonGo").on("click", function() { + {# Hide form #} + $("#upload_form_form").css("display", "none"); + + {% if handler != 'PhpMyAdmin\\Plugins\\Import\\Upload\\UploadNoplugin' %} + {# Some variable for javascript #} + {% set ajax_url = 'import_status.php?id=' ~ upload_id ~ get_common_raw({ + 'import_status': 1 + }, '&') %} + {% set promot_str = 'The file being uploaded is probably larger than the maximum allowed size or this is a known bug in webkit based (Safari, Google Chrome, Arora etc.) browsers.'|trans|js_format(false) %} + {% set statustext_str = '%s of %s'|trans|escape_js_string %} + {% set second_str = '%s/sec.'|trans|js_format(false) %} + {% set remaining_min = 'About %MIN min. %SEC sec. remaining.'|trans|js_format(false) %} + {% set remaining_second = 'About %SEC sec. remaining.'|trans|js_format(false) %} + {% set processed_str = 'The file is being processed, please be patient.'|trans|js_format(false) %} + {% set import_url = get_common_raw({'import_status': 1}, '&') %} + + {% set upload_html %} + {% apply spaceless %} + <div class="upload_progress"> + <div class="upload_progress_bar_outer"> + <div class="percentage"></div> + <div id="status" class="upload_progress_bar_inner"> + <div class="percentage"></div> + </div> + </div> + <div> + <img src="{{ pma_theme_image }}ajax_clock_small.gif" width="16" height="16" alt="ajax clock"> {{ 'Uploading your import fileā¦'|trans|js_format(false) -}} + </div> + <div id="statustext"></div> + </div> + {% endapply %} + {% endset %} + + {# Start output #} + var finished = false; + var percent = 0.0; + var total = 0; + var complete = 0; + var original_title = parent && parent.document ? parent.document.title : false; + var import_start; + + var perform_upload = function () { + new $.getJSON( + "{{ ajax_url|raw }}", + {}, + function(response) { + finished = response.finished; + percent = response.percent; + total = response.total; + complete = response.complete; + + if (total==0 && complete==0 && percent==0) { + $("#upload_form_status_info").html('<img src="{{ pma_theme_image }}ajax_clock_small.gif" width="16" height="16" alt="ajax clock"> {{ promot_str|raw }}'); + $("#upload_form_status").css("display", "none"); + } else { + var now = new Date(); + now = Date.UTC( + now.getFullYear(), + now.getMonth(), + now.getDate(), + now.getHours(), + now.getMinutes(), + now.getSeconds()) + + now.getMilliseconds() - 1000; + var statustext = Functions.sprintf( + "{{ statustext_str|raw }}", + Functions.formatBytes( + complete, 1, Messages.strDecimalSeparator + ), + Functions.formatBytes( + total, 1, Messages.strDecimalSeparator + ) + ); + + if ($("#importmain").is(":visible")) { + {# Show progress UI #} + $("#importmain").hide(); + $("#import_form_status") + .html('{{ upload_html|raw }}') + .show(); + import_start = now; + } + else if (percent > 9 || complete > 2000000) { + {# Calculate estimated time #} + var used_time = now - import_start; + var seconds = parseInt(((total - complete) / complete) * used_time / 1000); + var speed = Functions.sprintf( + "{{ second_str|raw }}", + Functions.formatBytes(complete / used_time * 1000, 1, Messages.strDecimalSeparator) + ); + + var minutes = parseInt(seconds / 60); + seconds %= 60; + var estimated_time; + if (minutes > 0) { + estimated_time = "{{ remaining_min|raw }}" + .replace("%MIN", minutes) + .replace("%SEC", seconds); + } + else { + estimated_time = "{{ remaining_second|raw }}" + .replace("%SEC", seconds); + } + + statustext += "<br>" + speed + "<br><br>" + estimated_time; + } + + var percent_str = Math.round(percent) + "%"; + $("#status").animate({width: percent_str}, 150); + $(".percentage").text(percent_str); + + {# Show percent in window title #} + if (original_title !== false) { + parent.document.title + = percent_str + " - " + original_title; + } + else { + document.title + = percent_str + " - " + original_title; + } + $("#statustext").html(statustext); + } + + if (finished == true) { + if (original_title !== false) { + parent.document.title = original_title; + } + else { + document.title = original_title; + } + $("#importmain").hide(); + {# Loads the message, either success or mysql error #} + $("#import_form_status") + .html('<img src="{{ pma_theme_image }}ajax_clock_small.gif" width="16" height="16" alt="ajax clock"> {{ processed_str|raw }}') + .show(); + $("#import_form_status").load("import_status.php?message=true&{{ import_url|raw }}"); + Navigation.reload(); + + {# If finished #} + } + else { + setTimeout(perform_upload, 1000); + } + }); + }; + setTimeout(perform_upload, 1000); + {% else %} + {# No plugin available #} + {% set image_tag -%} + <img src="{{ pma_theme_image -}} + ajax_clock_small.gif" width="16" height="16" alt="ajax clock"> + {{- 'Please be patient, the file is being uploaded. Details about the upload are not available.'|trans|js_format(false) -}} + {{- show_docu('faq', 'faq2-9') -}} + {%- endset %} + $('#upload_form_status_info').html('{{ image_tag|raw }}'); + $("#upload_form_status").css("display", "none"); + {% endif %} + }); +}); |
