Commit 715b4aa7 authored by Jerome Mariette's avatar Jerome Mariette
Browse files

make plugin1 uses smarty

parent 5dacf808
......@@ -112,7 +112,13 @@ class tx_nG6_db {
'LIMIT' => ''
);
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
return $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
$vals = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
return array('id' => $vals['uid'],
'name' => $vals['name'],
'hidden' => $vals['hidden'],
'public' => $vals['public'],
'group' => $vals['fe_group'],
'description' => $vals['description']);
}
/**
......@@ -476,6 +482,7 @@ class tx_nG6_db {
'tx_nG6_run.sequencer AS run_sequencer, '.
'tx_nG6_run.type AS run_type, '.
'tx_nG6_run.full_seq_size, '.
'tx_nG6_run.hidden AS run_hidden, '.
'tx_nG6_run.nb_sequences, '.
'tx_nG6_run.date AS run_date',
'FROM' => 'tx_nG6_project INNER JOIN ( tx_nG6_project_run INNER JOIN tx_nG6_run ON tx_nG6_project_run.run_id=tx_nG6_run.uid '.
......@@ -490,17 +497,19 @@ class tx_nG6_db {
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$result = array(
'id' => $row['run_id'],
'project_id' => $row['project_id'],
'project_name' => $row['project_name'],
'directory' => $row['run_directory'],
'name' => $row['run_name'],
'type' => $row['run_type'],
'sequencer' => $row['run_sequencer'],
'data_nature' => $row['run_data_nature'],
'full_seq_size' => $row['full_seq_size'],
'hidden' => $row['run_hidden'],
'species' => $row['run_species'],
'nb_sequences' => $row['nb_sequences'],
'full_seq_size' => $row['full_seq_size'],
'date' => $row['run_date'],
'data_nature' => $row['run_data_nature'],
'sequencer' => $row['run_sequencer'],
'type' => $row['run_type'],
'description' => $row['run_description']
);
}
......@@ -1167,7 +1176,7 @@ class tx_nG6_db {
} else {
$is_super_user = in_array($user_group, preg_split("/,/", $effective_supergroups));
}
return $is_super_user;
}
}
......
......@@ -59,7 +59,7 @@ class tx_nG6_pi1 extends tslib_pibase {
$this->pi_USER_INT_obj=1;
// Loading the LOCAL_LANG values
$this->pi_loadLL();
// Add the ng6 plugins css
$GLOBALS['TSFE']->additionalHeaderData[$this->prefixId] = '
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.js"></script>
......@@ -74,43 +74,6 @@ class tx_nG6_pi1 extends tslib_pibase {
<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"/>';
$content .= '<div id="user_information_dialog" title=""></div>';
$content .= '<div id="error_dialog" title=""></div>';
$content .= '<input type="hidden" id="cancel_btn_label" value="'.$this->pi_getLL('cancel_btn_label', '[cancel_btn_label]').'" />';
$content .= '<input type="hidden" id="ok_btn_label" value="'.$this->pi_getLL('ok_btn_label', '[ok_btn_label]').'" />';
$content .= '<input type="hidden" id="yes_btn_label" value="'.$this->pi_getLL('yes_btn_label', '[yes_btn_label]').'" />';
$content .= '<input type="hidden" id="no_btn_label" value="'.$this->pi_getLL('no_btn_label', '[no_btn_label]').'" />';
$content .= '<input type="hidden" id="confirmation_dialog_title" value="'.$this->pi_getLL('confirmation_dialog_title', '[confirmation_dialog_title]').'" />';
$content .= '<input type="hidden" id="information_error_title" value="'.$this->pi_getLL('information_error_title', '[information_error_title]').'" />';
$content .= '<input type="hidden" id="hide_dialog_title" value="'.$this->pi_getLL('hide_dialog_title', '[hide_dialog_title]').'" />';
$content .= '<input type="hidden" id="hide_confirmation_msg" value="'.$this->pi_getLL('hide_confirmation_msg', '[hide_confirmation_msg]').'" />';
$content .= '<input type="hidden" id="unhide_dialog_title" value="'.$this->pi_getLL('unhide_dialog_title', '[unhide_dialog_title]').'" />';
$content .= '<input type="hidden" id="unhide_confirmation_msg" value="'.$this->pi_getLL('unhide_confirmation_msg', '[unhide_confirmation_msg]').'" />';
$content .= '<input type="hidden" id="information_error_msg" value="'.$this->pi_getLL('information_error_msg', '[information_error_msg]').'" />';
$content .= '<input type="hidden" id="information_dialog_zero_check" value="'.$this->pi_getLL('information_dialog_zero_check', '[information_dialog_zero_check]').'" />';
$content .= '<input type="hidden" id="delete_confirmation_msg" value="'.$this->pi_getLL('delete_confirmation_msg', '[delete_confirmation_msg]').'" />';
$content .= '<input type="hidden" id="deleting_dialog_msg" value="'.$this->pi_getLL('deleting_dialog_msg', '[deleting_dialog_msg]').'" />';
$content .= '<input type="hidden" id="delete_authentication_dialog_msg" value="'.str_replace(array('###SPAN_SERVER###'), array($this->conf["server_name"]), $this->pi_getLL('delete_authentication_dialog_msg', '[delete_authentication_dialog_msg]')).'" />';
$content .= '<input type="hidden" id="user_login" value="'.$this->pi_getLL('user_login', '[user_login]').'" />';
$content .= '<input type="hidden" id="user_pwd" value="'.$this->pi_getLL('user_pwd', '[user_pwd]').'" />';
$content .= '<input type="hidden" id="user_group" value="'.$GLOBALS['TSFE']->fe_user->user['usergroup'].'" />';
$content .= '<input type="hidden" id="deleting_dialog_title" value="'.$this->pi_getLL('deleting_dialog_title', '[deleting_dialog_title]').'" />';
$content .= '<input type="hidden" id="delete_success_msg" value="'.$this->pi_getLL('delete_success_msg', '[delete_success_msg]').'" />';
$content .= '<input type="hidden" id="delete_dialog_rigth_error" value="'.$this->pi_getLL('delete_dialog_rigth_error', '[delete_dialog_rigth_error]').'" />';
$content .= '<input type="hidden" id="delete_dialog_authentification_error" value="'.$this->pi_getLL('delete_dialog_authentification_error', '[delete_dialog_authentification_error]').'" />';
$content .= '<input type="hidden" id="delete_dialog_connection_error" value="'.$this->pi_getLL('delete_dialog_connection_error', '[delete_dialog_connection_error]').'" />';
$content .= '<input type="hidden" id="publish_dialog_title" value="'.$this->pi_getLL('publish_dialog_title', '[publish_dialog_title]').'" />';
$content .= '<input type="hidden" id="publish_confirmation_msg" value="'.$this->pi_getLL('publish_confirmation_msg', '[publish_confirmation_msg]').'" />';
$content .= '<input type="hidden" id="unpublish_dialog_title" value="'.$this->pi_getLL('unpublish_dialog_title', '[unpublish_dialog_title]').'" />';
$content .= '<input type="hidden" id="unpublish_confirmation_msg" value="'.$this->pi_getLL('unpublish_confirmation_msg', '[unpublish_confirmation_msg]').'" />';
$content .= '<input type="hidden" id="data_folder" value="'.$this->conf["data"].'" />';
// If the user is authorized to access the specified project/run, display the page
if (tx_nG6_db::user_is_authorized($GLOBALS['TSFE']->fe_user->user['usergroup'], $this->piVars['project_id'], $this->piVars['run_id'])) {
......@@ -118,7 +81,7 @@ class tx_nG6_pi1 extends tslib_pibase {
// If the plugin is configured to display results by project
case 'project':
if ($this->piVars['analyze_id']) {
$content .= $this->pi_analyze_view('analyze');
$content .= $this->pi_analyze_view();
} elseif ($this->piVars['project_id'] && $this->piVars['run_id']) {
$content .= $this->pi_run_view();
}elseif ($this->piVars['project_id'] && $this->piVars['summary']) {
......@@ -130,7 +93,7 @@ class tx_nG6_pi1 extends tslib_pibase {
// If the plugin is configured to display results by run
case 'run':
if ($this->piVars['analyze_id']) {
$content .= $this->pi_analyze_view('analyze');
$content .= $this->pi_analyze_view();
} else {
$content .= $this->pi_run_view();
}
......@@ -157,465 +120,150 @@ class tx_nG6_pi1 extends tslib_pibase {
$content = "Le projet ".$this->piVars['project_id']." contient ".count($project_runs)." runs.";
return $content;
}
/**
* Shows a list of database entries
*
* @return HTML list of table entries
* Return the project view
*/
function pi_project_view() {
// If a single element should be displayed
if ($this->piVars['project_id']) {
return $this->pi_project_single_view($this->piVars['project_id']);
// If multiple projects
$projects = array();
// If a single element
if ($this->piVars['project_id']) {
$projects = array('project_'.$this->piVars['project_id'] => tx_nG6_db::select_project($this->piVars['project_id']));
} else {
// If the user is on a specific page
if (isset($this->piVars['project_page'])) {
$current_page = intval($this->internal['results_at_a_time']) * (intval($this->piVars['project_page']) -1);
$limit = "$current_page".",". $this->internal['results_at_a_time'] ;
} else $limit = '0,'.$this->internal['results_at_a_time'] ;
// Select all user projects
$projects = tx_nG6_db::select_all_user_projects($GLOBALS['TSFE']->fe_user->user['usergroup'], 'tx_nG6_project.name', $limit);
$all_projects = tx_nG6_db::select_all_user_projects($GLOBALS['TSFE']->fe_user->user['usergroup']);
// If there is at least one result
if (count($projects) > 0) {
$project_list = $this->pi_project_list_view($projects);
$nav_links = $this->pi_navigation_link_view('project_page', $this->piVars['project_page'], count($all_projects));
return $project_list.$nav_links;
// If there is no results to display
} else {
return $this->pi_getLL('no_raw','[no_raw]');
}
$projects = tx_nG6_db::select_all_user_projects($GLOBALS['TSFE']->fe_user->user['usergroup'], 'tx_nG6_project.name');
}
}
$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');
/**
* Creates a list from a database query
*
* @param ressource $res: A database result ressource
* @return A HTML list if result items
*/
function pi_project_list_view($projects) {
// First add the table header
$is_super_user = false;
// Add some information to the table
foreach($projects as $project_id => $project_values) {
if ($GLOBALS['TSFE']->loginUser && tx_nG6_db::is_super_user($GLOBALS['TSFE']->fe_user->user['usergroup'], 'project', $project_values['id']) ) {
$is_super_user = true;
if (tx_nG6_db::is_super_user($GLOBALS['TSFE']->fe_user->user['usergroup'], 'project', $project_values['id']) ) {
$projects[$project_id]['superuser'] = true;
} else {
$projects[$project_id]['superuser'] = false;
}
$projects[$project_id]['href'] = $this->pi_list_linkSingle($project_values['name'],$project_values['id'],1, array('project_id'=>$project_values['id']));
}
$content = '<table'.$this->pi_classParam('listrow').'><tr>';
if ($is_super_user) {
$content .= '<th><center><input type="checkbox" id="chk_all_project"></center></th>';
}
$content .= '<th>'.$this->pi_getLL('project_name','[project_name]').'</th>
<th>'.$this->pi_getLL('description','[description]').'</th>
</tr>';
// Then the row for each project
foreach($projects as $project_id => $project_values) {
// If it's not a hidden project
$hidden = $this->pi_classParam('hidden');
if ($project_values['hidden'] == 0) { $hidden = ''; }
// If it's not a public project
$public = '';
if ($GLOBALS['TSFE']->loginUser && $project_values['public'] == 0) { $public = $this->pi_classParam('public'); }
$content .= '<tr '.$public.'>';
$smarty->assign('projects', $projects);
$smarty->assign('login_user', $GLOBALS['TSFE']->loginUser);
$smarty->assign('user_group', $GLOBALS['TSFE']->fe_user->user['usergroup']);
$smarty->assign('data_folder', $this->conf["data"]);
$smarty->assign('server_name', $this->conf["server_name"]);
// If it's a single project, add runs and analysis information
if (count($projects) == 1) {
// projects updates possibility depends on projects rights (show checkboxes or not)
if ( $GLOBALS['TSFE']->loginUser && tx_nG6_db::is_super_user($GLOBALS['TSFE']->fe_user->user['usergroup'], 'project', $project_values['id']) ) {
$content .= '<td '.$hidden.'><center><input type="checkbox" id="chk_project_'.$project_values['id'].'" value="project_'.$project_values['id'].'"></center></td>';
$project_runs = tx_nG6_db::get_project_runs($GLOBALS['TSFE']->fe_user->user['usergroup'], $projects[key($projects)]['id']);
// Add some information to the table
foreach($project_runs as $run_id => $run_values) {
if (tx_nG6_db::is_super_user($GLOBALS['TSFE']->fe_user->user['usergroup'], 'run', $run_values['id']) ) {
$project_runs[$run_id]['superuser'] = true;
} else {
$project_runs[$run_id]['superuser'] = false;
}
$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']));
}
$content .= '<td '.$hidden.' >'.$this->pi_list_linkSingle($project_values['name'],$project_values['id'],1, array('project_id'=>$project_values['id'])).'</td>
<td '.$hidden.' >'.$project_values['description'].'</td>
</tr>';
}
$content .= '</table>';
// option toolbar
if ($is_super_user) {
$content .= '<div '.$this->pi_classParam('div-option-menu').'> '.$this->pi_getLL('toolbar_title','[toolbar_title]') .
'<button id="hide_project" type="button" class="btn pill-l"><span><span>'.$this->pi_getLL('hide_btn','[hide_btn]').'</span></span></button>' .
'<button id="unhide_project" type="button" class="btn pill-r"><span><span>'.$this->pi_getLL('unhide_btn','[unhide_btn]').'</span></span></button>' .
'&nbsp;<button id="delete_project" type="button" class="btn"><span><span>'.$this->pi_getLL('delete_btn','[delete_btn]').'</span></span></button>&nbsp;' .
'<button id="publish_project" type="button" class="btn pill-l"><span><span>'.$this->pi_getLL('publish_btn','[publish_btn]').'</span></span></button>' .
'<button id="unpublish_project" type="button" class="btn pill-r"><span><span>'.$this->pi_getLL('unpublish_btn','[unpublish_btn]').'</span></span></button>' .
'</div>';
$smarty->assign('project_runs', $project_runs);
$project_analysis = tx_nG6_db::get_project_analysis($GLOBALS['TSFE']->fe_user->user['usergroup'], $projects[key($projects)]['id']);
// Add some information to the table
foreach($project_analysis as $analysis_id => $analysis_values) {
if (tx_nG6_db::is_super_user($GLOBALS['TSFE']->fe_user->user['usergroup'], 'analyze', $analysis_values['id']) ) {
$project_analysis[$analysis_id]['superuser'] = true;
} else {
$project_analysis[$analysis_id]['superuser'] = false;
}
$project_analysis[$analysis_id]['href'] = $this->pi_list_linkSingle($analysis_values['name'],$analysis_values['id'],1, array('analyze_id'=>$analysis_values['id'], 'project_id'=>$projects[key($projects)]['uid']));
}
$smarty->assign('project_analysis', $project_analysis);
}
return $content;
}
if (isset($this->LOCAL_LANG[$this->LLkey]) && count($this->LOCAL_LANG[$this->LLkey]) > 0) {
$smarty->assign('llang', $this->LOCAL_LANG[$this->LLkey]);
} else {
$smarty->assign('llang', $this->LOCAL_LANG['default']);
}
return $smarty->fetch('project_view.tpl');
/**
* Display a single project
*
* @param string $project_id the project id
* @return HTML of a single project entry
*/
function pi_project_single_view($project_id) {
// First select the project values
$project = tx_nG6_db::select_project($project_id);
// Add the project description
$content = '<div'.$this->pi_classParam('singleView').'>
<h2>Projet '.$project['name'].' :</h2>
<p><strong>'.$project['description'].'</strong></p></div>';
// The project runs view
$content .= '<br /> <h3> '.$this->pi_getLL('runs_done','[runs_done]').'</h3> <br />';
$content .= $this->pi_run_view();
// And the analyses performed on the project
$content .= $this->pi_analyze_view('project');
return $content;
}
/**
* Shows a list of database entries
*
* @return HTML list of table entries
* Return the run view
*/
function pi_run_view() {
// If a single element should be displayed
if ($this->piVars['run_id']) {
return $this->pi_run_single_view($this->piVars['run_id']);
// If multiple runs
} else {
// If the user is on a specific page
if (isset($this->piVars['run_page'])) {
$current_page = intval($this->internal['results_at_a_time']) * (intval($this->piVars['run_page']) -1);
$limit = "$current_page".",". $this->internal['results_at_a_time'] ;
} else $limit = '0,'.$this->internal['results_at_a_time'] ;
// Select all runs from this project
if ($this->piVars['project_id']) {
$runs = tx_nG6_db::get_project_runs($GLOBALS['TSFE']->fe_user->user['usergroup'], $this->piVars['project_id'], 'tx_nG6_run.date DESC, tx_nG6_run.name ASC', $limit);
$all_runs = tx_nG6_db::get_project_runs($GLOBALS['TSFE']->fe_user->user['usergroup'], $this->piVars['project_id']);
// If no project defined, select all runs owned by the user
} else {
$runs = tx_nG6_db::select_all_user_runs($GLOBALS['TSFE']->fe_user->user['usergroup'], 'tx_nG6_run.date DESC, tx_nG6_run.name ASC', $limit);
$all_runs = tx_nG6_db::select_all_user_runs($GLOBALS['TSFE']->fe_user->user['usergroup']);
}
// If there is some results to display
if (count($runs) > 0) {
$run_list = $this->pi_run_list_view($runs);
$nav_links = $this->pi_navigation_link_view('run_page', $this->piVars['run_page'], count($all_runs));
return $run_list ."\n". $nav_links;
// If there is no results
} else {
return $this->pi_getLL('no_raw','[no_raw]');
}
$runs = array();
// If a single element
if ($this->piVars['run_id']) {
$runs = array('run_'.$this->piVars['run_id'] => tx_nG6_db::select_run($this->piVars['run_id']));
} else {
$runs = tx_nG6_db::select_all_user_runs($GLOBALS['TSFE']->fe_user->user['usergroup']);
}
}
$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');
/**
* Creates a list from a database query
*
* @param ressource $res: A database result ressource
* @return A HTML list if result items
*/
function pi_run_list_view($runs) {
// First add the table header
$is_super_user = false;
// Add some information to the table
foreach($runs as $run_id => $run_values) {
if ( $GLOBALS['TSFE']->loginUser && tx_nG6_db::is_super_user($GLOBALS['TSFE']->fe_user->user['usergroup'], 'run', $run_values['id']) ) {
$is_super_user = true;
if (tx_nG6_db::is_super_user($GLOBALS['TSFE']->fe_user->user['usergroup'], 'run', $run_values['id']) ) {
$runs[$run_id]['superuser'] = true;
} else {
$runs[$run_id]['superuser'] = false;
}
}
$content = '<table'.$this->pi_classParam('listrow').'><tr>';
if ($is_super_user) {
$content .= '<th><center><input type="checkbox" id="chk_all_run"></center></th>';
}
$content .= '<th>'.$this->pi_getLL('run_name','[run_name]').'</th>
<th>'.$this->pi_getLL('project_name','[project_name]').'</th>
<th>'.$this->pi_getLL('date','[date]').'</th>
<th>'.$this->pi_getLL('species','[species]').'</th>
<th>'.$this->pi_getLL('data_nature','[data_nature]').'</th>
<th>'.$this->pi_getLL('type','[type]').'</th>
<th>'.$this->pi_getLL('nb_sequences','[nb_sequences]').'</th>
<th>'.$this->pi_getLL('full_seq_size','[full_seq_size]').'</th>
<th>'.$this->pi_getLL('description','[description]').'</th>
<th>'.$this->pi_getLL('sequencer','[sequencer]').'</th>
</tr>';
// Then the row for each run
foreach($runs as $run_id => $run_values) {
// If the run is hidden
$hidden = $this->pi_classParam('hidden');
if ($run_values['hidden'] == 0) { $hidden = ''; }
// Add the row information
$content .= '<tr>';
// runs updates possibility depends on runs rights (show checkboxes or not)
if ( $GLOBALS['TSFE']->loginUser && tx_nG6_db::is_super_user($GLOBALS['TSFE']->fe_user->user['usergroup'], 'run', $run_values['id']) ) {
$content .= '<td '.$hidden.' ><center><input type="checkbox" id="chk_run_'.$run_values["id"].'" value="run_'.$run_values["id"].'"></center></td>';
if ($this->piVars['project_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']));
} else {
$runs[$run_id]['href'] = $this->pi_list_linkSingle($run_values['name'],$run_values['id'],1, array('run_id'=>$run_values['id']));
}
$content .='<td '.$hidden.' >'.$this->pi_list_linkSingle($run_values['name'],$run_id,1, array('run_id'=>$run_values['id'], 'project_id'=>$run_values['project_id'])).'</td>
<td '.$hidden.' >'.$run_values['project_name'].'</td>
<td '.$hidden.' >'.strftime('%d-%m-%y',$run_values['date']).'</td>
<td '.$hidden.' >'.$run_values['species'].'</td>
<td '.$hidden.' >'.$run_values['data_nature'].'</td>
<td '.$hidden.' >'.$run_values['type'].'</td>
<td '.$hidden.' >'.number_format($run_values['nb_sequences'], 0, ',', ' ').'</td>
<td '.$hidden.' >'.number_format($run_values['full_seq_size'], 0, ',', ' ').'</td>
<td '.$hidden.' >'.$run_values['description'].'</td>
<td '.$hidden.' >'.$run_values['sequencer'].'</td>
</tr>';
}
// Return the html table
$content .= '</table>' ;
if ($is_super_user) {
// option toolbar
$content .= '<div '.$this->pi_classParam('div-option-menu').'> '.$this->pi_getLL('toolbar_title','[toolbar_title]') .
'<button id="hide_run" type="button" class="btn pill-l"><span><span>'.$this->pi_getLL('hide_btn','[hide_btn]').'</span></span></button>' .
'<button id="unhide_run" type="button" class="btn pill-r"><span><span>'.$this->pi_getLL('unhide_btn','[unhide_btn]').'</span></span></button>' .
'&nbsp;<button id="delete_run" type="button" class="btn"><span><span>'.$this->pi_getLL('delete_btn','[delete_btn]').'</span></span></button>' .
'</div>';
}
return $content;
}
/**
* Display a single item from the database
*
* @param ressource $res: A database result ressource
* @return HTML of a single database entry
*/
function pi_run_single_view($run_id) {
// First select the run
$run = tx_nG6_db::select_run($run_id);
// Add the run description to the page content
$content = '<div'.$this->pi_classParam('singleView').'>';
$content .= '<h2>Run '.$run['name'].' :</h2>';
$content .= '<p><strong>'.$run['description'].'</strong></p> </div>
<table'.$this->pi_classParam('listrow').'>
<tr>
<th align="left">'.$this->pi_getLL('project_name','[project_name]').' :</th>
<td align="left">'.$run['project_name'].'</td>
</tr>
<tr>
<th align="left">'.$this->pi_getLL('date','[date]').' :</th>
<td align="left">'.strftime('%d-%m-%y',$run['date']).'</td>
</tr>
<tr>
<th align="left">'.$this->pi_getLL('species','[species]').' :</th>
<td align="left">'.$run['species'].'</td>
</tr>
<tr>
<th align="left">'.$this->pi_getLL('type','[type]').' :</th>
<td align="left">'.$run['type'].'</td>
</tr>
<tr>
<th align="left">'.$this->pi_getLL('data_nature','[data_nature]').' :</th>
<td align="left">'.$run['data_nature'].'</td>
</tr>
<tr>
<th align="left">'.$this->pi_getLL('nb_sequences','[nb_sequences]').' :</th>
<td align="left">'.number_format($run['nb_sequences'], 0, ',', ' ').'</td>
</tr>
<tr>
<th align="left">'.$this->pi_getLL('full_seq_size','[full_seq_size]').' :</th>
<td align="left">'.number_format($run['full_seq_size'], 0, ',', ' ').'</td>
</tr>
<tr>
<th align="left">'.$this->pi_getLL('sequencer','[sequencer]').' :</th>
<td align="left">'.$run['sequencer'].'</td>
</tr>
<tr>
<th align="left">'.$this->pi_getLL('downloads','[downloads]').' :</th>
<td align="left">'.$this->get_downloads_list($run['directory']).'</td>
</tr>
</table>';
// Add the run analysis
$content .= $this->pi_analyze_view('run');
$smarty->assign('runs', $runs);
$smarty->assign('first_id', key($runs));
$smarty->assign('login_user', $GLOBALS['TSFE']->loginUser);
$smarty->assign('user_group', $GLOBALS['TSFE']->fe_user->user['usergroup']);
$smarty->assign('data_folder', $this->conf["data"]);
$smarty->assign('server_name', $this->conf["server_name"]);
// Return the run HTML page
return $content;
}
/**
* Display a list of downloadable file
*
* @return HTML of a list of downlabale links
*/
function get_downloads_list($run_directory) {
$directory = (string)$this->conf['data'].$run_directory;
// Try to look at all files in the specified directory
try {
if (!is_dir($directory)) { throw new Exception('Error when attempting to open the data folder !'); }
$my_directory = opendir($directory) or die('Error when attempting to open the data folder !');
$download = '<p '.$this->pi_classParam('downloads').'><ul>';
// For every files
while($entry = @readdir($my_directory)) {
if(!is_dir($directory.'/'.$entry)&& $entry != '.' && $entry != '..' && !tx_nG6_utils::ends_with($entry, ".cfg")) {
$link = 'fileadmin/'.$run_directory.'/'.$entry;
$download .= '<li><a href="'.$link.'" target="_blank">'.$entry.'</a></li>';
// If it's a single run, add analysis information
if (count($runs) == 1) {
$run_analysis = tx_nG6_db::get_run_analysis($GLOBALS['TSFE']->fe_user->user['usergroup'], $runs[key($runs)]['id']);
// Add some information to the table
foreach($run_analysis as $analysis_id => $analysis_values) {
if (tx_nG6_db::is_super_user($GLOBALS['TSFE']->fe_user->user['usergroup'], 'analyze', $analysis_values['id']) ) {
$run_analysis[$analysis_id]['superuser'] = true;
} else {
$run_analysis[$analysis_id]['superuser'] = false;
}
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']));
}
}
$download .= '</ul>';
closedir($my_directory);
return $download;
$smarty->assign('run_analysis', $run_analysis);
}
catch (Exception $e) {
return $this->pi_getLL('not_synchro','[not_synchro]');
}
}
/**
* Shows a list of database entries
*
* @param string $type: What kind of analyze is it : run or project
* * @return HTML list of table entries
*/
function pi_analyze_view($type) {
// If a single element should be displayed:
if ($type == 'analyze') {
return $this->pi_analyze_single_view($this->piVars['analyze_id']);
// If multiple analyses
if (isset($this->LOCAL_LANG[$this->LLkey]) && count($this->LOCAL_LANG[$this->LLkey]) > 0) {
$smarty->assign('llang', $this->LOCAL_LANG[$this->LLkey]);
} else {
// If the user is on a specific page
if (isset($this->piVars['analyze_page'])) {
$current_page = intval($this->internal[<