Initial revision
[Packages/TYPO3.CMS.git] / typo3 / alt_menu.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2003 Kasper Skårhøj (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 * @author Kasper Skårhøj <kasper@typo3.com>
31 * @package TYPO3
32 * @subpackage core
33 *
34 * Revised for TYPO3 3.6 2/2003 by Kasper Skårhøj
35 * XHTML-trans compliant
36 */
37
38
39 require ('init.php');
40 require ('template.php');
41 require_once (PATH_t3lib.'class.t3lib_loadmodules.php');
42 require_once (PATH_t3lib.'class.t3lib_basicfilefunc.php');
43 require_once ('class.alt_menu_functions.inc');
44
45
46 // ***************************
47 // Script Class
48 // ***************************
49 class SC_alt_menu {
50
51 /**
52 * Initialize
53 * Loads the backend modules available for the logged in user.
54 */
55 function init() {
56 global $TBE_MODULES;
57
58 // Loads the backend modules available for the logged in user.
59 $this->loadModules = t3lib_div::makeInstance('t3lib_loadModules');
60 $this->loadModules->load($TBE_MODULES);
61 }
62
63 /**
64 * Main content generated
65 */
66 function main() {
67 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$HTTP_GET_VARS,$HTTP_POST_VARS,$CLIENT,$TYPO3_CONF_VARS;
68 global $TBE_TEMPLATE,$TYPO_VERSION;
69
70 $TBE_TEMPLATE->docType='xhtml_trans';
71 $TBE_TEMPLATE->divClass='vertical-menu';
72 $this->content.=$TBE_TEMPLATE->startPage('Vertical Backend Menu');
73
74 // Printing the menu
75 $alt_menuObj = t3lib_div::makeInstance('alt_menu_functions');
76 $this->content.=$alt_menuObj->topMenu($this->loadModules->modules);
77
78 // clear cache commands for Admins
79 if($BE_USER->isAdmin()) {
80 $this->content.='
81
82
83 <div align="left" style="width:110px; margin-top: 15px;">';
84
85 // Header: Admin functions
86 $this->content.='<h2 style="background-color: '.$TBE_TEMPLATE->bgColor5.';">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.adminFunctions',1).'</h2>';
87
88 // Table with those admin functions
89 $this->content.='<table border="0" cellpadding="0" cellspacing="1" width="100%">';
90
91 // Clearing of cache-files in typo3conf/ + menu
92 if ($TYPO3_CONF_VARS['EXT']['extCache']) {
93 if (t3lib_div::GPvar('_clearCacheFiles')) {
94 $this->removeCacheFiles();
95 }
96 $this->content.='<tr>
97 <td valign="top" align="center"><img src="'.$backPath.'mod/tools/em/em.gif" border="0" width="14" height="12" hspace="2" alt="" /></td>
98 <td><a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('_clearCacheFiles'=>1))).'">Clear cache files in typo3conf/</a></td>
99 </tr>';
100
101 // Divider
102 $this->content.='<tr>
103 <td colspan="2"><img src="'.$backPath.'gfx/altmenuline.gif" border="0" width="105" height="3" vspace="1" alt="" /></td>
104 </tr>';
105 }
106
107 // clear all page cache
108 $href = htmlspecialchars($this->backPath.'tce_db.php?vC='.$BE_USER->veriCode().
109 '&redirect='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')).
110 '&cacheCmd=all'
111 );
112 $this->content.='<tr>
113 <td valign="top" align="center"><img src="'.$backPath.'sysext/cms/layout/layout.gif" border="0" width="14" height="12" hspace="2" alt="" /></td>
114 <td><a href="'.$href.'">'.
115 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_all',1).
116 '</a></td>
117 </tr>';
118
119 $this->content.='</table>';
120 $this->content.='
121 </div>
122 ';
123 }
124
125 // Printing bottons (logout button)
126 $this->content.='<div align="center" style="width: 110px; margin-top:15px;">'.$alt_menuObj->topButtons().
127 '<br />['.htmlspecialchars($BE_USER->user['username']).']</div>';
128
129 // End page:
130 $this->content.=$TBE_TEMPLATE->endPage();
131 }
132
133 /**
134 * Unlink (delete) cache files
135 */
136 function removeCacheFiles() {
137 $cacheFiles=t3lib_extMgm::currentCacheFiles();
138 $out=0;
139 if (is_array($cacheFiles)) {
140 reset($cacheFiles);
141 while(list(,$cfile)=each($cacheFiles)) {
142 @unlink($cfile);
143 clearstatcache();
144 $out++;
145 }
146 }
147 return $out;
148 }
149
150 /**
151 * Outputs the content
152 */
153 function printContent() {
154 echo $this->content;
155 }
156 }
157
158 // Include extension?
159 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_menu.php']) {
160 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_menu.php']);
161 }
162
163
164
165
166
167
168
169
170
171
172
173
174 // Make instance:
175 $SOBE = t3lib_div::makeInstance('SC_alt_menu');
176 $SOBE->init();
177 $SOBE->main();
178 $SOBE->printContent();
179 ?>