fixed a few bugs
[Packages/TYPO3.CMS.git] / typo3 / alt_menu.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2003 Kasper Skaarhoj (kasper@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Displays the vertical menu in the left most frame of TYPO3s backend
29 *
30 * $Id$
31 * Revised for TYPO3 3.6 2/2003 by Kasper Skaarhoj
32 * XHTML-trans compliant
33 *
34 * @author Kasper Skaarhoj <kasper@typo3.com>
35 */
36 /**
37 * [CLASS/FUNCTION INDEX of SCRIPT]
38 *
39 *
40 *
41 * 79: class SC_alt_menu
42 * 90: function init()
43 * 106: function main()
44 * 191: function removeCacheFiles()
45 * 210: function printContent()
46 *
47 * TOTAL FUNCTIONS: 4
48 * (This index is automatically created/updated by the extension "extdeveval")
49 *
50 */
51
52
53 require ('init.php');
54 require ('template.php');
55 require_once (PATH_t3lib.'class.t3lib_loadmodules.php');
56 require_once (PATH_t3lib.'class.t3lib_basicfilefunc.php');
57 require_once ('class.alt_menu_functions.inc');
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72 /**
73 * Script Class for rendering the vertical menu in the left side of the backend frameset
74 *
75 * @author Kasper Skaarhoj <kasper@typo3.com>
76 * @package TYPO3
77 * @subpackage core
78 */
79 class SC_alt_menu {
80
81 // Internal, Static: GPvar
82 var $_clearCacheFiles;
83
84 /**
85 * Initialize
86 * Loads the backend modules available for the logged in user.
87 *
88 * @return void
89 */
90 function init() {
91 global $TBE_MODULES;
92
93 // Setting GPvars:
94 $this->_clearCacheFiles = t3lib_div::GPvar('_clearCacheFiles');
95
96 // Loads the backend modules available for the logged in user.
97 $this->loadModules = t3lib_div::makeInstance('t3lib_loadModules');
98 $this->loadModules->load($TBE_MODULES);
99 }
100
101 /**
102 * Main content generated
103 *
104 * @return void
105 */
106 function main() {
107 global $BE_USER,$TYPO3_CONF_VARS,$TBE_TEMPLATE,$TYPO_VERSION;
108
109 $TBE_TEMPLATE->docType='xhtml_trans';
110 $TBE_TEMPLATE->divClass='vertical-menu';
111 $this->content.=$TBE_TEMPLATE->startPage('Vertical Backend Menu');
112
113 // Printing the menu
114 $alt_menuObj = t3lib_div::makeInstance('alt_menu_functions');
115 $this->content.=$alt_menuObj->topMenu($this->loadModules->modules);
116
117 // clear cache commands for Admins
118 if($BE_USER->isAdmin()) {
119 $this->content.='
120
121 <!--
122 Menu with admin functions: Clearing cache:
123 -->
124 <div id="typo3-alt-menu-php-adminFunc">';
125
126 // Header: Admin functions
127 $this->content.='<h2 class="bgColor5">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.adminFunctions',1).'</h2>';
128
129 // Table with those admin functions
130 $this->content.='
131 <table border="0" cellpadding="0" cellspacing="1" width="100%">';
132
133 // Clearing of cache-files in typo3conf/ + menu
134 if ($TYPO3_CONF_VARS['EXT']['extCache']) {
135 if ($this->_clearCacheFiles) {
136 $this->removeCacheFiles();
137 }
138 $this->content.='
139 <tr>
140 <td valign="top" align="center"><img'.t3lib_iconWorks::skinImg($backPath,'gfx/clear_cache_files_in_typo3c.gif','width="21" height="18"').' alt="" /></td>
141 <td><a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('_clearCacheFiles'=>1))).'">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_allTypo3Conf',1).'</a></td>
142 </tr>';
143
144 // Divider
145 $this->content.='
146 <tr>
147 <td colspan="2"><img'.t3lib_iconWorks::skinImg($backPath,'gfx/altmenuline.gif','width="105" height="3"').' alt="" /></td>
148 </tr>';
149 }
150
151 // clear all page cache
152 $href = htmlspecialchars($this->backPath.'tce_db.php?vC='.$BE_USER->veriCode().
153 '&redirect='.rawurlencode(t3lib_div::getIndpEnv('TYPO3_REQUEST_SCRIPT')).
154 '&cacheCmd=all'
155 );
156 $this->content.='
157 <tr>
158 <td valign="top" align="center"><img'.t3lib_iconWorks::skinImg($backPath,'gfx/clear_all_cache.gif','width="21" height="18"').' alt="" /></td>
159 <td><a href="'.$href.'">'.
160 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_all',1).
161 '</a></td>
162 </tr>';
163
164 $this->content.='
165 </table>';
166 $this->content.='
167 </div>
168 ';
169 }
170
171 // Printing bottons (logout button)
172 $this->content.='
173
174
175 <!--
176 Logout button / username
177 -->
178 <div id="typo3-alt-menu-php-logininfo">'.$alt_menuObj->topButtons().
179 '<p id="username">['.htmlspecialchars($BE_USER->user['username']).']</p>
180 </div>';
181
182 // End page:
183 $this->content.=$TBE_TEMPLATE->endPage();
184 }
185
186 /**
187 * Unlink (delete) cache files
188 *
189 * @return integer The number of files deleted
190 */
191 function removeCacheFiles() {
192 $cacheFiles=t3lib_extMgm::currentCacheFiles();
193 $out=0;
194 if (is_array($cacheFiles)) {
195 reset($cacheFiles);
196 while(list(,$cfile)=each($cacheFiles)) {
197 @unlink($cfile);
198 clearstatcache();
199 $out++;
200 }
201 }
202 return $out;
203 }
204
205 /**
206 * Outputting the accumulated content to screen
207 *
208 * @return void
209 */
210 function printContent() {
211 echo $this->content;
212 }
213 }
214
215 // Include extension?
216 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_menu.php']) {
217 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_menu.php']);
218 }
219
220
221
222
223
224
225
226
227
228
229
230
231 // Make instance:
232 $SOBE = t3lib_div::makeInstance('SC_alt_menu');
233 $SOBE->init();
234 $SOBE->main();
235 $SOBE->printContent();
236 ?>