📄 class.tslib_menu.php
字号:
// Prepare IFSUB settings, overriding normal settings // IFSUB is true if there exist submenu items to the current item if ($this->mconf['IFSUB']) { $IFSUBinit = 0; // Flag: If $IFSUB is generated reset($NOconf); while (list($key,$val)=each($NOconf)) { if ($this->isItemState('IFSUB',$key)) { if (!$IFSUBinit) { // if this is the first IFSUB element, we must generate IFSUB. $IFSUBconf = $this->tmpl->splitConfArray($this->mconf['IFSUB.'],$splitCount); if ($this->mconf['IFSUBRO']) { $IFSUBROconf = $this->tmpl->splitConfArray($this->mconf['IFSUBRO.'],$splitCount); } $IFSUBinit = 1; } $NOconf[$key] = $IFSUBconf[$key]; // Substitute normal with ifsub if ($ROconf) { // If rollOver on normal, we must apply a state for rollOver on the active $ROconf[$key] = $IFSUBROconf[$key] ? $IFSUBROconf[$key] : $IFSUBconf[$key]; // If RollOver on active then apply this } } } } // Prepare active settings, overriding normal settings if ($this->mconf['ACT']) { $ACTinit = 0; // Flag: If $ACT is generated reset($NOconf); while (list($key,$val)=each($NOconf)) { // Find active if ($this->isItemState('ACT',$key)) { if (!$ACTinit) { // if this is the first 'active', we must generate ACT. $ACTconf = $this->tmpl->splitConfArray($this->mconf['ACT.'],$splitCount); // Prepare active rollOver settings, overriding normal active settings if ($this->mconf['ACTRO']) { $ACTROconf = $this->tmpl->splitConfArray($this->mconf['ACTRO.'],$splitCount); } $ACTinit = 1; } $NOconf[$key] = $ACTconf[$key]; // Substitute normal with active if ($ROconf) { // If rollOver on normal, we must apply a state for rollOver on the active $ROconf[$key] = $ACTROconf[$key] ? $ACTROconf[$key] : $ACTconf[$key]; // If RollOver on active then apply this } } } } // Prepare ACT (active)/IFSUB settings, overriding normal settings // ACTIFSUB is true if there exist submenu items to the current item and the current item is active if ($this->mconf['ACTIFSUB']) { $ACTIFSUBinit = 0; // Flag: If $ACTIFSUB is generated reset($NOconf); while (list($key,$val)=each($NOconf)) { // Find active if ($this->isItemState('ACTIFSUB',$key)) { if (!$ACTIFSUBinit) { // if this is the first 'active', we must generate ACTIFSUB. $ACTIFSUBconf = $this->tmpl->splitConfArray($this->mconf['ACTIFSUB.'],$splitCount); // Prepare active rollOver settings, overriding normal active settings if ($this->mconf['ACTIFSUBRO']) { $ACTIFSUBROconf = $this->tmpl->splitConfArray($this->mconf['ACTIFSUBRO.'],$splitCount); } $ACTIFSUBinit = 1; } $NOconf[$key] = $ACTIFSUBconf[$key]; // Substitute normal with active if ($ROconf) { // If rollOver on normal, we must apply a state for rollOver on the active $ROconf[$key] = $ACTIFSUBROconf[$key] ? $ACTIFSUBROconf[$key] : $ACTIFSUBconf[$key]; // If RollOver on active then apply this } } } } // Prepare CUR (current) settings, overriding normal settings // CUR is true if the current page equals the item here! if ($this->mconf['CUR']) { $CURinit = 0; // Flag: If $CUR is generated reset($NOconf); while (list($key,$val)=each($NOconf)) { if ($this->isItemState('CUR',$key)) { if (!$CURinit) { // if this is the first 'current', we must generate CUR. Basically this control is just inherited from the other implementations as current would only exist one time and thats it (unless you use special-features of HMENU) $CURconf = $this->tmpl->splitConfArray($this->mconf['CUR.'],$splitCount); if ($this->mconf['CURRO']) { $CURROconf = $this->tmpl->splitConfArray($this->mconf['CURRO.'],$splitCount); } $CURinit = 1; } $NOconf[$key] = $CURconf[$key]; // Substitute normal with current if ($ROconf) { // If rollOver on normal, we must apply a state for rollOver on the active $ROconf[$key] = $CURROconf[$key] ? $CURROconf[$key] : $CURconf[$key]; // If RollOver on active then apply this } } } } // Prepare CUR (current)/IFSUB settings, overriding normal settings // CURIFSUB is true if there exist submenu items to the current item and the current page equals the item here! if ($this->mconf['CURIFSUB']) { $CURIFSUBinit = 0; // Flag: If $CURIFSUB is generated reset($NOconf); while (list($key,$val)=each($NOconf)) { if ($this->isItemState('CURIFSUB',$key)) { if (!$CURIFSUBinit) { // if this is the first 'current', we must generate CURIFSUB. $CURIFSUBconf = $this->tmpl->splitConfArray($this->mconf['CURIFSUB.'],$splitCount); // Prepare current rollOver settings, overriding normal current settings if ($this->mconf['CURIFSUBRO']) { $CURIFSUBROconf = $this->tmpl->splitConfArray($this->mconf['CURIFSUBRO.'],$splitCount); } $CURIFSUBinit = 1; } $NOconf[$key] = $CURIFSUBconf[$key]; // Substitute normal with active if ($ROconf) { // If rollOver on normal, we must apply a state for rollOver on the current $ROconf[$key] = $CURIFSUBROconf[$key] ? $CURIFSUBROconf[$key] : $CURIFSUBconf[$key]; // If RollOver on current then apply this } } } } // Prepare active settings, overriding normal settings if ($this->mconf['USR']) { $USRinit = 0; // Flag: If $USR is generated reset($NOconf); while (list($key,$val)=each($NOconf)) { // Find active if ($this->isItemState('USR',$key)) { if (!$USRinit) { // if this is the first active, we must generate USR. $USRconf = $this->tmpl->splitConfArray($this->mconf['USR.'],$splitCount); // Prepare active rollOver settings, overriding normal active settings if ($this->mconf['USRRO']) { $USRROconf = $this->tmpl->splitConfArray($this->mconf['USRRO.'],$splitCount); } $USRinit = 1; } $NOconf[$key] = $USRconf[$key]; // Substitute normal with active if ($ROconf) { // If rollOver on normal, we must apply a state for rollOver on the active $ROconf[$key] = $USRROconf[$key] ? $USRROconf[$key] : $USRconf[$key]; // If RollOver on active then apply this } } } } // Prepare spacer settings, overriding normal settings if ($this->mconf['SPC']) { $SPCinit = 0; // Flag: If $SPC is generated reset($NOconf); while (list($key,$val)=each($NOconf)) { // Find spacers if ($this->isItemState('SPC',$key)) { if (!$SPCinit) { // if this is the first spacer, we must generate SPC. $SPCconf = $this->tmpl->splitConfArray($this->mconf['SPC.'],$splitCount); $SPCinit = 1; } $NOconf[$key] = $SPCconf[$key]; // Substitute normal with spacer } } } // Prepare Userdefined settings if ($this->mconf['USERDEF1']) { $USERDEF1init = 0; // Flag: If $USERDEF1 is generated reset($NOconf); while (list($key,$val)=each($NOconf)) { // Find active if ($this->isItemState('USERDEF1',$key)) { if (!$USERDEF1init) { // if this is the first active, we must generate USERDEF1. $USERDEF1conf = $this->tmpl->splitConfArray($this->mconf['USERDEF1.'],$splitCount); // Prepare active rollOver settings, overriding normal active settings if ($this->mconf['USERDEF1RO']) { $USERDEF1ROconf = $this->tmpl->splitConfArray($this->mconf['USERDEF1RO.'],$splitCount); } $USERDEF1init = 1; } $NOconf[$key] = $USERDEF1conf[$key]; // Substitute normal with active if ($ROconf) { // If rollOver on normal, we must apply a state for rollOver on the active $ROconf[$key] = $USERDEF1ROconf[$key] ? $USERDEF1ROconf[$key] : $USERDEF1conf[$key]; // If RollOver on active then apply this } } } } // Prepare Userdefined settings if ($this->mconf['USERDEF2']) { $USERDEF2init = 0; // Flag: If $USERDEF2 is generated reset($NOconf); while (list($key,$val)=each($NOconf)) { // Find active if ($this->isItemState('USERDEF2',$key)) { if (!$USERDEF2init) { // if this is the first active, we must generate USERDEF2. $USERDEF2conf = $this->tmpl->splitConfArray($this->mconf['USERDEF2.'],$splitCount); // Prepare active rollOver settings, overriding normal active settings if ($this->mconf['USERDEF2RO']) { $USERDEF2ROconf = $this->tmpl->splitConfArray($this->mconf['USERDEF2RO.'],$splitCount); } $USERDEF2init = 1; } $NOconf[$key] = $USERDEF2conf[$key]; // Substitute normal with active if ($ROconf) { // If rollOver on normal, we must apply a state for rollOver on the active $ROconf[$key] = $USERDEF2ROconf[$key] ? $USERDEF2ROconf[$key] : $USERDEF2conf[$key]; // If RollOver on active then apply this } } } } return array($NOconf,$ROconf); } /** * Creates the URL, target and onclick values for the menu item link. Returns them in an array as key/value pairs for <A>-tag attributes * This function doesn't care about the url, because if we let the url be redirected, it will be logged in the stat!!! * * @param integer Pointer to a key in the $this->menuArr array where the value for that key represents the menu item we are linking to (page record) * @param string Alternative target * @param integer Alternative type * @return array Returns an array with A-tag attributes as key/value pairs (HREF, TARGET and onClick) * @access private */ function link($key,$altTarget='',$typeOverride='') { // Mount points: $MP_var = $this->getMPvar($key); $MP_params = $MP_var ? '&MP='.rawurlencode($MP_var) : ''; // Setting override ID if ($this->mconf['overrideId'] || $this->menuArr[$key]['overrideId']) { $overrideArray = array(); // If a user script returned the value overrideId in the menu array we use that as page id $overrideArray['uid'] = $this->mconf['overrideId']?$this->mconf['overrideId']:$this->menuArr[$key]['overrideId']; $overrideArray['alias'] = ''; $MP_params = ''; // clear MP parameters since ID was changed. } else { $overrideArray=''; } // Setting main target: $mainTarget = $altTarget ? $altTarget : $this->mconf['target']; // Creating link: if ($this->mconf['collapse'] && $this->isActive($this->menuArr[$key]['uid'], $this->getMPvar($key))) { $thePage = $this->sys_page->getPage($this->menuArr[$key]['pid']); $LD = $this->tmpl->linkData($thePage,$mainTarget,'','',$overrideArray, $this->mconf['addParams'].$MP_params.$this->menuArr[$key]['_ADD_GETVARS'], $typeOverride); } else { $LD = $this->tmpl->linkData($this->menuArr[$key],$mainTarget,'','',$overrideArray, $this->mconf['addParams'].$MP_params.$this->I['val']['additionalParams'].$this->menuArr[$key]['_ADD_GETVARS'], $typeOverride); } // Override URL if using "External URL" as doktype with a valid e-mail address: if ($this->menuArr[$key]['doktype'] == 3 && $this->menuArr[$key]['urltype'] == 3 && t3lib_div::validEmail($this->menuArr[$key]['url'])) { // Create mailto-link using tslib_cObj::typolink (concerning spamProtectEmailAddresses): $LD['totalURL'] = $this->parent_cObj->typoLink_URL(array('parameter' => $this->menuArr[$key]['url'])); $LD['target'] = ''; } // Manipulation in case of access restricted pages: $this->changeLinksForAccessRestrictedPages($LD,$this->menuArr[$key],$mainTarget,$typeOverride); // Overriding URL / Target if set to do so: if ($this->menuArr[$key]['_OVERRIDE_HREF']) { $LD['totalURL'] = $this->menuArr[$key]['_OVERRIDE_HREF']; if ($this->menuArr[$key]['_OVERRIDE_TARGET']) $LD['target'] = $this->menuArr[$key]['_OVERRIDE_TARGET']; } // OnClick open in windows. $onClick=''; if ($this->mconf['JSWindow']) { $conf=$this->mconf['JSWindow.']; $url=$LD['totalURL']; $LD['totalURL'] = '#'; $onClick= 'openPic(\''.$GLOBALS['TSFE']->baseUrlWrap($url).'\',\''.($conf['newWindow']?md5($url):'theNewPage').'\',\''.$conf['params'].'\'); return false;'; $GLOBALS['TSFE']->setJS('openPic'); } // out: $list = array(); $list['HREF'] = strlen($LD['totalURL']) ? $LD['totalURL'] : $GLOBALS['TSFE']->baseUrl; // Added this check: What it does is to enter the baseUrl (if set, which it should for "realurl" based sites) as URL if the calculated value is empty. The problem is that no link is generated with a blank URL and blank URLs might appear when the realurl encoding is used and a link to the frontpage is generated. $list['TARGET'] = $LD['target']; $list['onClick'] = $onClick; return $list; } /** * Will change $LD (passed by reference) if the page is access restricted * * @param array $LD, the array from the linkData() function * @param array Page array * @param string Main target value * @param string Type number override if any * @return void ($LD passed by reference might be changed.) */ function changeLinksForAccessRestrictedPages(&$LD, $page, $mainTarget, $typeOverride) { // If access restricted pages should be shown in menus, change the link of such pages to link to a redirection page: if ($this->mconf['showAccessRestrictedPages'] && $this->mconf['showAccessRestrictedPages']!=='NONE' && !$GLOBALS['TSFE']->checkPageGroupAccess($page)) { $thePage = $this->sys_page->getPage($this->mconf['showAccessRestrictedPages']); $addParams = $this->mconf['showAccessRestrictedPages.']['addParams']; $addParams = str_replace('###RETURN_URL###',rawurlencode($LD['totalURL']),$addParams); $addParams = str_replace('###PAGE_ID###',$page['uid'],$addParams); $LD = $this->tmpl->linkData($thePage,$mainTarget,'','','', $addParams, $typeOverride); } } /** * Creates a submenu level to the current level - if configured for. * * @param integer Page id of the current page for which a submenu MAY be produced (if conditions are met) * @param string Object prefix, see ->start() * @return string HTML content of the submenu * @access private */ function subMenu($uid, $objSuffix='') { // Setting alternative menu item array if _SUB_MENU has been defined in the current ->menuArr $altArray = ''; if (is_array($this->menuArr[$this->I['key']]['_SUB_MENU']) && count($this->menuArr[$this->I['key']]['_SUB_MENU'])) { $altArray = $this->menuArr[$this->I['key']]['_SUB_MENU']; } // Make submenu if the page is the next active $cls = strtolower($this->conf[($this->menuNumber+1).$objSuffix]); $subLevelClass = ($cls && t3lib_div::inList($this->tmpl->menuclasses,$cls)) ? $cls : ''; if ($subLevelClass && ($this->mconf['expAll'] || $this->isNext($uid, $this->getMPvar($this->I['key'])) || is_array($altArray)) && !$this->mconf['sectionIndex']) { $submenu = t3lib_div::makeInstance('tslib_'.$subLevelClass); $submenu->entryLevel = $this->entryLevel+1; $submenu->rL_uidRegister = $this->rL_uidRegister; $submenu->MP_array = $this->MP_array; if ($this->menuArr[$this->I['key']]['_MP_PARAM']) { $submenu->MP_array[] = $this->menuArr[$this->I['key']]['_MP_PARAM']; } // especially scripts that build the submenu needs the parent data $submenu->parent_cObj = &$this->parent_cObj; $submenu->parentMenuArr = $this->menuArr;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -