Posted By

jsegars on 05/30/08


Tagged

typo3


Versions (?)

Saving Data to a T3D File


 / Published in: PHP
 

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

  1. $packageRow = t3lib_BEfunc::getRecord("tx_wectemplateadmin_package", $this->packageID);
  2.  
  3. $this->export = t3lib_div::makeInstance('tx_wectemplateadmin_impexp');
  4. $this->export->init(0, 'export');
  5. $this->export->setCharset($GLOBALS['LANG']->charSet);
  6. $this->export->extensionDependencies = 'templavoila';
  7. $this->export->showStaticRelations = 0;
  8. $this->export->includeExtFileResources = 0;
  9. $this->export->relStaticTables[]="tx_templavoila_datastructure";
  10. $this->export->includeExtFileResources = 0;
  11.  
  12. if ($packageRow['thumbnail']) {
  13. $this->export->addThumbnail(PATH_site.'uploads/tx_wectemplateadmin/'.$packageRow['thumbnail']);
  14. }
  15.  
  16. t3lib_div::loadTCA('tx_templavoila_tmplobj');
  17. unset($GLOBALS['TCA']['tx_templavoila_tmplobj']['columns']['fileref']['config']['softref']);
  18.  
  19. $uids = explode(',', $packageRow['records']);
  20. foreach($uids as $uid) {
  21. if($uid > 0) {
  22. $table = 'tx_templavoila_tmplobj';
  23. } else {
  24. $table = 'tx_templavoila_datastructure';
  25. $uid = abs($uid);
  26. }
  27.  
  28. $recordRow = t3lib_BEfunc::getRecord($table, $uid);
  29. $this->export->export_addRecord($table, $recordRow);
  30.  
  31. $this->export->export_addFilesFromRelations(); // MUST be after the DBrelations are set so that file from ALL added records are included!
  32. $templateFolder = dirname(PATH_site.$recordRow['fileref']);
  33. }
  34.  
  35. $this->export->export_addDBRelations();
  36. $this->export->setHeaderBasics();
  37.  
  38. // Meta data setting:
  39. $this->export->setMetaData(
  40. $packageRow['title'],
  41. $packageRow['description'],
  42. '', // Notes are empty
  43. $GLOBALS['BE_USER']->user['username'],
  44. $GLOBALS['BE_USER']->user['realName'],
  45. $GLOBALS['BE_USER']->user['email']
  46. );
  47.  
  48. if($packageRow['filename']) {
  49. $filename = 'uploads/tx_wectemplateadmin/'.$packageRow['filename'];
  50. } else {
  51. $filename = 'uploads/tx_wectemplateadmin/templateexport_'.date('YmdHi').'t3d';
  52. }
  53.  
  54. // Now the internal DAT array is ready to export:
  55.  
  56. // Write export
  57. $out = $this->export->compileMemoryToFileContent('t3d');
  58. t3lib_div::writeFile(PATH_site.$filename, $out);
  59.  
  60. return $filename;

Report this snippet  

You need to login to post a comment.