Only changes to function indexes, comments and stripping of trailing whitespace in...
[Packages/TYPO3.CMS.git] / typo3 / alt_main.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2004 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 * Main frameset of the TYPO3 backend
29 *
30 * $Id$
31 * Revised for TYPO3 3.6 2/2003 by Kasper Skaarhoj
32 * XHTML Compliant (almost)
33 *
34 * @author Kasper Skaarhoj <kasper@typo3.com>
35 */
36 /**
37 * [CLASS/FUNCTION INDEX of SCRIPT]
38 *
39 *
40 *
41 * 67: class SC_alt_main
42 * 86: function init()
43 * 108: function generateJScode()
44 * 305: function main()
45 * 379: function printContent()
46 *
47 * TOTAL FUNCTIONS: 4
48 * (This index is automatically created/updated by the extension "extdeveval")
49 *
50 */
51
52 require ('init.php');
53 require ('template.php');
54 require_once (PATH_t3lib.'class.t3lib_loadmodules.php');
55 require_once (PATH_t3lib.'class.t3lib_basicfilefunc.php');
56 require_once ('class.alt_menu_functions.inc');
57
58
59
60 /**
61 * Script Class for rendering of the main frameset for the TYPO3 backend.
62 *
63 * @author Kasper Skaarhoj <kasper@typo3.com>
64 * @package TYPO3
65 * @subpackage core
66 */
67 class SC_alt_main {
68
69 // Internal, dynamic:
70 var $content;
71 var $mainJScode;
72 var $loadModules; // Load modules-object
73 var $alt_menuObj; // Menu functions object.
74
75 // Internal, static:
76 var $leftMenuFrameW = 130;
77 var $selMenuFrame = 130;
78 var $topFrameH = 32;
79 var $shortcutFrameH = 30;
80
81 /**
82 * Initialization of the script class
83 *
84 * @return void
85 */
86 function init() {
87 global $TBE_MODULES,$TBE_STYLES;
88
89 // Initializes the backend modules structure for use later.
90 $this->loadModules = t3lib_div::makeInstance('t3lib_loadModules');
91 $this->loadModules->load($TBE_MODULES);
92
93 // Instantiates thee menu object which will generate some JavaScript for the goToModule() JS function in this frameset.
94 $this->alt_menuObj = t3lib_div::makeInstance('alt_menu_functions');
95
96 // Check for distances defined in the styles array:
97 if ($TBE_STYLES['dims']['leftMenuFrameW']) $this->leftMenuFrameW = $TBE_STYLES['dims']['leftMenuFrameW'];
98 if ($TBE_STYLES['dims']['topFrameH']) $this->topFrameH = $TBE_STYLES['dims']['topFrameH'];
99 if ($TBE_STYLES['dims']['shortcutFrameH']) $this->shortcutFrameH = $TBE_STYLES['dims']['shortcutFrameH'];
100 if ($TBE_STYLES['dims']['selMenuFrame']) $this->selMenuFrame = $TBE_STYLES['dims']['selMenuFrame'];
101 }
102
103 /**
104 * Generates the JavaScript code for the frameset.
105 *
106 * @return void
107 */
108 function generateJScode() {
109 global $BE_USER,$LANG;
110
111 $pt3=t3lib_div::dirname(t3lib_div::getIndpEnv('SCRIPT_NAME')).'/';
112 $goToModule_switch = $this->alt_menuObj->topMenu($this->loadModules->modules,0,"",4);
113 $fsMod = implode(chr(10),$this->alt_menuObj->fsMod);
114
115 $this->mainJScode='
116 /**
117 * Function similar to PHPs rawurlencode();
118 */
119 function rawurlencode(str) { //
120 var output = escape(str);
121 output = str_replace("*","%2A", output);
122 output = str_replace("+","%2B", output);
123 output = str_replace("/","%2F", output);
124 output = str_replace("@","%40", output);
125 return output;
126 }
127
128 /**
129 * String-replace function
130 */
131 function str_replace(match,replace,string) { //
132 var input = ""+string;
133 var matchStr = ""+match;
134 if (!matchStr) {return string;}
135 var output = "";
136 var pointer=0;
137 var pos = input.indexOf(matchStr);
138 while (pos!=-1) {
139 output+=""+input.substr(pointer, pos-pointer)+replace;
140 pointer=pos+matchStr.length;
141 pos = input.indexOf(match,pos+1);
142 }
143 output+=""+input.substr(pointer);
144 return output;
145 }
146
147 /**
148 * TypoSetup object.
149 */
150 function typoSetup() { //
151 this.PATH_typo3 = "'.$pt3.'";
152 this.username = "'.$BE_USER->user['username'].'";
153 this.uniqueID = "'.t3lib_div::shortMD5(uniqid('')).'";
154 this.navFrameWidth = 0;
155 }
156 var TS = new typoSetup();
157
158 /**
159 * Functions for session-expiry detection:
160 */
161 function busy() { //
162 this.loginRefreshed = busy_loginRefreshed;
163 this.checkLoginTimeout = busy_checkLoginTimeout;
164 this.openRefreshWindow = busy_OpenRefreshWindow;
165 this.busyloadTime=0;
166 this.openRefreshW=0;
167 }
168 function busy_loginRefreshed() { //
169 var date = new Date();
170 this.busyloadTime = Math.floor(date.getTime()/1000);
171 this.openRefreshW=0;
172 }
173 function busy_checkLoginTimeout() { //
174 var date = new Date();
175 var theTime = Math.floor(date.getTime()/1000);
176 if (theTime > this.busyloadTime+'.intval($BE_USER->auth_timeout_field).'-10) {
177 return true;
178 }
179 }
180 function busy_OpenRefreshWindow() { //
181 vHWin=window.open("login_frameset.php","relogin","height=350,width=700,status=0,menubar=0");
182 vHWin.focus();
183 this.openRefreshW=1;
184 }
185 function busy_checkLoginTimeout_timer() { //
186
187 if (busy.checkLoginTimeout()) {
188 if (!busy.openRefreshW && confirm('.$GLOBALS['LANG']->JScharCode($LANG->sL('LLL:EXT:lang/locallang_core.php:mess.refresh_login')).')) {
189 busy.openRefreshWindow();
190 }
191 }
192 window.setTimeout("busy_checkLoginTimeout_timer();",2*1000); // Each 2nd second is enough for checking. The popup will be triggered 10 seconds before the login expires (see above, busy_checkLoginTimeout())
193
194 // Detecting the frameset module navigation frame widths (do this AFTER setting new timeout so that any errors in the code below does not prevent another time to be set!)
195 if (top && top.content && top.content.nav_frame && top.content.nav_frame.document && top.content.nav_frame.document.body) {
196 TS.navFrameWidth = (top.content.nav_frame.document.documentElement && top.content.nav_frame.document.documentElement.clientWidth) ? top.content.nav_frame.document.documentElement.clientWidth : top.content.nav_frame.document.body.clientWidth;
197 }
198 }
199
200 /**
201 * Launcing information window for records/files (fileref as "table" argument)
202 */
203 function launchView(table,uid,bP) { //
204 var backPath= bP ? bP : "";
205 var thePreviewWindow="";
206 thePreviewWindow = window.open(TS.PATH_typo3+"show_item.php?table="+escape(table)+"&uid="+escape(uid),"ShowItem"+TS.uniqueID,"height=300,width=410,status=0,menubar=0,resizable=0,location=0,directories=0,scrollbars=1,toolbar=0");
207 if (thePreviewWindow && thePreviewWindow.focus) {
208 thePreviewWindow.focus();
209 }
210 }
211
212 /**
213 * Opens plain window with url
214 */
215 function openUrlInWindow(url,windowName) { //
216 regularWindow = window.open(url,windowName,"status=1,menubar=1,resizable=1,location=1,directories=0,scrollbars=1,toolbar=1");
217 regularWindow.focus();
218 return false;
219 }
220
221 /**
222 * Loads a URL in the topmenuFrame
223 */
224 function loadTopMenu(url) { //
225 top.topmenuFrame.location = url;
226 }
227
228 /**
229 * Returns incoming URL (to a module) unless nextLoadModuleUrl is set. If that is the case nextLoadModuleUrl is returned (and cleared)
230 * Used by the shortcut frame to set a "intermediate URL"
231 */
232 var nextLoadModuleUrl="";
233 function getModuleUrl(inUrl) { //
234 var nMU;
235 if (top.nextLoadModuleUrl) {
236 nMU=top.nextLoadModuleUrl;
237 top.nextLoadModuleUrl="";
238 return nMU;
239 } else {
240 return inUrl;
241 }
242 }
243
244 /**
245 * Print properties of an object
246 */
247 function debugObj(obj,name) { //
248 var acc;
249 for (i in obj) {
250 if (obj[i]) {
251 acc+=i+": "+obj[i]+"\n";
252 }
253 }
254 alert("Object: "+name+"\n\n"+acc);
255 }
256
257 /**
258 * Initialize login expiration warning object
259 */
260 var busy = new busy();
261 busy.loginRefreshed();
262 busy_checkLoginTimeout_timer();
263
264 /**
265 * Function used to switch switch module.
266 */
267 var currentModuleLoaded = "";
268 function goToModule(modName,cMR_flag) { //
269 var cMR = 0;
270 if (cMR_flag) cMR=1;
271
272 currentModuleLoaded=modName;
273
274 switch(modName) {'.$goToModule_switch.'
275 }
276 }
277
278 /**
279 * Frameset Module object
280 *
281 * Used in main modules with a frameset for submodules to keep the ID between modules
282 * Typically that is set by something like this in a Web>* sub module:
283 * if (top.fsMod) top.fsMod.recentIds["web"] = "\'.intval($this->id).\'";
284 * if (top.fsMod) top.fsMod.recentIds["file"] = "...(file reference/string)...";
285 */
286 function fsModules() { //
287 this.recentIds=new Array(); // used by frameset modules to track the most recent used id for list frame.
288 this.navFrameHighlightedID=new Array(); // used by navigation frames to track which row id was highlighted last time
289 this.currentMainLoaded="";
290 }
291 var fsMod = new fsModules();
292 '.$fsMod.'
293
294 // Used by Frameset Modules
295 var condensedMode = '.($BE_USER->uc['condensedMode']?1:0).';
296 var currentSubScript = "";
297 ';
298 }
299
300 /**
301 * Creates the header and frameset of the backend interface
302 *
303 * @return void
304 */
305 function main() {
306 global $BE_USER,$TYPO3_CONF_VARS,$TYPO_VERSION;
307
308 // Set doktype:
309 $GLOBALS['TBE_TEMPLATE']->docType='xhtml_frames';
310
311 // Make JS:
312 $this->generateJScode();
313 $GLOBALS['TBE_TEMPLATE']->JScode= '
314 <script type="text/javascript" src="md5.js"></script>
315 <script type="text/javascript" src="t3lib/jsfunc.evalfield.js"></script>
316 ';
317 $GLOBALS['TBE_TEMPLATE']->JScode.=$GLOBALS['TBE_TEMPLATE']->wrapScriptTags($this->mainJScode);
318
319 // Title:
320 $title = $TYPO3_CONF_VARS['SYS']['sitename'] ? $TYPO3_CONF_VARS['SYS']['sitename'].' [TYPO3 '.$TYPO_VERSION.']' : 'TYPO3 '.$TYPO_VERSION;
321
322 // Start page header:
323 $this->content.=$GLOBALS['TBE_TEMPLATE']->startPage($title);
324
325 // Creates frameset
326 $fr_content = '<frame name="content" src="'.($BE_USER->uc['startInTaskCenter']&&t3lib_extMgm::isLoaded('taskcenter')?t3lib_extMgm::extRelPath('taskcenter').'task/frameset.php':'alt_intro.php').'" marginwidth="0" marginheight="0" frameborder="0" scrolling="auto" noresize="noresize" />';
327 $fr_toplogo = '<frame name="toplogo" src="alt_toplogo.php" marginwidth="0" marginheight="0" frameborder="0" scrolling="no" noresize="noresize" />';
328 $fr_topmenu = '<frame name="topmenuFrame" src="alt_topmenu_dummy.php" marginwidth="0" marginheight="0" frameborder="0" scrolling="no" noresize="noresize" />';
329
330 $shortcutFrame=array();
331 if ($BE_USER->getTSConfigVal('options.shortcutFrame')) {
332 $shortcutFrame['rowH']=','.$this->shortcutFrameH;
333 $shortcutFrame['frameDef']='<frame name="shortcutFrame" src="alt_shortcut.php" marginwidth="0" marginheight="0" frameborder="0" scrolling="no" noresize="noresize" />';
334 }
335
336 // XHTML notice: ' framespacing="0" frameborder="0" border="0"' in FRAMESET elements breaks compatibility with XHTML-frames, but HOW ELSE can I control the visual appearance?
337 if ($GLOBALS['BE_USER']->uc['noMenuMode']) {
338 $this->content.= '
339 <frameset rows="'.$this->topFrameH.',*'.$shortcutFrame['rowH'].'" framespacing="0" frameborder="0" border="0">
340 '.(!strcmp($BE_USER->uc['noMenuMode'],'icons') ? '
341 <frameset cols="'.$this->leftMenuFrameW.',*" framespacing="0" frameborder="0" border="0">
342 '.$fr_toplogo.'
343 '.$fr_topmenu.'
344 </frameset>' : '
345 <frameset cols="'.$this->leftMenuFrameW.','.$this->selMenuFrame.',*" framespacing="0" frameborder="0" border="0">
346 '.$fr_toplogo.'
347 <frame name="menu" src="alt_menu_sel.php" scrolling="no" noresize="noresize" />
348 '.$fr_topmenu.'
349 </frameset>').'
350 '.$fr_content.'
351 '.$shortcutFrame['frameDef'].'
352 </frameset>
353 ';
354 } else {
355 $this->content.='
356 <frameset rows="'.$this->topFrameH.',*'.$shortcutFrame['rowH'].'" framespacing="0" frameborder="0" border="0">
357 <frameset cols="'.$this->leftMenuFrameW.',*" framespacing="0" frameborder="0" border="0">
358 '.$fr_toplogo.'
359 '.$fr_topmenu.'
360 </frameset>
361 <frameset cols="'.$this->leftMenuFrameW.',*" framespacing="0" frameborder="0" border="0">
362 <frame name="menu" src="alt_menu.php" marginwidth="0" marginheight="0" scrolling="auto" noresize="noresize" />
363 '.$fr_content.'
364 </frameset>
365 '.$shortcutFrame['frameDef'].'
366 </frameset>
367 ';
368 }
369 $this->content.='
370
371 </html>';
372 }
373
374 /**
375 * Outputting the accumulated content to screen
376 *
377 * @return void
378 */
379 function printContent() {
380 echo $this->content;
381 }
382 }
383
384 // Include extension?
385 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_main.php']) {
386 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_main.php']);
387 }
388
389
390
391
392
393
394
395
396
397
398
399 // ******************************
400 // Starting document output
401 // ******************************
402
403 // Make instance:
404 $SOBE = t3lib_div::makeInstance('SC_alt_main');
405 $SOBE->init();
406 $SOBE->main();
407 $SOBE->printContent();
408 ?>