Return to Snippet

Revision: 6555
at May 30, 2008 09:34 by jsegars


Updated Code
$packageRow = t3lib_BEfunc::getRecord("tx_wectemplateadmin_package", $this->packageID);

$this->export = t3lib_div::makeInstance('tx_wectemplateadmin_impexp');
$this->export->init(0, 'export');
$this->export->setCharset($GLOBALS['LANG']->charSet);
$this->export->extensionDependencies = 'templavoila';
$this->export->showStaticRelations = 0;
$this->export->includeExtFileResources = 0;
$this->export->relStaticTables[]="tx_templavoila_datastructure";
$this->export->includeExtFileResources = 0;

if ($packageRow['thumbnail']) {
	$this->export->addThumbnail(PATH_site.'uploads/tx_wectemplateadmin/'.$packageRow['thumbnail']);
}

t3lib_div::loadTCA('tx_templavoila_tmplobj');
unset($GLOBALS['TCA']['tx_templavoila_tmplobj']['columns']['fileref']['config']['softref']);

$uids = explode(',', $packageRow['records']);
foreach($uids as $uid) {
	if($uid > 0) {
		$table = 'tx_templavoila_tmplobj';
	} else {
		$table = 'tx_templavoila_datastructure';
		$uid = abs($uid);
	}
	
	$recordRow = t3lib_BEfunc::getRecord($table, $uid);
	$this->export->export_addRecord($table, $recordRow);
	
	$this->export->export_addFilesFromRelations();	// MUST be after the DBrelations are set so that file from ALL added records are included!
	$templateFolder = dirname(PATH_site.$recordRow['fileref']);
}

$this->export->export_addDBRelations();
$this->export->setHeaderBasics();

// Meta data setting:
$this->export->setMetaData(
	$packageRow['title'],
	$packageRow['description'],
	'', // Notes are empty
	$GLOBALS['BE_USER']->user['username'],
	$GLOBALS['BE_USER']->user['realName'],
	$GLOBALS['BE_USER']->user['email']
);

if($packageRow['filename']) {
	$filename = 'uploads/tx_wectemplateadmin/'.$packageRow['filename'];
} else {
	$filename = 'uploads/tx_wectemplateadmin/templateexport_'.date('YmdHi').'t3d';
}

// Now the internal DAT array is ready to export:

// Write export
$out = $this->export->compileMemoryToFileContent('t3d');
t3lib_div::writeFile(PATH_site.$filename, $out);	 

return $filename;

Revision: 6554
at May 30, 2008 09:31 by jsegars


Initial Code
		$packageRow = t3lib_BEfunc::getRecord("tx_wectemplateadmin_package", $this->packageID);
		
		$this->export = t3lib_div::makeInstance('tx_wectemplateadmin_impexp');
		$this->export->init(0, 'export');
		$this->export->setCharset($GLOBALS['LANG']->charSet);
		$this->export->extensionDependencies = 'templavoila';
		$this->export->showStaticRelations = 0;
		$this->export->includeExtFileResources = 0;
		$this->export->relStaticTables[]="tx_templavoila_datastructure";
		$this->export->includeExtFileResources = 0;
		
		if ($packageRow['thumbnail']) {
			$this->export->addThumbnail(PATH_site.'uploads/tx_wectemplateadmin/'.$packageRow['thumbnail']);
		}

		t3lib_div::loadTCA('tx_templavoila_tmplobj');
		unset($GLOBALS['TCA']['tx_templavoila_tmplobj']['columns']['fileref']['config']['softref']);
		
		$uids = explode(',', $packageRow['records']);
		foreach($uids as $uid) {
			if($uid > 0) {
				$table = 'tx_templavoila_tmplobj';
			} else {
				$table = 'tx_templavoila_datastructure';
				$uid = abs($uid);
			}
			
			$recordRow = t3lib_BEfunc::getRecord($table, $uid);
			$this->export->export_addRecord($table, $recordRow);
			
			$this->export->export_addFilesFromRelations();	// MUST be after the DBrelations are set so that file from ALL added records are included!
			$templateFolder = dirname(PATH_site.$recordRow['fileref']);
			$this->export->exportAllFiles($templateFolder.'/');
		}
		
		$this->export->export_addDBRelations();
		$this->export->setHeaderBasics();
		
		// Meta data setting:
		$this->export->setMetaData(
			$packageRow['title'],
			$packageRow['description'],
			'', // Notes are empty
			$GLOBALS['BE_USER']->user['username'],
			$GLOBALS['BE_USER']->user['realName'],
			$GLOBALS['BE_USER']->user['email']
		);
		
		if($packageRow['filename']) {
			$filename = 'uploads/tx_wectemplateadmin/'.$packageRow['filename'];
		} else {
			$filename = 'uploads/tx_wectemplateadmin/templateexport_'.date('YmdHi').'t3d';
		}
		
		// Now the internal DAT array is ready to export:
		
		// Write export
		$out = $this->export->compileMemoryToFileContent('t3d');
		t3lib_div::writeFile(PATH_site.$filename, $out);	 
		
		return $filename;

Initial URL


Initial Description
This snippet exports all TemplaVoila Template Objects and Data Structures associated with a specific template package to a T3D file.

Initial Title
Saving Data to a T3D File

Initial Tags


Initial Language
PHP