Commit 966cdeaa authored by Jerome Mariette's avatar Jerome Mariette
Browse files

first version download

parent 37533bf8
<?php
// Inclusion des librairies nécessaires
require_once(PATH_t3lib.'class.t3lib_befunc.php');
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 {
/* Méthode principale */
function main() {
/* 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>';
}
print $html;
} else if ($type == 'run'){
$r_analysis = $this->get_run_analysis($id);
$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>';
}
print $html;
} else {
print 'test';
}
}
function get_run_analysis($run_id) {
$results = array();
$queryParts = array(
'SELECT' => '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_run_analyze JOIN tx_nG6_analyze ON '.
'tx_nG6_analyze.uid=tx_nG6_run_analyze.analyze_id',
'WHERE' => 'tx_nG6_run_analyze.run_id='.$run_id,
'GROUPBY' => '',
'ORDERBY' => 'tx_nG6_analyze.name',
'LIMIT' => ''
);
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))
{
$analyze_id = $row['analyze_id'];
if (! isset ($results['analyse_'.$analyze_id]) )
{
$results['analyse_'.$analyze_id] = array(
'directory' => $row['analyze_directory'],
'name' => $row['analyze_name'],
'date' => $row['analyze_date'],
'description' => $row['analyse_description']
);
}
}
return $results;
}
function get_project_analysis($project_id) {
$results = array();
$queryParts = array(
'SELECT' => '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_analyze JOIN tx_nG6_analyze ON '.
'tx_nG6_analyze.uid=tx_nG6_project_analyze.analyze_id',
'WHERE' => 'tx_nG6_project_analyze.project_id='.$project_id,
'GROUPBY' => '',
'ORDERBY' => 'tx_nG6_analyze.name',
'LIMIT' => ''
);
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))
{
$analyze_id = $row['analyze_id'];
if (! isset ($results['analyse_'.$analyze_id]) )
{
$results['analyse_'.$analyze_id] = array(
'directory' => $row['analyze_directory'],
'name' => $row['analyze_name'],
'date' => $row['analyze_date'],
'description' => $row['analyse_description']
);
}
}
return $results;
}
function get_project_runs($project_id) {
$results = 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_project_run JOIN tx_nG6_run ON '.
'tx_nG6_run.uid=tx_nG6_project_run.run_id',
'WHERE' => 'tx_nG6_project_run.project_id='.$project_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]) )
{
$results['run_'.$run_id] = array(
'directory' => $row['run_directory'],
'name' => $row['run_name'],
'nb_sequences' => $row['nb_sequences'],
'date' => $row['run_date'],
'description' => $row['run_description']
);
}
}
return $results;
}
//Return archive's filepath.random_name
function createRandomArchiveName(){
$randomKey = $this->createRandomKey(10);
$pathname = $this->internal['temp_directory'].'/archiveNG6_'.$randomKey;
// 1 chance over 49**10 is still a risk
while( file_exists($pathname) )
$pathname = $this->internal['temp_directory'].'/archiveNG6_'.$randomKey;
return $pathname;
}
//Create a random string for a given length ($amount)
function createRandomKey($amount) {
// From http://snipplr.com/view/6347/php-random-key-generator/
$keyset = "abcdefghijklmABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$randkey = "";
for ($i=0; $i<$amount; $i++)
$randkey .= substr($keyset, rand(0, strlen($keyset)-1), 1);
return $randkey;
}
//Add a / to a directory pathname
function dirSlash($dir){
if (substr( $dir, -1) == "/")
return $dir;
return $dir."/";
}
/**
* Archivate data from $directories_src to an archive (structurated as $directories_dest)
*
* @param array $directories_src: list of directories to archivate
* @param array $directories_dest: list of directories to archivate
* @return string HTML link to the archive
*/
function archiveZip($directories_src , $directories_dest)
{
$dataDir = $this->internal['data'];
$zip = Array() ; //array of files
##Do an exhaustive list of files from the directories list
foreach($directories_src as $index => $dir_src)
{
$dir_src = $dataDir . $dir_src ;
$dir_dest = $directories_dest[$index];
//$zip = Array() ; //array of files
$subzip = $this->copyDirectoryAndList($dir_src, $dir_dest);
$zip = array_merge ( $zip , $subzip );
}
if( count($zip)==0 ){
return "\n\n".'No file to zip';
}
//TODO: chunk into small buffers (about 100MB)
//change cwd to the $this->internal['archive_root']
$normal_cwd = getcwd();
$this->internal['archive_root'] = $this->dirSlash($this->internal['archive_root']);
chdir(dirname($this->internal['archive_root']));
//write out zipped file
switch($this->internal["zip_option"])
{
case 'zip': //use zip.lib.php
foreach($zip as $key => $file){ #remove path above the archive
$zip[$key] = substr( $file, strlen("fileadmin/temp/") , strlen($file));
}
$outfile = basename($this->internal['archive_root']).'.zip';
## calls to zip.lib.php library
$ziper = new zipfile();
$ziper->addFiles($zip); //array of files
$ziper->output($outfile);
break;
case 'tar.gz': //system call
$archive_name = basename($this->internal['archive_root']);
$outfile = $archive_name.".tar";
system("tar -Pcf ".$outfile." ".$archive_name." --remove-files");
system("gzip ".$outfile);
$outfile .= '.gz';
system("rm -rf ".$archive_name);
break;
}
//restore cwd
chdir($normal_cwd);
unset($zip); //free memory //target="_blank"
return "\n\n".'<a id="download_link" href="'.$this->internal['temp_directory'].'/'.$outfile.'" > '.basename($outfile).'</a>';
}
/**
* Recursively copy the content of $dir_src into $dir_dest
*
* @param string $dir_src: name of the source directory
* @param string $dir_dest: name of the destination directory
* @return None
*/
function copyDirectoryAndList($dir_src, $dir_dest)
{
$zip = Array();
$dir_dest = $this->dirSlash($dir_dest);
$dir_src = $this->dirSlash($dir_src);
if (! file_exists($dir_src)) {
return $zip; //nothing to do
}
//Recursively build destination structure
if (! file_exists($dir_dest))
mkdir($dir_dest, 0755, true);
$iterator = new DirectoryIterator($dir_src);
foreach ($iterator as $fileinfo)
{
$filename = $fileinfo->getFilename() ;
$isNotRecursiveLink = ($filename!="." and $filename!="..") ;
$isNotCrap = ($isNotRecursiveLink and $filename!="index.html" and $filename!="run.cfg" );
if ($fileinfo->isDir() and $isNotCrap)
{ // get recursively subdirectories files
$dirpathname = $this->dirSlash($fileinfo->getPathname());
// then actualize the list of file to zip
$subzip = $this->copyDirectoryAndList( $dirpathname , $dir_dest.$fileinfo->getFilename() ) ;
$zip = array_merge ( $zip , $subzip );
}
elseif ($fileinfo->isFile() and $isNotCrap)
{ // copy file in new structure
$pathname_src = $fileinfo->getPathname();
$pathname_dest = $dir_dest . $fileinfo->getFilename();
copy( $pathname_src , $pathname_dest );
// add to zip
$zip[] = $pathname_dest;
}
}
return $zip; //Done
}
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/nG6/class.tx_nG6_eid.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/nG6/class.tx_nG6_eid.php']);
}
// instanciation
$SOBE = t3lib_div::makeInstance('tx_nG6_eid');
$SOBE->main();
?>
\ No newline at end of file
......@@ -38,7 +38,7 @@ $EM_CONF[$_EXTKEY] = array(
'suggests' => array(
),
),
'_md5_values_when_last_written' => 'a:24:{s:9:"ChangeLog";s:4:"f9b7";s:10:"README.txt";s:4:"9fa9";s:12:"ext_icon.gif";s:4:"1bdc";s:17:"ext_localconf.php";s:4:"7efc";s:14:"ext_tables.php";s:4:"e84d";s:14:"ext_tables.sql";s:4:"1b60";s:23:"icon_tx_nG6_analyze.gif";s:4:"475a";s:23:"icon_tx_nG6_project.gif";s:4:"475a";s:31:"icon_tx_nG6_project_analyze.gif";s:4:"475a";s:27:"icon_tx_nG6_project_run.gif";s:4:"475a";s:19:"icon_tx_nG6_run.gif";s:4:"475a";s:27:"icon_tx_nG6_run_analyze.gif";s:4:"475a";s:13:"locallang.xml";s:4:"a0c8";s:16:"locallang_db.xml";s:4:"2862";s:7:"tca.php";s:4:"4639";s:19:"doc/wizard_form.dat";s:4:"110b";s:20:"doc/wizard_form.html";s:4:"44cc";s:14:"pi1/ce_wiz.gif";s:4:"02b6";s:24:"pi1/class.tx_nG6_pi1.php";s:4:"e726";s:32:"pi1/class.tx_nG6_pi1_wizicon.php";s:4:"b2ac";s:13:"pi1/clear.gif";s:4:"cc11";s:17:"pi1/locallang.xml";s:4:"3bb2";s:24:"pi1/static/editorcfg.txt";s:4:"4730";s:20:"pi1/static/setup.txt";s:4:"7bca";s:14:"pi2/ce_wiz.gif";s:4:"02b6";s:24:"pi2/class.tx_nG6_pi2.php";s:4:"7164";s:32:"pi2/class.tx_nG6_pi2_wizicon.php";s:4:"ff00";s:13:"pi2/clear.gif";s:4:"cc11";s:17:"pi2/locallang.xml";s:4:"9216";s:24:"pi2/static/editorcfg.txt";s:4:"e404";s:14:"pi3/ce_wiz.gif";s:4:"02b6";s:24:"pi3/class.tx_nG6_pi3.php";s:4:"7164";s:32:"pi3/class.tx_nG6_pi3_wizicon.php";s:4:"ff00";s:13:"pi3/clear.gif";s:4:"cc11";s:17:"pi3/locallang.xml";s:4:"9216";s:24:"pi3/static/editorcfg.txt";s:4:"e404";s:14:"pi4/ce_wiz.gif";s:4:"02b6";s:24:"pi4/class.tx_nG6_pi4.php";s:4:"7164";s:32:"pi4/class.tx_nG6_pi4_wizicon.php";s:4:"ff00";s:13:"pi4/clear.gif";s:4:"cc11";s:17:"pi4/locallang.xml";s:4:"9216";s:24:"pi4/static/editorcfg.txt";s:4:"e404";}',
'_md5_values_when_last_written' => 'a:24:{s:9:"ChangeLog";s:4:"f9b7";s:10:"README.txt";s:4:"9fa9";s:12:"ext_icon.gif";s:4:"1bdc";s:31:"class.tx_nG6_eid.php";s:4:"bb99";s:17:"ext_localconf.php";s:4:"7efc";s:14:"ext_tables.php";s:4:"e84d";s:14:"ext_tables.sql";s:4:"1b60";s:23:"icon_tx_nG6_analyze.gif";s:4:"475a";s:23:"icon_tx_nG6_project.gif";s:4:"475a";s:31:"icon_tx_nG6_project_analyze.gif";s:4:"475a";s:27:"icon_tx_nG6_project_run.gif";s:4:"475a";s:19:"icon_tx_nG6_run.gif";s:4:"475a";s:27:"icon_tx_nG6_run_analyze.gif";s:4:"475a";s:13:"locallang.xml";s:4:"a0c8";s:16:"locallang_db.xml";s:4:"2862";s:7:"tca.php";s:4:"4639";s:19:"doc/wizard_form.dat";s:4:"110b";s:20:"doc/wizard_form.html";s:4:"44cc";s:14:"pi1/ce_wiz.gif";s:4:"02b6";s:24:"pi1/class.tx_nG6_pi1.php";s:4:"e726";s:32:"pi1/class.tx_nG6_pi1_wizicon.php";s:4:"b2ac";s:13:"pi1/clear.gif";s:4:"cc11";s:17:"pi1/locallang.xml";s:4:"3bb2";s:24:"pi1/static/editorcfg.txt";s:4:"4730";s:20:"pi1/static/setup.txt";s:4:"7bca";s:14:"pi2/ce_wiz.gif";s:4:"02b6";s:24:"pi2/class.tx_nG6_pi2.php";s:4:"7164";s:32:"pi2/class.tx_nG6_pi2_wizicon.php";s:4:"ff00";s:13:"pi2/clear.gif";s:4:"cc11";s:17:"pi2/locallang.xml";s:4:"9216";s:24:"pi2/static/editorcfg.txt";s:4:"e404";s:14:"pi3/ce_wiz.gif";s:4:"02b6";s:24:"pi3/class.tx_nG6_pi3.php";s:4:"7164";s:32:"pi3/class.tx_nG6_pi3_wizicon.php";s:4:"ff00";s:13:"pi3/clear.gif";s:4:"cc11";s:17:"pi3/locallang.xml";s:4:"9216";s:24:"pi3/static/editorcfg.txt";s:4:"e404";s:14:"pi4/ce_wiz.gif";s:4:"02b6";s:24:"pi4/class.tx_nG6_pi4.php";s:4:"7164";s:32:"pi4/class.tx_nG6_pi4_wizicon.php";s:4:"ff00";s:13:"pi4/clear.gif";s:4:"cc11";s:17:"pi4/locallang.xml";s:4:"9216";s:24:"pi4/static/editorcfg.txt";s:4:"e404";s:14:"pi5/ce_wiz.gif";s:4:"02b6";s:24:"pi5/class.tx_nG6_pi5.php";s:4:"7164";s:32:"pi5/class.tx_nG6_pi5_wizicon.php";s:4:"ff00";s:13:"pi5/clear.gif";s:4:"cc11";s:17:"pi5/locallang.xml";s:4:"9216";s:24:"pi5/static/editorcfg.txt";s:4:"e404";}',
);
?>
\ No newline at end of file
......@@ -33,4 +33,15 @@ t3lib_extMgm::addTypoScript($_EXTKEY,'editorcfg','
t3lib_extMgm::addPItoST43($_EXTKEY,'pi4/class.tx_nG6_pi4.php','_pi4','list_type',1);
## Extending TypoScript from static template uid=43 to set up userdefined tag:
t3lib_extMgm::addTypoScript($_EXTKEY,'editorcfg','
tt_content.CSS_editor.ch.tx_nG6_pi5 = < plugin.tx_nG6_pi5.CSS_editor
',43);
t3lib_extMgm::addPItoST43($_EXTKEY,'pi5/class.tx_nG6_pi5.php','_pi5','list_type',1);
## Added to do some ajax
$GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include']['tx_nG6'] = 'EXT:nG6/class.tx_nG6_eid.php';
?>
\ No newline at end of file
......@@ -159,4 +159,9 @@ t3lib_div::loadTCA('tt_content');
$TCA['tt_content']['types']['list']['subtypes_excludelist'][$_EXTKEY.'_pi4']='layout,select_key';
t3lib_extMgm::addPlugin(Array('LLL:EXT:nG6/locallang_db.xml:tt_content.list_type_pi4', $_EXTKEY.'_pi4'),'list_type');
if (TYPO3_MODE=="BE") $TBE_MODULES_EXT["xMOD_db_new_content_el"]["addElClasses"]["tx_nG6_pi4_wizicon"] = t3lib_extMgm::extPath($_EXTKEY).'pi4/class.tx_nG6_pi4_wizicon.php';
t3lib_div::loadTCA('tt_content');
$TCA['tt_content']['types']['list']['subtypes_excludelist'][$_EXTKEY.'_pi5']='layout,select_key';
t3lib_extMgm::addPlugin(Array('LLL:EXT:nG6/locallang_db.xml:tt_content.list_type_pi5', $_EXTKEY.'_pi5'),'list_type');
if (TYPO3_MODE=="BE") $TBE_MODULES_EXT["xMOD_db_new_content_el"]["addElClasses"]["tx_nG6_pi5_wizicon"] = t3lib_extMgm::extPath($_EXTKEY).'pi5/class.tx_nG6_pi5_wizicon.php';
?>
\ No newline at end of file
......@@ -4,11 +4,15 @@ plugin.tx_nG6_pi1 {
recursive =
view =
results_at_a_time = 20
data = /tools/typoweb/ng6/fileadmin
data = /var/www/typoweb/ng6/fileadmin
}
plugin.tx_nG6_pi2 {
result_page_id = 6
}
plugin.tx_nG6_pi3 {
redirection_page = 2
}
plugin.tx_nG6_pi5 {
temp_directory = /var/www/typoweb/ng6/fileadmin/temp
data = /var/www/typoweb/ng6/fileadmin
}
\ No newline at end of file
......@@ -14,6 +14,8 @@
<label index="pi3_plus_wiz_description">Adds nG6 search results to the page</label>
<label index="pi4_title">nG6 browser</label>
<label index="pi4_plus_wiz_description">Adds nG6 browser to the page</label>
<label index="pi5_title">nG6 downloader</label>
<label index="pi5_plus_wiz_description">Adds nG6 downloader to the page</label>
</languageKey>
<languageKey index="fr" type="array">
<label index="pi1_title">nG6</label>
......@@ -24,6 +26,8 @@
<label index="pi3_plus_wiz_description">Ajoute un resultat de recherche nG6 a la page</label>
<label index="pi4_title">navigateur nG6</label>
<label index="pi4_plus_wiz_description">Ajoute un navigateur nG6 a la page</label>
<label index="pi5_title">Centre de telechargement nG6</label>
<label index="pi5_plus_wiz_description">Ajoute un Centre de telechargement nG6 a la page</label>
</languageKey>
</data>
</T3locallang>
\ No newline at end of file
<?php
/***************************************************************
* Copyright notice
*
* (c) 2009 PF bioinformatique de Toulouse <>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Plugin 'nG6' for the 'nG6' extension.
*
* @author PF bioinformatique de Toulouse <>
*/
require_once(PATH_tslib.'class.tslib_pibase.php');
class tx_nG6_pi5 extends tslib_pibase {
var $prefixId = 'tx_nG6_pi5'; // Same as class name
var $scriptRelPath = 'pi5/class.tx_nG6_pi5.php'; // Path to this script relative to the extension dir.
var $extKey = 'nG6'; // The extension key.
//var $pi_checkCHash = TRUE;
/**
* Main method of your PlugIn
*
* @param string $content: The content of the PlugIn
* @param array $conf: The PlugIn Configuration
* @return The content that should be displayed on the website
*/
function main($content,$conf) {
if (strstr($this->cObj->currentRecord,'tt_content')) {
$conf['pidList'] = $this->cObj->data['pages'];
$conf['recursive'] = $this->cObj->data['recursive'];
}
$this->pi_loadLL();
$this->conf=$conf;
$this->pi_setPiVarDefaults();
$this->pi_USER_INT_obj=1;
return $this->pi_wrapInBaseClass($this->pi_form_view());
}
function pi_form_view () {
// add the jquery libs + the tree plugins and its css
$GLOBALS['TSFE']->additionalHeaderData[$this->prefixId] = '
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.cookie.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.hotkeys.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.jstree.min.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.ui.core.min.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.ui.dialog.min.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.ui.draggable.min.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.ui.resizable.min.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.bgiframe.min.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.url.packed.js"></script>
<link type="text/css" rel="stylesheet" media="screen" href="'.t3lib_extMgm::siteRelPath($this->extKey).'res/css/jquery.ui.core.css"/>
<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>';
$content .= '<script type="text/javascript" class="source">
$(function () {
$("#download_tree").jstree({
"themes" : {
"theme" : "default",
"dots" : false,
"icons" : false
},
"html_data" : {
"data" : $("#html_tree").attr("value"),
"ajax" : {
"url" : "index.php?eID=tx_nG6",
"data" : function (n) {
return { id : n.attr("id").split("_")[1] , type : n.attr("id").split("_")[0]};
}
}
},
"plugins" : [ "themes", "html_data", "ui", "checkbox" ]
});
$("#download_dialog").dialog({
autoOpen: false,
bgiframe: true,
resizable: false,
position: "center",
modal: true,
overlay: {
backgroundColor: "#000",
opacity: 0.5
}
});
$("#download_btn").click(function(){
var url_val = "index.php?eID=tx_nG6&type=download&values=";
$(".jstree-checked > ul > .jstree-checked, .jstree-undetermined > ul > .jstree-checked").each(function(){
url_val += $(this).attr("name")+";";
});
$("#download_dialog").dialog("option", "title", "Telechargement ...");
$("#download_dialog").html(\'<img src="fileadmin/templates/nG6template/images/light_wait.gif"/>\').dialog("open");
$.ajax({
url: "",
success: function(val) {
$("#download_dialog").html(val).dialog("open");
}
});
});
});
</script> ';
// Build the lists of all elements */
$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="';
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>';
}
$content .= $html_tree.'" />';
$content .= '<input class="tx-nG6-pi5-download" id="download_btn" type="button" value="Telecharger" />';
return $content;
}
function get_project_list() {
$results = array();
// If the user is not logged on display demonstration project
if (!$GLOBALS['TSFE']->loginUser) {
$where = 'fe_group=0';
} else {
$where = 'fe_group IN ('.$this->getCurrentUserGroups().')';
}
//First, get the analyzis project-scale
$queryParts = array(
'SELECT' => 'tx_nG6_project.uid AS project_id, '.
'tx_nG6_project.name AS project_name, '.
'tx_nG6_project.description AS project_description',
'FROM' => 'tx_nG6_project',
'WHERE' => $where,
'GROUPBY' => '',
'ORDERBY' => '',
'LIMIT' => ''
);
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))
{
$project_id = $row['project_id'];
$analyze_id = $row['analyze_id'];
$analyze_content = array(
'directory' => $row['directory'],
'name' => $row['analyze_name'],
'date' => $row['analyze_date'],
'description' => $row['analyse_description']
);
if (! isset ($results['project_'.$project_id]) ) //new project
{
$results['project_'.$project_id] = array(
'id' => $project_id,
'name' => $row['project_name'],
'description' => $row['project_description'],
'contents' => Array() );
}
//then add content
$results['project_'.$project_id]['contents']['analyze'.$analyze_id] = $analyze_content;
}
return $results;
}
/**
* Returns the content of a given field
*
* @param string $fN: name of table field
* @return Value of the field
*/
function getFieldContent($fN, $mergeArr=array()) {
switch($fN) {
case 'uid':
return $this->pi_list_linkSingle($this->internal['currentRow'][$fN],$this->internal['currentRow']['uid'],1, $mergeArr);
// The "1" means that the display of single items is CACHED! Set to zero to disable caching.
break;
case 'name':
return $this->pi_list_linkSingle($this->internal['currentRow'][$fN],$this->internal['currentRow']['uid'],1, $mergeArr);
// The "1" means that the display of single items is CACHED! Set to zero to disable caching.
break;
case 'date':
// %A %e. %B %Y
return strftime('%d-%m-%y',$this->internal['currentRow']['date']);
break;
default:
return $this->internal['currentRow'][$fN];
break;
}
}
/**
* Returns the label for a fieldname from local language array
*
* @param [type] $fN: ...
* @return [type] ...
*/