class.tx_nG6_pi1.php 18.6 KB
Newer Older
Jerome Mariette's avatar
Jerome Mariette committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?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');
31
32
require_once(t3lib_extMgm::extPath('nG6').'/lib/class.tx_nG6_db.php');
require_once(t3lib_extMgm::extPath('nG6').'/lib/class.tx_nG6_utils.php');
33
require_once(t3lib_extMgm::extPath('nG6').'/res/smarty/libs/Smarty.class.php'); 
Jerome Mariette's avatar
Jerome Mariette committed
34
35

class tx_nG6_pi1 extends tslib_pibase {
Jerome Mariette's avatar
sql ok    
Jerome Mariette committed
36
	
Jerome Mariette's avatar
Jerome Mariette committed
37
38
39
40
41
42
43
44
45
46
47
48
	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)	{
Jerome Mariette's avatar
sql ok    
Jerome Mariette committed
49
		
Jerome Mariette's avatar
Jerome Mariette committed
50
51
52
		if (strstr($this->cObj->currentRecord,'tt_content'))	{
			$conf['pidList'] = $this->cObj->data['pages'];
		}
Jerome Mariette's avatar
Jerome Mariette committed
53
54
		// Setting the TypoScript passed to this function in $this->conf
		$this->conf=$conf;
55
		
Jerome Mariette's avatar
sql ok    
Jerome Mariette committed
56
		$this->pi_setPiVarDefaults();
Jerome Mariette's avatar
Jerome Mariette committed
57
58
59
		// 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
60
61
		$this->pi_loadLL();		
		
62
		// Add the ng6 plugins css
Jerome Mariette's avatar
Jerome Mariette committed
63
64
65
		$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.ui.core.min.js"></script>
66
67
68
			<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>
Jerome Mariette's avatar
Jerome Mariette committed
69
70
71
72
			<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>
73
74
			<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/jquery.dataTables.plugins.js"></script>
Jerome Mariette's avatar
Jerome Mariette committed
75
			<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.url.packed.js"></script>
Jerome Mariette's avatar
Jerome Mariette committed
76
			<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.venny.js"></script>
Jerome Mariette's avatar
Jerome Mariette committed
77
			<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/tx_nG6_pi1.js"></script>
Jerome Mariette's avatar
Jerome Mariette committed
78
79
80
81
82
83
			<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/tx_nG6_classes.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>
Penom Nom's avatar
Penom Nom committed
84
85
			<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.datePicker.min.js"></script>
			<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.jeditable.min.js"></script>
86
			<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/tx_nG6_table.js"></script>
Jerome Mariette's avatar
Jerome Mariette committed
87
			<link type="text/css" rel="stylesheet" media="screen" href="'.t3lib_extMgm::siteRelPath($this->extKey).'res/css/unitip.css"/>
Jerome Mariette's avatar
Jerome Mariette committed
88
			<link type="text/css" rel="stylesheet" media="screen" href="'.t3lib_extMgm::siteRelPath($this->extKey).'res/css/jquery.venny.css"/>
89
			<link type="text/css" rel="stylesheet" media="screen" href="'.t3lib_extMgm::siteRelPath($this->extKey).'res/css/jquery.dataTables.css"/>
Penom Nom's avatar
Penom Nom committed
90
			<link type="text/css" rel="stylesheet" media="screen" href="'.t3lib_extMgm::siteRelPath($this->extKey).'res/css/jquery.datePicker.css"/>
Jerome Mariette's avatar
Jerome Mariette committed
91
92
93
			<link type="text/css" rel="stylesheet" media="screen" href="'.t3lib_extMgm::siteRelPath($this->extKey).'res/css/tx_nG6.css"/>
			<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"/>
94
95
			<link type="text/css" rel="stylesheet" media="screen" href="'.t3lib_extMgm::siteRelPath($this->extKey).'res/css/jquery.ui.dialog.css"/>
			<link type="text/css" rel="stylesheet" media="screen" href="'.t3lib_extMgm::siteRelPath($this->extKey).'res/css/jquery.ui.resizable.css"/>';
Jerome Mariette's avatar
Jerome Mariette committed
96
		
97
98
		tx_nG6_db::check_db_rights_level();

Jerome Mariette's avatar
Jerome Mariette committed
99
		// If the user is authorized to access the specified project/run, display the page
100
		if (tx_nG6_db::user_is_authorized($GLOBALS['TSFE']->fe_user->user['uid'], $this->piVars['project_id'], $this->piVars['run_id'])) {
Jerome Mariette's avatar
sql ok    
Jerome Mariette committed
101
			switch((string)$this->conf['view'])	{
Jerome Mariette's avatar
Jerome Mariette committed
102
				// If the plugin is configured to display results by project
Jerome Mariette's avatar
Jerome Mariette committed
103
104
				case 'project':
					if ($this->piVars['analyze_id']) {
Jerome Mariette's avatar
Jerome Mariette committed
105
						$content .= $this->pi_analyze_view();
Jerome Mariette's avatar
Jerome Mariette committed
106
					} elseif ($this->piVars['project_id'] && $this->piVars['run_id']) {
Jerome Mariette's avatar
Jerome Mariette committed
107
						$content .= $this->pi_run_view();
Jerome Mariette's avatar
Jerome Mariette committed
108
					} else {
Jerome Mariette's avatar
Jerome Mariette committed
109
						$content .= $this->pi_project_view();
Jerome Mariette's avatar
Jerome Mariette committed
110
111
					}
					break;
Jerome Mariette's avatar
Jerome Mariette committed
112
				// If the plugin is configured to display results by run
Jerome Mariette's avatar
Jerome Mariette committed
113
114
				case 'run':
					if ($this->piVars['analyze_id']) {
Jerome Mariette's avatar
Jerome Mariette committed
115
						$content .= $this->pi_analyze_view();
Jerome Mariette's avatar
Jerome Mariette committed
116
					} else {
Jerome Mariette's avatar
Jerome Mariette committed
117
						$content .= $this->pi_run_view();
Jerome Mariette's avatar
Jerome Mariette committed
118
					}
Jerome Mariette's avatar
Jerome Mariette committed
119
120
					break;
				// If the plugin is not configured, display by project is default
Jerome Mariette's avatar
Jerome Mariette committed
121
				default:
Jerome Mariette's avatar
Jerome Mariette committed
122
					$content .= $this->pi_project_view();
Jerome Mariette's avatar
Jerome Mariette committed
123
					break;
Jerome Mariette's avatar
Jerome Mariette committed
124
			}
Jerome Mariette's avatar
Jerome Mariette committed
125
		// If the user is not authorized
Jerome Mariette's avatar
Jerome Mariette committed
126
		} else {
Jerome Mariette's avatar
Jerome Mariette committed
127
			$content .= $this->pi_getLL('not_authorized','[not_authorized]');
Jerome Mariette's avatar
Jerome Mariette committed
128
		}
129
		
Jerome Mariette's avatar
Jerome Mariette committed
130
		return $this->pi_wrapInBaseClass($content);
Jerome Mariette's avatar
Jerome Mariette committed
131
	}
Jerome Mariette's avatar
Jerome Mariette committed
132

Jerome Mariette's avatar
Jerome Mariette committed
133
	/**
Jerome Mariette's avatar
Jerome Mariette committed
134
	 * Return the project view
Jerome Mariette's avatar
Jerome Mariette committed
135
	 */
Jerome Mariette's avatar
sql ok    
Jerome Mariette committed
136
	function pi_project_view()	{
Jerome Mariette's avatar
Jerome Mariette committed
137
138
139
140
141
		
		$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']));
Jerome Mariette's avatar
Jerome Mariette committed
142
		} else {
143
			$projects = tx_nG6_db::select_all_user_projects($GLOBALS['TSFE']->fe_user->user['uid'], 'tx_nG6_project.name');
Jerome Mariette's avatar
Jerome Mariette committed
144
		}
Jerome Mariette's avatar
Jerome Mariette committed
145
146
147
148
149
150
		$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;
151
		$smarty->security_settings['MODIFIER_FUNCS'] = array('count');		
Jerome Mariette's avatar
Jerome Mariette committed
152
		// Add some information to the table
153
		$project_ids = "";
154
		foreach($projects as $project_id => $project_values) {
155
			if (tx_nG6_db::is_administrator($GLOBALS['TSFE']->fe_user->user['uid'], 'project', $project_values['id']) ) {
Jerome Mariette's avatar
Jerome Mariette committed
156
157
158
				$projects[$project_id]['superuser'] = true;
			} else {
				$projects[$project_id]['superuser'] = false;
159
			}
160
			$project_ids .= $project_values['id'].",";
Jerome Mariette's avatar
Jerome Mariette committed
161
			$projects[$project_id]['href'] = $this->pi_list_linkSingle($project_values['name'],$project_values['id'],1, array('project_id'=>$project_values['id']));
162
		}
Jerome Mariette's avatar
Jerome Mariette committed
163
164
		$smarty->assign('projects', $projects);
		$smarty->assign('login_user', $GLOBALS['TSFE']->loginUser);
165
		$smarty->assign('user_id', $GLOBALS['TSFE']->fe_user->user['uid']);
Jerome Mariette's avatar
Jerome Mariette committed
166
167
		$smarty->assign('data_folder', $this->conf["data"]);
		$smarty->assign('server_name', $this->conf["server_name"]);
168
		$smarty->assign('project_ids', substr($project_ids,0,-1));
169

Jerome Mariette's avatar
Jerome Mariette committed
170
171
		// If it's a single project, add runs and analysis information
		if (count($projects) == 1) {
Jerome Mariette's avatar
Jerome Mariette committed
172

173
			$project_runs = tx_nG6_db::get_project_runs($GLOBALS['TSFE']->fe_user->user['uid'], $projects[key($projects)]['id']);			
Jerome Mariette's avatar
Jerome Mariette committed
174
175
			// Add some information to the table
			foreach($project_runs as $run_id => $run_values) {
176
				if (tx_nG6_db::is_administrator($GLOBALS['TSFE']->fe_user->user['uid'], 'run', $run_values['id']) ) {
Jerome Mariette's avatar
Jerome Mariette committed
177
178
179
180
181
					$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']));
182
			}
Jerome Mariette's avatar
Jerome Mariette committed
183
			$smarty->assign('project_runs', $project_runs);
184
			$project_analysis = tx_nG6_db::get_project_analysis($GLOBALS['TSFE']->fe_user->user['uid'], $projects[key($projects)]['id']);
Jerome Mariette's avatar
Jerome Mariette committed
185
186
			// Add some information to the table
			foreach($project_analysis as $analysis_id => $analysis_values) {
187
				if (tx_nG6_db::is_administrator($GLOBALS['TSFE']->fe_user->user['uid'], 'analyze', $analysis_values['id']) ) {
Jerome Mariette's avatar
Jerome Mariette committed
188
189
190
191
					$project_analysis[$analysis_id]['superuser'] = true;
				} else {
					$project_analysis[$analysis_id]['superuser'] = false;
				}
192
				$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']));
Jerome Mariette's avatar
Jerome Mariette committed
193
			}
Jerome Mariette's avatar
Jerome Mariette committed
194
			$smarty->assign('h_project_analysis', tx_nG6_utils::trace_hierarchy($project_analysis));
Jerome Mariette's avatar
Jerome Mariette committed
195
			$smarty->assign('project_analysis', $project_analysis);
196
197
		}	
		
Jerome Mariette's avatar
Jerome Mariette committed
198
199
200
201
		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']);
Jerome Mariette's avatar
Jerome Mariette committed
202
		}
Jerome Mariette's avatar
Jerome Mariette committed
203
		return $smarty->fetch('project_view.tpl');
Jerome Mariette's avatar
Jerome Mariette committed
204
	}
205
	
Jerome Mariette's avatar
sql ok    
Jerome Mariette committed
206

Jerome Mariette's avatar
Jerome Mariette committed
207
	/**
Jerome Mariette's avatar
Jerome Mariette committed
208
	 * Return the run view
Jerome Mariette's avatar
Jerome Mariette committed
209
	 */
Jerome Mariette's avatar
sql ok    
Jerome Mariette committed
210
    function pi_run_view() {
211

Jerome Mariette's avatar
Jerome Mariette committed
212
213
214
215
216
		$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 {
217
			$runs = tx_nG6_db::select_all_user_runs($GLOBALS['TSFE']->fe_user->user['uid']);
Jerome Mariette's avatar
Jerome Mariette committed
218
		}
Jerome Mariette's avatar
Jerome Mariette committed
219
220
221
222
223
224
225
		$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');
Jerome Mariette's avatar
sql ok    
Jerome Mariette committed
226

Jerome Mariette's avatar
Jerome Mariette committed
227
		// Add some information to the table
228
		$run_ids = "";
229
		foreach($runs as $run_id => $run_values) {
230
			if (tx_nG6_db::is_administrator($GLOBALS['TSFE']->fe_user->user['uid'], 'run', $run_values['id']) ) {
Jerome Mariette's avatar
Jerome Mariette committed
231
232
233
				$runs[$run_id]['superuser'] = true;
			} else {
				$runs[$run_id]['superuser'] = false;
234
			}
235
			$run_ids .= $run_values['id'].",";
Jerome Mariette's avatar
Jerome Mariette committed
236
237
238
239
			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']));
Jerome Mariette's avatar
Jerome Mariette committed
240
			}
241
		}
Jerome Mariette's avatar
Jerome Mariette committed
242
243
244
		$smarty->assign('runs', $runs);
		$smarty->assign('first_id', key($runs));
		$smarty->assign('login_user', $GLOBALS['TSFE']->loginUser);
245
		$smarty->assign('user_id', $GLOBALS['TSFE']->fe_user->user['uid']);
Jerome Mariette's avatar
Jerome Mariette committed
246
247
		$smarty->assign('data_folder', $this->conf["data"]);
		$smarty->assign('server_name', $this->conf["server_name"]);
248
		$smarty->assign('run_ids', substr($run_ids,0,-1));
249
		
Jerome Mariette's avatar
Jerome Mariette committed
250
251
		// If it's a single run, add analysis information
		if (count($runs) == 1) {
252
			$run_analysis = tx_nG6_db::get_run_analysis($GLOBALS['TSFE']->fe_user->user['uid'], $runs[key($runs)]['id']);
Jerome Mariette's avatar
Jerome Mariette committed
253
254
			// Add some information to the table
			foreach($run_analysis as $analysis_id => $analysis_values) {
255
				if (tx_nG6_db::is_administrator($GLOBALS['TSFE']->fe_user->user['uid'], 'analyze', $analysis_values['id']) ) {
Jerome Mariette's avatar
Jerome Mariette committed
256
257
258
259
260
261
262
263
					$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']));
Jerome Mariette's avatar
Jerome Mariette committed
264
265
				}
			}
Jerome Mariette's avatar
Jerome Mariette committed
266
			$smarty->assign('h_run_analysis', tx_nG6_utils::trace_hierarchy($run_analysis));
Jerome Mariette's avatar
Jerome Mariette committed
267
			$smarty->assign('run_analysis', $run_analysis);
Jerome Mariette's avatar
Jerome Mariette committed
268
		}
Jerome Mariette's avatar
Jerome Mariette committed
269
270
		if (isset($this->LOCAL_LANG[$this->LLkey]) && count($this->LOCAL_LANG[$this->LLkey]) > 0) {
			$smarty->assign('llang', $this->LOCAL_LANG[$this->LLkey]);
Jerome Mariette's avatar
Jerome Mariette committed
271
		} else {
Jerome Mariette's avatar
Jerome Mariette committed
272
273
274
			$smarty->assign('llang', $this->LOCAL_LANG['default']);
		}			
		return $smarty->fetch('run_view.tpl');
275
276
	}
	
Jerome Mariette's avatar
sql ok    
Jerome Mariette committed
277

Jerome Mariette's avatar
Jerome Mariette committed
278
	/**
Jerome Mariette's avatar
Jerome Mariette committed
279
	 * Return the analysis view
Jerome Mariette's avatar
Jerome Mariette committed
280
	 */
Jerome Mariette's avatar
Jerome Mariette committed
281
	function pi_analyze_view() {
282
		// First select the analyse
Jerome Mariette's avatar
Jerome Mariette committed
283
		$analyse = tx_nG6_db::select_analyse($this->piVars['analyze_id']);
Jerome Mariette's avatar
Jerome Mariette committed
284
		
285
286
287
288
289
290
291
292
293
294
		// 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);
Jerome Mariette's avatar
Jerome Mariette committed
295
			}
296
			return $content;
297
		// Else meaning using smarty
Jerome Mariette's avatar
Jerome Mariette committed
298
		} else {
299
300
301
302
303
304
305
306
307
308
			
			$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);
309
310
			$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));
Jerome Mariette's avatar
Jerome Mariette committed
311
			$smarty->assign('data_folder', $this->conf["data"]);
312
313
			
			// Then select analyse results
Jerome Mariette's avatar
Jerome Mariette committed
314
			$results = tx_nG6_db::select_analyse_results($this->piVars['analyze_id']);		
315
316
317
318
319
320
321
322
323
324
			$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']);
Jerome Mariette's avatar
Jerome Mariette committed
325
			if (isset($this->LOCAL_LANG[$this->LLkey]) && count($this->LOCAL_LANG[$this->LLkey]) > 0) {
326
327
328
329
330
				$smarty->assign('llang', $this->LOCAL_LANG[$this->LLkey]);
			} else {
				$smarty->assign('llang', $this->LOCAL_LANG['default']);
			}			
			// Try to process the analyse template
331
332
			try {
				if (file_exists(t3lib_extMgm::extPath($this->extKey).'pi1/analyzes/'.$analyse['class'].'.js')) {
Jerome Mariette's avatar
Jerome Mariette committed
333
					$GLOBALS['TSFE']->additionalHeaderData[$this->prefixId] .= '<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'pi1/analyzes/'.$analyse['class'].'.js"></script>';
334
335
336
337
338
				}
				return $smarty->fetch($analyse['class'].'.tpl'); 
			} catch (Exception $e) { 
				return str_replace(array('###ANALYSE_CLASS###'), array($analyse['class']), $this->pi_getLL('no_template_found','[no_template_found:###ANALYSE_CLASS###]')); 
			}
Jerome Mariette's avatar
Jerome Mariette committed
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
		}
	}
	
	/**
	 * 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;
	}
372
	
Jerome Mariette's avatar
Jerome Mariette committed
373
374
375
376
377
378
}

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']);
}

379
?>