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