Commit f31fe5a7 authored by Gerald Salin's avatar Gerald Salin
Browse files

utilisation du plugin dialog de jquery en lieu et place des alert javascript

parent 35ab5964
......@@ -46,13 +46,19 @@ class tx_nG6_eid {
$data_folder = trim(t3lib_div::_GP('data_folder'));
$tmp_folder = trim(t3lib_div::_GP('tmp_folder'));
print $this->get_download_file($ids, $data_folder, $tmp_folder);
}else if ($type == 'getFileSize') {
} else if ($type == 'getFileSize') {
$ids = trim(t3lib_div::_GP('ids'));
$data_folder = trim(t3lib_div::_GP('data_folder'));
print $this->get_file_size($ids, $data_folder);
}
}
}
/**
* for each $id, get the total size of all files in the corresponding folder
* @param string $ids : names of run or analysis for which we want to get the sizes of the contained files
* @param string $data_folder : root directory where the folders of the runs and analysis can be found
* @return integer $fileSize : total size of the files
*/
function get_file_size($ids, $data_folder) {
$src_directories = Array();
$vals = split(";", $ids);
......@@ -128,6 +134,7 @@ class tx_nG6_eid {
$dest_directories = Array();
$vals = split(";", $ids);
$temporary_dir = $this->createRandomArchiveName($tmp_folder);
$charToBeSubstituted = array(' ','/'); //characters to be replaced in the names of the run, the analyses....
foreach($vals as $val) {
if ($val != "undefined" && $val != "") {
$id = split("_", $val);
......@@ -135,19 +142,19 @@ class tx_nG6_eid {
$run = $this->get_run($id[1]);
if (!in_array($data_folder.$run["directory"], $src_directories)) {
$src_directories[] = $data_folder.$run["directory"];
$dest_directories[] = $temporary_dir."/Project_".str_replace(' ', '_', $run["project_name"]).'.'.$run["project_id"]."/Run_".str_replace(' ', '_', $run["name"]).".".$id[1]."/RawData";
$dest_directories[] = $temporary_dir."/Project_".str_replace($charToBeSubstituted, '_', $run["project_name"]).'.'.$run["project_id"]."/Run_".str_replace($charToBeSubstituted, '_', $run["name"]).".".$id[1]."/RawData";
}
} else if ($id[0] == "run") {
$run = $this->get_run($id[1]);
if (!in_array($data_folder.$run["directory"], $src_directories)) {
$src_directories[] = $data_folder.$run["directory"];
$dest_directories[] = $temporary_dir."/Project_".str_replace(' ', '_', $run["project_name"]).'.'.$run["project_id"]."/Run_".str_replace(' ', '_', $run["name"]).".".$id[1]."/RawData";
$dest_directories[] = $temporary_dir."/Project_".str_replace($charToBeSubstituted, '_', $run["project_name"]).'.'.$run["project_id"]."/Run_".str_replace($charToBeSubstituted, '_', $run["name"]).".".$id[1]."/RawData";
}
foreach($this->get_run_analysis($id[1]) as $analyse_id => $analyse_values) {
if (!in_array($data_folder.$analyse_values["directory"], $src_directories)) {
$src_directories[] = $data_folder.$analyse_values["directory"];
$aid = split("_", $analyse_id);
$dest_directories[] = $temporary_dir."/Project_".str_replace(' ', '_', $run["project_name"]).'.'.$run["project_id"]."/Run_".str_replace(' ', '_', $run["name"]).".".$id[1]."/Analyse_".str_replace(' ', '_', $analyse_values["name"]).".".$aid;
$dest_directories[] = $temporary_dir."/Project_".str_replace($charToBeSubstituted, '_', $run["project_name"]).'.'.$run["project_id"]."/Run_".str_replace($charToBeSubstituted, '_', $run["name"]).".".$id[1]."/Analyse_".str_replace($charToBeSubstituted, '_', $analyse_values["name"]).".".$aid;
}
}
} else if ($id[0] == "analyse") {
......@@ -156,9 +163,9 @@ class tx_nG6_eid {
$src_directories[] = $data_folder.$analyse["directory"];
// If it's a project analyse
if ($analyse["run_id"] == 'None') {
$dest_directories[] = $temporary_dir."/Project_".str_replace(' ', '_', $analyse["project_name"]).".".$analyse["project_id"]."/Project_analyses/".str_replace(' ', '_', $analyse["name"]).".".$id[1];
$dest_directories[] = $temporary_dir."/Project_".str_replace($charToBeSubstituted, '_', $analyse["project_name"]).".".$analyse["project_id"]."/Project_analyses/".str_replace($charToBeSubstituted, '_', $analyse["name"]).".".$id[1];
} else {
$dest_directories[] = $temporary_dir."/Project_".str_replace(' ', '_', $analyse["project_name"]).".".$analyse["project_id"]."/Run_".str_replace(' ', '_', $analyse["run_name"]).".".$analyse["run_id"]."/Analyse_".str_replace(' ', '_', $analyse["name"]).".".$id[1];
$dest_directories[] = $temporary_dir."/Project_".str_replace($charToBeSubstituted, '_', $analyse["project_name"]).".".$analyse["project_id"]."/Run_".str_replace($charToBeSubstituted, '_', $analyse["run_name"]).".".$analyse["run_id"]."/Analyse_".str_replace($charToBeSubstituted, '_', $analyse["name"]).".".$id[1];
}
}
}
......
......@@ -162,7 +162,7 @@ class tx_nG6_pi5 extends tslib_pibase {
$("#download_btn").removeClass("tx-nG6-pi5-download-disable");
}
});
$("#download_dialog").dialog({
$("#user_information_dialog").dialog({
autoOpen: false,
bgiframe: true,
resizable: false,
......@@ -177,45 +177,65 @@ class tx_nG6_pi5 extends tslib_pibase {
$("#download_btn").click(function() {
if (!$(this).hasClass("tx-nG6-pi5-download-disable")) {
var limitFileSize = 200000000; //limit size in byte for the data to be archived and downloaded
var timeOutOnSizeRetrieval = 5000; //timeout on the ajax request to calcultate the size of the files to be downloaded
var timeOutOnDataRetrieval = 90000; //timeout on the ajax request to archive the files to be downloaded
var url_test_filesize = "index.php?eID=tx_nG6&type=getFileSize&data_folder='.$this->conf["data"].'&ids=";
var url_val = "index.php?eID=tx_nG6&type=download&data_folder='.$this->conf["data"].'&tmp_folder='.$this->conf["temp"].'&ids=";
$(".jstree-checked > ul > .jstree-checked, .jstree-undetermined > ul > .jstree-checked").each(function(){
$(".jstree-checked > ul > .jstree-checked, .jstree-undetermined > ul > .jstree-checked").each(function(){
url_test_filesize += $(this).attr("id")+";";
url_val += $(this).attr("id")+";";
url_val += $(this).attr("id")+";";
});
$.ajax({
url: url_test_filesize,
timeout: 2500,
error: function(xhr, status, error) {
timeout: timeOutOnSizeRetrieval,
error: function(xhr, status, error) {
if(status == "timeout"){
// Display a generic error for now.
alert("'.$this->getFieldHeader('download_alert_timeout_getFileSize_msg').' '.$this->getFieldHeader('download_use_command_line_msg').'");
}
},
// Display a generic error.
$("#user_information_dialog").dialog("option", "title", "'.$this->getFieldHeader('user_information_dialog_error_title').'");
$("#user_information_dialog").html(\'<img src="fileadmin/templates/nG6template/images/Crystal_128_error.png"/> '.$this->getFieldHeader('user_information_dialog_alert_timeout_getFileSize_msg').' '.$this->getFieldHeader('user_information_dialog_use_command_line_msg').'\').dialog("open");
exit;
}
},
success: function(val,status, xhr) {
var limitFileSize = 200000000;//limite à 200 Mo
if (val == ""){
$("#user_information_dialog").dialog("option", "title", "'.$this->getFieldHeader('user_information_dialog_error_title').'");
$("#user_information_dialog").html(\'<img src="fileadmin/templates/nG6template/images/Crystal_128_error.png"/> '.$this->getFieldHeader('user_information_dialog_alert_data_not_accessible_msg').' '.$this->getFieldHeader('user_information_dialog_use_command_line_msg').'\').dialog("open");
exit;
}
if (val < limitFileSize){
//alert("OK, taille inferieure a " + limitFileSize/1000 + "Ko ("+ val/1000 +" Ko)");
$("#download_dialog").dialog("option", "title", "'.$this->getFieldHeader('download_dialog_title').'");
$("#download_dialog").html(\'<img src="fileadmin/templates/nG6template/images/light_wait.gif"/> '.$this->getFieldHeader('download_dialog_msg').'\').dialog("open");
$("#user_information_dialog").dialog("option", "title", "'.$this->getFieldHeader('user_information_dialog_download_title').'");
$("#user_information_dialog").html(\'<img src="fileadmin/templates/nG6template/images/light_wait.gif"/> '.$this->getFieldHeader('user_information_dialog_download_msg').'\').dialog("open");
$.ajax({
url: url_val,
timeout: 90000,
error: function(xhr, status, error) {
$("#download_dialog").dialog("close");
timeout: timeOutOnDataRetrieval,
error: function(xhr, status, error) {
$("#user_information_dialog").dialog("close");
if(status == "timeout"){
// Display a generic error for now.
alert("'.$this->getFieldHeader('download_alert_timeout_msg').' '.$this->getFieldHeader('download_use_command_line_msg').'");
// Display a generic error.
$("#user_information_dialog").dialog("option", "title", "'.$this->getFieldHeader('user_information_dialog_error_title').'");
$("#user_information_dialog").html(\'<img src="fileadmin/templates/nG6template/images/Crystal_128_error.png"/> '.$this->getFieldHeader('user_information_dialog_alert_timeout_msg').' '.$this->getFieldHeader('user_information_dialog_use_command_line_msg').'\').dialog("open");
// alert("'.$this->getFieldHeader('user_information_dialog_alert_timeout_msg').' '.$this->getFieldHeader('user_information_dialog_use_command_line_msg').'");
exit;
}
},
success: function(val,status, xhr) {
$("#download_dialog").dialog("close");
$("#user_information_dialog").dialog("close");
location.href = "'.$tmp_url.'/"+val;
}
});
}else{
alert("'.$this->getFieldHeader('download_alert_max_filesize_exceeded_msg').'(" + val/1000000 + " sur "+ limitFileSize/1000000+"Mo autorises). '.$this->getFieldHeader('download_use_command_line_msg').'");
$("#user_information_dialog").dialog("option", "title", "'.$this->getFieldHeader('user_information_dialog_error_title').'");
$("#user_information_dialog").html(\'<img src="fileadmin/templates/nG6template/images/Crystal_128_error.png"/> '.$this->getFieldHeader('user_information_dialog_alert_max_filesize_exceeded_msg').'(\' + Math.round(val/1000000) + \' '.$this->getFieldHeader('user_information_dialog_alert_max_filesize_exceeded_msg_on').' \' + limitFileSize/1000000+ \''.$this->getFieldHeader('user_information_dialog_alert_max_filesize_exceeded_msg_Mo_Allowed').'). '.$this->getFieldHeader('user_information_dialog_use_command_line_msg').'\').dialog("open");
//alert("'.$this->getFieldHeader('user_information_dialog_alert_max_filesize_exceeded_msg').'(" + Math.round(val/1000000) + " '.$this->getFieldHeader('user_information_dialog_alert_max_filesize_exceeded_msg_on').' "+ limitFileSize/1000000+" '.$this->getFieldHeader('user_information_dialog_alert_max_filesize_exceeded_msg_Mo_Allowed').'). '.$this->getFieldHeader('user_information_dialog_use_command_line_msg').'");
exit;
}
}
......@@ -236,7 +256,7 @@ class tx_nG6_pi5 extends tslib_pibase {
}
$html_tree .= "' />";
$content .= '<div '.$this->pi_classParam('download-builder-tree').'> <div '.$this->pi_classParam('download-builder-header').'> <h3>'.$this->getFieldHeader('msg').'</h3></div> <div id="download_dialog" title=""></div>'.$html_tree;
$content .= '<div '.$this->pi_classParam('download-builder-tree').'> <div '.$this->pi_classParam('download-builder-header').'> <h3>'.$this->getFieldHeader('msg').'</h3></div> <div id="user_information_dialog" title=""></div>'.$html_tree;
$content .= '<div id="download_tree"></div></div>';
$content .= '<div '.$this->pi_classParam('download-builder').'> ';
$content .= '<div '.$this->pi_classParam('download-builder-group').'> <h2>'.$this->getFieldHeader('download_list_title').'<h2> <div id="download_list"> <ul><li><span>'.$this->getFieldHeader('download_list_no_select').'</span></li></ul></div></div>';
......
......@@ -12,18 +12,22 @@
<label index="listFieldHeader_run_short_description">Run ###SPAN_NAME### (###SPAN_DATE###)</label>
<label index="listFieldHeader_analyse_description">Analyse ###SPAN_NAME###</label>
<label index="listFieldHeader_raw_data_label">Raw data</label>
<label index="listFieldHeader_download_dialog_title">Downloading</label>
<label index="listFieldHeader_download_dialog_msg">File creation in progress ...</label>
<label index="listFieldHeader_user_information_dialog_download_title">Downloading</label>
<label index="listFieldHeader_user_information_dialog_download_msg">File creation in progress ...</label>
<label index="listFieldHeader_title">Download center</label>
<label index="listFieldHeader_msg">First select all data you want to download, then click on the download button.</label>
<label index="listFieldHeader_download_list_title">Download Files list :</label>
<label index="listFieldHeader_download_format_title">Download format :</label>
<label index="listFieldHeader_download_list_no_select">No run neither any analyse selected.</label>
<label index="listFieldHeader_all">Raw data + all analyses</label>
<label index="listFieldHeader_download_alert_timeout_getFileSize_msg">Getting the size of the files to be downloaded takes too long time.</label>
<label index="listFieldHeader_download_alert_timeout_msg">The download takes too long time.</label>
<label index="listFieldHeader_download_alert_max_filesize_exceeded_msg">The total size of the files you want to download is too high </label>
<label index="listFieldHeader_download_use_command_line_msg">Please use the command line to get your data.</label>
<label index="listFieldHeader_user_information_dialog_alert_timeout_getFileSize_msg">Getting the size of the files to be downloaded takes too long time.</label>
<label index="listFieldHeader_user_information_dialog_alert_timeout_msg">The download takes too long time.</label>
<label index="listFieldHeader_user_information_dialog_alert_max_filesize_exceeded_msg">The total size of the files you want to download is too high </label>
<label index="listFieldHeader_user_information_dialog_use_command_line_msg">Please use the command line to get your data.</label>
<label index="listFieldHeader_user_information_dialog_alert_max_filesize_exceeded_msg_on">on</label>
<label index="listFieldHeader_user_information_dialog_alert_max_filesize_exceeded_msg_Mo_Allowed">Mo allowed</label>
<label index="listFieldHeader_user_information_dialog_alert_data_not_accessible_msg">It seems that data are not reachable by the web.</label>
<label index="listFieldHeader_user_information_dialog_error_title">Error</label>
</languageKey>
<languageKey index="fr" type="array">
<label index="listFieldHeader_download_btn_label">T&amp;eacute;l&amp;eacute;charger</label>
......@@ -32,18 +36,22 @@
<label index="listFieldHeader_run_short_description">Run ###SPAN_NAME### (###SPAN_DATE###)</label>
<label index="listFieldHeader_analyse_description">Analyse ###SPAN_NAME###</label>
<label index="listFieldHeader_raw_data_label">Donn&amp;eacute;es brutes</label>
<label index="listFieldHeader_download_dialog_title">T&amp;eacute;l&amp;eacute;chargement</label>
<label index="listFieldHeader_download_dialog_msg">Cr&amp;eacute;ation en cours ...</label>
<label index="listFieldHeader_user_information_dialog_download_title">T&amp;eacute;l&amp;eacute;chargement</label>
<label index="listFieldHeader_user_information_dialog_download_msg">Cr&amp;eacute;ation en cours ...</label>
<label index="listFieldHeader_title">T&amp;eacute;l&amp;eacute;chargement de vos donn&amp;eacute;es</label>
<label index="listFieldHeader_msg">S&amp;eacute;lectionner les donn&amp;eacute;es que vous souhaitez t&amp;eacute;l&amp;eacute;charger puis cliquer sur le bouton de t&amp;eacute;l&amp;eacute;chargement.</label>
<label index="listFieldHeader_download_list_title">Liste des fichiers &amp;agrave; t&amp;eacute;l&amp;eacute;charger :</label>
<label index="listFieldHeader_download_format_title">Format :</label>
<label index="listFieldHeader_download_list_no_select">Aucun run ni analyse s&amp;eacute;l&amp;eacute;ctionn&amp;eacute;.</label>
<label index="listFieldHeader_all">Donn&amp;eacute;es brutes + toutes les analyses</label>
<label index="listFieldHeader_download_alert_timeout_getFileSize_msg">La récupération de la taille totale des fichiers à charger prend trop de temps.</label>
<label index="listFieldHeader_download_alert_timeout_msg">Le chargement des données prend trop de temps.</label>
<label index="listFieldHeader_download_alert_max_filesize_exceeded_msg">La taille totale des fichiers que vous souhaitez télécharger est trop élevée </label>
<label index="listFieldHeader_download_use_command_line_msg">Veuillez utiliser l'outil en ligne de commande pour récupérer vos données SVP.</label>
<label index="listFieldHeader_user_information_dialog_alert_timeout_getFileSize_msg">La récupération de la taille totale des fichiers à charger prend trop de temps.</label>
<label index="listFieldHeader_user_information_dialog_alert_timeout_msg">Le chargement des données prend trop de temps.</label>
<label index="listFieldHeader_user_information_dialog_alert_max_filesize_exceeded_msg">La taille totale des fichiers que vous souhaitez télécharger est trop élevée </label>
<label index="listFieldHeader_user_information_dialog_use_command_line_msg">Veuillez utiliser l\'outil en ligne de commande pour récupérer vos données SVP.</label>
<label index="listFieldHeader_user_information_dialog_alert_max_filesize_exceeded_msg_on">sur</label>
<label index="listFieldHeader_user_information_dialog_alert_max_filesize_exceeded_msg_Mo_Allowed">Mo autorisés</label>
<label index="listFieldHeader_user_information_dialog_alert_data_not_accessible_msg">Il semble que les données ne soient pas accessibles en ligne.</label>
<label index="listFieldHeader_user_information_dialog_error_title">Erreur</label>
</languageKey>
</data>
</T3locallang>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment