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

📄 class.tx_impexp.php

📁 Typo3, 开源里边最强大的
💻 PHP
📖 第 1 页 / 共 5 页
字号:
<?php/****************************************************************  Copyright notice**  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)*  All rights reserved**  This script is part of the TYPO3 project. The TYPO3 project is*  free software; you can redistribute it and/or modify*  it under the terms of the GNU General Public License as published by*  the Free Software Foundation; either version 2 of the License, or*  (at your option) any later version.**  The GNU General Public License can be found at*  http://www.gnu.org/copyleft/gpl.html.*  A copy is found in the textfile GPL.txt and important notices to the license*  from the author is found in LICENSE.txt distributed with these scripts.***  This script is distributed in the hope that it will be useful,*  but WITHOUT ANY WARRANTY; without even the implied warranty of*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the*  GNU General Public License for more details.**  This copyright notice MUST APPEAR in all copies of the script!***************************************************************//** * T3D file Import/Export library (TYPO3 Record Document) * * @author	Kasper Skaarhoj <kasperYYYY@typo3.com> *//** * [CLASS/FUNCTION INDEX of SCRIPT] * * * *  198: class tx_impexp * *              SECTION: Initialize *  261:     function init($dontCompress=0,$mode='') * *              SECTION: Export / Init + Meta Data *  292:     function setHeaderBasics() *  316:     function setCharset($charset) *  331:     function setMetaData($title,$description,$notes,$packager_username,$packager_name,$packager_email) *  351:     function addThumbnail($imgFilepath) * *              SECTION: Export / Init Page tree *  389:     function setPageTree($idH) *  402:     function unsetExcludedSections($idH) *  424:     function flatInversePageTree($idH,$a=array()) *  447:     function flatInversePageTree_pid($idH,$a=array(),$pid=-1) * *              SECTION: Export *  486:     function export_addRecord($table,$row,$relationLevel=0) *  544:     function export_addDBRelations($relationLevel=0) *  648:     function export_addDBRelations_registerRelation($fI, &$addR, $tokenID='') *  672:     function export_addFilesFromRelations() *  773:     function export_addFile($fI, $recordRef='', $fieldname='') *  898:     function flatDBrels($dbrels) *  924:     function flatSoftRefs($dbrels) * *              SECTION: File Output *  988:     function compileMemoryToFileContent($type='') * 1014:     function createXML() * 1106:     function doOutputCompress() * 1117:     function addFilePart($data, $compress=FALSE) * *              SECTION: Import * 1150:     function importData($pid) * 1191:     function writeRecords_pages($pid) * 1246:     function writeRecords_pages_order($pid) * 1284:     function writeRecords_records($pid) * 1334:     function writeRecords_records_order($mainPid) * 1383:     function addSingle($table,$uid,$pid) * 1457:     function addToMapId($substNEWwithIDs) * 1477:     function getNewTCE() * 1491:     function unlinkTempFiles() * *              SECTION: Import / Relations setting * 1529:     function setRelations() * 1584:     function setRelations_db($itemArray) * 1611:     function import_addFileNameToBeCopied($fI) * 1634:     function setFlexFormRelations() * 1718:     function remapListedDBRecords_flexFormCallBack($pParams, $dsConf, $dataValue, $dataValue_ext1, $dataValue_ext2, $path) * *              SECTION: Import / Soft References * 1760:     function processSoftReferences() * 1851:     function processSoftReferences_flexFormCallBack($pParams, $dsConf, $dataValue, $dataValue_ext1, $dataValue_ext2, $path) * 1890:     function processSoftReferences_substTokens($tokenizedContent, $softRefCfgs, $table, $uid) * 1954:     function processSoftReferences_saveFile($relFileName, $cfg, $table, $uid) * 2015:     function processSoftReferences_saveFile_createRelFile($origDirPrefix, $fileName, $fileID, $table, $uid) * 2104:     function writeFileVerify($fileName, $fileID, $bypassMountCheck=FALSE) * 2131:     function checkOrCreateDir($dirPrefix) * 2164:     function verifyFolderAccess($dirPrefix, $noAlternative=FALSE) * *              SECTION: File Input * 2214:     function loadFile($filename,$all=0) * 2257:     function getNextFilePart($fd,$unserialize=0,$name='') * 2284:     function loadContent($filecontent) * 2302:     function getNextContentPart($filecontent,&$pointer,$unserialize=0,$name='') * 2327:     function loadInit() * 2343:     function fixCharsets() * *              SECTION: Visual rendering of import/export memory, $this->dat * 2398:     function displayContentOverview() * 2506:     function traversePageTree($pT,&$lines,$preCode='') * 2541:     function traversePageRecords($pT,&$lines) * 2568:     function traverseAllRecords($pT,&$lines) * 2590:     function singleRecordLines($table,$uid,&$lines,$preCode,$checkImportInPidRecord=0) * 2748:     function addRelations($rels,&$lines,$preCode,$recurCheck=array(),$htmlColorClass='') * 2813:     function addFiles($rels,&$lines,$preCode,$htmlColorClass='',$tokenID='') * 2931:     function checkDokType($checkTable,$doktype) * 2947:     function renderControls($r) * 2975:     function softrefSelector($cfg) * *              SECTION: Helper functions of kinds * 3051:     function isTableStatic($table) * 3065:     function inclRelation($table) * 3080:     function isExcluded($table,$uid) * 3092:     function includeSoftref($tokenID) * 3102:     function checkPID($pid) * 3119:     function dontIgnorePid($table, $uid) * 3132:     function doesRecordExist($table,$uid,$fields='') * 3142:     function getRecordPath($pid) * 3159:     function renderSelectBox($prefix,$value,$optValues) * 3183:     function compareRecords($databaseRecord, $importRecord, $table, $inverseDiff=FALSE) * 3250:     function getRTEoriginalFilename($string) * 3267:     function &getFileProcObj() * *              SECTION: Error handling * 3299:     function error($msg) * 3308:     function printErrorLog() * * TOTAL FUNCTIONS: 72 * (This index is automatically created/updated by the extension "extdeveval") * *//** * EXAMPLE for using the impexp-class for exporting stuff: * * 		// Create and initialize: * 	$this->export = t3lib_div::makeInstance('tx_impexp'); * 	$this->export->init(); * 		// Set which tables relations we will allow: * 	$this->export->relOnlyTables[]="tt_news";	// exclusively includes. See comment in the class * * 		// Adding records: * 	$this->export->export_addRecord("pages",$this->pageinfo); * 	$this->export->export_addRecord("pages",t3lib_BEfunc::getRecord("pages",38)); * 	$this->export->export_addRecord("pages",t3lib_BEfunc::getRecord("pages",39)); * 	$this->export->export_addRecord("tt_content",t3lib_BEfunc::getRecord("tt_content",12)); * 	$this->export->export_addRecord("tt_content",t3lib_BEfunc::getRecord("tt_content",74)); * 	$this->export->export_addRecord("sys_template",t3lib_BEfunc::getRecord("sys_template",20)); * * 		// Adding all the relations (recursively in 5 levels so relations has THEIR relations registered as well) * 	for($a=0;$a<5;$a++)	{ * 		$addR = $this->export->export_addDBRelations($a); * 		if (!count($addR)) break; * 	} * * 		// Finally load all the files. * 	$this->export->export_addFilesFromRelations();	// MUST be after the DBrelations are set so that file from ALL added records are included! * * 		// Now the internal DAT array is ready to export: * 	#debug($this->export->dat); * * 		// Write export * 	$out = $this->export->compileMemoryToFileContent(); * 	#t3lib_div::writeFile(PATH_site."fileadmin/relations.t3d",$out); * 	#debug(strlen($out)); */require_once(PATH_t3lib.'class.t3lib_tcemain.php');require_once (PATH_t3lib.'class.t3lib_diff.php');require_once (PATH_t3lib.'class.t3lib_parsehtml.php');require_once (PATH_t3lib.'class.t3lib_basicfilefunc.php');require_once (PATH_t3lib.'class.t3lib_extfilefunc.php');require_once (PATH_t3lib.'class.t3lib_refindex.php');@ini_set('max_execution_time',600);@ini_set('memory_limit','256m');/** * T3D file Import/Export library (TYPO3 Record Document) * * @author	Kasper Skaarhoj <kasperYYYY@typo3.com> * @package TYPO3 * @subpackage tx_impexp */class tx_impexp {		// Configuration, general	var $showStaticRelations = FALSE;		// If set, static relations (not exported) will be shown in overview as well	var $fileadminFolderName = 'fileadmin';	// Name of the "fileadmin" folder where files for export/import should be located	var $mode = '';							// Whether "import" or "export" mode of object. Set through init() function	var $update = FALSE;					// Updates all records that has same UID instead of creating new!	var $doesImport = FALSE;				// Is set by importData() when an import has been done.		// Configuration, import	var $display_import_pid_record = '';		// If set to a page-record, then the preview display of the content will expect this page-record to be the target for the import and accordingly display validation information. This triggers the visual view of the import/export memory to validate if import is possible	var $suggestedInsertUids = array();		// Used to register the forged UID values for imported records that we want to create with the same UIDs as in the import file. Admin-only feature.	var $import_mode = array();				// Setting import modes during update state: as_new, exclude, force_uid	var $global_ignore_pid = FALSE;			// If set, PID correct is ignored globally	var $force_all_UIDS = FALSE;			// If set, all UID values are forced! (update or import)	var $showDiff = FALSE;					// If set, a diff-view column is added to the overview.	var $allowPHPScripts = FALSE;			// If set, and if the user is admin, allow the writing of PHP scripts to fileadmin/ area.	var $enableLogging = FALSE;				// Disable logging when importing	var $softrefInputValues = array();		// Array of values to substitute in editable softreferences.	var $fileIDMap = array();				// Mapping between the fileID from import memory and the final filenames they are written to.		// Configuration, export	var $maxFileSize = 1000000;		// 1MB max file size	var $maxRecordSize = 1000000;	// 1MB max record size	var $maxExportSize = 10000000;	// 10MB max export size	var $relOnlyTables = array();	// add table names here which are THE ONLY ones which will be included into export if found as relations. '_ALL' will allow all tables.	var $relStaticTables = array();	// add tables names here which should not be exported with the file. (Where relations should be mapped to same UIDs in target system).	var $excludeMap = array();		// Exclude map. Keys are table:uid  pairs and if set, records are not added to the export.	var $softrefCfg = array();		// Soft Reference Token ID modes.	var $extensionDependencies = array();		// Listing extension dependencies.	var $dontCompress = 0;			// Set  by user: If set, compression in t3d files is disabled	var $includeExtFileResources = 0;	// Boolean, if set, HTML file resources are included.	var $extFileResourceExtensions = 'html,htm,css';	// Files with external media (HTML/css style references inside)		// Internal, dynamic:	var $import_mapId = array();		// After records are written this array is filled with [table][original_uid] = [new_uid]	var $import_newId = array();		// Keys are [tablename]:[new NEWxxx ids (or when updating it is uids)] while values are arrays with table/uid of the original record it is based on. By the array keys the new ids can be looked up inside tcemain	var $import_newId_pids = array();	// Page id map for page tree (import)	var $import_data = array();			// Internal data accumulation for writing records during import	var $errorLog = array();			// Error log.	var $cache_getRecordPath = array();	// Cache for record paths	var $checkPID_cache = array();		// Cache of checkPID values.	var $compress = 0;					// Set internally if the gzcompress function exists	var $dat = array();					// Internal import/export memory	var $fileProcObj = '';				// File processing object	/**************************	 *	 * Initialize	 *	 *************************/	/**	 * Init the object, both import and export	 *	 * @param	boolean		If set, compression in t3d files is disabled	 * @param	string		Mode of usage, either "import" or "export"	 * @return	void	 */	function init($dontCompress=0,$mode='')	{		$this->compress = function_exists('gzcompress');		$this->dontCompress = $dontCompress;		$this->mode = $mode;	}	/**************************	 *	 * Export / Init + Meta Data	 *	 *************************/	/**	 * Set header basics	 *	 * @return	void	 */	function setHeaderBasics()	{			// Initializing:		if (is_array($this->softrefCfg))	{			foreach($this->softrefCfg as $key => $value)	{				if (!strlen($value['mode']))	unset($this->softrefCfg[$key]);			}		}			// Setting in header memory:		$this->dat['header']['XMLversion'] = '1.0';		// Version of file format		$this->dat['header']['meta'] = array();			// Initialize meta data array (to put it in top of file)		$this->dat['header']['relStaticTables'] = $this->relStaticTables;	// Add list of tables to consider static		$this->dat['header']['excludeMap'] = $this->excludeMap;				// The list of excluded records		$this->dat['header']['softrefCfg'] = $this->softrefCfg;			// Soft Reference mode for elements		$this->dat['header']['extensionDependencies'] = $this->extensionDependencies;		// List of extensions the import depends on.	}	/**	 * Set charset	 *	 * @param	string		Charset for the content in the export. During import the character set will be converted if the target system uses another charset.	 * @return	void	 */	function setCharset($charset)	{		$this->dat['header']['charset'] = $charset;	}	/**	 * Sets meta data	 *	 * @param	string		Title of the export	 * @param	string		Description of the export	 * @param	string		Notes about the contents	 * @param	string		Backend Username of the packager (the guy making the export)	 * @param	string		Real name of the packager	 * @param	string		Email of the packager	 * @return	void	 */	function setMetaData($title,$description,$notes,$packager_username,$packager_name,$packager_email)	{		$this->dat['header']['meta'] = array(			'title' => $title,			'description' => $description,			'notes' => $notes,			'packager_username' => $packager_username,			'packager_name' => $packager_name,			'packager_email' => $packager_email,			'TYPO3_version' => TYPO3_version,#			'loaded_extensions' => $GLOBALS['TYPO3_CONF_VARS']['EXT']['extList'],			'created' => strftime('%A %e. %B %Y', time())		);	}	/**	 * Sets a thumbnail image to the exported file	 *	 * @param	string		Filename reference, gif, jpg, png. Absolute path.

⌨️ 快捷键说明

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