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
00294 if (!$BE_USER->uc['condensedMode'] && $moduleInfo['navFrameScript']) {
00295
00296
00297 $subNavFrameScript = $subInfo['navFrameScript'] ? $subInfo['navFrameScript'] : $moduleInfo['navFrameScript'];
00298 $subNavFrameScript = t3lib_div::resolveBackPath($subNavFrameScript);
00299
00300
00301 $subNavFrameScript = $this->wrapLinkWithAB($subNavFrameScript).$subInfo['navFrameScriptParam'];
00302
00303 $JScmd = '
00304 if (top.content.list_frame && top.fsMod.currentMainLoaded=="'.$moduleName.'") {
00305 top.currentSubScript="'.$origLink.'";
00306 top.content.list_frame.location=top.getModuleUrl(top.TS.PATH_typo3+"'.$this->wrapLinkWithAB($origLink).'"'.$addJS.'+additionalGetVariables);
00307 if(top.currentSubNavScript!="'.$subNavFrameScript.'") {
00308 top.currentSubNavScript="'.$subNavFrameScript.'";
00309 top.content.nav_frame.location=top.getModuleUrl(top.TS.PATH_typo3+"'.$subNavFrameScript.'");
00310 }
00311 } else {
00312 top.content.location=top.TS.PATH_typo3+(
00313 top.nextLoadModuleUrl?
00314 "'.($prefix?$this->wrapLinkWithAB($link).'&exScript=':'').'listframe_loader.php":
00315 "'.$this->wrapLinkWithAB($link).'"'.$addJS.'+additionalGetVariables
00316 );
00317 top.fsMod.currentMainLoaded="'.$moduleName.'";
00318 top.currentSubScript="'.$origLink.'";
00319 }
00320 ';
00321 }
00322 $selectItems[] = '<option value="top.goToModule(\''.$moduleName.'_'.$subName.'\');">'.htmlspecialchars('- '.$label).'</option>';
00323 $onClickString = htmlspecialchars('top.goToModule(\''.$moduleName.'_'.$subName.'\');'.$onBlur.'return false;');
00324
00325 $flabel = '<a href="#" onclick="'.$onClickString.'"'.$label_descr.'>'.htmlspecialchars($label).'</a>';
00326
00327 $mIcons[] = '<a href="#" onclick="'.$onClickString.'"'.$label_descr.' class="c-subitem" id="'.$moduleCSSId.'">'.$descr3_imageCode.'</a>';
00328
00329 $JScmd.= '
00330 top.highlightModuleMenuItem("'.$moduleCSSId.'");';
00331 $mJScmds[] = "case '".$moduleName.'_'.$subName."': \n ".$JScmd." \n break;";
00332 }
00333
00334 $subCode.='
00335 <tr class="c-subitem-row" id="'.$moduleCSSId.'">
00336 <td></td>
00337 <td align="center">'.(!$BE_USER->uc['hideSubmoduleIcons']?$imageCode:'').'</td>
00338 <td class="c-subitem-label">'.$flabel.'</td>
00339 </tr>';
00340
00341
00342 $descrCode.='
00343 <tr class="c-subitem-row">
00344 <td align="center">'.$imageCode.'</td>
00345 <td>'.$flabel.' </td>
00346 <td><strong>'.htmlspecialchars($LANG->moduleLabels['labels'][$subKey.'label']).'</strong><br />'.$LANG->moduleLabels['labels'][$subKey.'descr'].'</td>
00347 </tr>';
00348
00349
00350 $c++;
00351 if ($c<count($moduleInfo['sub'])) {
00352
00353 $subCode.='
00354 <tr class="c-divrow">
00355 <td colspan="3"><img'.t3lib_iconWorks::skinImg($backPath,'gfx/altmenuline.gif','width="105" height="3"').' alt="" /></td>
00356 </tr>';
00357 }
00358 }
00359
00360 if (count($theModules)>$mC) {
00361 $mIcons[]='<img src="'.$backPath.'gfx/acm_spacer2.gif" width="8" height="12" hspace="3" alt="" />';
00362 }
00363 }
00364
00365
00366 $subCode.='
00367 <tr class="c-endrow">
00368 <td colspan="3"></td>
00369 </tr>';
00370 $descrCode.='
00371 <tr class="c-endrow">
00372 <td colspan="3"></td>
00373 </tr>';
00374
00375
00376 $menuCode.=$subCode;
00377 }
00378
00379
00380 if ($menuCode) {
00381 if($collapsable == 1 || $config['expandAll'] == 1) {
00382 $collapseAllHTML = '<tr class="c-endrow">
00383 <td></td>
00384 <td align="center">
00385 <form action="alt_menu.php" method="get">
00386 <input type="hidden" name="collapsableExpandAll" value="1" />
00387 <input type="checkbox" name="expandAll" value="1" onclick="this.form.submit();" '.($config['expandAll']?'checked="checked"':'').' />
00388 </form>
00389 </td>
00390 <td class="c-subitem-label">'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.expandAll',1).'</td>
00391 </tr>';
00392 } else {
00393 $collapseAllHTML = '';
00394 }
00395
00396 $final = '
00397
00398
00399 <!--
00400 Vertical module menu, shown in left frame of backend.
00401 -->
00402 <table border="0" cellpadding="0" cellspacing="0" id="typo3-vmenu">
00403 '.$menuCode.'
00404 <tr class="c-endrow">
00405 <td colspan="3">'.t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'menu_modules', $GLOBALS['BACK_PATH']).'</td></tr>
00406 '.$collapseAllHTML.'
00407 </table>';
00408 }
00409
00410
00411 if ($descr==1) {
00412 $descrCode = '
00413
00414
00415 <!--
00416 Listing of modules, for Help > About modules
00417 -->
00418 <table border="0" cellpadding="0" cellspacing="0" id="typo3-about-modules">
00419 '.$descrCode.'
00420 </table>';
00421 $final = $descrCode;
00422 }
00423
00424
00425 if ($descr==2) {
00426
00427
00428 if ($BE_USER->isAdmin()) {
00429 $functionArray = $this->adminFunctions($backPath);
00430 if (count($functionArray)) {
00431 $selectItems[] = '<option value=""></option>';
00432 foreach($functionArray as $fAoptions) {
00433 $selectItems[] = '<option value="'.htmlspecialchars("document.location='".$fAoptions['href']."';").'">[ '.htmlspecialchars($fAoptions['title']).' ]</option>';
00434 }
00435 }
00436 }
00437
00438
00439 $selectItems[] = '<option value=""></option>';
00440 $selectItems[] = '<option value="'.htmlspecialchars("top.location='logout.php';").'">[ '.$LANG->sL('LLL:EXT:lang/locallang_core.php:buttons.logout',1).' ]</option>';
00441 $final = '
00442 <select name="menuselector" onchange="eval(this.options[this.selectedIndex].value);">
00443 '.implode('
00444 ',$selectItems).'
00445 </select>';
00446 }
00447
00448 if ($descr==3) {
00449 $final = ''.implode('',$mIcons).'';
00450 }
00451
00452
00453 if ($descr==4) {
00454 $final = chr(10).implode(chr(10),$mJScmds).chr(10);
00455 }
00456
00457
00458 return $final;
00459 }
00460
00468 function getNavFramePrefix($moduleInfo, $subModuleInfo=array()) {
00469 global $BE_USER;
00470
00471 $prefix = '';
00472 $navFrameScriptParam = $subModuleInfo['navFrameScriptParam'] ? $subModuleInfo['navFrameScriptParam'] : $moduleInfo['navFrameScriptParam'];
00473 if ($moduleInfo['navFrameScript']) {
00474 $navFrameScript = t3lib_div::resolveBackPath($moduleInfo['navFrameScript']);
00475 $navFrameScript = $this->wrapLinkWithAB($navFrameScript);
00476
00477 if ($BE_USER->uc['condensedMode']) {
00478 $prefix=$navFrameScript.$navFrameScriptParam.'¤tSubScript=';
00479 } else {
00480 $prefix='alt_mod_frameset.php?'.
00481 'fW="+top.TS.navFrameWidth+"'.
00482 '&nav="+top.TS.PATH_typo3+"'.rawurlencode($navFrameScript.$navFrameScriptParam).
00483 '&script=';
00484 }
00485 }
00486 return $prefix;
00487 }
00488
00498 function mIconFile($Ifilename,$backPath) {
00499 if (t3lib_div::isAbsPath($Ifilename)) {
00500 return $Ifilename;
00501 }
00502 return $backPath.$Ifilename;
00503 }
00504
00513 function mIconFilename($Ifilename,$backPath) {
00514 if (t3lib_div::isAbsPath($Ifilename)) {
00515 $Ifilename = '../'.substr($Ifilename,strlen(PATH_site));
00516 }
00517 return $backPath.$Ifilename;
00518 }
00519
00525 function topButtons() {
00526 global $LANG;
00527
00528 $out.= '<form action="logout.php" target="_top"><input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:buttons.logout',1).'" /></form>';
00529 return $out;
00530 }
00531
00537 function adminButtons() {
00538 global $LANG;
00539
00540 $functionArray = $this->adminFunctions('');
00541
00542 $icons=array();
00543 foreach($functionArray as $fAoptions) {
00544 $icons[]= '<a href="'.htmlspecialchars($fAoptions['href']).'">'.$fAoptions['icon'].'</a>';
00545 }
00546
00547 return implode('',$icons);
00548 }
00549
00556 function adminFunctions($backPath) {
00557 global $LANG,$BE_USER,$TYPO3_CONF_VARS;
00558
00559 $functions=array();
00560
00561
00562 if ($TYPO3_CONF_VARS['EXT']['extCache']) {
00563 $title = $LANG->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_allTypo3Conf');
00564 $functions[]=array(
00565 'title' => $title,
00566 'href' => $backPath.'tce_db.php?vC='.$BE_USER->veriCode().'&redirect='.rawurlencode(t3lib_div::getIndpEnv('TYPO3_REQUEST_SCRIPT')).'&cacheCmd=temp_CACHED',
00567 'icon' => '<img'.t3lib_iconWorks::skinImg($backPath,'gfx/clear_cache_files_in_typo3c.gif','width="21" height="18"').' title="'.htmlspecialchars($title).'" alt="" />'
00568 );
00569 }
00570
00571
00572 $title = $LANG->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_all');
00573 $functions[]=array(
00574 'title' => $title,
00575 'href' => $backPath.'tce_db.php?vC='.$BE_USER->veriCode().'&redirect='.rawurlencode(t3lib_div::getIndpEnv('TYPO3_REQUEST_SCRIPT')).'&cacheCmd=all',
00576 'icon' => '<img'.t3lib_iconWorks::skinImg($backPath,'gfx/clear_all_cache.gif','width="21" height="18"').' title="'.htmlspecialchars($title).'" alt="" />'
00577 );
00578
00579
00580 return $functions;
00581 }
00582
00589 function wrapLinkWithAB($link) {
00590 if (!strstr($link,'?')) {
00591 return $link.'?';
00592 } else return $link;
00593 }
00594 }
00595
00596
00597 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.alt_menu_functions.inc']) {
00598 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.alt_menu_functions.inc']);
00599 }
00600 ?>