Newer
Older
<?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');
require_once(t3lib_extMgm::extPath('nG6').'/lib/class.tx_nG6_db.php');
require_once(t3lib_extMgm::extPath('nG6').'/lib/class.tx_nG6_utils.php');
require_once(t3lib_extMgm::extPath('nG6').'/lib/class.tx_nG6_upgrade.php');
require_once(t3lib_extMgm::extPath('nG6').'/res/smarty/libs/Smarty.class.php');
var $prefixId = 'tx_nG6_pi1'; // Same as class name
var $scriptRelPath = 'pi1/class.tx_nG6_pi1.php'; // Path to this script relative to the extension dir.
var $extKey = 'nG6'; // The extension key.
/**
* 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'];
}
// Setting the TypoScript passed to this function in $this->conf
$this->conf=$conf;
// Configuring so caching is not expected. This value means that no cHash params are ever set. We do this, because it's a USER_INT object!
$this->pi_USER_INT_obj=1;
// Loading the LOCAL_LANG values
$GLOBALS['TSFE']->additionalHeaderData[$this->prefixId] = '
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/bootstrap.min.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/bootstrap-editable.min.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/bootstrap-datepicker.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/bootstrap-typeahead.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/DT_bootstrap.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.validate.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jflow-activewf.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jflow-availablewf.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jflow-wfform.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jflow-wfstatus.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.tmpl.min.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/tx_nG6_pi1.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/tx_nG6_utils.js"></script>
<script type="text/javascript" src="typo3/md5.js"></script>
<link type="text/css" rel="stylesheet" media="screen" href="'.t3lib_extMgm::siteRelPath($this->extKey).'res/css/jflow.css"/>
<link type="text/css" rel="stylesheet" media="screen" href="'.t3lib_extMgm::siteRelPath($this->extKey).'res/css/bootstrap.min.css"/>
<link type="text/css" rel="stylesheet" media="screen" href="'.t3lib_extMgm::siteRelPath($this->extKey).'res/css/bootstrap-responsive.min.css"/>
<link type="text/css" rel="stylesheet" media="screen" href="'.t3lib_extMgm::siteRelPath($this->extKey).'res/css/DT_bootstrap.css"/>
<link type="text/css" rel="stylesheet" media="screen" href="'.t3lib_extMgm::siteRelPath($this->extKey).'res/css/bootstrap-editable.css"/>
<link type="text/css" rel="stylesheet" media="screen" href="'.t3lib_extMgm::siteRelPath($this->extKey).'res/css/datepicker.css"/>
<link type="text/css" rel="stylesheet" media="screen" href="'.t3lib_extMgm::siteRelPath($this->extKey).'res/css/tx_nG6.css"/>';
tx_nG6_db::check_db_rights_level();
if($this->piVars['upgrade']){
$content = tx_nG6_upgrade::upgrade($this->piVars['upgrade']);
}
else if(! $this->pi_is_install_finalized()) {
$content .= $this->pi_install_view();
}
else {
switch((string)$this->conf['view']) {
// If the plugin is configured to display results by run
case 'run':
if ($this->piVars['analyze_id']) {
$content .= $this->pi_analyze_view();
} else {
$content .= $this->pi_run_view();
}
break;
// If the plugin is not configured, display by project is default
default:
if ($this->piVars['analyze_id']) {
$content .= $this->pi_analyze_view();
} elseif ($this->piVars['project_id'] && $this->piVars['run_id']) {
$content .= $this->pi_run_view();
} else {
$content .= $this->pi_project_view();
}
if (!$GLOBALS['TSFE']->loginUser) { $user_id = null; }
else { $user_id = $GLOBALS['TSFE']->fe_user->user['uid']; }
// If a single element
if ($this->piVars['project_id']) {
if (tx_nG6_db::user_is_authorized($user_id, $this->piVars['project_id'], $this->piVars['run_id'])) {
$projects = array('project_'.$this->piVars['project_id'] => tx_nG6_db::select_project($this->piVars['project_id']));
}
$projects = tx_nG6_db::select_all_user_projects($user_id, 'tx_nG6_project.name');
// If there is no project the user can access
if (count($projects) > 0) {
$smarty = new Smarty();
$smarty->setTemplateDir(t3lib_extMgm::extPath('nG6').'/pi1');
$smarty->setCompileDir(t3lib_extMgm::extPath('nG6').'/res/smarty/templates_c');
$smarty->setCacheDir(t3lib_extMgm::extPath('nG6').'/res/smarty/cache');
$smarty->setConfigDir(t3lib_extMgm::extPath('nG6').'/res/smarty/configs');
$smarty->security = true;
$smarty->security_settings['MODIFIER_FUNCS'] = array('count');
$project_ids = "";
foreach($projects as $project_id => $project_values) {
// project admin ?
$projects[$project_id]['is_admin'] = tx_nG6_db::is_project_administrator($GLOBALS['TSFE']->fe_user->user['uid'], $project_values['id']);
// project manager ?
$projects[$project_id]['is_manager'] = tx_nG6_db::is_project_manager($GLOBALS['TSFE']->fe_user->user['uid'], $project_values['id']);
// project member ?
$projects[$project_id]['is_member'] = tx_nG6_db::is_project_member($GLOBALS['TSFE']->fe_user->user['uid'], $project_values['id']);
$project_ids .= $project_values['id'].",";
$projects[$project_id]['href'] = $this->pi_list_linkSingle($project_values['name'],$project_values['id'],1, array('project_id'=>$project_values['id']));
$smarty->assign('projects', $projects);
$smarty->assign('login_user', $GLOBALS['TSFE']->loginUser);
$smarty->assign('user_id', $GLOBALS['TSFE']->fe_user->user['uid']);
$smarty->assign('user_login', $GLOBALS['TSFE']->fe_user->user['username']);
$smarty->assign('data_folder', $this->conf["data"]);
$smarty->assign('from_email', $this->conf["FromEmail"]);
$smarty->assign('server_name', $this->conf["server_name"]);
$smarty->assign('project_ids', substr($project_ids,0,-1));
$smarty->assign('pid', $this->conf['userpidList']);
$smarty->assign('server_url', $this->conf['server_url']);
// If it's a single project, add runs and analysis information
if (count($projects) == 1) {
// Get all users on project
$project_users = tx_nG6_db::get_all_users_on_project($projects[key($projects)]['id']);
$smarty->assign('project_users', $project_users);
// Add some information to the table
$project_runs = tx_nG6_db::get_project_runs($projects[key($projects)]['id']);
foreach($project_runs as $run_id => $run_values) {
$project_runs[$run_id]['is_admin'] = tx_nG6_db::is_administrator($GLOBALS['TSFE']->fe_user->user['uid'], 'run', $run_values['id']);
$project_runs[$run_id]['href'] = $this->pi_list_linkSingle($run_values['name'],$run_values['id'],1, array('run_id'=>$run_values['id'], 'project_id'=>$run_values['project_id']));
}
$smarty->assign('project_runs', $project_runs);
$project_analysis = tx_nG6_db::get_project_analysis($projects[key($projects)]['id']);
// Add some information to the table
foreach($project_analysis as $analysis_id => $analysis_values) {
$project_analysis[$analysis_id]['is_admin'] = tx_nG6_db::is_administrator($GLOBALS['TSFE']->fe_user->user['uid'], 'analyze', $analysis_values['id']);
$project_analysis[$analysis_id]['href'] = $this->pi_list_linkSingle($analysis_values['name'],$analysis_values['id'],1, array('analyze_id'=>$analysis_values['id'], 'project_id'=>$this->piVars['project_id']));
}
$smarty->assign('h_analysis', tx_nG6_utils::trace_hierarchy($project_analysis));
$smarty->assign('project_analysis', $project_analysis);
}
return $smarty->fetch('project_view.tpl');
} else {
return "<div class='alert alert-error'><b>Access denied</b> - You are not authorized to access this page.</div>";
if (!$GLOBALS['TSFE']->loginUser) { $user_id = null; }
else { $user_id = $GLOBALS['TSFE']->fe_user->user['uid']; }
// If a single element
if ($this->piVars['run_id']) {
if (tx_nG6_db::user_is_authorized($user_id, $this->piVars['project_id'], $this->piVars['run_id'])) {
$runs = array('run_'.$this->piVars['run_id'] => tx_nG6_db::select_run($this->piVars['run_id']));
}
if (count($runs) > 0) {
$smarty = new Smarty();
$smarty->setTemplateDir(t3lib_extMgm::extPath('nG6').'/pi1');
$smarty->setCompileDir(t3lib_extMgm::extPath('nG6').'/res/smarty/templates_c');
$smarty->setCacheDir(t3lib_extMgm::extPath('nG6').'/res/smarty/cache');
$smarty->setConfigDir(t3lib_extMgm::extPath('nG6').'/res/smarty/configs');
$smarty->security = true;
$smarty->security_settings['MODIFIER_FUNCS'] = array('count');
$run_ids = "";
foreach($runs as $run_id => $run_values) {
if (tx_nG6_db::is_administrator($user_id, 'run', $run_values['id']) ) {
$runs[$run_id]['is_admin'] = true;
} else {
$runs[$run_id]['is_admin'] = false;
}
$run_ids .= $run_values['id'].",";
$runs[$run_id]['href'] = $this->pi_list_linkSingle($run_values['name'],$run_values['id'],1, array('run_id'=>$run_values['id'], 'project_id'=>$run_values['project_id']));
$runs[$run_id]['href'] = $this->pi_list_linkSingle($run_values['name'],$run_values['id'],1, array('run_id'=>$run_values['id']));
$smarty->assign('runs', $runs);
$smarty->assign('login_user', $GLOBALS['TSFE']->loginUser);
$smarty->assign('user_id', $GLOBALS['TSFE']->fe_user->user['uid']);
$smarty->assign('data_folder', $this->conf["data"]);
$smarty->assign('server_name', $this->conf["server_name"]);
$smarty->assign('server_url', $this->conf['server_url']);
$smarty->assign('run_ids', substr($run_ids,0,-1));
// If it's a single run, add analysis information
if (count($runs) == 1) {
$run_analysis = tx_nG6_db::get_run_analysis($runs[key($runs)]['id']);
// Add some information to the table
foreach($run_analysis as $analysis_id => $analysis_values) {
$run_analysis[$analysis_id]['is_admin'] = tx_nG6_db::is_administrator($GLOBALS['TSFE']->fe_user->user['uid'], 'analyze', $analysis_values['id']);
if ($this->piVars['project_id']) {
$run_analysis[$analysis_id]['href'] = $this->pi_list_linkSingle($analysis_values['name'],$analysis_values['id'],1, array('analyze_id'=>$analysis_values['id'], 'project_id'=>$this->piVars['project_id'], 'run_id'=>$this->piVars['run_id']));
} else {
$run_analysis[$analysis_id]['href'] = $this->pi_list_linkSingle($analysis_values['name'],$analysis_values['id'],1, array('analyze_id'=>$analysis_values['id'], 'run_id'=>$this->piVars['run_id']));
}
}
$smarty->assign('h_analysis', tx_nG6_utils::trace_hierarchy($run_analysis));
$smarty->assign('run_analysis', $run_analysis);
}
return $smarty->fetch('run_view.tpl');
} else {
return "<div class='alert alert-error'><b>Access denied</b> - You are not authorized to access this page.</div>";
// First select the analyse
$analyse = tx_nG6_db::select_analyse($this->piVars['analyze_id']);
// Handle old fashion
if (file_exists($this->conf['data'].$analyse['directory'].'/index.html' )) {
// Add the analyse description
$content = '<div id="img_dialog" title=""></div>';
$content .= '<input type="hidden" id="analyse_name" value="'.$analyse['name'].'" />';
$content .= '<div'.$this->pi_classParam('singleView').'>';
$content .= '<h2>Analyse '.$analyse['name'].' : <span>'.$analyse['description'].'</span></h2></div>';
$fp = fopen((string)$this->conf['data'].$analyse['directory'].'/index.html',"r");
while (!feof($fp)) {
$content .= fgets($fp, 4096);
// Else meaning using smarty
$smarty = new Smarty();
$smarty->setTemplateDir(t3lib_extMgm::extPath('nG6').'/pi1/analyzes');
$smarty->setCompileDir(t3lib_extMgm::extPath('nG6').'/res/smarty/templates_c');
$smarty->setCacheDir(t3lib_extMgm::extPath('nG6').'/res/smarty/cache');
$smarty->setConfigDir(t3lib_extMgm::extPath('nG6').'/res/smarty/configs');
$smarty->security = true;
$smarty->security_settings['MODIFIER_FUNCS'] = array('count');
$smarty->assign('analyse', $analyse);
Jerome Mariette
committed
$analysis_size = tx_nG6_db::get_analysis_size($this->piVars['analyze_id'], $this->conf['data']);
$smarty->assign('analyse_size', tx_nG6_utils::get_octet_string_representation($analysis_size));
// Then select analyse results
$results = tx_nG6_db::select_analyse_results($this->piVars['analyze_id']);
$smarty->assign('analyse_results', $results);
// Select the run file description
if ($analyse['run_id'] != 'None') {
$descriptions = tx_nG6_db::select_mid_descriptions($analyse['run_id']);
} else {
$descriptions = array();
}
$smarty->assign('descriptions', $descriptions);
$smarty->assign('data_folder', $this->conf['data']);
// Try to process the analyse template
try {
if (file_exists(t3lib_extMgm::extPath($this->extKey).'pi1/analyzes/'.$analyse['class'].'.js')) {
$GLOBALS['TSFE']->additionalHeaderData[$this->prefixId] .= '
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'pi1/analyzes/'.$analyse['class'].'.js"></script>';
$GLOBALS['TSFE']->additionalHeaderData[$this->prefixId] .= '
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/tx_nG6_pi1_analysis.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.venny.min.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.highcharts.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.highcharts.exporting.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.highcharts.more.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.highcharts.exportcsv.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jsphylosvg-min.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/raphael-min.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/unitip.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.jstree.min.js"></script>
<link type="text/css" rel="stylesheet" media="screen" href="'.t3lib_extMgm::siteRelPath($this->extKey).'res/css/unitip.css"/>';
return $smarty->fetch($analyse['class'].'.tpl');
} catch (Exception $e) {
return 'No template found for class ' . $analyse['class'];
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
/**
* Return the install view
*/
function pi_install_view() {
$smarty = new Smarty();
$smarty->setTemplateDir(t3lib_extMgm::extPath('nG6').'/pi1');
$smarty->setCompileDir(t3lib_extMgm::extPath('nG6').'/res/smarty/templates_c');
$smarty->setCacheDir(t3lib_extMgm::extPath('nG6').'/res/smarty/cache');
$smarty->setConfigDir(t3lib_extMgm::extPath('nG6').'/res/smarty/configs');
$smarty->security = true;
$smarty->security_settings['MODIFIER_FUNCS'] = array('count');
$smarty->assign('server_name', $this->conf["server_name"]);
$smarty->assign('server_url', $this->conf['server_url']);
$smarty->assign('pid', $this->conf['userpidList']);
return $smarty->fetch('install_view.tpl');
}
/**
* Does installation need is finalized ( admin_install user exist in db )
*
* @param integer Alternative page ID for the link. (By default this function links to the SAME page!)
* @return boolean If true, intallation allready finalysed
*/
function pi_is_install_finalized() {
$res = tx_nG6_db::select_user_by_username("admin_install");
if ($res == null){
return true;
}
else
{
return false;
}
}
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
/**
* Overloading of the tslib_pibase->pi_list_linkSingle function so piVars[showUid] is not set.
* Uses pi_linkTP for the linking
*
* @param string The content string to wrap in <a> tags
* @param integer UID of the record for which to display details (basically this will become the value of [showUid]
* @param boolean See pi_linkTP_keepPIvars
* @param array Array of values to override in the current piVars. Same as $overrulePIvars in pi_linkTP_keepPIvars
* @param boolean If true, only the URL is returned, not a full link
* @param integer Alternative page ID for the link. (By default this function links to the SAME page!)
* @return string The input string wrapped in <a> tags
* @see pi_linkTP(), pi_linkTP_keepPIvars()
*/
function pi_list_linkSingle($str,$uid,$cache=FALSE,$mergeArr=array(),$urlOnly=FALSE,$altPageId=0) {
if ($this->prefixId) {
if ($cache) {
$overrulePIvars=(array)$mergeArr;
$str = $this->pi_linkTP($str,Array($this->prefixId=>$overrulePIvars),$cache,$altPageId);
} else {
$overrulePIvars=(array)$mergeArr;
$str = $this->pi_linkTP_keepPIvars($str,$overrulePIvars,$cache,0,$altPageId);
}
// If urlOnly flag, return only URL as it has recently be generated.
if ($urlOnly) {
$str = $this->cObj->lastTypoLinkUrl;
}
}
return $str;
}
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/nG6/pi1/class.tx_nG6_pi1.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/nG6/pi1/class.tx_nG6_pi1.php']);
}