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

📄 class.tx_impexp.php

📁 Typo3, 开源里边最强大的
💻 PHP
📖 第 1 页 / 共 5 页
字号:
	 * @return	void	 */	function addThumbnail($imgFilepath)	{		if (@is_file($imgFilepath))	{			$imgInfo = @getimagesize($imgFilepath);			if (is_array($imgInfo))	{				$fileContent = t3lib_div::getUrl($imgFilepath);				$this->dat['header']['thumbnail'] = array(					'imgInfo' => $imgInfo,					'content' => $fileContent,					'filesize' => strlen($fileContent),					'filemtime' => filemtime($imgFilepath),					'filename' => basename($imgFilepath)				);			}		}	}	/**************************	 *	 * Export / Init Page tree	 *	 *************************/	/**	 * Sets the page-tree array in the export header and returns the array in a flattened version	 *	 * @param	array		Hierarchy of ids, the page tree: array([uid] => array("uid" => [uid], "subrow" => array(.....)), [uid] => ....)	 * @return	array		The hierarchical page tree converted to a one-dimensional list of pages	 */	function setPageTree($idH)	{		$this->dat['header']['pagetree'] = $this->unsetExcludedSections($idH);		return $this->flatInversePageTree($this->dat['header']['pagetree']);	}	/**	 * Removes entries in the page tree which are found in ->excludeMap[]	 *	 * @param	array		Page uid hierarchy	 * @return	array		Modified input array	 * @access private	 * @see setPageTree()	 */	function unsetExcludedSections($idH)	{		if (is_array($idH))	{			reset($idH);			while(list($k,$v) = each($idH))	{				if ($this->excludeMap['pages:'.$idH[$k]['uid']])	{					unset($idH[$k]);				} elseif (is_array($idH[$k]['subrow']))	{					$idH[$k]['subrow'] = $this->unsetExcludedSections($idH[$k]['subrow']);				}			}		}		return $idH;	}	/**	 * Recursively flattening the idH array (for setPageTree() function)	 *	 * @param	array		Page uid hierarchy	 * @param	array		Accumulation array of pages (internal, don't set from outside)	 * @return	array		Array with uid-uid pairs for all pages in the page tree.	 * @see flatInversePageTree_pid()	 */	function flatInversePageTree($idH,$a=array())	{		if (is_array($idH))	{			$idH = array_reverse($idH);			reset($idH);			while(list($k,$v) = each($idH))	{				$a[$v['uid']] = $v['uid'];				if (is_array($v['subrow']))	{					$a = $this->flatInversePageTree($v['subrow'],$a);				}			}		}		return $a;	}	/**	 * Recursively flattening the idH array (for setPageTree() function), setting PIDs as values	 *	 * @param	array		Page uid hierarchy	 * @param	array		Accumulation array of pages (internal, don't set from outside)	 * @param	integer		PID value (internal)	 * @return	array		Array with uid-pid pairs for all pages in the page tree.	 * @see flatInversePageTree()	 */	function flatInversePageTree_pid($idH,$a=array(),$pid=-1)	{		if (is_array($idH))	{			$idH = array_reverse($idH);			reset($idH);			while(list($k,$v) = each($idH))	{				$a[$v['uid']] = $pid;				if (is_array($v['subrow']))	{					$a = $this->flatInversePageTree_pid($v['subrow'],$a,$v['uid']);				}			}		}		return $a;	}	/**************************	 *	 * Export	 *	 *************************/	/**	 * Adds the record $row from $table.	 * No checking for relations done here. Pure data.	 *	 * @param	string		Table name	 * @param	array		Record row.	 * @param	integer		(Internal) if the record is added as a relation, this is set to the "level" it was on.	 * @return	void	 */	function export_addRecord($table,$row,$relationLevel=0)	{		t3lib_BEfunc::workspaceOL($table,$row);		if (strcmp($table,'') && is_array($row) && $row['uid']>0 && !$this->excludeMap[$table.':'.$row['uid']])	{			if ($this->checkPID($table==='pages' ? $row['uid'] : $row['pid']))	{				if (!isset($this->dat['records'][$table.':'.$row['uid']]))	{						// Prepare header info:					$headerInfo = array();					$headerInfo['uid'] = $row['uid'];					$headerInfo['pid'] = $row['pid'];					$headerInfo['title'] = t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle($table,$row),40);					$headerInfo['size'] = strlen(serialize($row));					if ($relationLevel)	{						$headerInfo['relationLevel'] = $relationLevel;					}						// If record content is not too large in size, set the header content and add the rest:					if ($headerInfo['size']<$this->maxRecordSize)	{							// Set the header summary:						$this->dat['header']['records'][$table][$row['uid']] = $headerInfo;							// Create entry in the PID lookup:						$this->dat['header']['pid_lookup'][$row['pid']][$table][$row['uid']]=1;							// Initialize reference index object:						$refIndexObj = t3lib_div::makeInstance('t3lib_refindex');						$refIndexObj->WSOL = TRUE;	// Yes to workspace overlays for exporting....							// Data:						$this->dat['records'][$table.':'.$row['uid']] = array();						$this->dat['records'][$table.':'.$row['uid']]['data'] = $row;						$this->dat['records'][$table.':'.$row['uid']]['rels'] = $refIndexObj->getRelations($table,$row);						$this->errorLog = array_merge($this->errorLog,$refIndexObj->errorLog);	// Merge error logs.							// Add information about the relations in the record in the header:						$this->dat['header']['records'][$table][$row['uid']]['rels'] = $this->flatDBrels($this->dat['records'][$table.':'.$row['uid']]['rels']);							// Add information about the softrefs to header:						$this->dat['header']['records'][$table][$row['uid']]['softrefs'] = $this->flatSoftRefs($this->dat['records'][$table.':'.$row['uid']]['rels']);					} else $this->error('Record '.$table.':'.$row['uid'].' was larger than maxRecordSize ('.t3lib_div::formatSize($this->maxRecordSize).')');				} else $this->error('Record '.$table.':'.$row['uid'].' already added.');			} else $this->error('Record '.$table.':'.$row['uid'].' was outside your DB mounts!');		}	}	/**	 * This analyses the existing added records, finds all database relations to records and adds these records to the export file.	 * This function can be called repeatedly until it returns an empty array. In principle it should not allow to infinite recursivity, but you better set a limit...	 * Call this BEFORE the ext_addFilesFromRelations (so files from added relations are also included of course)	 *	 * @param	integer		Recursion level	 * @return	array		overview of relations found and added: Keys [table]:[uid], values array with table and id	 * @see export_addFilesFromRelations()	 */	function export_addDBRelations($relationLevel=0)	{		global $TCA;			// Initialize:		$addR = array();			// Traverse all "rels" registered for "records"		if (is_array($this->dat['records']))	{			reset($this->dat['records']);			while(list($k) = each($this->dat['records']))	{				if (is_array($this->dat['records'][$k]))	{					reset($this->dat['records'][$k]['rels']);					while(list($fieldname,$vR) = each($this->dat['records'][$k]['rels']))	{#debug($vR);							// For all DB types of relations:						if ($vR['type']=='db')	{							foreach($vR['itemArray'] as $fI)	{								$this->export_addDBRelations_registerRelation($fI, $addR);							}						}							// For all flex/db types of relations:						if ($vR['type']=='flex')	{								// DB relations in flex form fields:							if (is_array($vR['flexFormRels']['db']))	{								foreach($vR['flexFormRels']['db'] as $subList)	{									foreach($subList as $fI)	{										$this->export_addDBRelations_registerRelation($fI, $addR);									}								}							}								// DB oriented soft references in flex form fields:							if (is_array($vR['flexFormRels']['softrefs']))	{								foreach($vR['flexFormRels']['softrefs'] as $subList)	{									foreach($subList['keys'] as $spKey => $elements)	{										foreach($elements as $el)	{											if ($el['subst']['type'] === 'db' && $this->includeSoftref($el['subst']['tokenID']))	{												list($tempTable, $tempUid) = explode(':', $el['subst']['recordRef']);												$fI = array(													'table' => $tempTable,													'id' => $tempUid												);												$this->export_addDBRelations_registerRelation($fI, $addR, $el['subst']['tokenID']);											}										}									}								}							}						}							// In any case, if there are soft refs:						if (is_array($vR['softrefs']['keys']))	{							foreach($vR['softrefs']['keys'] as $spKey => $elements)	{								foreach($elements as $el)	{									if ($el['subst']['type'] === 'db' && $this->includeSoftref($el['subst']['tokenID']))	{										list($tempTable, $tempUid) = explode(':', $el['subst']['recordRef']);										$fI = array(											'table' => $tempTable,											'id' => $tempUid										);										$this->export_addDBRelations_registerRelation($fI, $addR, $el['subst']['tokenID']);									}								}							}						}					}				}			}		} else $this->error('There were no records available.');			// Now, if there were new records to add, do so:		if (count($addR))	{			foreach($addR as $fI)	{					// Get and set record:				$row = t3lib_BEfunc::getRecord($fI['table'],$fI['id']);				if (is_array($row))	{					$this->export_addRecord($fI['table'],$row,$relationLevel+1);				}					// Set status message				if ($fI['id']>0)	{	// Relation pointers always larger than zero except certain "select" types with negative values pointing to uids - but that is not supported here.					$rId = $fI['table'].':'.$fI['id'];					if (!isset($this->dat['records'][$rId]))	{						$this->dat['records'][$rId] = 'NOT_FOUND';						$this->error('Relation record '.$rId.' was not found!');					}				}			}		}			// Return overview of relations found and added		return $addR;	}	/**	 * Helper function for export_addDBRelations()	 *	 * @param	array		Array with table/id keys to add	 * @param	array		Add array, passed by reference to be modified	 * @param	string		Softref Token ID, if applicable.	 * @return	void	 * @see export_addDBRelations()	 */	function export_addDBRelations_registerRelation($fI, &$addR, $tokenID='')	{		global $TCA;		$rId = $fI['table'].':'.$fI['id'];		if (isset($TCA[$fI['table']])				&& !$this->isTableStatic($fI['table'])				&& !$this->isExcluded($fI['table'],$fI['id'])				&& (!$tokenID || $this->includeSoftref($tokenID))				&& $this->inclRelation($fI['table'])				)	{			if (!isset($this->dat['records'][$rId]))	{					// Set this record to be included since it is not already.				$addR[$rId] = $fI;			}		}	}	/**	 * This adds all files in relations.	 * Call this method AFTER adding all records including relations.	 *	 * @return	void	 * @see export_addDBRelations()	 */	function export_addFilesFromRelations()	{			// Traverse all "rels" registered for "records"		if (is_array($this->dat['records']))	{			reset($this->dat['records']);			while(list($k)=each($this->dat['records']))	{				if (is_array($this->dat['records'][$k]['rels']))	{					reset($this->dat['records'][$k]['rels']);					while(list($fieldname,$vR)=each($this->dat['records'][$k]['rels']))	{							// For all file type relations:						if ($vR['type']=='file')	{							foreach($vR['newValueFiles'] as $key => $fI)	{								$this->export_addFile($fI, $k, $fieldname);									// Remove the absolute reference to the file so it doesn't expose absolute paths from source server:								unset($this->dat['records'][$k]['rels'][$fieldname]['newValueFiles'][$key]['ID_absFile']);							}						}							// For all flex type relations:						if ($vR['type']=='flex')	{							if (is_array($vR['flexFormRels']['file']))	{								foreach($vR['flexFormRels']['file'] as $key => $subList)	{									foreach($subList as $subKey => $fI)	{										$this->export_addFile($fI, $k, $fieldname);

⌨️ 快捷键说明

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