Author: as
Date: Wed Dec 12 10:00:59 2007
New Revision: 6969

Log:
- Added the getContentType() method in ezcFeed to return its Content-Type.

Modified:
    trunk/Feed/ChangeLog
    trunk/Feed/src/feed.php
    trunk/Feed/src/interfaces/processor.php
    trunk/Feed/src/processors/atom.php
    trunk/Feed/src/processors/rss1.php
    trunk/Feed/src/processors/rss2.php
    trunk/Feed/tests/feed_test.php

Modified: trunk/Feed/ChangeLog
==============================================================================
--- trunk/Feed/ChangeLog [iso-8859-1] (original)
+++ trunk/Feed/ChangeLog [iso-8859-1] Wed Dec 12 10:00:59 2007
@@ -13,6 +13,7 @@
 - Completed support for creating and parsing RSS2 feeds.
 - Completed support for creating and parsing RSS1 feeds.
 - Completed support for creating and parsing ATOM feeds.
+- Added the getContentType() method in ezcFeed to return its Content-Type.
 
 
 1.0beta1 - Monday 18 December 2006

Modified: trunk/Feed/src/feed.php
==============================================================================
--- trunk/Feed/src/feed.php [iso-8859-1] (original)
+++ trunk/Feed/src/feed.php [iso-8859-1] Wed Dec 12 10:00:59 2007
@@ -125,12 +125,20 @@
     protected $feedProcessor;
 
     /**
-     * Holds the feed type.
+     * Holds the feed type (eg. 'rss2').
      *
      * @var string
      * @ignore
      */
     protected $feedType;
+
+    /**
+     * Holds the feed content type (eg. 'application/rss+xml').
+     *
+     * @var string
+     * @ignore
+     */
+    protected $contentType;
 
     /**
      * Creates a new feed of type $type.
@@ -157,6 +165,7 @@
 
         $this->feedType = $type;
         $this->feedProcessor = new self::$supportedFeedTypes[$type];
+        $this->contentType = $this->feedProcessor->getContentType();
     }
 
     /**
@@ -390,5 +399,16 @@
     {
         return $this->feedType;
     }
+
+    /**
+     * Returns the feed content type of this feed object
+     * (eg. 'application/rss+xml').
+     *
+     * @return string
+     */
+    public function getContentType()
+    {
+        return $this->contentType;
+    }
 }
 ?>

Modified: trunk/Feed/src/interfaces/processor.php
==============================================================================
--- trunk/Feed/src/interfaces/processor.php [iso-8859-1] (original)
+++ trunk/Feed/src/interfaces/processor.php [iso-8859-1] Wed Dec 12 10:00:59 
2007
@@ -31,6 +31,14 @@
     protected $feedType;
 
     /**
+     * Holds the feed content type (eg. 'application/rss+xml').
+     *
+     * @var string
+     * @ignore
+     */
+    protected $contentType;
+
+    /**
      * Holds the feed schema for the current feed type.
      *
      * @var array(string=>mixed)
@@ -240,5 +248,16 @@
             return $element;
         }
     }
+
+    /**
+     * Returns the feed content type of this feed object
+     * (eg. 'application/rss+xml').
+     *
+     * @return string
+     */
+    public function getContentType()
+    {
+        return $this->contentType;
+    }
 }
 ?>

Modified: trunk/Feed/src/processors/atom.php
==============================================================================
--- trunk/Feed/src/processors/atom.php [iso-8859-1] (original)
+++ trunk/Feed/src/processors/atom.php [iso-8859-1] Wed Dec 12 10:00:59 2007
@@ -26,6 +26,11 @@
     const FEED_TYPE = 'atom';
 
     /**
+     * Defines the feed content type of this processor.
+     */
+    const CONTENT_TYPE = 'application/atom+xml';
+
+    /**
      * Holds the definitions for the elements in ATOM.
      *
      * @var array(string=>mixed)
@@ -272,6 +277,7 @@
     public function __construct()
     {
         $this->feedType = self::FEED_TYPE;
+        $this->contentType = self::CONTENT_TYPE;
         $this->schema = new ezcFeedSchema( self::$atomSchema );
     }
 

Modified: trunk/Feed/src/processors/rss1.php
==============================================================================
--- trunk/Feed/src/processors/rss1.php [iso-8859-1] (original)
+++ trunk/Feed/src/processors/rss1.php [iso-8859-1] Wed Dec 12 10:00:59 2007
@@ -26,6 +26,11 @@
     const FEED_TYPE = 'rss1';
 
     /**
+     * Defines the feed content type of this processor.
+     */
+    const CONTENT_TYPE = 'application/rss+xml';
+
+    /**
      * Holds the definitions for the elements in RSS1.
      *
      * @var array(string=>mixed)
@@ -98,6 +103,7 @@
     public function __construct()
     {
         $this->feedType = self::FEED_TYPE;
+        $this->contentType = self::CONTENT_TYPE;
         $this->schema = new ezcFeedSchema( self::$rss1Schema );
     }
 

Modified: trunk/Feed/src/processors/rss2.php
==============================================================================
--- trunk/Feed/src/processors/rss2.php [iso-8859-1] (original)
+++ trunk/Feed/src/processors/rss2.php [iso-8859-1] Wed Dec 12 10:00:59 2007
@@ -26,6 +26,11 @@
     const FEED_TYPE = 'rss2';
 
     /**
+     * Defines the feed content type of this processor.
+     */
+    const CONTENT_TYPE = 'application/rss+xml';
+
+    /**
      * Holds the RSS2 feed schema.
      *
      * @var array(string=>mixed)
@@ -160,6 +165,7 @@
     public function __construct()
     {
         $this->feedType = self::FEED_TYPE;
+        $this->contentType = self::CONTENT_TYPE;
         $this->schema = new ezcFeedSchema( self::$rss2Schema );
 
         // set default values

Modified: trunk/Feed/tests/feed_test.php
==============================================================================
--- trunk/Feed/tests/feed_test.php [iso-8859-1] (original)
+++ trunk/Feed/tests/feed_test.php [iso-8859-1] Wed Dec 12 10:00:59 2007
@@ -33,6 +33,7 @@
         $feed = new ezcFeed( 'rss1' );
         $this->assertEquals( 'ezcFeed', get_class( $feed ) );
         $this->assertEquals( 'rss1', $feed->getFeedType() );
+        $this->assertEquals( 'application/rss+xml', $feed->getContentType() );
     }
 
     public function testCreateFeedSupportedRss2()
@@ -40,6 +41,7 @@
         $feed = new ezcFeed( 'rss2' );
         $this->assertEquals( 'ezcFeed', get_class( $feed ) );
         $this->assertEquals( 'rss2', $feed->getFeedType() );
+        $this->assertEquals( 'application/rss+xml', $feed->getContentType() );
     }
 
     public function testCreateFeedSupportedAtom()
@@ -47,6 +49,7 @@
         $feed = new ezcFeed( 'atom' );
         $this->assertEquals( 'ezcFeed', get_class( $feed ) );
         $this->assertEquals( 'atom', $feed->getFeedType() );
+        $this->assertEquals( 'application/atom+xml', $feed->getContentType() );
     }
 
     public function testCreateFeedNotSupported()
@@ -145,6 +148,7 @@
         $feed = ezcFeed::parse( $file );
 
         $this->assertEquals( 'atom', $feed->getFeedType() );
+        $this->assertEquals( 'application/atom+xml', $feed->getContentType() );
     }
 
     public function testParseAtom2()
@@ -178,6 +182,7 @@
         $feed = ezcFeed::parse( $file );
 
         $this->assertEquals( 'rss1', $feed->getFeedType() );
+        $this->assertEquals( 'application/rss+xml', $feed->getContentType() );
     }
 
     public function testParseRss2()
@@ -188,6 +193,7 @@
         $feed = ezcFeed::parse( $file );
 
         $this->assertEquals( 'rss2', $feed->getFeedType() );
+        $this->assertEquals( 'application/rss+xml', $feed->getContentType() );
     }
 
     public function testParseRss2Podcast1()


-- 
svn-components mailing list
svn-components@lists.ez.no
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to