Documentation TYPO3 par Ameos

alt_main.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2004 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 ***************************************************************/
00054 require ('init.php');
00055 require ('template.php');
00056 require_once (PATH_t3lib.'class.t3lib_loadmodules.php');
00057 require_once (PATH_t3lib.'class.t3lib_basicfilefunc.php');
00058 require_once ('class.alt_menu_functions.inc');
00059 $LANG->includeLLFile('EXT:lang/locallang_misc.xml');
00060 
00061 
00062 
00063 
00071 class SC_alt_main {
00072 
00073                 // Internal, dynamic:
00074         var $content;
00075         var $mainJScode;
00076         var $loadModules;               // Load modules-object
00077         var $alt_menuObj;               // Menu functions object.
00078 
00079                 // Internal, static:
00080         var $leftMenuFrameW = 130;
00081         var $selMenuFrame = 130;
00082         var $topFrameH = 32;
00083         var $shortcutFrameH = 30;
00084 
00090         function init() {
00091                 global $TBE_MODULES,$TBE_STYLES;
00092 
00093                         // Initializes the backend modules structure for use later.
00094                 $this->loadModules = t3lib_div::makeInstance('t3lib_loadModules');
00095                 $this->loadModules->load($TBE_MODULES);
00096 
00097                         // Instantiates thee menu object which will generate some JavaScript for the goToModule() JS function in this frameset.
00098                 $this->alt_menuObj = t3lib_div::makeInstance('alt_menu_functions');
00099 
00100                         // Check for distances defined in the styles array:
00101                 if ($TBE_STYLES['dims']['leftMenuFrameW'])              $this->leftMenuFrameW = $TBE_STYLES['dims']['leftMenuFrameW'];
00102                 if ($TBE_STYLES['dims']['topFrameH'])           $this->topFrameH = $TBE_STYLES['dims']['topFrameH'];
00103                 if ($TBE_STYLES['dims']['shortcutFrameH'])              $this->shortcutFrameH = $TBE_STYLES['dims']['shortcutFrameH'];
00104                 if ($TBE_STYLES['dims']['selMenuFrame'])                $this->selMenuFrame = $TBE_STYLES['dims']['selMenuFrame'];
00105         }
00106 
00112         function generateJScode()       {
00113                 global $BE_USER,$LANG;
00114 
00115                 $pt3 = t3lib_div::dirname(t3lib_div::getIndpEnv('SCRIPT_NAME')).'/';
00116                 $goToModule_switch = $this->alt_menuObj->topMenu($this->loadModules->modules,0,"",4);
00117                 $fsMod = implode(chr(10),$this->alt_menuObj->fsMod);
00118 
00119                         // If another page module was specified, replace the default Page module with the new one
00120                 $newPageModule = trim($GLOBALS['BE_USER']->getTSConfigVal('options.overridePageModule'));
00121                 $pageModule = t3lib_BEfunc::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
00122 
00123                 $this->mainJScode='
00127         function rawurlencode(str)      {       //
00128                 var output = escape(str);
00129                 output = str_replace("*","%2A", output);
00130                 output = str_replace("+","%2B", output);
00131                 output = str_replace("/","%2F", output);
00132                 output = str_replace("@","%40", output);
00133                 return output;
00134         }
00135 
00139         function str_replace(match,replace,string)      {       //
00140                 var input = ""+string;
00141                 var matchStr = ""+match;
00142                 if (!matchStr)  {return string;}
00143                 var output = "";
00144                 var pointer=0;
00145                 var pos = input.indexOf(matchStr);
00146                 while (pos!=-1) {
00147                         output+=""+input.substr(pointer, pos-pointer)+replace;
00148                         pointer=pos+matchStr.length;
00149                         pos = input.indexOf(match,pos+1);
00150                 }
00151                 output+=""+input.substr(pointer);
00152                 return output;
00153         }
00154 
00158         function typoSetup()    {       //
00159                 this.PATH_typo3 = "'.$pt3.'";
00160                 this.PATH_typo3_enc = "'.rawurlencode($pt3).'";
00161                 this.username = "'.$BE_USER->user['username'].'";
00162                 this.uniqueID = "'.t3lib_div::shortMD5(uniqid('')).'";
00163                 this.navFrameWidth = 0;
00164         }
00165         var TS = new typoSetup();
00166 
00170         function busy() {       //
00171                 this.loginRefreshed = busy_loginRefreshed;
00172                 this.checkLoginTimeout = busy_checkLoginTimeout;
00173                 this.openRefreshWindow = busy_OpenRefreshWindow;
00174                 this.busyloadTime=0;
00175                 this.openRefreshW=0;
00176         }
00177         function busy_loginRefreshed()  {       //
00178                 var date = new Date();
00179                 this.busyloadTime = Math.floor(date.getTime()/1000);
00180                 this.openRefreshW=0;
00181         }
00182         function busy_checkLoginTimeout()       {       //
00183                 var date = new Date();
00184                 var theTime = Math.floor(date.getTime()/1000);
00185                 if (theTime > this.busyloadTime+'.intval($BE_USER->auth_timeout_field).'-10)    {
00186                         return true;
00187                 }
00188         }
00189         function busy_OpenRefreshWindow()       {       //
00190                 vHWin=window.open("login_frameset.php","relogin","height=350,width=700,status=0,menubar=0,location=1");
00191                 vHWin.focus();
00192                 this.openRefreshW=1;
00193         }
00194         function busy_checkLoginTimeout_timer() {       //
00195 
00196                 if (busy.checkLoginTimeout())   {
00197                         if (!busy.openRefreshW && confirm('.$GLOBALS['LANG']->JScharCode($LANG->sL('LLL:EXT:lang/locallang_core.php:mess.refresh_login')).'))   {
00198                                 busy.openRefreshWindow();
00199                         }
00200                 }
00201                 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())
00202 
00203                         // 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!)
00204                 if (top && top.content && top.content.nav_frame && top.content.nav_frame.document && top.content.nav_frame.document.body)       {
00205                         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;
00206                 }
00207         }
00208 
00212         function launchView(table,uid,bP)       {       //
00213                 var backPath= bP ? bP : "";
00214                 var thePreviewWindow="";
00215                 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");
00216                 if (thePreviewWindow && thePreviewWindow.focus) {
00217                         thePreviewWindow.focus();
00218                 }
00219         }
00220 
00224         function openUrlInWindow(url,windowName)        {       //
00225                 regularWindow = window.open(url,windowName,"status=1,menubar=1,resizable=1,location=1,directories=0,scrollbars=1,toolbar=1");
00226                 regularWindow.focus();
00227                 return false;
00228         }
00229 
00233         function loadTopMenu(url)       {       //
00234                 top.topmenuFrame.location = url;
00235         }
00236 
00240         function loadEditId(id,addGetVars)      {       //
00241                 top.fsMod.recentIds["web"]=id;
00242                 top.fsMod.navFrameHighlightedID["web"]="pages"+id+"_0";         // For highlighting
00243 
00244                 if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav)  {
00245                         top.content.nav_frame.refresh_nav();
00246                 }
00247 
00248                 top.goToModule("'.$pageModule.'", 0, addGetVars?addGetVars:"");
00249         }
00250 
00255         var nextLoadModuleUrl="";
00256         function getModuleUrl(inUrl)    {       //
00257                 var nMU;
00258                 if (top.nextLoadModuleUrl)      {
00259                         nMU=top.nextLoadModuleUrl;
00260                         top.nextLoadModuleUrl="";
00261                         return nMU;
00262                 } else {
00263                         return inUrl;
00264                 }
00265         }
00266 
00270         function debugObj(obj,name)     {       //
00271                 var acc;
00272                 for (i in obj) {
00273                         if (obj[i])     {
00274                                 acc+=i+":  "+obj[i]+"\n";
00275                         }
00276                 }
00277                 alert("Object: "+name+"\n\n"+acc);
00278         }
00279 
00283         var busy = new busy();
00284         busy.loginRefreshed();
00285         busy_checkLoginTimeout_timer();
00286 
00287 
00291         var currentlyHighLightedId = "";
00292         var currentlyHighLighted_restoreValue = "";
00293         function highlightModuleMenuItem(trId, mainModule)      {       //
00294                         // Get document object:
00295                 if (top.menu && top.menu.document)      {
00296                         var docObj = top.menu.document;
00297                         var HLclass = mainModule ? "c-mainitem-HL" : "c-subitem-row-HL";
00298                 } else if (top.topmenuFrame && top.topmenuFrame.document)       {
00299                         var docObj = top.topmenuFrame.document;
00300                         var HLclass = mainModule ? "c-mainitem-HL" : "c-subitem-HL";
00301                 }
00302 
00303                 if (docObj)     {
00304                                 // Reset old:
00305                         if (currentlyHighLightedId && docObj.getElementById(currentlyHighLightedId))    {
00306                                 docObj.getElementById(currentlyHighLightedId).attributes.getNamedItem("class").nodeValue = currentlyHighLighted_restoreValue;
00307                         }
00308                                 // Set new:
00309                         currentlyHighLightedId = trId;
00310                         if (currentlyHighLightedId && docObj.getElementById(currentlyHighLightedId))    {
00311                                 var classAttribObject = docObj.getElementById(currentlyHighLightedId).attributes.getNamedItem("class");
00312                                 currentlyHighLighted_restoreValue = classAttribObject.nodeValue;
00313                                 classAttribObject.nodeValue = HLclass;
00314                         }
00315                 }
00316         }
00317 
00321         var currentModuleLoaded = "";
00322         function goToModule(modName,cMR_flag,addGetVars)        {       //
00323                 var additionalGetVariables = "";
00324                 if (addGetVars) additionalGetVariables = addGetVars;
00325 
00326                 var cMR = 0;
00327                 if (cMR_flag)   cMR = 1;
00328 
00329                 currentModuleLoaded = modName;
00330 
00331                 switch(modName) {'.$goToModule_switch.'
00332                 }
00333         }
00334 
00343         function fsModules()    {       //
00344                 this.recentIds=new Array();                                     // used by frameset modules to track the most recent used id for list frame.
00345                 this.navFrameHighlightedID=new Array();         // used by navigation frames to track which row id was highlighted last time
00346                 this.currentMainLoaded="";
00347         }
00348         var fsMod = new fsModules();
00349         '.$fsMod.'
00350 
00351                 // Used by Frameset Modules
00352         var condensedMode = '.($BE_USER->uc['condensedMode']?1:0).';
00353         var currentSubScript = "";
00354         var currentSubNavScript = "";
00355 
00356                 // Used for tab-panels:
00357         var DTM_currentTabs = new Array();
00358                 ';
00359 
00360                         // Check editing of page:
00361                 $this->editPageHandling();
00362         }
00363 
00370         function editPageHandling()     {
00371                 global $BE_USER;
00372 
00373                 if (!t3lib_extMgm::isLoaded('cms'))     return;
00374 
00375                         // EDIT page:
00376                 $editId = ereg_replace('[^[:alnum:]_]','',t3lib_div::_GET('edit'));
00377                 $theEditRec = '';
00378 
00379                 if ($editId)    {
00380 
00381                                 // Looking up the page to edit, checking permissions:
00382                         $where = ' AND ('.$BE_USER->getPagePermsClause(2).' OR '.$BE_USER->getPagePermsClause(16).')';
00383                         if (t3lib_div::testInt($editId))        {
00384                                 $theEditRec = t3lib_BEfunc::getRecord('pages',$editId,'*',$where);
00385                         } else {
00386                                 $records = t3lib_BEfunc::getRecordsByField('pages','alias',$editId,$where);
00387                                 if (is_array($records)) {
00388                                         reset($records);
00389                                         $theEditRec = current($records);
00390                                 }
00391                         }
00392 
00393                                 // If the page was accessible, then let the user edit it.
00394                         if (is_array($theEditRec) && $BE_USER->isInWebMount($theEditRec['uid']))        {
00395                                         // Setting JS code to open editing:
00396                                 $this->mainJScode.='
00397                 // Load page to edit:
00398         window.setTimeout("top.loadEditId('.intval($theEditRec['uid']).');",500);
00399                         ';
00400                                         // Checking page edit parameter:
00401                                 if(!$BE_USER->getTSConfigVal('options.shortcut_onEditId_dontSetPageTree')) {
00402 
00403                                                 // Expanding page tree:
00404                                         t3lib_BEfunc::openPageTree(intval($theEditRec['pid']),!$BE_USER->getTSConfigVal('options.shortcut_onEditId_keepExistingExpanded'));
00405                                 }
00406                         } else {
00407                                 $this->mainJScode.='
00408                 // Warning about page editing:
00409         alert('.$GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->getLL('noEditPage'),$editId)).');
00410                         ';
00411                         }
00412                 }
00413         }
00414 
00420         function main() {
00421                 global $BE_USER,$TYPO3_CONF_VARS;
00422 
00423                         // Set doktype:
00424                 $GLOBALS['TBE_TEMPLATE']->docType='xhtml_frames';
00425 
00426                         // Make JS:
00427                 $this->generateJScode();
00428                 $GLOBALS['TBE_TEMPLATE']->JScode= '
00429                         <script type="text/javascript" src="md5.js"></script>
00430                         <script type="text/javascript" src="t3lib/jsfunc.evalfield.js"></script>
00431                         ';
00432                 $GLOBALS['TBE_TEMPLATE']->JScode.=$GLOBALS['TBE_TEMPLATE']->wrapScriptTags($this->mainJScode);
00433 
00434                         // Title:
00435                 $title = $TYPO3_CONF_VARS['SYS']['sitename'] ? $TYPO3_CONF_VARS['SYS']['sitename'].' [TYPO3 '.TYPO3_version.']' : 'TYPO3 '.TYPO3_version;
00436 
00437                         // Start page header:
00438                 $this->content.=$GLOBALS['TBE_TEMPLATE']->startPage($title);
00439 
00440                         // Creates frameset
00441                 $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" />';
00442                 $fr_toplogo = '<frame name="toplogo" src="alt_toplogo.php" marginwidth="0" marginheight="0" frameborder="0" scrolling="no" noresize="noresize" />';
00443                 $fr_topmenu = '<frame name="topmenuFrame" src="alt_topmenu_dummy.php" marginwidth="0" marginheight="0" frameborder="0" scrolling="no" noresize="noresize" />';
00444 
00445                 $shortcutFrame=array();
00446                 if ($BE_USER->getTSConfigVal('options.shortcutFrame'))  {
00447                         $shortcutFrame['rowH']=','.$this->shortcutFrameH;
00448                         $shortcutFrame['frameDef']='<frame name="shortcutFrame" src="alt_shortcut.php" marginwidth="0" marginheight="0" frameborder="0" scrolling="no" noresize="noresize" />';
00449                 }
00450 
00451                         // 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?
00452                 if ($GLOBALS['BE_USER']->uc['noMenuMode'])      {
00453                         $this->content.= '
00454                         <frameset rows="'.$this->topFrameH.',*'.$shortcutFrame['rowH'].'" framespacing="0" frameborder="0" border="0">
00455                                 '.(!strcmp($BE_USER->uc['noMenuMode'],'icons') ? '
00456                                 <frameset cols="'.$this->leftMenuFrameW.',*" framespacing="0" frameborder="0" border="0">
00457                                         '.$fr_toplogo.'
00458                                         '.$fr_topmenu.'
00459                                 </frameset>' : '
00460                                 <frameset cols="'.$this->leftMenuFrameW.','.$this->selMenuFrame.',*" framespacing="0" frameborder="0" border="0">
00461                                         '.$fr_toplogo.'
00462                                         <frame name="menu" src="alt_menu_sel.php" scrolling="no" noresize="noresize" />
00463                                         '.$fr_topmenu.'
00464                                 </frameset>').'
00465                                 '.$fr_content.'
00466                                 '.$shortcutFrame['frameDef'].'
00467                         </frameset>
00468                         ';
00469                 } else {
00470                         $this->content.='
00471                         <frameset rows="'.$this->topFrameH.',*'.$shortcutFrame['rowH'].'" framespacing="0" frameborder="0" border="0">
00472                                 <frameset cols="'.$this->leftMenuFrameW.',*" framespacing="0" frameborder="0" border="0">
00473                                         '.$fr_toplogo.'
00474                                         '.$fr_topmenu.'
00475                                 </frameset>
00476                                 <frameset cols="'.$this->leftMenuFrameW.',*" framespacing="0" frameborder="0" border="0">
00477                                         <frame name="menu" src="alt_menu.php" marginwidth="0" marginheight="0" scrolling="auto" noresize="noresize" />
00478                                         '.$fr_content.'
00479                                 </frameset>
00480                                 '.$shortcutFrame['frameDef'].'
00481                         </frameset>
00482                         ';
00483                 }
00484                 $this->content.='
00485 
00486 </html>';
00487         }
00488 
00494         function printContent() {
00495                 echo $this->content;
00496         }
00497 }
00498 
00499 // Include extension?
00500 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_main.php'])      {
00501         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_main.php']);
00502 }
00503 
00504 
00505 
00506 
00507 
00508 
00509 
00510 
00511 // ******************************
00512 // Starting document output
00513 // ******************************
00514 
00515 // Make instance:
00516 $SOBE = t3lib_div::makeInstance('SC_alt_main');
00517 $SOBE->init();
00518 $SOBE->main();
00519 $SOBE->printContent();
00520 ?>


Généré par Les spécialistes TYPO3 avec  doxygen 1.4.6