Author: as
Date: Mon Oct  8 17:15:23 2007
New Revision: 6393

Log:
- Fixed the creating of modules with the correct feed type.
- Added some comments.
- Removed the unused method newItem() from ezcFeedItem.

Modified:
    trunk/Feed/src/feed_item.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

Modified: trunk/Feed/src/feed_item.php
==============================================================================
--- trunk/Feed/src/feed_item.php [iso-8859-1] (original)
+++ trunk/Feed/src/feed_item.php [iso-8859-1] Mon Oct  8 17:15:23 2007
@@ -31,10 +31,17 @@
         $modules = $this->feedProcessor->getModules();
         foreach ( $modules as $moduleName => $moduleObj )
         {
-            $this->$moduleName = $this->feedProcessor->addItemModule( 
$moduleName, ezcFeed::getModule( $moduleName, $this->feedType ), $this );
+            $this->$moduleName = $this->feedProcessor->addItemModule( 
$moduleName, ezcFeed::getModule( $moduleName, 
$this->feedProcessor->getFeedType() ), $this );
         }
     }
-    
+
+    /**
+     * Sets the property $property to $value.
+     *
+     * @param string $property The property name
+     * @param mixed $value The property value
+     * @ignore
+     */
     public function __set( $property, $value )
     {
         switch ( $property )
@@ -63,6 +70,16 @@
         }
     }
 
+    /**
+     * Returns the value of property $property.
+     *
+     * @throws ezcBasePropertyNotFoundException
+     *         If the property $property does not exist.
+     *
+     * @param string $property The property name
+     * @return mixed
+     * @ignore
+     */
     public function __get( $property )
     {
         switch ( $property )
@@ -80,20 +97,8 @@
                 return $this->feedProcessor->getFeedItemElement( $this, 
$property );
 
             default:
-                return false;
+                throw new ezcBasePropertyNotFoundException( $property );
         }
-    }
-
-    /**
-     * Returns new item for this feed
-     *
-     * @return ezcFeedItem
-     */
-    public function newItem()
-    {
-        $item = new ezcFeedItem();
-        $this->items[] = $item;
-        return $item;
     }
 
     public function setMetaData( $element, $value )

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] Mon Oct  8 17:15:23 
2007
@@ -16,11 +16,27 @@
 abstract class ezcFeedProcessor
 {
     /**
-     * A list of modules which are loaded
+     * Holds the names of the supported modules by this processor. Child 
classes
+     * must populate this array with the modules that they support.
+     *
+     * @var array(string)
+     */
+    protected $supportedModules = array();
+
+    /**
+     * Holds the feed type.
+     *
+     * @var string
+     */
+    protected $feedType;
+
+    /**
+     * A list of modules which are loaded.
      *
      * @var array(string=>ezcFeedModule)
      */
     protected $modules = array();
+
     protected $moduleMetaData = array();
 
     public function isModuleSupported( $moduleName )
@@ -151,5 +167,10 @@
     abstract public function setFeedElement( $element, $value );
     abstract public function setFeedItemElement( $item, $element, $value );
     abstract public function generate();
+
+    public function getFeedType()
+    {
+        return $this->feedType;
+    }
 }
 ?>

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] Mon Oct  8 17:15:23 2007
@@ -16,6 +16,19 @@
 class ezcFeedAtom extends ezcFeedProcessor implements ezcFeedParser
 {
     protected $supportedModules = array();
+
+    /**
+     * Defines the feed type of this processor.
+     */
+    const FEED_TYPE = 'rss1';
+
+    /**
+     * Creates a new ATOM processor.
+     */
+    public function __construct()
+    {
+        $this->feedType = self::FEED_TYPE;
+    }
 
     public function setFeedElement( $element, $value )
     {

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] Mon Oct  8 17:15:23 2007
@@ -15,6 +15,19 @@
  */
 class ezcFeedRss1 extends ezcFeedRss
 {
+    /**
+     * Defines the feed type of this processor.
+     */
+    const FEED_TYPE = 'rss1';
+
+    /**
+     * Creates a new RSS1 processor.
+     */
+    public function __construct()
+    {
+        $this->feedType = self::FEED_TYPE;
+    }
+
     protected $supportedModules = array();
 
     public function setFeedElement( $element, $value )

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] Mon Oct  8 17:15:23 2007
@@ -16,6 +16,11 @@
 class ezcFeedRss2 extends ezcFeedRss
 {
     /**
+     * Defines the feed type of this processor.
+     */
+    const FEED_TYPE = 'rss2';
+
+    /**
      * A list of modules that are supported by this feed type
      *
      * @var array(string)
@@ -58,12 +63,16 @@
 
     protected $usedPrefixes = array();
 
+    /**
+     * Creates a new RSS2 processor.
+     */
     public function __construct()
     {
         // set default values
         $this->setMetaData( 'published', $this->prepareDate( time() ) );
         $this->setMetaData( 'generator', "eZ components" );
         $this->setMetaData( 'docs', 
'http://www.rssboard.org/rss-specification' );
+        $this->feedType = self::FEED_TYPE;
     }
 
     public function setFeedElement( $element, $value )


-- 
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to