00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00073 class alt_menu_functions {
00074
00075
00076 var $fsMod = array();
00077
00094 function topMenu($theModules,$dontLink=0,$backPath='',$descr=0) {
00095 global $LANG, $TBE_TEMPLATE, $BE_USER;
00096
00097
00098 $tmpArr = $BE_USER->getTSConfig('options.moduleMenuCollapsable');
00099 $collapsable = ($tmpArr['value'] ? 0 : 1);
00100 unset($tmpArr);
00101
00102
00103 $final='';
00104 $menuCode='';
00105 $descrCode='';
00106 $collection=array();
00107 $menuCode_sub='';
00108 $selectItems=array();
00109 $mIcons=array();
00110 $mJScmds=array();
00111 $onBlur=$GLOBALS['CLIENT']['FORMSTYLE'] ? 'this.blur();' : '';
00112
00113 $selectItems[] = '<option value="">[ '.$LANG->sL('LLL:EXT:lang/locallang_core.php:buttons.selMenu_modules',1).' ]</option>';
00114 $mC=0;
00115
00116
00117 if ($BE_USER->getTSConfigVal('options.disableDocModuleInAB')) {
00118 unset($theModules['doc']);
00119 }
00120
00121
00122 if ($collapsable == 1) {
00123 $config = is_array ($BE_USER->uc['moduleData']['alt_menu.php']) ? $BE_USER->uc['moduleData']['alt_menu.php'] : array();
00124 $collapsedOverride = t3lib_div::_GP('collapsedOverride');
00125 if (is_array ($collapsedOverride)) {
00126 $config = array_merge ($config, $collapsedOverride);
00127 }
00128
00129 if (t3lib_div::_GP('collapsableExpandAll') == 1) {
00130 $config['expandAll'] = t3lib_div::_GP('expandAll');
00131 }
00132
00133 if ($config['expandAll'] && is_array($collapsedOverride)) {
00134 $config = $collapsedOverride;
00135 }
00136
00137 $BE_USER->uc['moduleData']['alt_menu.php'] = $config;
00138 $BE_USER->writeUC($BE_USER->uc);
00139
00140
00141 if($config['expandAll'] == 1) {
00142 foreach($config as $key => $value) {
00143 if($key != 'expandAll')
00144 $config[$key] = 0;
00145 }
00146 }
00147 }
00148
00149
00150 reset($theModules);
00151 while(list($moduleName,$moduleInfo)=each($theModules)) {
00152 $mC++;
00153
00154 $prefix = $this->getNavFramePrefix($moduleInfo);
00155 if ($prefix) {
00156 $this->fsMod[]='fsMod.recentIds["'.$moduleName.'"]="";';
00157 }
00158
00159
00160 if (is_array($moduleInfo['sub'])) {
00161
00162 if ($moduleInfo['defaultMod']) {
00163 $link = $moduleInfo['sub'][$moduleInfo['defaultMod']]['script'];
00164 } else {
00165 reset($moduleInfo['sub']);
00166 $subTemp = current($moduleInfo['sub']);
00167 $link = $subTemp['script'];
00168 }
00169 $link_sub = 1;
00170 $link = '';
00171 } else {
00172 $link = $moduleInfo['script'];
00173 $link_sub = 0;
00174 }
00175
00176 $link = t3lib_div::resolveBackPath($link);
00177
00178 $moduleKey = $moduleName.'_tab';
00179 $moduleCSSId = 'ID_'.t3lib_div::md5int($moduleName);
00180
00181 $collection[$moduleKey] = array(
00182 'moduleName' => $moduleName,
00183 'title' => $LANG->moduleLabels['tabs'][$moduleKey],
00184 'onclick' => 'top.goToModule(\''.$moduleName.'\');',
00185 );
00186
00187
00188 $image = @getimagesize($this->mIconFile($LANG->moduleLabels['tabs_images'][$moduleKey],$backPath));
00189 $imageCode='';
00190 $descr3_title = $LANG->moduleLabels['tabs'][$moduleKey].' ';
00191 if ($image) {
00192 $Ifilename = $this->mIconFilename($LANG->moduleLabels['tabs_images'][$moduleKey],$backPath);
00193 $collection[$moduleKey]['icon'] = array($Ifilename, $image[3]);
00194 $imageCode = '<img src="'.$Ifilename.'" '.$image[3].' alt="" />';
00195 $descr3_imageCode = '<img src="'.$Ifilename.'" '.$image[3].' title="'.htmlspecialchars($descr3_title).'" alt="" />';
00196 } else {
00197 $descr3_imageCode = '<img'.t3lib_iconWorks::skinImg($backPath,'gfx/dummy_module.gif','width="14" height="12"').' title="'.htmlspecialchars($descr3_title).'" alt="" />';
00198 }
00199
00200
00201 $label = $LANG->moduleLabels['tabs'][$moduleKey];
00202 if ($link && $prefix) $link=$prefix.rawurlencode($link);
00203 if ($link && !$dontLink) {
00204 $label = '<a href="#" onclick="top.goToModule(\''.$moduleName.'\');'.$onBlur.'return false;">'.$label.'</a>';
00205
00206 $mIcons[] = '<a href="#" onclick="top.goToModule(\''.$moduleName.'\');'.$onBlur.'return false;" class="c-mainitem" id="'.$moduleCSSId.'">'.$descr3_imageCode.'</a>';
00207
00208 $JScmd = '
00209 top.content.location=top.getModuleUrl(top.TS.PATH_typo3+"'.$this->wrapLinkWithAB($link).'"+additionalGetVariables);
00210 top.highlightModuleMenuItem("'.$moduleCSSId.'",1);';
00211 $mJScmds[] = "case '".$moduleName."': \n ".$JScmd." \n break;";
00212 }
00213
00214 $selectItems[] = '<option value="top.goToModule(\''.$moduleName.'\');">'.htmlspecialchars($LANG->moduleLabels['tabs'][$moduleKey]).'</option>';
00215 $label=' <b>'.$label.'</b> ';
00216
00217
00218
00219 if($collapsable == 1 && is_array($moduleInfo['sub'])) {
00220 $collapseJS = 'onclick="window.location.href=\'alt_menu.php?collapsedOverride['.$moduleName.']='.($config[$moduleName] ? '0' : '1').'\'"';
00221 $collapseIcon = '<span class="c-iconCollapse"><img'.t3lib_iconWorks::skinImg($backPath,'gfx/ol/'.($config[$moduleName] ? 'plusbullet.gif':'minusbullet.gif'),'width="18" height="16"').' title="" alt="" /></span>';
00222 } else {
00223 $collapseJS = $collapseIcon = '';
00224 }
00225
00226
00227 $menuCode.='
00228 <tr class="c-mainitem" id="'.$moduleCSSId.'">
00229 <td colspan="3" '.$collapseJS.' >'.$imageCode.'<span class="c-label">'.$label.'</span>'.$collapseIcon.'</td>
00230 </tr>';
00231
00232
00233 $descrCode.='
00234 <tr class="c-mainitem bgColor4">
00235 <td colspan="3">'.$imageCode.$label.'</td>
00236 </tr>';
00237
00238
00239
00240 if($collapsable == 1 && $config[$moduleName] == 1 && $descr == 0 && $config['expandAll'] != 1) {
00241 unset($moduleInfo['sub']);
00242 }
00243
00244
00245 $subCode='';
00246 if (is_array($moduleInfo['sub'])) {
00247 reset($moduleInfo['sub']);
00248 $collection[$moduleKey]['subitems'] = array();
00249 $c=0;
00250 while(list($subName,$subInfo)=each($moduleInfo['sub'])) {
00251 if ($c==0) {
00252 $subCode.='
00253 <tr class="c-first">
00254 <td colspan="3"></td>
00255 </tr>';
00256 $descrCode.='
00257 <tr class="c-first">
00258 <td colspan="3"></td>
00259 </tr>';
00260 }
00261
00262 $link = t3lib_div::resolveBackPath($subInfo['script']);
00263 $prefix = $this->getNavFramePrefix($moduleInfo, $subInfo);
00264
00265 $subKey = $moduleName.'_'.$subName.'_tab';
00266 $moduleCSSId = 'ID_'.t3lib_div::md5int($moduleName.'_'.$subName);
00267
00268 $collection[$moduleKey]['subitems'][$subKey] = array(
00269 'moduleName' => $moduleName.'_'.$subName,
00270 'title' => $LANG->moduleLabels['tabs'][$subKey],
00271 'onclick' => 'top.goToModule(\''.$moduleName.'_'.$subName.'\');',
00272 );
00273
00274
00275 $image = @getimagesize($this->mIconFile($LANG->moduleLabels['tabs_images'][$subKey],$backPath));
00276 $imageCode='';
00277 $descr3_title = $LANG->moduleLabels['tabs'][$subKey].': '.$LANG->moduleLabels['labels'][$subKey.'label'];
00278 if ($image) {
00279 $Ifilename = $this->mIconFilename($LANG->moduleLabels['tabs_images'][$subKey],$backPath);
00280 $collection[$moduleKey]['subitems'][$subKey]['icon'] = array($Ifilename, $image[3]);
00281 $imageCode = '<img src="'.$Ifilename.'" '.$image[3].' title="'.htmlspecialchars($LANG->moduleLabels['labels'][$subKey.'label']).'" alt="" />';
00282 $descr3_imageCode = '<img src="'.$Ifilename.'" '.$image[3].' title="'.htmlspecialchars($descr3_title).'" alt="" />';
00283 } else {
00284 $descr3_imageCode = '<img'.t3lib_iconWorks::skinImg($backPath,'gfx/dummy_module.gif','width="14" height="12"').' title="'.htmlspecialchars($descr3_title).'" alt="" />';
00285 }
00286
00287
00288 $label = $LANG->moduleLabels['tabs'][$subKey];
00289 $label_descr = ' title="'.htmlspecialchars($LANG->moduleLabels['labels'][$subKey.'label']).'"';
00290 $flabel = htmlspecialchars($label);
00291 $origLink = $link;
00292 if ($link && $prefix) $link=$prefix.rawurlencode($link);
00293
00294
00295 $addJS = '';
00296 if ($moduleInfo['navFrameScript']) {$addJS="+'&id='+top.rawurlencode(top.fsMod.recentIds['".$moduleName."'])";}
00297
00298
00299 if ($link && !$dontLink) {
00300
00301 if ($addJS && $BE_USER->uc['condensedMode']) {$addJS.= "+(cMR?'&cMR=1':'')";}
00302
00303
00304 $JScmd = '
00305 top.content.location=top.getModuleUrl(top.TS.PATH_typo3+"'.$this->wrapLinkWithAB($link).'"'.$addJS.'+additionalGetVariables);
00306 top.fsMod.currentMainLoaded="'.$moduleName.'";
00307 ';
00308
00309 if ($subInfo['navFrameScript']) {
00310 $JScmd.='
00311 top.currentSubScript="'.$origLink.'";';
00312 }
00313
00314
00315 if (!$BE_USER->uc['condensedMode'] && $moduleInfo['navFrameScript']) {
00316
00317
00318 $subNavFrameScript = $subInfo['navFrameScript'] ? $subInfo['navFrameScript'] : $moduleInfo['navFrameScript'];
00319 $subNavFrameScript = t3lib_div::resolveBackPath($subNavFrameScript);
00320
00321
00322 $subNavFrameScript = $this->wrapLinkWithAB($subNavFrameScript).$subInfo['navFrameScriptParam'];
00323
00324 $JScmd = '
00325 if (top.content.list_frame && top.fsMod.currentMainLoaded=="'.$moduleName.'") {
00326 top.currentSubScript="'.$origLink.'";
00327 top.content.list_frame.location=top.getModuleUrl(top.TS.PATH_typo3+"'.$this->wrapLinkWithAB($origLink).'"'.$addJS.'+additionalGetVariables);
00328 if(top.currentSubNavScript!="'.$subNavFrameScript.'") {
00329 top.currentSubNavScript="'.$subNavFrameScript.'";
00330 top.content.nav_frame.location=top.getModuleUrl(top.TS.PATH_typo3+"'.$subNavFrameScript.'");
00331 }
00332 } else {
00333 top.content.location=top.TS.PATH_typo3+(
00334 top.nextLoadModuleUrl?
00335 "'.($prefix?$this->wrapLinkWithAB($link).'&exScript=':'').'listframe_loader.php":
00336 "'.$this->wrapLinkWithAB($link).'"'.$addJS.'+additionalGetVariables
00337 );
00338 top.fsMod.currentMainLoaded="'.$moduleName.'";
00339 top.currentSubScript="'.$origLink.'";
00340 }
00341 ';
00342 }
00343 $selectItems[] = '<option value="top.goToModule(\''.$moduleName.'_'.$subName.'\');">'.htmlspecialchars('- '.$label).'</option>';
00344 $onClickString = htmlspecialchars('top.goToModule(\''.$moduleName.'_'.$subName.'\');'.$onBlur.'return false;');
00345
00346 $flabel = '<a href="#" onclick="'.$onClickString.'"'.$label_descr.'>'.htmlspecialchars($label).'</a>';
00347
00348 $mIcons[] = '<a href="#" onclick="'.$onClickString.'"'.$label_descr.' class="c-subitem" id="'.$moduleCSSId.'">'.$descr3_imageCode.'</a>';
00349
00350 $JScmd.= '
00351 top.highlightModuleMenuItem("'.$moduleCSSId.'");';
00352 $mJScmds[] = "case '".$moduleName.'_'.$subName."': \n ".$JScmd." \n break;";
00353 }
00354
00355 $subCode.='
00356 <tr class="c-subitem-row" id="'.$moduleCSSId.'">
00357 <td></td>
00358 <td align="center">'.(!$BE_USER->uc['hideSubmoduleIcons']?$imageCode:'').'</td>
00359 <td class="c-subitem-label">'.$flabel.'</td>
00360 </tr>';
00361
00362
00363 $descrCode.='
00364 <tr class="c-subitem-row">
00365 <td align="center">'.$imageCode.'</td>
00366 <td>'.$flabel.' </td>
00367 <td><strong>'.htmlspecialchars($LANG->moduleLabels['labels'][$subKey.'label']).'</strong><br />'.$LANG->moduleLabels['labels'][$subKey.'descr'].'</td>
00368 </tr>';
00369
00370
00371 $c++;
00372 if ($c<count($moduleInfo['sub'])) {
00373
00374 $subCode.='
00375 <tr class="c-divrow">
00376 <td colspan="3"><img'.t3lib_iconWorks::skinImg($backPath,'gfx/altmenuline.gif','width="105" height="3"').' alt="" /></td>
00377 </tr>';
00378 }
00379 }
00380
00381 if (count($theModules)>$mC) {
00382 $mIcons[]='<img src="'.$backPath.'gfx/acm_spacer2.gif" width="8" height="12" hspace="3" alt="" />';
00383 }
00384 }
00385
00386
00387 $subCode.='
00388 <tr class="c-endrow">
00389 <td colspan="3"></td>
00390 </tr>';
00391 $descrCode.='
00392 <tr class="c-endrow">
00393 <td colspan="3"></td>
00394 </tr>';
00395
00396
00397 $menuCode.=$subCode;
00398 }
00399
00400
00401 if ($menuCode) {
00402 if($collapsable == 1 || $config['expandAll'] == 1) {
00403 $collapseAllHTML = '<tr class="c-endrow">
00404 <td></td>
00405 <td align="center">
00406 <form action="alt_menu.php" method="get">
00407 <input type="hidden" name="collapsableExpandAll" value="1" />
00408 <input type="checkbox" name="expandAll" id="expandall" value="1" onclick="this.form.submit();" '.($config['expandAll']?'checked="checked"':'').' />
00409 </form>
00410 </td>
00411 <td class="c-subitem-label"><label for="expandall">'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.expandAll',1).'</label></td>
00412 </tr>';
00413 } else {
00414 $collapseAllHTML = '';
00415 }
00416
00417 $final = '
00418
00419
00420 <!--
00421 Vertical module menu, shown in left frame of backend.
00422 -->
00423 <table border="0" cellpadding="0" cellspacing="0" id="typo3-vmenu">
00424 '.$menuCode.'
00425 <tr class="c-endrow">
00426 <td colspan="3">'.t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'menu_modules', $GLOBALS['BACK_PATH']).'</td></tr>
00427 '.$collapseAllHTML.'
00428 </table>';
00429 }
00430
00431
00432 if ($descr==1) {
00433 $descrCode = '
00434
00435
00436 <!--
00437 Listing of modules, for Help > About modules
00438 -->
00439 <table border="0" cellpadding="0" cellspacing="0" id="typo3-about-modules">
00440 '.$descrCode.'
00441 </table>';
00442 $final = $descrCode;
00443 }
00444
00445
00446 if ($descr==2) {
00447
00448
00449 if ($BE_USER->isAdmin()) {
00450 $functionArray = $this->adminFunctions($backPath);
00451 if (count($functionArray)) {
00452 $selectItems[] = '<option value=""></option>';
00453 foreach($functionArray as $fAoptions) {
00454 $selectItems[] = '<option value="'.htmlspecialchars("window.location.href='".$fAoptions['href']."';").'">[ '.htmlspecialchars($fAoptions['title']).' ]</option>';
00455 }
00456 }
00457 }
00458
00459
00460 $selectItems[] = '<option value=""></option>';
00461 $selectItems[] = '<option value="'.htmlspecialchars("top.location='logout.php';").'">[ '.$LANG->sL('LLL:EXT:lang/locallang_core.php:buttons.logout',1).' ]</option>';
00462 $final = '
00463 <select name="menuselector" onchange="eval(this.options[this.selectedIndex].value);">
00464 '.implode('
00465 ',$selectItems).'
00466 </select>';
00467 }
00468
00469 if ($descr==3) {
00470 $final = ''.implode('',$mIcons).'';
00471 }
00472
00473
00474 if ($descr==4) {
00475 $final = chr(10).implode(chr(10),$mJScmds).chr(10);
00476 }
00477
00478
00479 if ($descr==5) {
00480 $final = $collection;
00481 }
00482
00483
00484 return $final;
00485 }
00486
00494 function getNavFramePrefix($moduleInfo, $subModuleInfo=array()) {
00495 global $BE_USER;
00496
00497 $prefix = '';
00498 $navFrameScript = $subModuleInfo['navFrameScript'] ? $subModuleInfo['navFrameScript'] : $moduleInfo['navFrameScript'];
00499 $navFrameScriptParam = isset($subModuleInfo['navFrameScriptParam']) ? $subModuleInfo['navFrameScriptParam'] : $moduleInfo['navFrameScriptParam'];
00500 if ($navFrameScript) {
00501 $navFrameScript = t3lib_div::resolveBackPath($navFrameScript);
00502 $navFrameScript = $this->wrapLinkWithAB($navFrameScript);
00503
00504 if ($BE_USER->uc['condensedMode']) {
00505 $prefix=$navFrameScript.$navFrameScriptParam.'¤tSubScript=';
00506 } else {
00507 $prefix='alt_mod_frameset.php?'.
00508 'fW="+top.TS.navFrameWidth+"'.
00509 '&nav="+top.TS.PATH_typo3+"'.rawurlencode($navFrameScript.$navFrameScriptParam).
00510 '&script=';
00511 }
00512 }
00513 return $prefix;
00514 }
00515
00525 function mIconFile($Ifilename,$backPath) {
00526 if (t3lib_div::isAbsPath($Ifilename)) {
00527 return $Ifilename;
00528 }
00529 return $backPath.$Ifilename;
00530 }
00531
00540 function mIconFilename($Ifilename,$backPath) {
00541 if (t3lib_div::isAbsPath($Ifilename)) {
00542 $Ifilename = '../'.substr($Ifilename,strlen(PATH_site));
00543 }
00544 return $backPath.$Ifilename;
00545 }
00546
00552 function topButtons() {
00553 global $LANG;
00554
00555 $label = $GLOBALS['BE_USER']->user['ses_backuserid'] ? 'LLL:EXT:lang/locallang_core.php:buttons.exit' : 'LLL:EXT:lang/locallang_core.php:buttons.logout';
00556 $out.= '<form action="logout.php" target="_top"><input type="submit" value="'.$LANG->sL($label,1).'" /></form>';
00557 return $out;
00558 }
00559
00565 function adminButtons() {
00566 global $LANG;
00567
00568 $functionArray = $this->adminFunctions('');
00569
00570 $icons=array();
00571 foreach($functionArray as $fAoptions) {
00572 $icons[]= '<a href="'.htmlspecialchars($fAoptions['href']).'">'.$fAoptions['icon'].'</a>';
00573 }
00574
00575 return implode('',$icons);
00576 }
00577
00584 function adminFunctions($backPath) {
00585 global $LANG,$BE_USER,$TYPO3_CONF_VARS;
00586
00587 $functions=array();
00588
00589
00590 if ($TYPO3_CONF_VARS['EXT']['extCache']) {
00591 $title = $LANG->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_allTypo3Conf');
00592 $functions[]=array(
00593 'id' => 'temp_CACHED',
00594 'title' => $title,
00595 'href' => $backPath.'tce_db.php?vC='.$BE_USER->veriCode().'&redirect='.rawurlencode(t3lib_div::getIndpEnv('TYPO3_REQUEST_SCRIPT')).'&cacheCmd=temp_CACHED',
00596 'icon' => '<img'.t3lib_iconWorks::skinImg($backPath,'gfx/clear_cache_files_in_typo3c.gif','width="21" height="18"').' title="'.htmlspecialchars($title).'" alt="" />'
00597 );
00598 }
00599
00600
00601 $title = $LANG->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_all');
00602 $functions[]=array(
00603 'id' => 'all',
00604 'title' => $title,
00605 'href' => $backPath.'tce_db.php?vC='.$BE_USER->veriCode().'&redirect='.rawurlencode(t3lib_div::getIndpEnv('TYPO3_REQUEST_SCRIPT')).'&cacheCmd=all',
00606 'icon' => '<img'.t3lib_iconWorks::skinImg($backPath,'gfx/clear_all_cache.gif','width="21" height="18"').' title="'.htmlspecialchars($title).'" alt="" />'
00607 );
00608
00609
00610 return $functions;
00611 }
00612
00619 function wrapLinkWithAB($link) {
00620 if (!strstr($link,'?')) {
00621 return $link.'?';
00622 } else return $link;
00623 }
00624 }
00625
00626
00627 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.alt_menu_functions.inc']) {
00628 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.alt_menu_functions.inc']);
00629 }
00630 ?>