Tons of changes made to the CORE. All scripts has more a less been modified. Primaril...
[Packages/TYPO3.CMS.git] / typo3 / alt_main.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 * 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 * 288: function main()
45 * 362: 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 }
155 var TS = new typoSetup();
156
157 /**
158 * Functions for session-expiry detection:
159 */
160 function busy() { //
161 this.loginRefreshed = busy_loginRefreshed;
162 this.checkLoginTimeout = busy_checkLoginTimeout;
163 this.openRefreshWindow = busy_OpenRefreshWindow;
164 this.busyloadTime=0;
165 this.openRefreshW=0;
166 }
167 function busy_loginRefreshed() { //
168 var date = new Date();
169 this.busyloadTime = Math.floor(date.getTime()/1000);
170 this.openRefreshW=0;
171 }
172 function busy_checkLoginTimeout() { //
173 var date = new Date();
174 var theTime = Math.floor(date.getTime()/1000);
175 if (theTime > this.busyloadTime+'.intval($BE_USER->auth_timeout_field).'-10) {
176 return true;
177 }
178 }
179 function busy_OpenRefreshWindow() { //
180 vHWin=window.open("login_frameset.php","relogin","height=350,width=700,status=0,menubar=0");
181 vHWin.focus();
182 this.openRefreshW=1;
183 }
184 function busy_checkLoginTimeout_timer() { //
185 if (busy.checkLoginTimeout()) {
186 if (!busy.openRefreshW && confirm('.$GLOBALS['LANG']->JScharCode($LANG->sL('LLL:EXT:lang/locallang_core.php:mess.refresh_login')).')) {
187 busy.openRefreshWindow();
188 }
189 }
190 window.setTimeout("busy_checkLoginTimeout_timer();",5*1000); // Each 5th second is enough for checking. The popup will be triggered 10 seconds before the login expires (see above, busy_checkLoginTimeout())
191 }
192
193 /**
194 * Launcing information window for records/files (fileref as "table" argument)
195 */
196 function launchView(table,uid,bP) { //
197 var backPath= bP ? bP : "";
198 var thePreviewWindow="";
199 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");
200 if (thePreviewWindow && thePreviewWindow.focus) {
201 thePreviewWindow.focus();
202 }
203 }
204
205 /**
206 * Opens plain window with url
207 */
208 function openUrlInWindow(url,windowName) { //
209 regularWindow = window.open(url,windowName,"status=1,menubar=1,resizable=1,location=1,directories=0,scrollbars=1,toolbar=1");
210 regularWindow.focus();
211 return false;
212 }
213
214 /**
215 * Loads a URL in the topmenuFrame
216 */
217 function loadTopMenu(url) { //
218 top.topmenuFrame.location = url;
219 }
220
221 /**
222 * Returns incoming URL (to a module) unless nextLoadModuleUrl is set. If that is the case nextLoadModuleUrl is returned (and cleared)
223 * Used by the shortcut frame to set a "intermediate URL"
224 */
225 var nextLoadModuleUrl="";
226 function getModuleUrl(inUrl) { //
227 var nMU;
228 if (top.nextLoadModuleUrl) {
229 nMU=top.nextLoadModuleUrl;
230 top.nextLoadModuleUrl="";
231 return nMU;
232 } else {
233 return inUrl;
234 }
235 }
236
237 /**
238 * Print properties of an object
239 */
240 function debugObj(obj,name) { //
241 var acc;
242 for (i in obj) {
243 if (obj[i]) {
244 acc+=i+": "+obj[i]+"\n";
245 }
246 }
247 alert("Object: "+name+"\n\n"+acc);
248 }
249
250 /**
251 * Initialize login expiration warning object
252 */
253 var busy = new busy();
254 busy.loginRefreshed();
255 busy_checkLoginTimeout_timer();
256
257 /**
258 * Function used to switch switch module.
259 */
260 var currentModuleLoaded = "";
261 function goToModule(modName,cMR_flag) { //
262 var cMR = 0;
263 if (cMR_flag) cMR=1;
264
265 currentModuleLoaded=modName;
266
267 switch(modName) {'.$goToModule_switch.'
268 }
269 }
270
271 /**
272 * Frameset Module object
273 *
274 * Used in main modules with a frameset for submodules to keep the ID between modules
275 * Typically that is set by something like this in a Web>* sub module:
276 * if (top.fsMod) top.fsMod.recentIds["web"] = "\'.intval($this->id).\'";
277 * if (top.fsMod) top.fsMod.recentIds["file"] = "...(file reference/string)...";
278 */
279 function fsModules() { //
280 this.recentIds=new Array(); // used by frameset modules to track the most recent used id for list frame.
281 this.navFrameHighlightedID=new Array(); // used by navigation frames to track which row id was highlighted last time
282 this.currentMainLoaded="";
283 }
284 var fsMod = new fsModules();
285 '.$fsMod.'
286
287 // Used by Frameset Modules
288 var condensedMode = '.($BE_USER->uc['condensedMode']?1:0).';
289 var currentSubScript = "";
290 ';
291 }
292
293 /**
294 * Creates the header and frameset of the backend interface
295 *
296 * @return void
297 */
298 function main() {
299 global $BE_USER,$TYPO3_CONF_VARS,$TYPO_VERSION;
300
301 // Set doktype:
302 $GLOBALS['TBE_TEMPLATE']->docType='xhtml_frames';
303
304 // Make JS:
305 $this->generateJScode();
306 $GLOBALS['TBE_TEMPLATE']->JScode= '
307 <script type="text/javascript" src="md5.js"></script>
308 <script type="text/javascript" src="t3lib/jsfunc.evalfield.js"></script>
309 ';
310 $GLOBALS['TBE_TEMPLATE']->JScode.=$GLOBALS['TBE_TEMPLATE']->wrapScriptTags($this->mainJScode);
311
312 // Title:
313 $title = $TYPO3_CONF_VARS['SYS']['sitename'] ? $TYPO3_CONF_VARS['SYS']['sitename'].' [TYPO3 '.$TYPO_VERSION.']' : 'TYPO3 '.$TYPO_VERSION;
314
315 // Start page header:
316 $this->content.=$GLOBALS['TBE_TEMPLATE']->startPage($title);
317
318 // Creates frameset
319 $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" />';
320 $fr_toplogo = '<frame name="toplogo" src="alt_toplogo.php" marginwidth="0" marginheight="0" frameborder="0" scrolling="no" noresize="noresize" />';
321 $fr_topmenu = '<frame name="topmenuFrame" src="alt_topmenu_dummy.php" marginwidth="0" marginheight="0" frameborder="0" scrolling="no" noresize="noresize" />';
322
323 $shortcutFrame=array();
324 if ($BE_USER->getTSConfigVal('options.shortcutFrame')) {
325 $shortcutFrame['rowH']=','.$this->shortcutFrameH;
326 $shortcutFrame['frameDef']='<frame name="shortcutFrame" src="alt_shortcut.php" marginwidth="0" marginheight="0" frameborder="0" scrolling="no" noresize="noresize" />';
327 }
328
329 // 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?
330 if ($GLOBALS['BE_USER']->uc['noMenuMode']) {
331 $this->content.= '
332 <frameset rows="'.$this->topFrameH.',*'.$shortcutFrame['rowH'].'" framespacing="0" frameborder="0" border="0">
333 '.(!strcmp($BE_USER->uc['noMenuMode'],'icons') ? '
334 <frameset cols="'.$this->leftMenuFrameW.',*" framespacing="0" frameborder="0" border="0">
335 '.$fr_toplogo.'
336 '.$fr_topmenu.'
337 </frameset>' : '
338 <frameset cols="'.$this->leftMenuFrameW.','.$this->selMenuFrame.',*" framespacing="0" frameborder="0" border="0">
339 '.$fr_toplogo.'
340 <frame name="menu" src="alt_menu_sel.php" scrolling="no" noresize="noresize" />
341 '.$fr_topmenu.'
342 </frameset>').'
343 '.$fr_content.'
344 '.$shortcutFrame['frameDef'].'
345 </frameset>
346 ';
347 } else {
348 $this->content.='
349 <frameset rows="'.$this->topFrameH.',*'.$shortcutFrame['rowH'].'" framespacing="0" frameborder="0" border="0">
350 <frameset cols="'.$this->leftMenuFrameW.',*" framespacing="0" frameborder="0" border="0">
351 '.$fr_toplogo.'
352 '.$fr_topmenu.'
353 </frameset>
354 <frameset cols="'.$this->leftMenuFrameW.',*" framespacing="0" frameborder="0" border="0">
355 <frame name="menu" src="alt_menu.php" marginwidth="0" marginheight="0" scrolling="auto" noresize="noresize" />
356 '.$fr_content.'
357 </frameset>
358 '.$shortcutFrame['frameDef'].'
359 </frameset>
360 ';
361 }
362 $this->content.='
363
364 </html>';
365 }
366
367 /**
368 * Outputting the accumulated content to screen
369 *
370 * @return void
371 */
372 function printContent() {
373 echo $this->content;
374 }
375 }
376
377 // Include extension?
378 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_main.php']) {
379 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_main.php']);
380 }
381
382
383
384
385
386
387
388
389
390
391
392 // ******************************
393 // Starting document output
394 // ******************************
395
396 // Make instance:
397 $SOBE = t3lib_div::makeInstance('SC_alt_main');
398 $SOBE->init();
399 $SOBE->main();
400 $SOBE->printContent();
401 ?>