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

📄 class.tx_lowlevel_cleaner_core.php

📁 Typo3, 开源里边最强大的
💻 PHP
📖 第 1 页 / 共 2 页
字号:
						}					}						// Content:					if (is_array($res[$key]))	{						if (count($res[$key]))	{							if ($this->cli_echo('',1)) { print_r($res[$key]); }						} else {							$this->cli_echo('(None)'.chr(10).chr(10));						}					} else {						$this->cli_echo($res[$key].chr(10).chr(10));					}				}			}		}	}	/**************************	 *	 * Page tree traversal	 *	 *************************/	/**	 * Traverses the FULL/part of page tree, mainly to register ALL validly connected records (to find orphans) but also to register deleted records, versions etc.	 * Output (in $this->recStats) can be useful for multiple purposes.	 *	 * @param	integer		Root page id from where to start traversal. Use "0" (zero) to have full page tree (necessary when spotting orphans, otherwise you can run it on parts only)	 * @param	integer		Depth to traverse. zero is do not traverse at all. 1 = 1 sublevel, 1000= 1000 sublevels (all...)	 * @param	boolean		If >0, will echo information about the traversal process.	 * @param	string		Call back function (from this class or subclass)	 * @return	void	 */	function genTree($rootID,$depth=1000,$echoLevel=0,$callBack='')	{			// Initialize:		$this->workspaceIndex = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid,title','sys_workspace','1=1'.t3lib_BEfunc::deleteClause('sys_workspace'),'','','','uid');		$this->workspaceIndex[-1] = TRUE;		$this->workspaceIndex[0] = TRUE;		$this->recStats = array(			'all' => array(),									// All records connected in tree including versions (the reverse are orphans). All Info and Warning categories below are included here (and therefore safe if you delete the reverse of the list)			'deleted' => array(),								// Subset of "alL" that are deleted-flagged [Info]			'versions' => array(),								// Subset of "all" which are offline versions (pid=-1). [Info]			'versions_published' => array(),					// Subset of "versions" that is a count of 1 or more (has been published) [Info]			'versions_liveWS' => array(),						// Subset of "versions" that exists in live workspace [Info]			'versions_lost_workspace' => array(),				// Subset of "versions" that doesn't belong to an existing workspace [Warning: Fix by move to live workspace]			'versions_inside_versioned_page' => array(),		// Subset of "versions" This is versions of elements found inside an already versioned branch / page. In real life this can work out, but is confusing and the backend should prevent this from happening to people. [Warning: Fix by deleting those versions (or publishing them)]			'illegal_record_under_versioned_page' => array(),	// If a page is "element" or "page" version and records are found attached to it, they might be illegally attached, so this will tell you. [Error: Fix by deleting orphans since they are not registered in "all" category]			'misplaced_at_rootlevel' => array(),				// Subset of "all": Those that should not be at root level but are. [Warning: Fix by moving record into page tree]			'misplaced_inside_tree' => array(),					// Subset of "all": Those that are inside page tree but should be at root level [Warning: Fix by setting PID to zero]		);			// Start traversal:		$this->genTree_traverse($rootID,$depth,$echoLevel,$callBack);		if ($echoLevel>0)	echo chr(10).chr(10);	}	/**	 * Recursive traversal of page tree:	 *	 * @param	integer		Page root id (must be online, valid page record - or zero for page tree root)	 * @param	integer		Depth	 * @param	integer		Echo Level	 * @param	string		Call back function (from this class or subclass)	 * @param	string		DON'T set from outside, internal. (indicates we are inside a version of a page)	 * @param	integer		DON'T set from outside, internal. (1: Indicates that rootID is a version of a page, 2: ...that it is even a version of a version (which triggers a warning!)	 * @param	string		Internal string that accumulates the path	 * @return	void	 * @access private	 */	function genTree_traverse($rootID,$depth,$echoLevel=0,$callBack='',$versionSwapmode='',$rootIsVersion=0,$accumulatedPath='')	{			// Register page:		$this->recStats['all']['pages'][$rootID] = $rootID;		$pageRecord = t3lib_BEfunc::getRecordRaw('pages','uid='.intval($rootID),'deleted,title,t3ver_count,t3ver_wsid');		$accumulatedPath.='/'.$pageRecord['title'];			// Register if page is deleted:		if ($pageRecord['deleted'])	{			$this->recStats['deleted']['pages'][$rootID] = $rootID;		}			// If rootIsVersion is set it means that the input rootID is that of a version of a page. See below where the recursive call is made.		if ($rootIsVersion)	{			$this->recStats['versions']['pages'][$rootID] = $rootID;			if ($pageRecord['t3ver_count']>=1 && $pageRecord['t3ver_wsid']==0)	{	// If it has been published and is in archive now...				$this->recStats['versions_published']['pages'][$rootID] = $rootID;			}			if ($pageRecord['t3ver_wsid']==0)	{	// If it has been published and is in archive now...				$this->recStats['versions_liveWS']['pages'][$rootID] = $rootID;			}			if (!isset($this->workspaceIndex[$pageRecord['t3ver_wsid']]))	{	// If it doesn't belong to a workspace...				$this->recStats['versions_lost_workspace']['pages'][$rootID] = $rootID;			}			if ($rootIsVersion==2)	{	// In case the rootID is a version inside a versioned page				$this->recStats['versions_inside_versioned_page']['pages'][$rootID] = $rootID;			}		}		if ($echoLevel>0)			echo chr(10).$accumulatedPath.' ['.$rootID.']'.				($pageRecord['deleted'] ? ' (DELETED)':'').				($this->recStats['versions_published']['pages'][$rootID] ? ' (PUBLISHED)':'')				;		if ($echoLevel>1 && $this->recStats['versions_lost_workspace']['pages'][$rootID])			echo chr(10).'	ERROR! This version belongs to non-existing workspace ('.$pageRecord['t3ver_wsid'].')!';		if ($echoLevel>1 && $this->recStats['versions_inside_versioned_page']['pages'][$rootID])			echo chr(10).'	WARNING! This version is inside an already versioned page or branch!';			// Call back:		if ($callBack)	{			$this->$callBack('pages',$rootID,$echoLevel,$versionSwapmode,$rootIsVersion);		}			// Traverse tables of records that belongs to page:		foreach($GLOBALS['TCA'] as $tableName => $cfg)	{			if ($tableName!='pages') {					// Select all records belonging to page:				$resSub = $GLOBALS['TYPO3_DB']->exec_SELECTquery(					'uid'.($GLOBALS['TCA'][$tableName]['ctrl']['delete']?','.$GLOBALS['TCA'][$tableName]['ctrl']['delete']:''),					$tableName,					'pid='.intval($rootID).						($this->genTree_traverseDeleted ? '' : t3lib_BEfunc::deleteClause($tableName))				);				$count = $GLOBALS['TYPO3_DB']->sql_num_rows($resSub);				if ($count)	{					if ($echoLevel==2)	echo chr(10).'	\-'.$tableName.' ('.$count.')';				}				while ($rowSub = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($resSub))	{					if ($echoLevel==3)	echo chr(10).'	\-'.$tableName.':'.$rowSub['uid'];						// If the rootID represents an "element" or "page" version type, we must check if the record from this table is allowed to belong to this:					if ($versionSwapmode=='SWAPMODE:-1' || ($versionSwapmode=='SWAPMODE:0' && !$GLOBALS['TCA'][$tableName]['ctrl']['versioning_followPages']))	{							// This is illegal records under a versioned page - therefore not registered in $this->recStats['all'] so they should be orphaned:						$this->recStats['illegal_record_under_versioned_page'][$tableName][$rowSub['uid']] = $rowSub['uid'];						if ($echoLevel>1)	echo chr(10).'		ERROR! Illegal record ('.$tableName.':'.$rowSub['uid'].') under versioned page!';					} else {						$this->recStats['all'][$tableName][$rowSub['uid']] = $rowSub['uid'];							// Register deleted:						if ($GLOBALS['TCA'][$tableName]['ctrl']['delete'] && $rowSub[$GLOBALS['TCA'][$tableName]['ctrl']['delete']])	{							$this->recStats['deleted'][$tableName][$rowSub['uid']] = $rowSub['uid'];							if ($echoLevel==3)	echo ' (DELETED)';						}							// Check location of records regarding tree root:						if (!$GLOBALS['TCA'][$tableName]['ctrl']['rootLevel'] && $rootID==0) {							$this->recStats['misplaced_at_rootlevel'][$tableName][$rowSub['uid']] = $rowSub['uid'];							if ($echoLevel>1)	echo chr(10).'		ERROR! Misplaced record ('.$tableName.':'.$rowSub['uid'].') on rootlevel!';						}						if ($GLOBALS['TCA'][$tableName]['ctrl']['rootLevel']==1 && $rootID>0) {							$this->recStats['misplaced_inside_tree'][$tableName][$rowSub['uid']] = $rowSub['uid'];							if ($echoLevel>1)	echo chr(10).'		ERROR! Misplaced record ('.$tableName.':'.$rowSub['uid'].') inside page tree!';						}							// Traverse plugins:						if ($callBack)	{							$this->$callBack($tableName,$rowSub['uid'],$echoLevel,$versionSwapmode,$rootIsVersion);						}							// Add any versions of those records:						if ($this->genTree_traverseVersions)	{							$versions = t3lib_BEfunc::selectVersionsOfRecord($tableName, $rowSub['uid'], 'uid,t3ver_wsid,t3ver_count'.($GLOBALS['TCA'][$tableName]['ctrl']['delete']?','.$GLOBALS['TCA'][$tableName]['ctrl']['delete']:''), 0, TRUE);							if (is_array($versions))	{								foreach($versions as $verRec)	{									if (!$verRec['_CURRENT_VERSION'])	{										if ($echoLevel==3)	echo chr(10).'		\-[#OFFLINE VERSION: WS#'.$verRec['t3ver_wsid'].'/Cnt:'.$verRec['t3ver_count'].'] '.$tableName.':'.$verRec['uid'].')';										$this->recStats['all'][$tableName][$verRec['uid']] = $verRec['uid'];											// Register deleted:										if ($GLOBALS['TCA'][$tableName]['ctrl']['delete'] && $verRec[$GLOBALS['TCA'][$tableName]['ctrl']['delete']])	{											$this->recStats['deleted'][$tableName][$verRec['uid']] = $verRec['uid'];											if ($echoLevel==3)	echo ' (DELETED)';										}											// Register version:										$this->recStats['versions'][$tableName][$verRec['uid']] = $verRec['uid'];										if ($verRec['t3ver_count']>=1 && $verRec['t3ver_wsid']==0)	{	// Only register published versions in LIVE workspace (published versions in draft workspaces are allowed)											$this->recStats['versions_published'][$tableName][$verRec['uid']] = $verRec['uid'];											if ($echoLevel==3)	echo ' (PUBLISHED)';										}										if ($verRec['t3ver_wsid']==0)	{											$this->recStats['versions_liveWS'][$tableName][$verRec['uid']] = $verRec['uid'];										}										if (!isset($this->workspaceIndex[$verRec['t3ver_wsid']]))	{											$this->recStats['versions_lost_workspace'][$tableName][$verRec['uid']] = $verRec['uid'];											if ($echoLevel>1)	echo chr(10).'		ERROR! Version ('.$tableName.':'.$verRec['uid'].') belongs to non-existing workspace ('.$verRec['t3ver_wsid'].')!';										}										if ($versionSwapmode)	{	// In case we are inside a versioned branch, there should not exists versions inside that "branch".											$this->recStats['versions_inside_versioned_page'][$tableName][$verRec['uid']] = $verRec['uid'];											if ($echoLevel>1)	echo chr(10).'		ERROR! This version ('.$tableName.':'.$verRec['uid'].') is inside an already versioned page or branch!';										}											// Traverse plugins:										if ($callBack)	{											$this->$callBack($tableName,$verRec['uid'],$echoLevel,$versionSwapmode,$rootIsVersion);										}									}								}							}							unset($versions);						}					}				}			}		}		unset($resSub);		unset($rowSub);			// Find subpages to root ID and traverse (only when rootID is not a version or is a branch-version):		if (!$versionSwapmode || $versionSwapmode=='SWAPMODE:1')	{			if ($depth>0)	{				$depth--;				$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(					'uid',					'pages',					'pid='.intval($rootID).						($this->genTree_traverseDeleted ? '' : t3lib_BEfunc::deleteClause('pages')),					'',					'sorting'				);				while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))	{					$this->genTree_traverse($row['uid'],$depth,$echoLevel,$callBack,$versionSwapmode,0,$accumulatedPath);				}			}				// Add any versions of pages			if ($rootID>0 && $this->genTree_traverseVersions)	{				$versions = t3lib_BEfunc::selectVersionsOfRecord('pages', $rootID, 'uid,t3ver_oid,t3ver_wsid,t3ver_count,t3ver_swapmode', 0, TRUE);				if (is_array($versions))	{					foreach($versions as $verRec)	{						if (!$verRec['_CURRENT_VERSION'])	{							$this->genTree_traverse($verRec['uid'],$depth,$echoLevel,$callBack,'SWAPMODE:'.t3lib_div::intInRange($verRec['t3ver_swapmode'],-1,1),$versionSwapmode?2:1,$accumulatedPath.' [#OFFLINE VERSION: WS#'.$verRec['t3ver_wsid'].'/Cnt:'.$verRec['t3ver_count'].']');						}					}				}			}		}	}	/**************************	 *	 * Helper functions	 *	 *************************/	/**	 * Compile info-string	 *	 * @param	array		Input record from sys_refindex	 * @return	string		String identifying the main record of the reference	 */	function infoStr($rec)	{		return $rec['tablename'].':'.$rec['recuid'].':'.$rec['field'].':'.$rec['flexpointer'].':'.$rec['softref_key'].($rec['deleted'] ? ' (DELETED)':'');	}}if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/lowlevel/class.tx_lowlevel_cleaner.php'])	{	include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/lowlevel/class.tx_lowlevel_cleaner.php']);}?>

⌨️ 快捷键说明

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