class.tx_nG6_pi6.php 7.59 KB
Newer Older
Jerome Mariette's avatar
Jerome Mariette committed
1
<?php
gsalin's avatar
gsalin committed
2
//namespace ng6\Controller;
Jerome Mariette's avatar
Jerome Mariette committed
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
/***************************************************************
*  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 <>
 */
30
31
require_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/Classes/Controller/class.tx_nG6_utils.php');
require_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/Classes/Controller/tx_nG6_db.php');
32
require_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/res/smarty/libs/Smarty.class.php'); 
gsalin's avatar
gsalin committed
33
use \TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
gsalin's avatar
#213    
gsalin committed
34
use TYPO3\CMS\Core\Context\Context;
35
36
use nG6\Controller\tx_nG6_db;
use nG6\Controller\tx_nG6_utils;
37
class tx_nG6_pi6 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
Jerome Mariette's avatar
Jerome Mariette committed
38
39
40
	var $prefixId = 'tx_nG6_pi6';		// Same as class name
	var $scriptRelPath = 'pi6/class.tx_nG6_pi6.php';	// Path to this script relative to the extension dir.
	var $extKey = 'nG6';	// The extension key.
41
	
Jerome Mariette's avatar
Jerome Mariette committed
42
	//var $pi_checkCHash = TRUE;
43
	
Jerome Mariette's avatar
Jerome Mariette committed
44
45
46
47
48
49
50
51
	/**
	 * 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)	{
gsalin's avatar
#213    
gsalin committed
52
53
54
	    $context = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(Context::class);
	    $user_id = $context->getPropertyFromAspect('frontend.user', 'id');
	    $user_name = $context->getPropertyFromAspect('frontend.user', 'username');
Jerome Mariette's avatar
Jerome Mariette committed
55
56
57
58
59
60
61
62
		if (strstr($this->cObj->currentRecord,'tt_content'))	{
			$conf['pidList'] = $this->cObj->data['pages'];
			$conf['recursive'] = $this->cObj->data['recursive'];
		}
		$this->pi_loadLL();
		$this->conf=$conf;
		$this->pi_setPiVarDefaults();
		$this->pi_USER_INT_obj=1;
63

Jerome Mariette's avatar
Jerome Mariette committed
64
65
		// Add the jquery libs + the tree plugins and its css
		$GLOBALS['TSFE']->additionalHeaderData[$this->prefixId] = '
gsalin's avatar
gsalin committed
66
67
68
69
70
71
72
73
74
75
			<script type="text/javascript" src="'.\TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(ExtensionManagementUtility::extPath($this->extKey)).'res/js/jquery.min.js"></script>
			<script type="text/javascript" src="'.\TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(ExtensionManagementUtility::extPath($this->extKey)).'res/js/highstock.js"></script>
			<script type="text/javascript" src="'.\TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(ExtensionManagementUtility::extPath($this->extKey)).'res/js/jquery.highcharts.exporting.js"></script>
			<script type="text/javascript" src="'.\TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(ExtensionManagementUtility::extPath($this->extKey)).'res/js/jquery.dataTables.min.js"></script>
			<script type="text/javascript" src="'.\TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(ExtensionManagementUtility::extPath($this->extKey)).'res/js/bootstrap.min.js"></script>
			<script type="text/javascript" src="'.\TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(ExtensionManagementUtility::extPath($this->extKey)).'res/js/dataTables.bootstrap.js"></script>
			<script type="text/javascript" src="'.\TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(ExtensionManagementUtility::extPath($this->extKey)).'res/js/typeahead.bundle.js"></script>
			<script type="text/javascript" src="'.\TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(ExtensionManagementUtility::extPath($this->extKey)).'res/js/jflow.min.js"></script>
			<script type="text/javascript" src="'.\TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(ExtensionManagementUtility::extPath($this->extKey)).'res/js/tx_nG6_utils.js"></script>
			<script type="text/javascript" src="'.\TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(ExtensionManagementUtility::extPath($this->extKey)).'res/js/tx_nG6_pi6.js"></script>
Penom Nom's avatar
Penom Nom committed
76
					
gsalin's avatar
gsalin committed
77
78
79
80
81
82
			<link type="text/css" rel="stylesheet" media="screen" href="'.\TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(ExtensionManagementUtility::extPath($this->extKey)).'res/css/bootstrap-theme.min.css"/>
			<link type="text/css" rel="stylesheet" media="screen" href="'.\TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(ExtensionManagementUtility::extPath($this->extKey)).'res/css/dataTables.bootstrap.css"/>
			<link type="text/css" rel="stylesheet" media="screen" href="'.\TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(ExtensionManagementUtility::extPath($this->extKey)).'res/css/typeaheadjs.css"/>	
			<link type="text/css" rel="stylesheet" media="screen" href="'.\TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(ExtensionManagementUtility::extPath($this->extKey)).'res/css/font-awesome.css"/>
			<link type="text/css" rel="stylesheet" media="screen" href="'.\TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(ExtensionManagementUtility::extPath($this->extKey)).'res/css/jflow.min.css"/>
			<link type="text/css" rel="stylesheet" media="screen" href="'.\TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(ExtensionManagementUtility::extPath($this->extKey)).'res/css/tx_nG6.css"/>';
Jerome Mariette's avatar
Jerome Mariette committed
83
84

		$smarty = new Smarty();
85
86
87
88
		$smarty->setTemplateDir(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/pi6');
		$smarty->setCompileDir(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/res/smarty/templates_c');
		$smarty->setCacheDir(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/res/smarty/cache');
		$smarty->setConfigDir(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/res/smarty/configs');
Jerome Mariette's avatar
Jerome Mariette committed
89
90
91
		$smarty->security = true;
		$smarty->security_settings['MODIFIER_FUNCS'] = array('count');

Jerome Mariette's avatar
Jerome Mariette committed
92
		$group_list = tx_nG6_db::get_group_list();		
gsalin's avatar
#213    
gsalin committed
93
94
95
		$smarty->assign('login_user', $user_namer);
		$smarty->assign('user_id', $user_id);
		$smarty->assign('user_name', $user_namer);
Jerome Mariette's avatar
Jerome Mariette committed
96
97
		$smarty->assign('group_list', $group_list);
		$smarty->assign('data_folder', $this->conf["data"]);
98
		$smarty->assign('server_url', $this->conf['server_url']);
99
        $smarty->assign('server_name', $this->conf["server_name"]);
100
                
101
102
		$distribution = tx_nG6_db::select_projects_repartition('create_user', 'title');
		$smarty->assign('distribution', $distribution);
Penom Nom's avatar
Penom Nom committed
103
		$smarty->assign('ng6_admin_users', tx_nG6_db::get_ng6_admin_users() );
104
105
		
		$smarty->assign('ng6_superadmin_users', tx_nG6_db::get_ng6_superadmin_users() );
gsalin's avatar
#213    
gsalin committed
106
		$smarty->assign('is_current_user_superadmin', tx_nG6_db::is_user_ng6_superadmin($user_id) );
Romain Therville's avatar
Romain Therville committed
107
		$smarty->assign('available_space_ids', tx_nG6_utils::get_available_space_ids());
Romain Therville's avatar
Romain Therville committed
108
109
        $smarty->assign('tx_nG6_pi6_redirection_page',$this->conf['redirection_page']);
        
110
		$smarty->assign('ng6_purge_delay',$this->conf['delay_purge']);
Jerome Mariette's avatar
Jerome Mariette committed
111
112
		return $smarty->fetch('administration_view.tpl');
	}
113
        
gsalin's avatar
gsalin committed
114
   
Jerome Mariette's avatar
Jerome Mariette committed
115
116
117
118
119
120
}

if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/nG6/pi6/class.tx_nG6_pi6.php'])	{
	include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/nG6/pi6/class.tx_nG6_pi6.php']);
}

121
?>