Source for file XMLFilepathPartImporter.class.php

Documentation is available at XMLFilepathPartImporter.class.php

  1. <?php
  2. /**
  3. * @since 10/6/05
  4. * @package polyphony.importer
  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: XMLFilepathPartImporter.class.php,v 1.14 2007/09/19 14:04:47 adamfranco Exp $
  10. */
  11. require_once(POLYPHONY."/main/library/Importer/XMLImporters/XMLImporter.class.php");
  12.  
  13. /**
  14. * imports the filename, filedata, and mimetype of a file
  15. *
  16. * @since 10/6/05
  17. * @package polyphony.importer
  18. *
  19. * @copyright Copyright &copy; 2005, Middlebury College
  20. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  21. *
  22. * @version $Id: XMLFilepathPartImporter.class.php,v 1.14 2007/09/19 14:04:47 adamfranco Exp $
  23. */
  24. class XMLFilepathPartImporter extends XMLImporter {
  25. /**
  26. * Constructor
  27. *
  28. *
  29. * @return object XMLFilepathImporterImporter
  30. * @access public
  31. * @since 10/6/05
  32. */
  33. function XMLFilepathPartImporter ($existingArray) {
  34. parent::XMLImporter($existingArray);
  35. }
  36. /**
  37. * Filters nodes of incorrect type
  38. *
  39. * @param object DOMIT_Node
  40. * @return boolean
  41. * @static
  42. * @access public
  43. * @since 10/6/05
  44. */
  45. function isImportable ($element) {
  46. if ($element->nodeName == "filepathpart")
  47. return true;
  48. else
  49. return false;
  50. }
  51.  
  52. /**
  53. * Sets up importer's self-knowledge
  54. *
  55. * @access public
  56. * @since 10/6/05
  57. */
  58. function setupSelf () {
  59. $this->_childImporterList = NULL;
  60. $this->_childElementList = NULL;
  61. $this->_info = array();
  62. }
  63.  
  64. /**
  65. * Checks if the user is able to import underneath this level
  66. *
  67. * @param string $authZQString qualifier for authz checking
  68. * @access public
  69. * @since 11/3/05
  70. */
  71. function canImportBelow($authZQString) {
  72. return true;
  73. }
  74.  
  75. /**
  76. * Imports the current node's information
  77. *
  78. * @access public
  79. * @since 10/6/05
  80. */
  81. function importNode () {
  82. $idManager = Services::getService("Id");
  83. $mime = Services::getService("MIME");
  84. $FILE_DATA_ID =$idManager->getId("FILE_DATA");
  85. $FILE_NAME_ID =$idManager->getId("FILE_NAME");
  86. $MIME_TYPE_ID =$idManager->getId("MIME_TYPE");
  87. $THUMBNAIL_DATA_ID =$idManager->getId("THUMBNAIL_DATA");
  88. $THUMBNAIL_MIME_TYPE_ID =$idManager->getId("THUMBNAIL_MIME_TYPE");
  89.  
  90. $this->getNodeInfo();
  91.  
  92. $this->_parent->createPart($FILE_DATA_ID,
  93. file_get_contents($this->_info['filepath']));
  94. $this->_parent->createPart($FILE_NAME_ID,
  95. basename($this->_info['filepath']));
  96. $this->_parent->createPart($MIME_TYPE_ID,
  97. $mime->getMIMETypeForFileName($this->_info['filepath']));
  98.  
  99. $this->_myId = null;
  100. }
  101.  
  102. /**
  103. * Sets the node's internal information
  104. *
  105. * @access public
  106. * @since 10/6/05
  107. */
  108. function getNodeInfo () {
  109. $path = $this->_node->getText();
  110. if (!ereg("^([a-zA-Z]+://|[a-zA-Z]+:\\|/)", $path))
  111. $path = $this->_node->ownerDocument->xmlPath.$path;
  112.  
  113. $this->_info['filepath'] = $path;
  114. }
  115. /**
  116. * Relegates Children to their classes
  117. *
  118. * @param object mixed $topImporter is the importer instance that parsed the XML
  119. * @access public
  120. * @since 10/6/05
  121. */
  122. function relegateChildren ($topImporter) {
  123. /* this node should not have children */
  124. }
  125. }
  126.  
  127. ?>

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