class.tx_nG6_pi1.php 34.2 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
56
		$this->internal['results_at_a_time'] = $conf["results_at_a_time"];
		
Jerome Mariette's avatar
sql ok    
Jerome Mariette committed
57
		$this->pi_setPiVarDefaults();
Jerome Mariette's avatar
Jerome Mariette committed
58
59
60
61
		// 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();
62

63
		// Add the ng6 plugins css
Jerome Mariette's avatar
Jerome Mariette committed
64
65
66
67
68
69
70
71
72
73
74
75
76
		$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>
			<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.ui.dialog.min.js"></script>
			<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.ui.draggable.min.js"></script>
			<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.ui.resizable.min.js"></script> 
			<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.bgiframe.min.js"></script>
			<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.url.packed.js"></script>
			<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/tx_nG6_pi1.js"></script>
			<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"/>
			<link type="text/css" rel="stylesheet" media="screen" href="'.t3lib_extMgm::siteRelPath($this->extKey).'res/css/jquery.ui.dialog.css"/>';
77

78
		$content .= '<div id="user_information_dialog" title=""></div>';
79
80
		$content .= '<div id="error_dialog" title=""></div>';
		
81
82
		$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]').'" />';
83
84
		$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]').'" />';
85
		$content .= '<input type="hidden" id="confirmation_dialog_title" value="'.$this->pi_getLL('confirmation_dialog_title', '[confirmation_dialog_title]').'" />';
86
87
		$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]').'" />';
88
		$content .= '<input type="hidden" id="hide_confirmation_msg" value="'.$this->pi_getLL('hide_confirmation_msg', '[hide_confirmation_msg]').'" />';
89
		$content .= '<input type="hidden" id="unhide_dialog_title" value="'.$this->pi_getLL('unhide_dialog_title', '[unhide_dialog_title]').'" />';
90
		$content .= '<input type="hidden" id="unhide_confirmation_msg" value="'.$this->pi_getLL('unhide_confirmation_msg', '[unhide_confirmation_msg]').'" />';
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
		$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"].'" />';	
Jerome Mariette's avatar
Jerome Mariette committed
114
		
Jerome Mariette's avatar
Jerome Mariette committed
115
		// If the user is authorized to access the specified project/run, display the page
116
		if (tx_nG6_db::user_is_authorized($GLOBALS['TSFE']->fe_user->user['usergroup'], $this->piVars['project_id'], $this->piVars['run_id'])) {
Jerome Mariette's avatar
sql ok    
Jerome Mariette committed
117
			switch((string)$this->conf['view'])	{
Jerome Mariette's avatar
Jerome Mariette committed
118
				// If the plugin is configured to display results by project
Jerome Mariette's avatar
Jerome Mariette committed
119
120
				case 'project':
					if ($this->piVars['analyze_id']) {
Jerome Mariette's avatar
Jerome Mariette committed
121
						$content .= $this->pi_analyze_view('analyze');
Jerome Mariette's avatar
Jerome Mariette committed
122
					} elseif ($this->piVars['project_id'] && $this->piVars['run_id']) {
Jerome Mariette's avatar
Jerome Mariette committed
123
						$content .= $this->pi_run_view();
124
					}elseif ($this->piVars['project_id'] && $this->piVars['summary']) {
Jerome Mariette's avatar
Jerome Mariette committed
125
						$content .= $this->pi_project_summary();
Jerome Mariette's avatar
Jerome Mariette committed
126
					} else {
Jerome Mariette's avatar
Jerome Mariette committed
127
						$content .= $this->pi_project_view();
Jerome Mariette's avatar
Jerome Mariette committed
128
129
					}
					break;
Jerome Mariette's avatar
Jerome Mariette committed
130
				// If the plugin is configured to display results by run
Jerome Mariette's avatar
Jerome Mariette committed
131
132
				case 'run':
					if ($this->piVars['analyze_id']) {
Jerome Mariette's avatar
Jerome Mariette committed
133
						$content .= $this->pi_analyze_view('analyze');
Jerome Mariette's avatar
Jerome Mariette committed
134
					} else {
Jerome Mariette's avatar
Jerome Mariette committed
135
						$content .= $this->pi_run_view();
Jerome Mariette's avatar
Jerome Mariette committed
136
					}
Jerome Mariette's avatar
Jerome Mariette committed
137
138
					break;
				// If the plugin is not configured, display by project is default
Jerome Mariette's avatar
Jerome Mariette committed
139
				default:
Jerome Mariette's avatar
Jerome Mariette committed
140
					$content .= $this->pi_project_view();
Jerome Mariette's avatar
Jerome Mariette committed
141
					break;
Jerome Mariette's avatar
Jerome Mariette committed
142
			}
Jerome Mariette's avatar
Jerome Mariette committed
143
		// If the user is not authorized
Jerome Mariette's avatar
Jerome Mariette committed
144
		} else {
Jerome Mariette's avatar
Jerome Mariette committed
145
			$content .= $this->pi_getLL('not_authorized','[not_authorized]');
Jerome Mariette's avatar
Jerome Mariette committed
146
		}
Jerome Mariette's avatar
Jerome Mariette committed
147
		return $this->pi_wrapInBaseClass($content);
Jerome Mariette's avatar
Jerome Mariette committed
148
	}
149
	
150
151
	/**
	 * Shows the summary and statistics for a project
Jerome Mariette's avatar
Jerome Mariette committed
152
	 * TODELETE
153
154
155
	 * @return	HTML list of table entries
	 */
	function pi_project_summary()	{
Jerome Mariette's avatar
Jerome Mariette committed
156
157
158
		$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;
159
	}
160
	
Jerome Mariette's avatar
Jerome Mariette committed
161
162
163
164
165
	/**
	 * Shows a list of database entries
	 *
	 * @return	HTML list of table entries
	 */
Jerome Mariette's avatar
sql ok    
Jerome Mariette committed
166
167
	function pi_project_view()	{

Jerome Mariette's avatar
Jerome Mariette committed
168
169
170
171
		// If a single element should be displayed
		if ($this->piVars['project_id'])	{
			
			return $this->pi_project_single_view($this->piVars['project_id']);
172

Jerome Mariette's avatar
Jerome Mariette committed
173
		// If multiple projects
Jerome Mariette's avatar
Jerome Mariette committed
174
		} else {
Jerome Mariette's avatar
Jerome Mariette committed
175
176
177
			
			// If the user is on a specific page
			if (isset($this->piVars['project_page'])) {
178
179
				$current_page = intval($this->internal['results_at_a_time']) * (intval($this->piVars['project_page']) -1);
				$limit = "$current_page".",". $this->internal['results_at_a_time'] ;
Jerome Mariette's avatar
Jerome Mariette committed
180
181
182
183
184
185
			} 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']);
			
Jerome Mariette's avatar
sql ok    
Jerome Mariette committed
186
			// If there is at least one result
Jerome Mariette's avatar
Jerome Mariette committed
187
188
189
190
191
192
193
194
195
			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]');
196
			}
Jerome Mariette's avatar
Jerome Mariette committed
197
198
199
200
201
		}
	}

	/**
	 * Creates a list from a database query
Jerome Mariette's avatar
sql ok    
Jerome Mariette committed
202
	 * 
Jerome Mariette's avatar
Jerome Mariette committed
203
204
205
	 * @param	ressource	$res: A database result ressource
	 * @return	A HTML list if result items
	 */
Jerome Mariette's avatar
Jerome Mariette committed
206
207
208
	function pi_project_list_view($projects)	{

		// First add the table header
209
210
211
212
213
214
215
216
217
218
219
220
221
		$is_super_user = false;
		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;
			}
		}
		$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>';
Jerome Mariette's avatar
Jerome Mariette committed
222
223
224
						
		// Then the row for each project	
		foreach($projects as $project_id => $project_values) {
225
			
Jerome Mariette's avatar
Jerome Mariette committed
226
227
228
			// If it's not a hidden project
			$hidden = $this->pi_classParam('hidden');
			if ($project_values['hidden'] == 0) { $hidden = ''; }
229
230
231
232

			// If it's not a public project
			$public = '';
			if ($GLOBALS['TSFE']->loginUser && $project_values['public'] == 0) { $public = $this->pi_classParam('public'); }
Jerome Mariette's avatar
Jerome Mariette committed
233
			
234
			$content .= '<tr '.$public.'>';
Jerome Mariette's avatar
Jerome Mariette committed
235

236
237
238
239
240
241
242
			// 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>';
			}
			$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>';
Jerome Mariette's avatar
Jerome Mariette committed
243

Jerome Mariette's avatar
Jerome Mariette committed
244
		}
Jerome Mariette's avatar
Jerome Mariette committed
245
		$content .= '</table>';
246
		
Jerome Mariette's avatar
Jerome Mariette committed
247
		// option toolbar
248
249
250
251
252
253
254
255
256
		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>';
		}
Jerome Mariette's avatar
Jerome Mariette committed
257
		return $content;
Jerome Mariette's avatar
Jerome Mariette committed
258
259
260
	}

	/**
Jerome Mariette's avatar
Jerome Mariette committed
261
	 * Display a single project
Jerome Mariette's avatar
sql ok    
Jerome Mariette committed
262
	 * 
Jerome Mariette's avatar
Jerome Mariette committed
263
264
	 * @param	string	$project_id	the project id
	 * @return	HTML of a single project entry
Jerome Mariette's avatar
Jerome Mariette committed
265
	 */
Jerome Mariette's avatar
Jerome Mariette committed
266
267
268
269
270
271
	function pi_project_single_view($project_id)	{
		
		// First select the project values 
		$project = tx_nG6_db::select_project($project_id);
		
		// Add the project description
Jerome Mariette's avatar
Jerome Mariette committed
272
		$content = '<div'.$this->pi_classParam('singleView').'>
Jerome Mariette's avatar
Jerome Mariette committed
273
274
275
276
277
278
			        <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
Jerome Mariette's avatar
sql ok    
Jerome Mariette committed
279
		$content .= $this->pi_analyze_view('project');
Jerome Mariette's avatar
Jerome Mariette committed
280
		return $content;
Jerome Mariette's avatar
Jerome Mariette committed
281
		
Jerome Mariette's avatar
Jerome Mariette committed
282
	}
Jerome Mariette's avatar
sql ok    
Jerome Mariette committed
283

Jerome Mariette's avatar
Jerome Mariette committed
284
285
286
287
288
	/**
	 * Shows a list of database entries
	 *
	 * @return	HTML list of table entries
	 */
Jerome Mariette's avatar
sql ok    
Jerome Mariette committed
289
    function pi_run_view() {
Jerome Mariette's avatar
Jerome Mariette committed
290
291
292
    	
    	// If a single element should be displayed
		if ($this->piVars['run_id'])    {       
293
		
Jerome Mariette's avatar
Jerome Mariette committed
294
			return $this->pi_run_single_view($this->piVars['run_id']);
295
		
Jerome Mariette's avatar
Jerome Mariette committed
296
297
298
299
300
		// If multiple runs
		} else {        
			
			// If the user is on a specific page
			if (isset($this->piVars['run_page'])) {
301
302
				$current_page = intval($this->internal['results_at_a_time']) * (intval($this->piVars['run_page']) -1);
				$limit = "$current_page".",". $this->internal['results_at_a_time'] ;
Jerome Mariette's avatar
Jerome Mariette committed
303
			} else $limit = '0,'.$this->internal['results_at_a_time'] ; 
304
		   
Jerome Mariette's avatar
Jerome Mariette committed
305
			// Select all runs from this project
Jerome Mariette's avatar
Jerome Mariette committed
306
			if ($this->piVars['project_id']) {
Jerome Mariette's avatar
Jerome Mariette committed
307
308
309
				$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
Jerome Mariette's avatar
Jerome Mariette committed
310
			} else {
Jerome Mariette's avatar
Jerome Mariette committed
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
            	$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]');
 			}
 			
		}
Jerome Mariette's avatar
sql ok    
Jerome Mariette committed
328
329
    }

Jerome Mariette's avatar
Jerome Mariette committed
330
331
332
333
334
335
	/**
	 * Creates a list from a database query
	 *
	 * @param	ressource	$res: A database result ressource
	 * @return	A HTML list if result items
	 */
Jerome Mariette's avatar
Jerome Mariette committed
336
337
338
	function pi_run_list_view($runs) {
		
		// First add the table header
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
		$is_super_user = false;
		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;
			}
		}
		$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>';
					 
Jerome Mariette's avatar
Jerome Mariette committed
361
362
363
364
365
366
367
368
		// 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
369
			$content .= '<tr>';
Jerome Mariette's avatar
Jerome Mariette committed
370
			// runs updates possibility depends on runs rights (show checkboxes or not)
371
			if ( $GLOBALS['TSFE']->loginUser && tx_nG6_db::is_super_user($GLOBALS['TSFE']->fe_user->user['usergroup'], 'run', $run_values['id']) ) {
372
				$content .= '<td '.$hidden.' ><center><input type="checkbox" id="chk_run_'.$run_values["id"].'" value="run_'.$run_values["id"].'"></center></td>';
Jerome Mariette's avatar
Jerome Mariette committed
373
374
375
376
377
378
379
380
381
382
383
384
			}
			$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>';
Jerome Mariette's avatar
Jerome Mariette committed
385
		}
Jerome Mariette's avatar
Jerome Mariette committed
386
		// Return the html table
Jerome Mariette's avatar
Jerome Mariette committed
387
		$content .= '</table>' ;
388
		if ($is_super_user) {
Jerome Mariette's avatar
Jerome Mariette committed
389
		// option toolbar
390
391
392
393
394
395
		$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>';
		}
Jerome Mariette's avatar
Jerome Mariette committed
396
		return $content;
Jerome Mariette's avatar
Jerome Mariette committed
397
398
399
400
	}

	/**
	 * Display a single item from the database
Jerome Mariette's avatar
sql ok    
Jerome Mariette committed
401
402
	 * 
	 * @param	ressource	$res: A database result ressource
Jerome Mariette's avatar
Jerome Mariette committed
403
404
	 * @return	HTML of a single database entry
	 */
Jerome Mariette's avatar
Jerome Mariette committed
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
	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
Jerome Mariette's avatar
sql ok    
Jerome Mariette committed
454
		$content .= $this->pi_analyze_view('run');
455
		
Jerome Mariette's avatar
Jerome Mariette committed
456
457
		// Return the run HTML page
		return $content;
Jerome Mariette's avatar
Jerome Mariette committed
458
459
	}
	
Jerome Mariette's avatar
Jerome Mariette committed
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
	/**
	 * 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>';
				}
			}
			$download .= '</ul>';		
			closedir($my_directory);
			return $download;
		}
		catch (Exception $e) {
			return $this->pi_getLL('not_synchro','[not_synchro]');
		}
	}	
	
Jerome Mariette's avatar
Jerome Mariette committed
489
490
491
492
493
494
	/**
	 * Shows a list of database entries
	 *
	 * @param	string		$type: What kind of analyze is it : run or project
	 * 	 * @return	HTML list of table entries
	 */
Jerome Mariette's avatar
sql ok    
Jerome Mariette committed
495
	function pi_analyze_view($type)	{
496
		
Jerome Mariette's avatar
Jerome Mariette committed
497
498
499
500
		// If a single element should be displayed:
		if ($type == 'analyze')	{
			
			return $this->pi_analyze_single_view($this->piVars['analyze_id']);
501
		
Jerome Mariette's avatar
Jerome Mariette committed
502
503
504
505
506
		// If multiple analyses
		} else {
			
			// If the user is on a specific page
			if (isset($this->piVars['analyze_page'])) {
507
508
				$current_page = intval($this->internal['results_at_a_time']) * (intval($this->piVars['analyze_page']) -1);
				$limit = "$current_page".",". $this->internal['results_at_a_time'] ;
Jerome Mariette's avatar
Jerome Mariette committed
509
510
511
			} else $limit = '0,'.$this->internal['results_at_a_time'] ; 
			
			// If we want run analyses
Jerome Mariette's avatar
Jerome Mariette committed
512
513
			if ($type == 'run') {
				// Selects Analyzis done on this run
Jerome Mariette's avatar
Jerome Mariette committed
514
515
516
517
518
519
520
521
				$analyses = tx_nG6_db::get_run_analysis($GLOBALS['TSFE']->fe_user->user['usergroup'], $this->piVars['run_id'], 'tx_nG6_analyze.name', $limit);
				$all_analyses = tx_nG6_db::get_run_analysis($GLOBALS['TSFE']->fe_user->user['usergroup'], $this->piVars['run_id']);
			} else {
				$analyses = tx_nG6_db::get_project_analysis($GLOBALS['TSFE']->fe_user->user['usergroup'], $this->piVars['project_id'], 'tx_nG6_analyze.name', $limit);
				$all_analyses = tx_nG6_db::get_project_analysis($GLOBALS['TSFE']->fe_user->user['usergroup'], $this->piVars['project_id']);
			}

			// Define an empty content
Jerome Mariette's avatar
sql ok    
Jerome Mariette committed
522
			$content='';
Jerome Mariette's avatar
Jerome Mariette committed
523
524
525
526
527
528
			
			// If there is some analyse
			if (count($analyses) > 0) {	
				$analyze_list = $this->pi_analyze_list_view($analyses);
				$nav_links = $this->pi_navigation_link_view('analyze_page', $this->piVars['analyze_page'], count($all_analyses));
				$content.= $analyze_list.$nav_links;
Jerome Mariette's avatar
Jerome Mariette committed
529
			}
Jerome Mariette's avatar
Jerome Mariette committed
530
531
			
			// Return the final HTML
Jerome Mariette's avatar
sql ok    
Jerome Mariette committed
532
			return $content;
Jerome Mariette's avatar
Jerome Mariette committed
533
534
535
536
537
538
539
540
541
		}
	}

	/**
	 * Creates a list from a database query
	 *
	 * @param	ressource	$res: A database result ressource
	 * @return	A HTML list if result items
	 */
Jerome Mariette's avatar
Jerome Mariette committed
542
543
544
	function pi_analyze_list_view($analyses) {
		
		// First add the table header to the HTML
545
546
547
548
549
550
551
		// First add the table header
		$is_super_user = false;
		foreach($analyses as $analyse_id => $analyse_values) {
			if ( $GLOBALS['TSFE']->loginUser && tx_nG6_db::is_super_user($GLOBALS['TSFE']->fe_user->user['usergroup'], 'analyze', $analyse_values['id']) ) {
				$is_super_user = true;
			}
		}
Jerome Mariette's avatar
Jerome Mariette committed
552
		$content = '<br /> <h3> '.$this->pi_getLL('analyzes_done','[analyzes_done]').'</h3> <br />
553
554
555
556
557
558
559
560
561
				   <table'.$this->pi_classParam('listrow').'>';
		if ($is_super_user) {
			$content .= '<th><center><input type="checkbox" id="chk_all_analysis"></center></th>';
		}
		$content .= '<th>'.$this->pi_getLL('name','[name]').'</th>
					 <th>'.$this->pi_getLL('description','[description]').'</th>
					 <th>'.$this->pi_getLL('software','[software]').'</th>
					 <th>'.$this->pi_getLL('version','[version]').'</th>
				     </tr>';
Jerome Mariette's avatar
Jerome Mariette committed
562
563
564
565
566
567
568
569
				   
		// Then the row for each analyse
		foreach($analyses as $analyse_id => $analyse_values) {

			// If it's not a hidden analyse
			$hidden = $this->pi_classParam('hidden');
			if ($analyse_values['hidden'] == 0) { $hidden = ''; }

570
			$content .= '<tr>';
Jerome Mariette's avatar
Jerome Mariette committed
571
			// analyzes updates possibility depends on analyzes rights (show checkboxes or not)
572
			if ( $GLOBALS['TSFE']->loginUser && tx_nG6_db::is_super_user($GLOBALS['TSFE']->fe_user->user['usergroup'], 'analyze', $analyse_values['id']) ) {
573
				$content .= '<td '.$hidden.' ><center><input type="checkbox" id="chk_analysis_'.$analyse_values["id"].'" value="analysis_'.$analyse_values["id"].'"></center></td>';
Jerome Mariette's avatar
Jerome Mariette committed
574
575
			}
			$content .='<td '.$hidden.' >'.$this->pi_list_linkSingle($analyse_values['name'],$analyse_values['id'],1, array('analyze_id'=>$analyse_values['id'], 'project_id'=>$this->piVars['project_id'], 'run_id'=>$this->piVars['run_id'])).'</td>
Jerome Mariette's avatar
Jerome Mariette committed
576
577
578
579
580
						 <td '.$hidden.' >'.$analyse_values['description'].'</td>
						 <td '.$hidden.' >'.$analyse_values['software'].'</td>
						 <td '.$hidden.' >'.$analyse_values['version'].'</td>
						 </tr>';

Jerome Mariette's avatar
Jerome Mariette committed
581
		}
Jerome Mariette's avatar
Jerome Mariette committed
582
		$content.='</table>' ;
583
		if ($is_super_user) {
Jerome Mariette's avatar
Jerome Mariette committed
584
		// option toolbar
585
586
587
588
589
590
		$content .= '<div '.$this->pi_classParam('div-option-menu').'> '.$this->pi_getLL('toolbar_title','[toolbar_title]') .
					'<button id="hide_analysis" type="button" class="btn pill-l"><span><span>'.$this->pi_getLL('hide_btn','[hide_btn]').'</span></span></button>' .
					'<button id="unhide_analysis" type="button" class="btn pill-r"><span><span>'.$this->pi_getLL('unhide_btn','[unhide_btn]').'</span></span></button>' .
					'&nbsp;<button id="delete_analysis" type="button" class="btn"><span><span>'.$this->pi_getLL('delete_btn','[delete_btn]').'</span></span></button>' .
					'</div>';
		}
Jerome Mariette's avatar
Jerome Mariette committed
591
		return $content;
Jerome Mariette's avatar
Jerome Mariette committed
592
593
	}

Jerome Mariette's avatar
sql ok    
Jerome Mariette committed
594

Jerome Mariette's avatar
Jerome Mariette committed
595
596
597
598
599
	/**
	 * Display a single item from the database
	 *
	 * @return	HTML of a single database entry
	 */
Jerome Mariette's avatar
Jerome Mariette committed
600
601
602
	function pi_analyze_single_view($analyse_id) {
		
		// Add the jquery libs
603
604
605
606
607
608
609
610
		$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>
			<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.ui.dialog.min.js"></script>
			<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.ui.draggable.min.js"></script>
			<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.ui.resizable.min.js"></script> 
			<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.bgiframe.min.js"></script>
			<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.url.packed.js"></script>
611
			<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/tx_nG6_pi1.js"></script>
612
			<link type="text/css" rel="stylesheet" media="screen" href="'.t3lib_extMgm::siteRelPath($this->extKey).'res/css/tx_nG6.css"/>
613
614
615
			<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"/>';
616
617
618

		// First select the analyse
		$analyse = tx_nG6_db::select_analyse($analyse_id);
Jerome Mariette's avatar
Jerome Mariette committed
619
		
620
621
622
623
624
625
626
627
628
629
		// 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
630
			}
Jerome Mariette's avatar
Jerome Mariette committed
631
			
632
		// Else meaning using smarty
Jerome Mariette's avatar
Jerome Mariette committed
633
		} else {
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
			
			$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);
			
			// Then select analyse results
			$results = tx_nG6_db::select_analyse_results($analyse_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']);
Jerome Mariette's avatar
Jerome Mariette committed
657
			if (isset($this->LOCAL_LANG[$this->LLkey]) && count($this->LOCAL_LANG[$this->LLkey]) > 0) {
658
659
660
661
662
663
664
				$smarty->assign('llang', $this->LOCAL_LANG[$this->LLkey]);
			} else {
				$smarty->assign('llang', $this->LOCAL_LANG['default']);
			}			
			// Try to process the analyse template
			try { $content = $smarty->fetch($analyse['class'].'.tpl'); } 
			catch (Exception $e) { $content = 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
665
		}
Jerome Mariette's avatar
Jerome Mariette committed
666
		
667
		// Return the analyse display
Jerome Mariette's avatar
Jerome Mariette committed
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
		return $content;
	}
	
	/**
	 * 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;
	}
	
702
703
704
	/**
	 * Display links for navigation in run lists or analyse lists. Called only if $end>1
	 *
Jerome Mariette's avatar
Jerome Mariette committed
705
	 * @param	$name	name of the variable set in GET: run_page or analyze_page
706
	 * @param	$start	current page number
Jerome Mariette's avatar
Jerome Mariette committed
707
	 * @param	$total_count	current total number of rows
708
709
710
711
712
713
714
715
	 *
	 * @return	HTML navigation links
	 */
	function pi_navigation_link_view($name, $start, $total_count) 
	{  
		$start = intval($start);		
		
		//max page number
Jerome Mariette's avatar
Jerome Mariette committed
716
		$end = $total_count/$this->internal['results_at_a_time'] ;
717
718
719
720
721
722
723
724
725
726
727
728
729
730
		$end = ceil($end) ;
		//repair URL mistakes caused by the nasty user  		
		if ($start > $end)
			$start = $end;
		if (($start < 1) or (! $start))
			$start = 1; 
					
		$start=(string)$start ; $end=(string)$end ;
		//create navigation links
		
		$go_back = $this->pi_linkTP_keepPIvars ('<<', array ($name => 1))	.' '.		$this->pi_linkTP_keepPIvars ('<', array ($name => $start-1));
		$go_ahead= $this->pi_linkTP_keepPIvars ('>', array ($name => $start+1)).' '.$this->pi_linkTP_keepPIvars ('>>', array ($name => $end)); 
		$current_pos = 'page '.$start. '/'.$end;
		
Jerome Mariette's avatar
Jerome Mariette committed
731
732
733
734
735
736
737
		//do nothing
		if( $end == '1' ) { return '' ;
		//don't display << nor <
		} elseif($start == '1')	{ $go_back = '';
		//don't display > nor >>
		} elseif($start == $end) { $go_ahead = '';
		//display both		
738
739
740
741
		}		
		$content = '<div align="right">'.$go_back .' '. $current_pos .' '. $go_ahead .'</div>' ;
		return $content;
	}	
Jerome Mariette's avatar
Jerome Mariette committed
742
743
744
745
746
747
748
		
}

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

749
?>