=== modified file 'includes/FeedsImporter.inc' --- includes/FeedsImporter.inc 2009-10-21 22:49:47 +0000 +++ includes/FeedsImporter.inc 2009-11-24 14:31:13 +0000 @@ -62,6 +62,42 @@ } /** + * Minimalist interface for enclosures (ie. a file attached to a + * FeedResult item) + */ +interface FeedResultEnclosure { + const DEFAULT_MIME_TYPE = 'application/octet-stream'; + + /** + * Returns the URL for the file/enclosure. Any valid URL is an acceptable + * result. + * + * @return A string containing a valid URL (RFC 1738) for the file/enclosure. + */ + public function getUrl(); + + /** + * Returns the file/enclosure description. + * + * @return A string containing the file/enclosure description. + * + */ + public function getDescription(); + + /** + * Returns the interned type of the file/enclosure. The returned value must + * never be empty. Implementations should return + * application/octet-stream when a correct mime type cannot be + * determined. + * + * @return A string containing the internet media type of the file/enclosure. + * + * @see FeedResultEnclosure::DEFAULT_MIME_TYPE + */ + public function getMime(); +} + +/** * Class defining an importer object. This is the main hub for Feeds module's * functionality. * === modified file 'plugins/FeedsSimplePieParser.inc' --- plugins/FeedsSimplePieParser.inc 2009-11-02 20:05:10 +0000 +++ plugins/FeedsSimplePieParser.inc 2009-11-24 14:54:00 +0000 @@ -65,7 +65,7 @@ $mime = $enclosure->get_real_type(); if ($mime != '') { list($type, $subtype) = split('/', $mime); - $item['enclosures'][$type][$subtype][] = $enclosure; + $item['enclosures'][$type][$subtype][] = new FeedsSimplePieEnclosure($enclosure); } } } @@ -181,4 +181,54 @@ $words = array_slice($words, 0, 3); return implode(' ', $words); } +} + +/** + * Adapter to present a SimplePie_Enclosure as a FeedResultEnclosure. + * + * @see FeedResultEnclosure + * @see SimplePie_Enclosure + */ +class FeedsSimplePieEnclosure implements FeedResultEnclosure { + var $simplepie_enclosure; + function __construct(SimplePie_Enclosure $enclosure) { + $this->_simplepie_enclosure = $enclosure; + } + + /** + * Returns the URL for the file/enclosure. Any valid URL is an acceptable + * result. + * + * @return A string containing a valid URL (RFC 1738) for the file/enclosure. + * + * @see SimplePie_Enclosure::get_link() + */ + public function getUrl() { + return $this->_simplepie_enclosure->get_link(); + } + + /** + * Returns the file/enclosure description. + * + * @return A string containing the file/enclosure description. + * + * @see SimplePie_Enclosure::get_description() + */ + public function getDescription() { + return $this->_simplepie_enclosure->get_description(); + } + + /** + * Returns the interned type of the file/enclosure. The returned value must + * never be empty. Implementations should return + * application/octet-stream when a correct mime type cannot be + * determined. + * + * @return A string containing the internet media type of the file/enclosure. + * + * @see SimplePie_Enclosure::get_real_type() + */ + public function getMime() { + return $this->_simplepie_enclosure->get_real_type(); + } } \ No newline at end of file