Source for file XMLRemoteFileRecordExporter.class.php

Documentation is available at XMLRemoteFileRecordExporter.class.php

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

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