Commit 5b421e47 authored by Jerome Mariette's avatar Jerome Mariette
Browse files

No commit message

No commit message
parent 2f1de1c7
......@@ -6,7 +6,6 @@ require_once(PATH_t3lib.'stddb/tables.php');
require_once(t3lib_extMgm::extPath('cms','ext_tables.php'));
require_once(PATH_t3lib.'class.t3lib_db.php');
class tx_nG6_eid {
......@@ -15,44 +14,89 @@ class tx_nG6_eid {
/* connect to the databse */
tslib_eidtools::connectDB();
$html = '';
$id = trim(t3lib_div::_GP('id'));
$type = trim(t3lib_div::_GP('type'));
if ($type == 'project') {
// First all project runs
$p_runs = $this->get_project_runs($id);
foreach($p_runs as $run_id => $run_values) {
$html .= '<li class="jstree-closed" id=\''.$run_id.'\'> <a href=\'#\'>'.$run_values["name"].'</a></li>';
}
// Then all project analysis
$p_analysis = $this->get_project_analysis($id);
foreach($p_analysis as $analyse_id => $analyse_values) {
$html .= '<li id=\''.$analyse_values["directory"].'\' name=\''.$analyse_values["directory"].'\'> <a href=\'#\'>'.$analyse_values["name"].'</a></li>';
$html .= '<li id=\''.$analyse_id.'\'> <a href=\'#\'>'.$analyse_values["name"].'</a></li>';
}
print $html;
} else if ($type == 'run'){
$r_analysis = $this->get_run_analysis($id);
$run_info = $this->get_run($id);
$html .= '<li id=\'data_'.$id.'\' > <a href=\'#\'>Donn&eacute;es brutes</a></li>';
$html .= '<li id=\'data_'.$id.'\'> <a href=\'#\'>Donn&eacute;es brutes</a></li>';
foreach($r_analysis as $analyse_id => $analyse_values) {
$html .= '<li id=\''.$analyse_values["directory"].'\' name=\''.$analyse_values["directory"].'\'> <a href=\'#\'>'.$analyse_values["name"].'</a></li>';
$html .= '<li id=\''.$analyse_id.'\'> <a href=\'#\'>'.$analyse_values["name"].'</a></li>';
}
print $html;
} else {
print 'test';
} else if ($type == 'download') {
$ids = trim(t3lib_div::_GP('ids'));
$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);
}
}
function get_download_file($ids, $data_folder, $tmp_folder) {
$src_directories = Array();
$dest_directories = Array();
$vals = split(";", $ids);
$temporary_dir = $this->createRandomArchiveName($tmp_folder);
$i = 0;
$tmp = "";
foreach($vals as $val) {
if ($val != "undefined" && $val != "") {
$id = split("_", $val);
if ($id[0] == "data") {
$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."/".str_replace(' ', '_', $run["name"])."_".$id[1];
}
} 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."/".str_replace(' ', '_', $run["name"])."_".$id[1];
}
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"];
$dest_directories[] = $temporary_dir."/".str_replace(' ', '_', $run["name"])."_".$id[1]."/".str_replace(' ', '_', $analyse_values["name"])."_".$analyse_id;
}
}
} else if ($id[0] == "analyse") {
$analyse = $this->get_analyse($id[1]);
if (!in_array($data_folder.$analyse["directory"], $src_directories)) {
$src_directories[] = $data_folder.$analyse["directory"];
// If it's a project analyse
if ($analyse["run_id"] == 'None') {
$dest_directories[] = $temporary_dir."/".str_replace(' ', '_', $analyse["project_name"])."_".$analyse["project_id"]."/".str_replace(' ', '_', $analyse["name"])."_".$id[1];
} else {
$dest_directories[] = $temporary_dir."/".str_replace(' ', '_', $analyse["project_name"])."_".$analyse["project_id"]."/".str_replace(' ', '_', $analyse["run_name"])."_".$analyse["run_id"]."/".str_replace(' ', '_', $analyse["name"])."_".$id[1];
}
}
} else if ($id[0] == "project") {
$tmp .= "p".$id[1].", ";
}
$i++;
}
}
$this->archiveZip($src_directories, $dest_directories);
}
function get_run_analysis($run_id) {
$results = array();
......@@ -86,7 +130,7 @@ class tx_nG6_eid {
}
return $results;
}
function get_project_analysis($project_id) {
$results = array();
......@@ -120,7 +164,116 @@ class tx_nG6_eid {
}
return $results;
}
function get_run($run_id) {
$result = array();
$queryParts = Array(
'SELECT' => 'tx_nG6_run.uid AS run_id,'.
'tx_nG6_run.directory AS run_directory,'.
'tx_nG6_run.description AS run_description, '.
'tx_nG6_run.name AS run_name, '.
'tx_nG6_run.nb_sequences, '.
'tx_nG6_run.date AS run_date',
'FROM' => 'tx_nG6_run',
'WHERE' => 'tx_nG6_run.uid='.$run_id,
'GROUPBY' => '',
'ORDERBY' => 'tx_nG6_run.date DESC',
'LIMIT' => ''
);
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))
{
$run_id = $row['run_id'];
if (! isset ($results['run_'.$run_id]) )
{
$result = array(
'directory' => $row['run_directory'],
'name' => $row['run_name'],
'nb_sequences' => $row['nb_sequences'],
'date' => $row['run_date'],
'description' => $row['run_description']
);
}
}
return $result;
}
function get_analyse($analyse_id) {
$queryParts = array(
'SELECT' => 'tx_nG6_project.uid AS project_id,'.
'tx_nG6_project.name AS project_name,'.
'tx_nG6_analyze.uid AS analyze_id,'.
'tx_nG6_analyze.directory AS analyze_directory,'.
'tx_nG6_analyze.name AS analyze_name, '.
'tx_nG6_analyze.date AS analyze_date, '.
'tx_nG6_analyze.description AS analyze_description ',
'FROM' => 'tx_nG6_project INNER JOIN (tx_nG6_project_analyze INNER JOIN tx_nG6_analyze ON ' .
'tx_nG6_analyze.uid=tx_nG6_project_analyze.analyze_id) ON tx_nG6_project.uid = tx_nG6_project_analyze.project_id ',
'WHERE' => 'tx_nG6_analyze.uid='.$analyse_id,
'GROUPBY' => '',
'ORDERBY' => '',
'LIMIT' => ''
);
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
// If it's a project analyse
if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) {
$result = array();
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))
{
$result = array(
'project_name' => $row['project_name'],
'project_id' => $row['project_id'],
'run_name' => 'None',
'run_id' => 'None',
'directory' => $row['analyze_directory'],
'name' => $row['analyze_name'],
'date' => $row['analyze_date'],
'description' => $row['analyze_description']
);
}
return $result;
} else {
$queryParts = array(
'SELECT' => 'tx_nG6_project.name AS project_name,'.
'tx_nG6_project.uid AS project_id,'.
'tx_nG6_run.uid AS run_id,'.
'tx_nG6_run.name AS run_name,'.
'tx_nG6_analyze.uid AS analyze_id,'.
'tx_nG6_analyze.directory AS analyze_directory,'.
'tx_nG6_analyze.name AS analyze_name, '.
'tx_nG6_analyze.date AS analyze_date, '.
'tx_nG6_analyze.description AS analyze_description',
'FROM' => 'tx_nG6_project INNER JOIN ( tx_nG6_project_run INNER JOIN ( tx_nG6_run INNER JOIN ( tx_nG6_run_analyze INNER JOIN '.
'tx_nG6_analyze ON tx_nG6_analyze.uid = tx_nG6_run_analyze.analyze_id) ON tx_nG6_run_analyze.run_id = tx_nG6_run.uid '.
') ON tx_nG6_run.uid = tx_nG6_project_run.run_id) ON tx_nG6_project_run.project_id = tx_nG6_project.uid ',
'WHERE' => 'tx_nG6_analyze.uid='.$analyse_id,
'GROUPBY' => '',
'ORDERBY' => 'tx_nG6_analyze.name',
'LIMIT' => ''
);
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
$result = array();
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))
{
$result = array(
'project_name' => $row['project_name'],
'project_id' => $row['project_id'],
'run_name' => $row['run_name'],
'run_id' => $row['run_id'],
'directory' => $row['analyze_directory'],
'name' => $row['analyze_name'],
'date' => $row['analyze_date'],
'description' => $row['analyze_description']
);
}
return $result;
}
}
function get_project_runs($project_id) {
$results = array();
......@@ -158,12 +311,12 @@ class tx_nG6_eid {
}
//Return archive's filepath.random_name
function createRandomArchiveName(){
function createRandomArchiveName ($tmp_dir) {
$randomKey = $this->createRandomKey(10);
$pathname = $this->internal['temp_directory'].'/archiveNG6_'.$randomKey;
$pathname = $tmp_dir.'/archiveNG6_'.$randomKey;
// 1 chance over 49**10 is still a risk
while( file_exists($pathname) )
$pathname = $this->internal['temp_directory'].'/archiveNG6_'.$randomKey;
$pathname = $tmp_dir.'/archiveNG6_'.$randomKey;
return $pathname;
}
......
......@@ -4,7 +4,7 @@ plugin.tx_nG6_pi1 {
recursive =
view =
results_at_a_time = 20
data = /var/www/typoweb/ng6/fileadmin
data = /tools/typoweb/ng6/fileadmin
}
plugin.tx_nG6_pi2 {
result_page_id = 6
......@@ -13,6 +13,6 @@ plugin.tx_nG6_pi3 {
redirection_page = 2
}
plugin.tx_nG6_pi5 {
temp_directory = /var/www/typoweb/ng6/fileadmin/temp
temp = /var/www/typoweb/ng6/fileadmin/tmp
data = /var/www/typoweb/ng6/fileadmin
}
\ No newline at end of file
......@@ -75,6 +75,7 @@ class tx_nG6_pi5 extends tslib_pibase {
<link type="text/css" rel="stylesheet" media="screen" href="'.t3lib_extMgm::siteRelPath($this->extKey).'res/css/jquery.ui.theme.css"/>
<link type="text/css" rel="stylesheet" media="screen" href="'.t3lib_extMgm::siteRelPath($this->extKey).'res/css/jquery.ui.dialog.css"/>';
// Sets the page content
$content = '<h2>Telechargement de vos donnees</h2>';
$content .= '<p>Selectionner dans l\'arbre les informations que vous souhaitez telecharger puis cliquer sur le bouton de telechargement. </p>';
......@@ -109,14 +110,15 @@ class tx_nG6_pi5 extends tslib_pibase {
}
});
$("#download_btn").click(function(){
var url_val = "index.php?eID=tx_nG6&type=download&values=";
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(){
url_val += $(this).attr("name")+";";
url_val += $(this).attr("id")+";";
});
alert(url_val);
$("#download_dialog").dialog("option", "title", "Telechargement ...");
$("#download_dialog").html(\'<img src="fileadmin/templates/nG6template/images/light_wait.gif"/>\').dialog("open");
$.ajax({
url: "",
url: url_val,
success: function(val) {
$("#download_dialog").html(val).dialog("open");
}
......@@ -129,14 +131,15 @@ class tx_nG6_pi5 extends tslib_pibase {
$arrayProject = $this->get_project_list();
$content .= '<div id="download_dialog" title=""></div>'.
'<div id="download_tree"></div>';
$html_tree = '<input type="hidden" name = "html_tree" id="html_tree" value="';
$html_tree = "<input type='hidden' name = 'html_tree' id='html_tree' value='";
foreach($arrayProject as $project_id => $project_array) {
$html_tree .= '<li class=\'jstree-closed\' id=\''.$project_id.'\'> <a href=\'#\'>'.
str_replace(array('###SPAN_NAME###'), array($project_array['name']), $this->getFieldHeader('project_description')).'</a></li>';
$html_tree .= "<li class=\"jstree-closed\" id=\"".$project_id."\"> <a href=\"#\">".
str_replace(array('###SPAN_NAME###'), array($project_array['name']), $this->getFieldHeader('project_description'))."</a></li>";
}
$content .= $html_tree.'" />';
$content .= '<input class="tx-nG6-pi5-download" id="download_btn" type="button" value="Telecharger" />';
$content .= $html_tree."' />";
$content .= '<input class="tx-nG6-pi5-download" id="download_btn" type="button" value="'.$this->getFieldHeader('download_btn_label').'" />';
return $content;
}
......
......@@ -6,13 +6,13 @@
</meta>
<data type="array">
<languageKey index="default" type="array">
<label index="listFieldHeader_download_btn">Download</label>
<label index="listFieldHeader_download_btn_label">Download</label>
<label index="listFieldHeader_project_description">Project ###SPAN_NAME###</label>
<label index="listFieldHeader_run_description">Run ###SPAN_NAME### - (###SPAN_DATE###) produced ###SPAN_NB_SEQ### reads</label>
<label index="listFieldHeader_analyse_description">Analyse ###SPAN_NAME###</label>
</languageKey>
<languageKey index="fr" type="array">
<label index="listFieldHeader_download_btn">Télécharger</label>
<label index="listFieldHeader_download_btn_label">T&amp;eacute;l&amp;eacute;charger</label>
<label index="listFieldHeader_project_description">Projet ###SPAN_NAME###</label>
<label index="listFieldHeader_analyse_description">Run ###SPAN_NAME### - r&amp;eacute;alis&amp;eacute; le ###SPAN_DATE###, ###SPAN_NB_SEQ### lectures</label>
<label index="listFieldHeader_analyse_description">Analyse ###SPAN_NAME###</label>
......
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