⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 class.tslib_menu.php

📁 Typo3, 开源里边最强大的
💻 PHP
📖 第 1 页 / 共 5 页
字号:
										$temp[$temp_key]['_MP_PARAM'] = implode(',',$rl_MParray);									}								} else unset($temp[$temp_key]);							}								// For normal mount points, set the variable for next level.							if ($v_rl['_MP_PARAM'] && !$v_rl['_MOUNT_OL'])	{								$rl_MParray[] = $v_rl['_MP_PARAM'];						}						}					break;					case 'browse':						list($value)=t3lib_div::intExplode(',',$value);						if (!$value) {							$value=$GLOBALS['TSFE']->page['uid'];						}						if ($value!=$this->tmpl->rootLine[0]['uid'])	{	// Will not work out of rootline							$recArr=array();							$value_rec=$this->sys_page->getPage($value);	// The page record of the 'value'.							if ($value_rec['pid'])	{	// 'up' page cannot be outside rootline								$recArr['up']=$this->sys_page->getPage($value_rec['pid']);	// The page record of 'up'.							}							if ($recArr['up']['pid'] && $value_rec['pid']!=$this->tmpl->rootLine[0]['uid'])	{	// If the 'up' item was NOT level 0 in rootline...								$recArr['index']=$this->sys_page->getPage($recArr['up']['pid']);	// The page record of "index".							}								// prev / next is found							$prevnext_menu = $this->sys_page->getMenu($value_rec['pid'],'*',$altSortField);							$lastKey=0;							$nextActive=0;							reset($prevnext_menu);							while(list($k_b,$v_b)=each($prevnext_menu))	{								if ($nextActive)	{									$recArr['next']=$v_b;									$nextActive=0;								}								if ($v_b['uid']==$value)	{									if ($lastKey)	{										$recArr['prev']=$prevnext_menu[$lastKey];									}									$nextActive=1;								}								$lastKey=$k_b;							}							reset($prevnext_menu);							$recArr['first']=pos($prevnext_menu);							end($prevnext_menu);							$recArr['last']=pos($prevnext_menu);								// prevsection / nextsection is found							if (is_array($recArr['index']))	{	// You can only do this, if there is a valid page two levels up!								$prevnextsection_menu = $this->sys_page->getMenu($recArr['index']['uid'],'*',$altSortField);								$lastKey=0;								$nextActive=0;								reset($prevnextsection_menu);								while(list($k_b,$v_b)=each($prevnextsection_menu))	{									if ($nextActive)	{										$sectionRec_temp = $this->sys_page->getMenu($v_b['uid'],'*',$altSortField);										if (count($sectionRec_temp))	{											reset($sectionRec_temp);											$recArr['nextsection']=pos($sectionRec_temp);											end ($sectionRec_temp);											$recArr['nextsection_last']=pos($sectionRec_temp);											$nextActive=0;										}									}									if ($v_b['uid']==$value_rec['pid'])	{										if ($lastKey)	{											$sectionRec_temp = $this->sys_page->getMenu($prevnextsection_menu[$lastKey]['uid'],'*',$altSortField);											if (count($sectionRec_temp))	{												reset($sectionRec_temp);												$recArr['prevsection']=pos($sectionRec_temp);												end ($sectionRec_temp);												$recArr['prevsection_last']=pos($sectionRec_temp);											}										}										$nextActive=1;									}									$lastKey=$k_b;								}							}							if ($this->conf['special.']['items.']['prevnextToSection'])	{								if (!is_array($recArr['prev']) && is_array($recArr['prevsection_last']))	{									$recArr['prev']=$recArr['prevsection_last'];								}								if (!is_array($recArr['next']) && is_array($recArr['nextsection']))	{									$recArr['next']=$recArr['nextsection'];								}							}							$items = explode('|',$this->conf['special.']['items']);							$c=0;							while(list($k_b,$v_b)=each($items))	{								$v_b=strtolower(trim($v_b));								if (intval($this->conf['special.'][$v_b.'.']['uid']))	{									$recArr[$v_b] = $this->sys_page->getPage(intval($this->conf['special.'][$v_b.'.']['uid']));	// fetches the page in case of a hardcoded pid in template								}								if (is_array($recArr[$v_b]))	{									$temp[$c]=$recArr[$v_b];									if ($this->conf['special.'][$v_b.'.']['target'])	{										$temp[$c]['target']=$this->conf['special.'][$v_b.'.']['target'];									}									if (is_array($this->conf['special.'][$v_b.'.']['fields.']))	{										reset($this->conf['special.'][$v_b.'.']['fields.']);										while(list($fk,$val)=each($this->conf['special.'][$v_b.'.']['fields.']))	{											$temp[$c][$fk]=$val;										}									}									$c++;								}							}						}					break;				}			} elseif (is_array($this->alternativeMenuTempArray))	{	// Setting $temp array if not level 1.				$temp = $this->alternativeMenuTempArray;			} elseif ($this->mconf['sectionIndex']) {				if ($GLOBALS['TSFE']->sys_language_uid && count($this->sys_page->getPageOverlay($this->id)))	{					$sys_language_uid = intval($GLOBALS['TSFE']->sys_language_uid);				} else $sys_language_uid=0;				$selectSetup = Array(					'pidInList'=>$this->id,					'orderBy'=>$altSortField,					'where' => 'colPos=0 AND sys_language_uid='.$sys_language_uid,					'andWhere' => 'sectionIndex!=0'					);				switch($this->mconf['sectionIndex.']['type'])	{					case 'all':						unset($selectSetup['andWhere']);					break;					case 'header':						$selectSetup['andWhere']='header_layout!=100 AND header!=""';					break;				}				$basePageRow=$this->sys_page->getPage($this->id);				if (is_array($basePageRow))	{					$res = $GLOBALS['TSFE']->cObj->exec_getQuery('tt_content',	$selectSetup);					while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))	{						$GLOBALS['TSFE']->sys_page->versionOL('tt_content',$row);						if (is_array($row))	{							$temp[$row['uid']] = $basePageRow;							$temp[$row['uid']]['title'] = $row['header'];							$temp[$row['uid']]['nav_title'] = $row['header'];							$temp[$row['uid']]['subtitle'] = $row['subheader'];							$temp[$row['uid']]['starttime'] = $row['starttime'];							$temp[$row['uid']]['endtime'] = $row['endtime'];							$temp[$row['uid']]['fe_group'] = $row['fe_group'];							$temp[$row['uid']]['media'] = $row['media'];							$temp[$row['uid']]['header_layout'] = $row['header_layout'];							$temp[$row['uid']]['bodytext'] = $row['bodytext'];							$temp[$row['uid']]['image'] = $row['image'];							$temp[$row['uid']]['sectionIndex_uid'] = $row['uid'];						}					}				}			} else {	// Default:				$temp = $this->sys_page->getMenu($this->id,'*',$altSortField);		// gets the menu			}			$c=0;			$c_b=0;			$minItems = intval($this->mconf['minItems'] ? $this->mconf['minItems'] : $this->conf['minItems']);			$maxItems = intval($this->mconf['maxItems'] ? $this->mconf['maxItems'] : $this->conf['maxItems']);			$begin = tslib_cObj::calc($this->mconf['begin'] ? $this->mconf['begin'] : $this->conf['begin']);			$banUidArray = $this->getBannedUids();				// Fill in the menuArr with elements that should go into the menu:			$this->menuArr = Array();			foreach($temp as $data)	{				$spacer = (t3lib_div::inList($this->spacerIDList,$data['doktype']) || !strcmp($data['ITEM_STATE'],'SPC')) ? 1 : 0;		// if item is a spacer, $spacer is set				if ($this->filterMenuPages($data, $banUidArray, $spacer))	{					$c_b++;					if ($begin<=$c_b)	{		// If the beginning item has been reached.						$this->menuArr[$c] = $data;						$this->menuArr[$c]['isSpacer'] = $spacer;						$c++;						if ($maxItems && $c>=$maxItems)	{							break;						}					}				}			}				// Fill in fake items, if min-items is set.			if ($minItems)	{				while($c<$minItems)	{					$this->menuArr[$c] = Array(						'title' => '...',						'uid' => $GLOBALS['TSFE']->id					);					$c++;				}			}				// Setting number of menu items			$GLOBALS['TSFE']->register['count_menuItems'] = count($this->menuArr);				//	Passing the menuArr through a user defined function:			if ($this->mconf['itemArrayProcFunc'])	{				if (!is_array($this->parentMenuArr)) {$this->parentMenuArr=array();}				$this->menuArr = $this->userProcess('itemArrayProcFunc',$this->menuArr);			}			$this->hash = md5(serialize($this->menuArr).serialize($this->mconf).serialize($this->tmpl->rootLine).serialize($this->MP_array));			$serData = $this->sys_page->getHash($this->hash, 60*60*24);			if (!$serData)	{				$this->generate();				$this->sys_page->storeHash($this->hash, serialize($this->result),'MENUDATA');			} else {				$this->result = unserialize($serData);			}				// End showAccessRestrictedPages			if ($this->mconf['showAccessRestrictedPages'])	{					// RESTORING where_groupAccess				$this->sys_page->where_groupAccess = $SAVED_where_groupAccess;			}		}	}	/**	 * Includes the PHP script defined for the HMENU special type "userdefined".	 * This script is supposed to populate the array $menuItemsArray with a set of page records comprising the menu.	 * The "userdefined" type is deprecated since "userfunction" has arrived since and is a better choice for many reasons (like using classes/functions for rendering the menu)	 *	 * @param	array		TypoScript parameters for "special.". In particular the property "file" is reserved and specifies the file to include. Seems like any other property can be used freely by the script.	 * @param	string		The sorting field. Can be used from the script in the $incFile.	 * @return	array		An array with the menu items	 * @access private	 */	function includeMakeMenu($conf,$altSortField)	{		$incFile = $GLOBALS['TSFE']->tmpl->getFileName($conf['file']);		if ($incFile && $GLOBALS['TSFE']->checkFileInclude($incFile))	{			include($incFile);		}		return is_array($menuItemsArray) ? $menuItemsArray : array();	}	/**	 * Checks if a page is OK to include in the final menu item array. Pages can be excluded if the doktype is wrong, if they are hidden in navigation, have a uid in the list of banned uids etc.	 *	 * @param	array		Array of menu items	 * @param	array		Array of page uids which are to be excluded	 * @param	boolean		If set, then the page is a spacer.	 * @return	boolean		Returns true if the page can be safely included.	 */	function filterMenuPages(&$data,$banUidArray,$spacer)	{		if ($data['_SAFE'])	return TRUE;		$uid = $data['uid'];		if ($this->mconf['SPC'] || !$spacer)	{	// If the spacer-function is not enabled, spacers will not enter the $menuArr			if (!t3lib_div::inList($this->doktypeExcludeList,$data['doktype']))	{		// Page may not be 'not_in_menu' or 'Backend User Section'				if (!$data['nav_hide'] || $this->conf['includeNotInMenu'])	{	// Not hidden in navigation					if (!t3lib_div::inArray($banUidArray,$uid))	{	// not in banned uid's							// Checks if the default language version can be shown:							// Block page is set, if l18n_cfg allows plus: 1) Either default language or 2) another language but NO overlay record set for page!						$blockPage = $data['l18n_cfg']&1 && (!$GLOBALS['TSFE']->sys_language_uid || ($GLOBALS['TSFE']->sys_language_uid && !$data['_PAGES_OVERLAY']));						if (!$blockPage)	{								// Checking if a page should be shown in the menu depending on whether a translation exists:							$tok = TRUE;							if ($GLOBALS['TSFE']->sys_language_uid && t3lib_div::hideIfNotTranslated($data['l18n_cfg']))	{	// There is an alternative language active AND the current page requires a translation:								if (!$data['_PAGES_OVERLAY'])	{									$tok = FALSE;								}							}								// Continue if token is true:							if ($tok)	{									// Checking if "&L" should be modified so links to non-accessible pages will not happen.								if ($this->conf['protectLvar'])	{									$languageUid = intval($GLOBALS['TSFE']->config['config']['sys_language_uid']);									if ($languageUid && ($this->conf['protectLvar']=='all' || t3lib_div::hideIfNotTranslated($data['l18n_cfg'])))	{										$olRec = $GLOBALS['TSFE']->sys_page->getPageOverlay($data['uid'], $languageUid);										if (!count($olRec))	{												// If no pages_language_overlay record then page can NOT be accessed in the language pointed to by "&L" and therefore we protect the link by setting "&L=0"											$data['_ADD_GETVARS'].= '&L=0';										}									}								}								return TRUE;							}						}					}				}			}		}	}	/**	 * Generating the per-menu-item configuration arrays based on the settings for item states (NO, RO, ACT, CUR etc) set in ->mconf (config for the current menu object)	 * Basically it will produce an individual array for each menu item based on the item states. BUT in addition the "optionSplit" syntax for the values is ALSO evaluated here so that all property-values are "option-splitted" and the output will thus be resolved.	 * Is called from the "generate" functions in the extension classes. The function is processor intensive due to the option split feature in particular. But since the generate function is not always called (since the ->result array may be cached, see makeMenu) it doesn't hurt so badly.	 *	 * @param	integer		Number of menu items in the menu	 * @return	array		An array with two keys: array($NOconf,$ROconf) - where $NOconf contains the resolved configuration for each item when NOT rolled-over and $ROconf contains the ditto for the mouseover state (if any)	 * @access private	 */	function procesItemStates($splitCount)	{			// Prepare normal settings		if (!is_array($this->mconf['NO.']) && $this->mconf['NO'])	$this->mconf['NO.']=array();	// Setting a blank array if NO=1 and there are no properties.		$NOconf = $this->tmpl->splitConfArray($this->mconf['NO.'],$splitCount);			// Prepare rollOver settings, overriding normal settings		$ROconf=array();		if ($this->mconf['RO'])	{			$ROconf = $this->tmpl->splitConfArray($this->mconf['RO.'],$splitCount);		}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -