Source for file XMLThumbpathPartImporter.class.php

Documentation is available at XMLThumbpathPartImporter.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: XMLThumbpathPartImporter.class.php,v 1.12 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 thumbnaildata, and thumbnailmimetype 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: XMLThumbpathPartImporter.class.php,v 1.12 2007/09/19 14:04:47 adamfranco Exp $
  23. */
  24. class XMLThumbpathPartImporter extends XMLImporter {
  25. /**
  26. * Constructor
  27. *
  28. *
  29. * @return object XMLThumbpathPartImporter
  30. * @access public
  31. * @since 10/6/05
  32. */
  33. function XMLThumbpathPartImporter ($existingArray) {
  34. parent::XMLImporter($existingArray);
  35. }
  36. /**
  37. * Sets up importer's self-knowledge
  38. *
  39. * @access public
  40. * @since 10/6/05
  41. */
  42. function setupSelf () {
  43. $this->_childImporterList = NULL;
  44. $this->_childElementList = NULL;
  45. $this->_info = array();
  46. }
  47. /**
  48. * Filters nodes of incorrect type
  49. *
  50. * @param object DOMIT_Node
  51. * @return boolean
  52. * @static
  53. * @access public
  54. * @since 10/6/05
  55. */
  56. function isImportable ($element) {
  57. if ($element->nodeName == "thumbpathpart")
  58. return true;
  59. else
  60. return false;
  61. }
  62.  
  63. /**
  64. * Checks if the user is able to import underneath this level
  65. *
  66. * @param string $authZQString qualifier for authz checking
  67. * @access public
  68. * @since 11/3/05
  69. */
  70. function canImportBelow($authZQString) {
  71. return true;
  72. }
  73.  
  74. /**
  75. * Imports the current node's information
  76. *
  77. * @access public
  78. * @since 10/6/05
  79. */
  80. function importNode () {
  81. $idManager = Services::getService("Id");
  82. $image = Services::getService("ImageProcessor");
  83.  
  84. $THUMBNAIL_DATA_ID =$idManager->getId("THUMBNAIL_DATA");
  85. $THUMBNAIL_MIME_TYPE_ID =$idManager->getId("THUMBNAIL_MIME_TYPE");
  86.  
  87. $this->getNodeInfo();
  88.  
  89. if ($image->isFormatSupported($this->_info['mime'])) {
  90. $this->_parent->createPart($THUMBNAIL_DATA_ID,
  91. $image->generateThumbnailData($this->_info['mime'],
  92. file_get_contents($this->_info['filepath'])));
  93. $this->_parent->createPart($THUMBNAIL_MIME_TYPE_ID,
  94. $image->getThumbnailFormat());
  95. }
  96. $this->_myId = null;
  97. }
  98.  
  99. /**
  100. * Sets the node's internal information
  101. *
  102. * @access public
  103. * @since 10/6/05
  104. */
  105. function getNodeInfo () {
  106. $mime = Services::getService("MIME");
  107. $path = $this->_node->getText();
  108. if (!ereg("^([a-zA-Z]+://|[a-zA-Z]+:\\|/)", $path))
  109. $path = $this->_node->ownerDocument->xmlPath.$path;
  110. $this->_info['filepath'] = $path;
  111.  
  112. $this->_info['mime'] = $mime->getMIMETypeForFileName(
  113. $this->_info['filepath']);
  114. }
  115. /**
  116. * Relegates Children to their classes
  117. *
  118. * @param object mixed $topImporter will be passed down
  119. * @access public
  120. * @since 10/10/05
  121. */
  122. function relegateChildren ($topImporter) {
  123. }
  124. }
  125.  
  126. ?>

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