Source for file XMLFileRecordExporter.class.php

Documentation is available at XMLFileRecordExporter.class.php

  1. <?php
  2. /**
  3. * @since 10/17/05
  4. * @package polyphony.exporter
  5. *
  6. * @copyright Copyright &copy; 2005, Middlebury College
  7. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  8. *
  9. * @version $Id: XMLFileRecordExporter.class.php,v 1.12 2007/09/19 14:04:44 adamfranco Exp $
  10. */
  11.  
  12. //require_once(POLYPHONY."/main/library/Exporter/XMLPartExporter.class.php");
  13.  
  14. /**
  15. * Exports into XML for use with the XML Importer
  16. *
  17. * @since 10/17/05
  18. * @package polyphony.exporter
  19. *
  20. * @copyright Copyright &copy; 2005, Middlebury College
  21. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  22. *
  23. * @version $Id: XMLFileRecordExporter.class.php,v 1.12 2007/09/19 14:04:44 adamfranco Exp $
  24. */
  25. class XMLFileRecordExporter {
  26. /**
  27. * Constructor
  28. *
  29. * Maintains the archive, xml file and destination folder for data files
  30. *
  31. * @param object Archive_Tar
  32. * @param resource
  33. * @param string
  34. * @access public
  35. * @since 10/17/05
  36. */
  37. function XMLFileRecordExporter ($xmlFile, $fileDir) {
  38. $this->_xml =$xmlFile;
  39. $this->_fileDir = $fileDir;
  40. $this->_childExporterList = null;
  41. $this->_childElementList = null;
  42. }
  43.  
  44. /**
  45. * Exporter of All things
  46. *
  47. * @param object HarmoniFileRecord
  48. * @access public
  49. * @since 10/17/05
  50. */
  51. function export ($record) {
  52. $this->_object =$record;
  53. $this->_myId =$this->_object->getId();
  54.  
  55. $this->getFileParts();
  56.  
  57. fwrite($this->_xml,
  58. "\t\t<filerecord ".
  59. "id=\"".$this->_myId->getIdString()."\">\n".
  60. "\t\t\t<filedatapart>".$this->_info['f_name']."</filedatapart>\n".
  61. "\t\t\t<filedimensionspart>\n".
  62. "\t\t\t\t<width>".$this->_info['f_dime'][0]."</width>\n".
  63. "\t\t\t\t<height>".$this->_info['f_dime'][1]."</height>\n".
  64. "\t\t\t</filedimensionspart>\n".
  65. "\t\t\t<mimepart>".$this->_info['f_mime']."</mimepart>\n".
  66. "\t\t\t<thumbdatapart>".$this->_info['t_name']."</thumbdatapart>\n".
  67. "\t\t\t<thumbdimensionspart>\n".
  68. "\t\t\t\t<width>".$this->_info['t_dime'][0]."</width>\n".
  69. "\t\t\t\t<height>".$this->_info['t_dime'][1]."</height>\n".
  70. "\t\t\t</thumbdimensionspart>\n".
  71. "\t\t\t<thumbmimepart>".$this->_info['t_mime']."</thumbmimepart>\n".
  72. "\t\t</filerecord>\n");
  73. }
  74.  
  75. /**
  76. * Exporter of partstructures
  77. *
  78. * Adds partstructure elements to the xml, which contain the necessary
  79. * information to create the same partstructure.
  80. *
  81. * @access public
  82. * @since 10/17/05
  83. */
  84. function getFileParts () {
  85. $idManager = Services::getService("Id");
  86. $this->_info = array();
  87. $FILE_DATA_ID =$idManager->getId("FILE_DATA");
  88. $FILE_NAME_ID =$idManager->getId("FILE_NAME");
  89. $FILE_DIME_ID =$idManager->getId("DIMENSIONS");
  90. $MIME_TYPE_ID =$idManager->getId("MIME_TYPE");
  91. $THUMB_DATA_ID =$idManager->getId("THUMBNAIL_DATA");
  92. $THUMB_MIME_ID =$idManager->getId("THUMBNAIL_MIME_TYPE");
  93. $THUMB_DIME_ID =$idManager->getId("THUMBNAIL_DIMENSIONS");
  94. $parts =$this->_object->getPartsByPartStructure($FILE_NAME_ID);
  95. if ($parts->count() == 1) {
  96. $part =$parts->next();
  97. $path = $this->_fileDir."/".$part->getValue();
  98. // CHECK FOR FILE NAME UNIQUENESS HERE
  99. $this->_dataFile = fopen($path, "wb");
  100. $this->_info['f_name'] = basename($path);
  101. }
  102. $parts =$this->_object->getPartsByPartStructure($FILE_DATA_ID);
  103. if ($parts->count() == 1) {
  104. $part =$parts->next();
  105. fwrite($this->_dataFile, $part->getValue());
  106. fclose($this->_dataFile);
  107. }
  108. $parts =$this->_object->getPartsByPartStructure($FILE_DIME_ID);
  109. if ($parts->count() == 1) {
  110. $part =$parts->next();
  111. $this->_info['f_dime'] = $part->getValue();
  112. }
  113. $parts =$this->_object->getPartsByPartStructure($MIME_TYPE_ID);
  114. if ($parts->count() == 1) {
  115. $part =$parts->next();
  116. $this->_info['f_mime'] = $part->getValue();
  117. }
  118. $path = $this->_fileDir."/THUMB_".$this->_info['f_name'];
  119. $this->_info['t_name'] = basename($path);
  120. $this->_thumbFile = fopen($path, "wb");
  121. $parts =$this->_object->getPartsByPartStructure($THUMB_DATA_ID);
  122. if ($parts->count() == 1) {
  123. $part =$parts->next();
  124. fwrite($this->_thumbFile, $part->getValue());
  125. fclose($this->_thumbFile);
  126. }
  127. $parts =$this->_object->getPartsByPartStructure($THUMB_MIME_ID);
  128. if ($parts->count() == 1) {
  129. $part =$parts->next();
  130. $this->_info['t_mime'] = $part->getValue();
  131. }
  132. $parts =$this->_object->getPartsByPartStructure($THUMB_DIME_ID);
  133. if ($parts->count() == 1) {
  134. $part =$parts->next();
  135. $this->_info['t_dime'] = $part->getValue();
  136. }
  137. }
  138. }
  139. ?>

Documentation generated on Wed, 19 Sep 2007 10:28:35 -0400 by phpDocumentor 1.3.0RC3