Documentation TYPO3 par Ameos

alt_main.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00055 require ('init.php');
00056 require ('template.php');
00057 require_once (PATH_t3lib.'class.t3lib_loadmodules.php');
00058 require_once (PATH_t3lib.'class.t3lib_basicfilefunc.php');
00059 require_once ('class.alt_menu_functions.inc');
00060 $LANG->includeLLFile('EXT:lang/locallang_misc.xml');
00061 
00062 
00063 
00064 
00072 class SC_alt_main {
00073 
00074                 // Internal, dynamic:
00075         var $content;
00076         var $mainJScode;
00077         var $loadModules;               // Load modules-object
00078         var $alt_menuObj;               // Menu functions object.
00079 
00080                 // Internal, static:
00081         var $leftMenuFrameW = 130;
00082         var $selMenuFrame = 130;
00083         var $topFrameH = 32;
00084         var $shortcutFrameH = 30;
00085 
00091         function init() {
00092                 global $TBE_MODULES,$TBE_STYLES;
00093 
00094                         // Initializes the backend modules structure for use later.
00095                 $this->loadModules = t3lib_div::makeInstance('t3lib_loadModules');
00096                 $this->loadModules->load($TBE_MODULES);
00097 
00098                         // Instantiates thee menu object which will generate some JavaScript for the goToModule() JS function in this frameset.
00099                 $this->alt_menuObj = t3lib_div::makeInstance('alt_menu_functions');
00100 
00101                         // Check for distances defined in the styles array:
00102                 if ($TBE_STYLES['dims']['leftMenuFrameW'])              $this->leftMenuFrameW = $TBE_STYLES['dims']['leftMenuFrameW'];
00103                 if ($TBE_STYLES['dims']['topFrameH'])           $this->topFrameH = $TBE_STYLES['dims']['topFrameH'];
00104                 if ($TBE_STYLES['dims']['shortcutFrameH'])              $this->shortcutFrameH = $TBE_STYLES['dims']['shortcutFrameH'];
00105                 if ($TBE_STYLES['dims']['selMenuFrame'])                $this->selMenuFrame = $TBE_STYLES['dims']['selMenuFrame'];
00106         }
00107 
00113         function generateJScode()       {
00114                 global $BE_USER,$LANG;
00115 
00116                 $pt3 = t3lib_div::dirname(t3lib_div::getIndpEnv('SCRIPT_NAME')).'/';
00117                 $goToModule_switch = $this->alt_menuObj->topMenu($this->loadModules->modules,0,"",4);
00118                 $fsMod = implode(chr(10),$this->alt_menuObj->fsMod);
00119 
00120                         // If another page module was specified, replace the default Page module with the new one
00121                 $newPageModule = trim($GLOBALS['BE_USER']->getTSConfigVal('options.overridePageModule'));
00122                 $pageModule = t3lib_BEfunc::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
00123 
00124                 $this->mainJScode='
00128         function rawurlencode(str)      {       //
00129                 var output = escape(str);
00130                 output = str_replace("*","%2A", output);
00131                 output = str_replace("+","%2B", output);
00132                 output = str_replace("/","%2F", output);
00133                 output = str_replace("@","%40", output);
00134                 return output;
00135         }
00136 
00140         function str_replace(match,replace,string)      {       //
00141                 var input = ""+string;
00142                 var matchStr = ""+match;
00143                 if (!matchStr)  {return string;}
00144                 var output = "";
00145                 var pointer=0;
00146                 var pos = input.indexOf(matchStr);
00147                 while (pos!=-1) {
00148                         output+=""+input.substr(pointer, pos-pointer)+replace;
00149                         pointer=pos+matchStr.length;
00150                         pos = input.indexOf(match,pos+1);
00151                 }
00152                 output+=""+input.substr(pointer);
00153                 return output;
00154         }
00155 
00159         function typoSetup()    {       //
00160                 this.PATH_typo3 = "'.$pt3.'";
00161                 this.PATH_typo3_enc = "'.rawurlencode($pt3).'";
00162                 this.username = "'.$BE_USER->user['username'].'";
00163                 this.uniqueID = "'.t3lib_div::shortMD5(uniqid('')).'";
00164                 this.navFrameWidth = 0;
00165         }
00166         var TS = new typoSetup();
00167 
00171         function busy() {       //
00172                 this.loginRefreshed = busy_loginRefreshed;
00173                 this.checkLoginTimeout = busy_checkLoginTimeout;
00174                 this.openRefreshWindow = busy_OpenRefreshWindow;
00175                 this.busyloadTime=0;
00176                 this.openRefreshW=0;
00177                 this.reloginCancelled=0;
00178         }
00179         function busy_loginRefreshed()  {       //
00180                 var date = new Date();
00181                 this.busyloadTime = Math.floor(date.getTime()/1000);
00182                 this.openRefreshW=0;
00183         }
00184         function busy_checkLoginTimeout()       {       //
00185                 var date = new Date();
00186                 var theTime = Math.floor(date.getTime()/1000);
00187                 if (theTime > this.busyloadTime+'.intval($BE_USER->auth_timeout_field).'-30)    {
00188                         return true;
00189                 }
00190         }
00191         function busy_OpenRefreshWindow()       {       //
00192                 vHWin=window.open("login_frameset.php","relogin_"+TS.uniqueID,"height=350,width=700,status=0,menubar=0,location=1");
00193                 vHWin.focus();
00194                 this.openRefreshW=1;
00195         }
00196         function busy_checkLoginTimeout_timer() {       //
00197                 if (busy.checkLoginTimeout() && !busy.reloginCancelled && !busy.openRefreshW)   {
00198                         if (confirm('.$GLOBALS['LANG']->JScharCode($LANG->sL('LLL:EXT:lang/locallang_core.php:mess.refresh_login')).')) {
00199                                 busy.openRefreshWindow();
00200                         } else  {
00201                                 busy.reloginCancelled = 1;
00202                         }
00203                 }
00204                 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())
00205 
00206                         // 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!)
00207                 if (top && top.content && top.content.nav_frame && top.content.nav_frame.document && top.content.nav_frame.document.body)       {
00208                         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;
00209                 }
00210         }
00211 
00215         function launchView(table,uid,bP)       {       //
00216                 var backPath= bP ? bP : "";
00217                 var thePreviewWindow="";
00218                 thePreviewWindow = window.open(TS.PATH_typo3+"show_item.php?table="+encodeURIComponent(table)+"&uid="+encodeURIComponent(uid),"ShowItem"+TS.uniqueID,"height=400,width=550,status=0,menubar=0,resizable=0,location=0,directories=0,scrollbars=1,toolbar=0");
00219                 if (thePreviewWindow && thePreviewWindow.focus) {
00220                         thePreviewWindow.focus();
00221                 }
00222         }
00223 
00227         function openUrlInWindow(url,windowName)        {       //
00228                 regularWindow = window.open(url,windowName,"status=1,menubar=1,resizable=1,location=1,directories=0,scrollbars=1,toolbar=1");
00229                 regularWindow.focus();
00230                 return false;
00231         }
00232 
00236         function loadTopMenu(url)       {       //
00237                 top.topmenuFrame.location = url;
00238         }
00239 
00243         function loadEditId(id,addGetVars)      {       //
00244                 top.fsMod.recentIds["web"]=id;
00245                 top.fsMod.navFrameHighlightedID["web"]="pages"+id+"_0";         // For highlighting
00246 
00247                 if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav)  {
00248                         top.content.nav_frame.refresh_nav();
00249                 }
00250 
00251                 top.goToModule("'.$pageModule.'", 0, addGetVars?addGetVars:"");
00252         }
00253 
00258         var nextLoadModuleUrl="";
00259         function getModuleUrl(inUrl)    {       //
00260                 var nMU;
00261                 if (top.nextLoadModuleUrl)      {
00262                         nMU=top.nextLoadModuleUrl;
00263                         top.nextLoadModuleUrl="";
00264                         return nMU;
00265                 } else {
00266                         return inUrl;
00267                 }
00268         }
00269 
00273         function debugObj(obj,name)     {       //
00274                 var acc;
00275                 for (i in obj) {
00276                         if (obj[i])     {
00277                                 acc+=i+":  "+obj[i]+"\n";
00278                         }
00279                 }
00280                 alert("Object: "+name+"\n\n"+acc);
00281         }
00282 
00286         var busy = new busy();
00287         busy.loginRefreshed();
00288         busy_checkLoginTimeout_timer();
00289 
00290 
00294         var currentlyHighLightedId = "";
00295         var currentlyHighLighted_restoreValue = "";
00296         var currentlyHighLightedMain = "";
00297         function highlightModuleMenuItem(trId, mainModule)      {       //
00298                 currentlyHighLightedMain = mainModule;
00299                         // Get document object:
00300                 if (top.menu && top.menu.document)      {
00301                         var docObj = top.menu.document;
00302                         var HLclass = mainModule ? "c-mainitem-HL" : "c-subitem-row-HL";
00303                 } else if (top.topmenuFrame && top.topmenuFrame.document)       {
00304                         var docObj = top.topmenuFrame.document;
00305                         var HLclass = mainModule ? "c-mainitem-HL" : "c-subitem-HL";
00306                 }
00307 
00308                 if (docObj)     {
00309                                 // Reset old:
00310                         if (currentlyHighLightedId && docObj.getElementById(currentlyHighLightedId))    {
00311                                 docObj.getElementById(currentlyHighLightedId).attributes.getNamedItem("class").nodeValue = currentlyHighLighted_restoreValue;
00312                         }
00313                                 // Set new:
00314                         currentlyHighLightedId = trId;
00315                         if (currentlyHighLightedId && docObj.getElementById(currentlyHighLightedId))    {
00316                                 var classAttribObject = docObj.getElementById(currentlyHighLightedId).attributes.getNamedItem("class");
00317                                 currentlyHighLighted_restoreValue = classAttribObject.nodeValue;
00318                                 classAttribObject.nodeValue = HLclass;
00319                         }
00320                 }
00321         }
00322 
00326         function restoreHighlightedModuleMenuItem() {   //
00327                 if (currentlyHighLightedId) {
00328                         highlightModuleMenuItem(currentlyHighLightedId,currentlyHighLightedMain);
00329                 }
00330         }
00331 
00335         var currentModuleLoaded = "";
00336         function goToModule(modName,cMR_flag,addGetVars)        {       //
00337                 var additionalGetVariables = "";
00338                 if (addGetVars) additionalGetVariables = addGetVars;
00339 
00340                 var cMR = 0;
00341                 if (cMR_flag)   cMR = 1;
00342 
00343                 currentModuleLoaded = modName;
00344 
00345                 switch(modName) {'.$goToModule_switch.'
00346                 }
00347         }
00348 
00357         function fsModules()    {       //
00358                 this.recentIds=new Array();                                     // used by frameset modules to track the most recent used id for list frame.
00359                 this.navFrameHighlightedID=new Array();         // used by navigation frames to track which row id was highlighted last time
00360                 this.currentMainLoaded="";
00361                 this.currentBank="0";
00362         }
00363         var fsMod = new fsModules();
00364         '.$fsMod.'
00365 
00366                 // Used by Frameset Modules
00367         var condensedMode = '.($BE_USER->uc['condensedMode']?1:0).';
00368         var currentSubScript = "";
00369         var currentSubNavScript = "";
00370 
00371                 // Used for tab-panels:
00372         var DTM_currentTabs = new Array();
00373                 ';
00374 
00375                         // Check editing of page:
00376                 $this->editPageHandling();
00377                 $this->startModule();
00378         }
00379 
00386         function editPageHandling()     {
00387                 global $BE_USER;
00388 
00389                 if (!t3lib_extMgm::isLoaded('cms'))     return;
00390 
00391                         // EDIT page:
00392                 $editId = preg_replace('/[^[:alnum:]_]/','',t3lib_div::_GET('edit'));
00393                 $theEditRec = '';
00394 
00395                 if ($editId)    {
00396 
00397                                 // Looking up the page to edit, checking permissions:
00398                         $where = ' AND ('.$BE_USER->getPagePermsClause(2).' OR '.$BE_USER->getPagePermsClause(16).')';
00399                         if (t3lib_div::testInt($editId))        {
00400                                 $theEditRec = t3lib_BEfunc::getRecordWSOL('pages',$editId,'*',$where);
00401                         } else {
00402                                 $records = t3lib_BEfunc::getRecordsByField('pages','alias',$editId,$where);
00403                                 if (is_array($records)) {
00404                                         reset($records);
00405                                         $theEditRec = current($records);
00406                                         t3lib_BEfunc::workspaceOL('pages', $theEditRec);
00407                                 }
00408                         }
00409 
00410                                 // If the page was accessible, then let the user edit it.
00411                         if (is_array($theEditRec) && $BE_USER->isInWebMount($theEditRec['uid']))        {
00412                                         // Setting JS code to open editing:
00413                                 $this->mainJScode.='
00414                 // Load page to edit:
00415         window.setTimeout("top.loadEditId('.intval($theEditRec['uid']).');",500);
00416                         ';
00417                                         // Checking page edit parameter:
00418                                 if(!$BE_USER->getTSConfigVal('options.shortcut_onEditId_dontSetPageTree')) {
00419 
00420                                                 // Expanding page tree:
00421                                         t3lib_BEfunc::openPageTree(intval($theEditRec['pid']),!$BE_USER->getTSConfigVal('options.shortcut_onEditId_keepExistingExpanded'));
00422                                 }
00423                         } else {
00424                                 $this->mainJScode.='
00425                 // Warning about page editing:
00426         alert('.$GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->getLL('noEditPage'),$editId)).');
00427                         ';
00428                         }
00429                 }
00430         }
00431 
00437         function startModule() {
00438                 global $BE_USER;
00439                 $module = preg_replace('/[^[:alnum:]_]/','',t3lib_div::_GET('module'));
00440                 if (!$module && $BE_USER->uc['startInTaskCenter']) {
00441                         $module = 'user_task';
00442                 }
00443 
00444                 $params = t3lib_div::_GET('modParams');
00445                 if ($module) {
00446                         $this->mainJScode.='
00447                 // open in module:
00448         window.setTimeout("top.goToModule(\''.$module.'\',false,\''.$params.'\');",500);
00449                         ';
00450                 }
00451         }
00452 
00453 
00459         function main() {
00460                 global $BE_USER,$TYPO3_CONF_VARS;
00461 
00462                         // Set doktype:
00463                 $GLOBALS['TBE_TEMPLATE']->docType='xhtml_frames';
00464 
00465                         // Make JS:
00466                 $this->generateJScode();
00467                 $GLOBALS['TBE_TEMPLATE']->JScode= '
00468                         <script type="text/javascript" src="md5.js"></script>
00469                         <script type="text/javascript" src="../t3lib/jsfunc.evalfield.js"></script>
00470                         ';
00471                 $GLOBALS['TBE_TEMPLATE']->JScode.=$GLOBALS['TBE_TEMPLATE']->wrapScriptTags($this->mainJScode);
00472 
00473                         // Title:
00474                 $title = $TYPO3_CONF_VARS['SYS']['sitename'] ? $TYPO3_CONF_VARS['SYS']['sitename'].' [TYPO3 '.TYPO3_version.']' : 'TYPO3 '.TYPO3_version;
00475 
00476                         // Start page header:
00477                 $this->content.=$GLOBALS['TBE_TEMPLATE']->startPage($title);
00478 
00479                         // Creates frameset
00480                 $fr_content = '<frame name="content" src="alt_intro.php" marginwidth="0" marginheight="0" frameborder="0" scrolling="auto" noresize="noresize" />';
00481                 $fr_toplogo = '<frame name="toplogo" src="alt_toplogo.php" marginwidth="0" marginheight="0" frameborder="0" scrolling="no" noresize="noresize" />';
00482                 $fr_topmenu = '<frame name="topmenuFrame" src="alt_topmenu_dummy.php" marginwidth="0" marginheight="0" frameborder="0" scrolling="no" noresize="noresize" />';
00483 
00484                 $shortcutFrame=array();
00485                 if ($BE_USER->getTSConfigVal('options.shortcutFrame'))  {
00486                         $shortcutFrame['rowH']=','.$this->shortcutFrameH;
00487                         $shortcutFrame['frameDef']='<frame name="shortcutFrame" src="alt_shortcut.php" marginwidth="0" marginheight="0" frameborder="0" scrolling="no" noresize="noresize" />';
00488                 }
00489 
00490                         // 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?
00491                 if ($GLOBALS['BE_USER']->uc['noMenuMode'])      {
00492                         $this->content.= '
00493                         <frameset rows="'.$this->topFrameH.',*'.$shortcutFrame['rowH'].'" framespacing="0" frameborder="0" border="0">
00494                                 '.(!strcmp($BE_USER->uc['noMenuMode'],'icons') ? '
00495                                 <frameset cols="'.$this->leftMenuFrameW.',*" framespacing="0" frameborder="0" border="0">
00496                                         '.$fr_toplogo.'
00497                                         '.$fr_topmenu.'
00498                                 </frameset>' : '
00499                                 <frameset cols="'.$this->leftMenuFrameW.','.$this->selMenuFrame.',*" framespacing="0" frameborder="0" border="0">
00500                                         '.$fr_toplogo.'
00501                                         <frame name="menu" src="alt_menu_sel.php" scrolling="no" noresize="noresize" />
00502                                         '.$fr_topmenu.'
00503                                 </frameset>').'
00504                                 '.$fr_content.'
00505                                 '.$shortcutFrame['frameDef'].'
00506                         </frameset>
00507                         ';
00508                 } else {
00509                         $this->content.='
00510                         <frameset rows="'.$this->topFrameH.',*'.$shortcutFrame['rowH'].'" framespacing="0" frameborder="0" border="0">
00511                                 <frameset cols="'.$this->leftMenuFrameW.',*" framespacing="0" frameborder="0" border="0">
00512                                         '.$fr_toplogo.'
00513                                         '.$fr_topmenu.'
00514                                 </frameset>
00515                                 <frameset cols="'.$this->leftMenuFrameW.',*" framespacing="0" frameborder="0" border="0">
00516                                         <frame name="menu" src="alt_menu.php" marginwidth="0" marginheight="0" scrolling="auto" noresize="noresize" />
00517                                         '.$fr_content.'
00518                                 </frameset>
00519                                 '.$shortcutFrame['frameDef'].'
00520                         </frameset>
00521                         ';
00522                 }
00523                 $this->content.='
00524 
00525 </html>';
00526         }
00527 
00533         function printContent() {
00534                 echo $this->content;
00535         }
00536 }
00537 
00538 // Include extension?
00539 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_main.php'])      {
00540         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_main.php']);
00541 }
00542 
00543 
00544 
00545 
00546 
00547 
00548 
00549 // ******************************
00550 // Starting document output
00551 // ******************************
00552 
00553 // Make instance:
00554 $SOBE = t3lib_div::makeInstance('SC_alt_main');
00555 $SOBE->init();
00556 $SOBE->main();
00557 $SOBE->printContent();
00558 
00559 ?>


Généré par TYPO3 Ameos avec  doxygen 1.4.6