Commit b79cb8cd authored by Jerome Mariette's avatar Jerome Mariette
Browse files

code cleaning

parent 7f7aa4dd
......@@ -52,14 +52,14 @@ class tx_nG6_eid {
if ($type == 'project') {
$project_id = trim(t3lib_div::_GP('id'));
// Select all runs linked to the project
$project_runs = tx_nG6_db::get_project_runs($user_group, $project_id);
$project_runs = tx_nG6_db::get_project_runs($user_group, $project_id, 'tx_nG6_run.date DESC');
// for each run
$html_tree = '';
foreach($project_runs as $run_id => $run_values) {
$html_tree .= '<li class="jstree-closed" name=\''.str_replace(array('###SPAN_NAME###', '###SPAN_DATE###'), array($run_values["name"], strftime('%d-%m-%y',$run_values["date"])), trim(t3lib_div::_GP('run_short_description'))).'\' id=\''.$run_id.'\'> <a href=\'#\'>'.str_replace(array('###SPAN_NAME###', '###SPAN_DATE###', '###SPAN_NB_SEQ###', '###SPAN_SPECIES###'), array($run_values["name"], strftime('%d-%m-%y',$run_values["date"]), $run_values["nb_sequences"], $run_values["species"]), trim(t3lib_div::_GP('run_description'))).'</a></li>';
$html_tree .= '<li class="jstree-closed" name=\''.str_replace(array('###SPAN_NAME###', '###SPAN_DATE###'), array($run_values['name'], strftime('%d-%m-%y',$run_values['date'])), trim(t3lib_div::_GP('run_short_description'))).'\' id=\''.$run_id.'\'> <a href=\'#\'>'.str_replace(array('###SPAN_NAME###', '###SPAN_DATE###', '###SPAN_NB_SEQ###', '###SPAN_SPECIES###'), array($run_values['name'], strftime('%d-%m-%y',$run_values['date']), $run_values['nb_sequences'], $run_values['species']), trim(t3lib_div::_GP('run_description'))).'</a></li>';
}
// Then all project analysis
$project_analysis = tx_nG6_db::get_project_analysis($user_group, $project_id);
$project_analysis = tx_nG6_db::get_project_analysis($user_group, $project_id, 'tx_nG6_analyze.name');
foreach($project_analysis as $analyse_id => $analyse_values) {
$html_tree .= '<li name=\''.str_replace(array('###SPAN_NAME###'), array($analyse_values["name"]), trim(t3lib_div::_GP('analyse_description'))).'\' id=\''.$analyse_id.'\'> <a href=\'#\'>'.str_replace(array('###SPAN_NAME###'), array($analyse_values["name"]), trim(t3lib_div::_GP('analyse_description'))).'</a></li>';
}
......@@ -70,8 +70,8 @@ class tx_nG6_eid {
} else if ($type == 'run'){
$run_id = trim(t3lib_div::_GP('id'));
// Select all analysis linked to the run and the run information
$run_analysis = tx_nG6_db::get_run_analysis($user_group, $run_id);
$run_info = tx_nG6_db::get_run($run_id);
$run_analysis = tx_nG6_db::get_run_analysis($user_group, $run_id, 'tx_nG6_analyze.name');
$run_info = tx_nG6_db::select_run($run_id);
// for each analysis
$html_tree = '';
$html_tree .= '<li name=\'run_'.$run_id.'_'.trim(t3lib_div::_GP("raw_data_description")).'\' id=\'data_'.$run_id.'\'> <a href=\'#\'>'.trim(t3lib_div::_GP("raw_data_description")).'</a></li>';
......@@ -263,7 +263,7 @@ class tx_nG6_eid {
if ($val != "undefined" && $val != "") {
$id = preg_split("/_/", $val);
if ($id[0] == "data") {
$run = tx_nG6_db::get_run($id[1]);
$run = tx_nG6_db::select_run($id[1]);
if (!in_array($data_folder.$run["directory"], $src_directories)) {
$src_directories[] = $data_folder.$run["directory"];
$ddest = $output_folder."/Project_".str_replace($char_to_replace, '_', $run["project_name"]);
......@@ -271,14 +271,14 @@ class tx_nG6_eid {
$dest_directories[] = $ddest;
}
} else if ($id[0] == "run") {
$run = tx_nG6_db::get_run($id[1]);
$run = tx_nG6_db::select_run($id[1]);
if (!in_array($data_folder.$run["directory"], $src_directories)) {
$src_directories[] = $data_folder.$run["directory"];
$ddest = $output_folder."/Project_".str_replace($char_to_replace, '_', $run["project_name"]);
$ddest .= '.'.$run["project_id"]."/Run_".str_replace($char_to_replace, '_', $run["name"]).".".$id[1]."/RawData";
$dest_directories[] = $ddest;
}
foreach(tx_nG6_db::get_run_analysis($user_group, $id[1]) as $analyse_id => $analyse_values) {
foreach(tx_nG6_db::get_run_analysis($user_group, $id[1], 'tx_nG6_analyze.name') as $analyse_id => $analyse_values) {
$aid = preg_split("/_/", $analyse_id);
if (!in_array($data_folder.$analyse_values["directory"], $src_directories)) {
$src_directories[] = $data_folder.$analyse_values["directory"];
......@@ -289,7 +289,7 @@ class tx_nG6_eid {
}
}
} else if ($id[0] == "analyse") {
$analyse = tx_nG6_db::get_analyse($id[1]);
$analyse = tx_nG6_db::select_analyse($id[1]);
if (!in_array($data_folder.$analyse["directory"], $src_directories)) {
$src_directories[] = $data_folder.$analyse["directory"];
// If it's a project analyse
......
......@@ -42,7 +42,7 @@ class tx_nG6_db {
* @param string $user_group the user group
* @return table with all projects
*/
function select_all_user_projects($user_group) {
function select_all_user_projects($user_group, $orderby='', $limit='') {
$projects = array();
// If the user is not logged on display demonstration project
......@@ -61,8 +61,8 @@ class tx_nG6_db {
'FROM' => 'tx_nG6_project',
'WHERE' => $where,
'GROUPBY' => '',
'ORDERBY' => '',
'LIMIT' => ''
'ORDERBY' => $orderby,
'LIMIT' => $limit
);
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
$user_groups = t3lib_div::intExplode(',',tx_nG6_db::get_user_groups($user_group));
......@@ -85,6 +85,7 @@ class tx_nG6_db {
$projects['project_'.$project_id] = array(
'id' => $project_id,
'name' => $row['project_name'],
'hidden' => $row['project_hidden'],
'description' => $row['project_description']);
}
......@@ -118,24 +119,30 @@ class tx_nG6_db {
* @param string $project_id the project id
* @return hash table with all runs information
*/
function get_project_runs($user_group, $project_id) {
function get_project_runs($user_group, $project_id, $orderby='', $limit='') {
// First select all runs from the database
$queryParts = Array(
'SELECT' => 'tx_nG6_run.uid AS run_id,'.
'tx_nG6_run.directory AS run_directory,'.
'tx_nG6_run.species AS run_species,'.
'tx_nG6_run.description AS run_description, '.
'tx_nG6_run.data_nature AS run_data_nature, '.
'tx_nG6_run.sequencer AS run_sequencer, '.
'tx_nG6_run.type AS run_type, '.
'tx_nG6_run.name AS run_name, '.
'tx_nG6_run.nb_sequences, '.
'tx_nG6_project.uid AS project_id, '.
'tx_nG6_run.nb_sequences AS run_nb_sequences, '.
'tx_nG6_run.full_seq_size AS run_full_seq_size, '.
'tx_nG6_run.date AS run_date, '.
'tx_nG6_run.hidden AS run_hidden, '.
'tx_nG6_project.name AS project_name, '.
'tx_nG6_project.fe_group AS project_fe_group',
'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 '.
' ) ON tx_nG6_project.uid=tx_nG6_project_run.project_id',
'WHERE' => 'tx_nG6_project.uid='.$project_id,
'GROUPBY' => '',
'ORDERBY' => 'tx_nG6_run.date DESC',
'LIMIT' => ''
'ORDERBY' => $orderby,
'LIMIT' => $limit
);
// Then create the result hash table
$results = array();
......@@ -158,11 +165,20 @@ class tx_nG6_db {
if (!isset($results['run_'.$run_id]) and $user_allowed) {
$results['run_'.$run_id] = array(
'id' => $run_id,
'directory' => $row['run_directory'],
'name' => $row['run_name'],
'project_name' => $row['project_name'],
'fe_group' => $row['project_fe_group'],
'hidden' => $row['run_hidden'],
'species' => $row['run_species'],
'nb_sequences' => $row['nb_sequences'],
'nb_sequences' => $row['run_nb_sequences'],
'full_seq_size' => $row['run_full_seq_size'],
'project_id' => $row['project_id'],
'date' => $row['run_date'],
'data_nature' => $row['run_data_nature'],
'sequencer' => $row['run_sequencer'],
'type' => $row['run_type'],
'description' => $row['run_description']
);
}
......@@ -177,13 +193,15 @@ class tx_nG6_db {
* @param string $project_id the project id
* @return hash table with all analysis information
*/
function get_project_analysis($user_group, $project_id) {
function get_project_analysis($user_group, $project_id, $orderby, $limit) {
// First select all analysis from the database
$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.software AS analyze_software, '.
'tx_nG6_analyze.version AS analyze_version, '.
'tx_nG6_analyze.description AS analyze_description, '.
'tx_nG6_analyze.hidden AS analyze_hidden, '.
'tx_nG6_project.fe_group AS project_fe_group',
......@@ -191,8 +209,8 @@ class tx_nG6_db {
'tx_nG6_analyze.uid=tx_nG6_project_analyze.analyze_id) ON tx_nG6_project.uid = tx_nG6_project_analyze.project_id ',
'WHERE' => 'tx_nG6_project_analyze.project_id='.$project_id,
'GROUPBY' => '',
'ORDERBY' => 'tx_nG6_analyze.name',
'LIMIT' => ''
'ORDERBY' => $orderby,
'LIMIT' => $limit
);
// Then create the result hash table
$results = array();
......@@ -217,8 +235,12 @@ class tx_nG6_db {
$results['analyse_'.$analyze_id] = array(
'directory' => $row['analyze_directory'],
'name' => $row['analyze_name'],
'id' => $row['analyze_id'],
'hidden' => $row['analyze_hidden'],
'software' => $row['analyze_software'],
'version' => $row['analyze_version'],
'date' => $row['analyze_date'],
'description' => $row['analyse_description']
'description' => $row['analyze_description']
);
}
}
......@@ -230,13 +252,94 @@ class tx_nG6_db {
* Run functions
*------------------------------------------------------------*/
/**
* Select all run for the specified user
*
* @param string $user_group the user group
* @return table with all projects
*/
function select_all_user_runs($user_group, $orderby='', $limit='') {
// If the user is not logged on display demonstration project
if (!$GLOBALS['TSFE']->loginUser) {
$where = 'fe_group=0';
} else {
$where = 'fe_group IN ('.tx_nG6_db::get_user_groups($user_group).')';
}
// Execute the request
$queryParts = Array(
'SELECT' => 'tx_nG6_run.uid AS run_id,'.
'tx_nG6_run.directory AS run_directory,'.
'tx_nG6_run.species AS run_species,'.
'tx_nG6_run.description AS run_description, '.
'tx_nG6_run.data_nature AS run_data_nature, '.
'tx_nG6_run.sequencer AS run_sequencer, '.
'tx_nG6_run.type AS run_type, '.
'tx_nG6_run.name AS run_name, '.
'tx_nG6_run.nb_sequences AS run_nb_sequences, '.
'tx_nG6_run.full_seq_size AS run_full_seq_size, '.
'tx_nG6_run.date AS run_date, '.
'tx_nG6_run.hidden AS run_hidden, '.
'tx_nG6_project.uid AS project_id, '.
'tx_nG6_project.name AS project_name, '.
'tx_nG6_project.fe_group AS project_fe_group',
'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 '.
' ) ON tx_nG6_project.uid=tx_nG6_project_run.project_id',
'WHERE' => $where,
'GROUPBY' => '',
'ORDERBY' => $orderby,
'LIMIT' => $limit
);
// Then create the result hash table
$results = array();
$user_groups = t3lib_div::intExplode(',',tx_nG6_db::get_user_groups($user_group));
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$run_id = $row['run_id'];
// Is the user allowed to see this run
$user_allowed = false;
if ($row['run_hidden'] == 0) {
$user_allowed = true;
} else {
foreach(tx_nG6_db::get_super_groups_of($row['project_fe_group']) AS $valeur) {
if (in_array($valeur, $user_groups)) {
$user_allowed = true;
}
}
}
if (!isset($results['run_'.$run_id]) and $user_allowed) {
$results['run_'.$run_id] = array(
'id' => $run_id,
'directory' => $row['run_directory'],
'name' => $row['run_name'],
'project_name' => $row['project_name'],
'fe_group' => $row['project_fe_group'],
'project_id' => $row['project_id'],
'hidden' => $row['run_hidden'],
'species' => $row['run_species'],
'nb_sequences' => $row['run_nb_sequences'],
'full_seq_size' => $row['run_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']
);
}
}
return $results;
}
/**
* Select all information for the specified run
*
* @param string $run_id the run id
* @return hash table with all the run information
*/
function get_run($run_id) {
function select_run($run_id) {
// First select the run from the database
......@@ -246,7 +349,12 @@ class tx_nG6_db {
'tx_nG6_run.uid AS run_id,'.
'tx_nG6_run.directory AS run_directory,'.
'tx_nG6_run.description AS run_description, '.
'tx_nG6_run.species AS run_species, '.
'tx_nG6_run.name AS run_name, '.
'tx_nG6_run.data_nature AS run_data_nature, '.
'tx_nG6_run.sequencer AS run_sequencer, '.
'tx_nG6_run.type AS run_type, '.
'tx_nG6_run.full_seq_size, '.
'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 '.
......@@ -260,19 +368,21 @@ class tx_nG6_db {
$result = array();
$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(
'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'],
'species' => $row['run_species'],
'nb_sequences' => $row['nb_sequences'],
'date' => $row['run_date'],
'description' => $row['run_description']
);
}
}
return $result;
}
......@@ -283,13 +393,15 @@ class tx_nG6_db {
* @param string $run_id the run id
* @return hash table with all analysis information
*/
function get_run_analysis($user_group, $run_id) {
function get_run_analysis($user_group, $run_id, $orderby='', $limit='') {
// First select all analysis from the database
$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.software AS analyze_software, '.
'tx_nG6_analyze.version AS analyze_version, '.
'tx_nG6_analyze.hidden AS analyze_hidden, '.
'tx_nG6_analyze.description AS analyze_description, '.
'tx_nG6_project.fe_group AS project_fe_group',
......@@ -298,8 +410,8 @@ class tx_nG6_db {
') 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_run_analyze.run_id='.$run_id,
'GROUPBY' => '',
'ORDERBY' => 'tx_nG6_analyze.name',
'LIMIT' => ''
'ORDERBY' => $orderby,
'LIMIT' => $limit
);
// Then create the result hash table
$results = array();
......@@ -324,8 +436,12 @@ class tx_nG6_db {
$results['analyse_'.$analyze_id] = array(
'directory' => $row['analyze_directory'],
'name' => $row['analyze_name'],
'id' => $row['analyze_id'],
'hidden' => $row['analyze_hidden'],
'software' => $row['analyze_software'],
'version' => $row['analyze_version'],
'date' => $row['analyze_date'],
'description' => $row['analyse_description']
'description' => $row['analyze_description']
);
}
}
......@@ -343,7 +459,7 @@ class tx_nG6_db {
* @param string $analyse_id the analyse id
* @return hash table with all analyse information
*/
function get_analyse($analyse_id) {
function select_analyse($analyse_id) {
// First select all analyse information
$queryParts = array(
......
......@@ -49,15 +49,20 @@ class tx_nG6_pi1 extends tslib_pibase {
if (strstr($this->cObj->currentRecord,'tt_content')) {
$conf['pidList'] = $this->cObj->data['pages'];
}
$this->conf=$conf; // Setting the TypoScript passed to this function in $this->conf
// Setting the TypoScript passed to this function in $this->conf
$this->conf=$conf;
$this->internal['results_at_a_time'] = $conf["results_at_a_time"];
$this->pi_setPiVarDefaults();
$this->pi_USER_INT_obj=1; // 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_loadLL(); // Loading the LOCAL_LANG values
// 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
$this->pi_loadLL();
// 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'])) {
switch((string)$this->conf['view']) {
// If the plugin is configured to display results by project
case 'project':
if ($this->piVars['analyze_id']) {
return $this->pi_wrapInBaseClass($this->pi_analyze_view('analyze'));
......@@ -69,6 +74,7 @@ class tx_nG6_pi1 extends tslib_pibase {
return $this->pi_wrapInBaseClass($this->pi_project_view());
}
break;
// If the plugin is configured to display results by run
case 'run':
if ($this->piVars['analyze_id']) {
return $this->pi_wrapInBaseClass($this->pi_analyze_view('analyze'));
......@@ -76,38 +82,25 @@ class tx_nG6_pi1 extends tslib_pibase {
return $this->pi_wrapInBaseClass($this->pi_run_view());
}
break;
// If the plugin is not configured, display by project is default
default:
return $this->pi_wrapInBaseClass($this->pi_project_view());
break;
}
// If the user is not authorized
} else {
return $this->pi_wrapInBaseClass($this->getFieldHeader('not_authorized'));
return $this->pi_wrapInBaseClass($this->pi_getLL('not_authorized','[not_authorized]'));
}
}
/**
* Shows the summary and statistics for a project
*
* TODELETE
* @return HTML list of table entries
*/
function pi_project_summary() {
$queryParts = array(
'SELECT' => 'tx_nG6_run.uid AS run_id, tx_nG6_run.name AS name, tx_nG6_project.name AS project_name,' .
'tx_nG6_run.date AS date, tx_nG6_run.species AS run_species, tx_nG6_run.data_nature AS run_data_nature,' .
'tx_nG6_run.type AS run_type, tx_nG6_run.nb_sequences AS run_nb_sequences, tx_nG6_run.full_seq_size AS run_full_seq_size,' .
'tx_nG6_run.description AS run_description, tx_nG6_run.sequencer AS run_sequencer,' .
'tx_nG6_run.directory AS run_directory, tx_nG6_run.hidden AS run_hidden, tx_nG6_project.name AS project_name,' .
'tx_nG6_project.fe_group AS project_fe_group',
'FROM' => 'tx_nG6_run INNER JOIN (tx_nG6_project_run INNER JOIN tx_nG6_project ON tx_nG6_project_run.project_id=tx_nG6_project.uid)' .
'ON tx_nG6_run.uid=tx_nG6_project_run.run_id',
'WHERE' => 'tx_nG6_project.uid = '.$this->piVars['project_id'],
'GROUPBY' => '',
'ORDERBY' => '',
'LIMIT' => ''
);
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
$content = "Le projet ".$this->piVars['project_id']." contient " . $GLOBALS['TYPO3_DB']->sql_num_rows($res) . " runs.";
$project_runs = tx_nG6_db::get_project_runs($GLOBALS['TSFE']->fe_user->user['usergroup'], $this->piVars['project_id']);
$content = "Le projet ".$this->piVars['project_id']." contient ".count($project_runs)." runs.";
return $content;
}
......@@ -118,56 +111,34 @@ class tx_nG6_pi1 extends tslib_pibase {
*/
function pi_project_view() {
if ($this->piVars['project_id']) { // If a single element should be displayed
// If a single element should be displayed
if ($this->piVars['project_id']) {
$this->internal['currentRow'] = tx_nG6_db::select_project($this->piVars['project_id']);
return $this->pi_project_single_view();
return $this->pi_project_single_view($this->piVars['project_id']);
// If multiple projects
} else {
if (isset($this->piVars['project_page'])) //project position
{
// 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'] ;
} 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 the user is not logged on display demonstration project
if (!$GLOBALS['TSFE']->loginUser) {
$where = 'fe_group=0';
} else {
$where = 'fe_group IN ('.tx_nG6_db::get_user_groups($GLOBALS['TSFE']->fe_user->user['usergroup']).')';
}
$queryParts = array(
'SELECT' => '*',
'FROM' => 'tx_nG6_project',
'WHERE' => $where,
'GROUPBY' => '',
'ORDERBY' => 'tx_nG6_project.name',
'LIMIT' => $limit
);
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
// If there is at least one result
if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) {
//request total in DB
$queryPartsc = array(
'SELECT' => $queryParts['SELECT'],
'FROM' => $queryParts['FROM'],
'WHERE' => $queryParts['WHERE'],
'GROUPBY' => '',
'ORDERBY' => $queryParts['ORDERBY'],
'LIMIT' => ''
);
$resc = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryPartsc);
$total_count = $GLOBALS['TYPO3_DB']->sql_num_rows($resc);
//generate HTML
$project_list= $this->pi_project_list_view($res);
$nav_links = $this->pi_navigation_link_view('project_page', $this->piVars['project_page'], $total_count);
return $project_list ."\n". $nav_links;
} else { // If no results
return $this->getFieldHeader('no_raw');
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]');
}
}
}
......@@ -178,56 +149,52 @@ class tx_nG6_pi1 extends tslib_pibase {
* @param ressource $res: A database result ressource
* @return A HTML list if result items
*/
function pi_project_list_view($res) {
$nb_project = 0;
function pi_project_list_view($projects) {
// First add the table header
$content = '<table'.$this->pi_classParam('listrow').'>
<tr>
<th>'.$this->getFieldHeader('project_name').'</th>
<th>'.$this->getFieldHeader('description').'</th>
<th>'.$this->pi_getLL('project_name','[project_name]').'</th>
<th>'.$this->pi_getLL('description','[description]').'</th>
</tr>';
while($this->internal['currentRow'] = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
if ($this->internal['currentRow']['hidden'] == 0) { // If it's not a hidden project
$content .= '<tr>
<td>'.$this->getFieldContent('name', array('project_id'=>$this->internal['currentRow']['uid'])).'</td>
<td>'.$this->getFieldContent('description').'</td>
</tr>';
$nb_project++;
} else {
$user_groups = t3lib_div::intExplode(',',tx_nG6_db::get_user_groups($GLOBALS['TSFE']->fe_user->user['usergroup']));
$user_allowed = false;
foreach(tx_nG6_db::get_super_groups_of($this->internal['currentRow']['fe_group']) AS $valeur) {
if (in_array($valeur, $user_groups)) {
$user_allowed = true;
$nb_project++;
}
}
if ($user_allowed) {
// 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 = ''; }
$content .= '<tr>
<td '.$this->pi_classParam('hidden').' >'.$this->getFieldContent('name', array('project_id'=>$this->internal['currentRow']['uid'])).'</td>
<td '.$this->pi_classParam('hidden').' >'.$this->getFieldContent('description').'</td>
<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>';
}
}
}
if ($nb_project > 0) {
// Return the whole table
return $content .= '</table>';
} else {
return $this->getFieldHeader('no_raw');
}
}
/**
* Display a single item from the database
* Display a single project
*
* @return HTML of a single database entry
* @param string $project_id the project id
* @return HTML of a single project entry
*/
function pi_project_single_view() {
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 '.$this->internal['currentRow']['name'].' :</h2>
<p><strong>'.$this->getFieldContent('description').'</strong></p>
</div>'.$this->pi_getEditPanel().$this->pi_run_view($content, $this->conf, $this->internal['currentRow']['uid']);
<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 />';