Author: as
Date: Thu Nov  1 14:55:30 2007
New Revision: 6661

Log:
- Better (and more correct) implementation for 'about' RSS1 channel attribute.

Modified:
    trunk/Feed/src/feed.php
    trunk/Feed/src/interfaces/processor.php
    trunk/Feed/src/processors/rss1.php
    trunk/Feed/src/structs/feed_schema.php
    
trunk/Feed/tests/rss1/regression/generate/incomplete/title+link+description.in
    trunk/Feed/tests/rss1/regression/generate/incomplete/title+link.in
    trunk/Feed/tests/rss1/regression/generate/incomplete/title.in
    trunk/Feed/tests/rss1/regression/generate/item/item_about+title+link.in
    trunk/Feed/tests/rss1/regression/generate/item/item_about+title.in
    trunk/Feed/tests/rss1/regression/generate/item/item_about.in
    trunk/Feed/tests/rss1/regression/generate/item/item_multiple.in

Modified: trunk/Feed/src/feed.php
==============================================================================
--- trunk/Feed/src/feed.php [iso-8859-1] (original)
+++ trunk/Feed/src/feed.php [iso-8859-1] Thu Nov  1 14:55:30 2007
@@ -193,6 +193,7 @@
             case 'rating':
             case 'textInput':
             case 'cloud':
+            case 'about': // required in RSS1
                 $this->feedProcessor->set( $property, $value );
                 break;
 
@@ -239,6 +240,7 @@
             case 'rating':
             case 'textInput':
             case 'cloud':
+            case 'about': // required in RSS1
                 $value = $this->feedProcessor->get( $property );
                 return $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] Thu Nov  1 14:55:30 
2007
@@ -158,6 +158,11 @@
             {
                 $this->elements[$this->schema->getMulti( $name )] = array();
             }
+            else if ( $this->schema->isAttribute( $name ) )
+            {
+                $this->elements[$name] = $value;
+                return;
+            }
             else
             {
                 $this->elements[$name] = new ezcFeedElement( 
$this->schema->getSchema( $name ) );

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] Thu Nov  1 14:55:30 2007
@@ -73,6 +73,8 @@
         'textInput'    => array( '#'          => 'string',
                                  'ATTRIBUTES' => array( 'resource' => 'string' 
) ),
 
+        'ATTRIBUTES'   => array( 'about'      => 'string' ),
+
         'REQUIRED'     => array( 'title', 'link', 'description' ),
         'OPTIONAL'     => array( 'image', 'textinput' ),
 
@@ -142,8 +144,7 @@
      */
     protected function generateChannel()
     {
-        $channel = $this->get( 'channel' );
-        $data = ( $channel !== null ) ? $channel->about : null;
+        $data = $this->get( 'about' );
 
         if ( is_null( $data ) )
         {

Modified: trunk/Feed/src/structs/feed_schema.php
==============================================================================
--- trunk/Feed/src/structs/feed_schema.php [iso-8859-1] (original)
+++ trunk/Feed/src/structs/feed_schema.php [iso-8859-1] Thu Nov  1 14:55:30 2007
@@ -166,6 +166,17 @@
     }
 
     /**
+     * Returns whether the $element is an attribute.
+     *
+     * @param string $element The schema element
+     * @return bool
+     */
+    public function isAttribute( $element )
+    {
+        return isset( $this->schema['ATTRIBUTES'][$element] );
+    }
+
+    /**
      * Returns if $element does not accept a value for the root node. If 
$subElement
      * is present then returns if the subelement $subElement of element 
$element
      * accepts a value for the root node.

Modified: 
trunk/Feed/tests/rss1/regression/generate/incomplete/title+link+description.in
==============================================================================
--- 
trunk/Feed/tests/rss1/regression/generate/incomplete/title+link+description.in 
[iso-8859-1] (original)
+++ 
trunk/Feed/tests/rss1/regression/generate/incomplete/title+link+description.in 
[iso-8859-1] Thu Nov  1 14:55:30 2007
@@ -1,5 +1,5 @@
 <?php
-return array( 'channel' => array( array( 'about' => 'Channel about' ) ),
+return array( 'about' => 'Channel about',
               'title' => 'Feed title',
               'link' => 'Feed link',
               'description' => 'Feed description',

Modified: trunk/Feed/tests/rss1/regression/generate/incomplete/title+link.in
==============================================================================
--- trunk/Feed/tests/rss1/regression/generate/incomplete/title+link.in 
[iso-8859-1] (original)
+++ trunk/Feed/tests/rss1/regression/generate/incomplete/title+link.in 
[iso-8859-1] Thu Nov  1 14:55:30 2007
@@ -1,5 +1,5 @@
 <?php
-return array( 'channel' => array( array( 'about' => 'Channel about' ) ),
+return array( 'about' => 'Channel about',
               'title' => 'Feed title',
               'link' => 'Feed link',
             );

Modified: trunk/Feed/tests/rss1/regression/generate/incomplete/title.in
==============================================================================
--- trunk/Feed/tests/rss1/regression/generate/incomplete/title.in [iso-8859-1] 
(original)
+++ trunk/Feed/tests/rss1/regression/generate/incomplete/title.in [iso-8859-1] 
Thu Nov  1 14:55:30 2007
@@ -1,5 +1,5 @@
 <?php
-return array( 'channel' => array( array( 'about' => 'Channel about' ) ),
+return array( 'about' => 'Channel about',
               'title' => 'Feed title',
             );
 ?>

Modified: 
trunk/Feed/tests/rss1/regression/generate/item/item_about+title+link.in
==============================================================================
--- trunk/Feed/tests/rss1/regression/generate/item/item_about+title+link.in 
[iso-8859-1] (original)
+++ trunk/Feed/tests/rss1/regression/generate/item/item_about+title+link.in 
[iso-8859-1] Thu Nov  1 14:55:30 2007
@@ -1,5 +1,5 @@
 <?php
-return array( 'channel' => array( array( 'about' => 'Channel about' ) ),
+return array( 'about' => 'Channel about',
               'title' => 'Feed title',
               'link' => 'Feed link',
               'description' => 'Feed description',

Modified: trunk/Feed/tests/rss1/regression/generate/item/item_about+title.in
==============================================================================
--- trunk/Feed/tests/rss1/regression/generate/item/item_about+title.in 
[iso-8859-1] (original)
+++ trunk/Feed/tests/rss1/regression/generate/item/item_about+title.in 
[iso-8859-1] Thu Nov  1 14:55:30 2007
@@ -1,5 +1,5 @@
 <?php
-return array( 'channel' => array( array( 'about' => 'Channel about' ) ),
+return array( 'about' => 'Channel about',
               'title' => 'Feed title',
               'link' => 'Feed link',
               'description' => 'Feed description',

Modified: trunk/Feed/tests/rss1/regression/generate/item/item_about.in
==============================================================================
--- trunk/Feed/tests/rss1/regression/generate/item/item_about.in [iso-8859-1] 
(original)
+++ trunk/Feed/tests/rss1/regression/generate/item/item_about.in [iso-8859-1] 
Thu Nov  1 14:55:30 2007
@@ -1,5 +1,5 @@
 <?php
-return array( 'channel' => array( array( 'about' => 'Channel about' ) ),
+return array( 'about' => 'Channel about',
               'title' => 'Feed title',
               'link' => 'Feed link',
               'description' => 'Feed description',

Modified: trunk/Feed/tests/rss1/regression/generate/item/item_multiple.in
==============================================================================
--- trunk/Feed/tests/rss1/regression/generate/item/item_multiple.in 
[iso-8859-1] (original)
+++ trunk/Feed/tests/rss1/regression/generate/item/item_multiple.in 
[iso-8859-1] Thu Nov  1 14:55:30 2007
@@ -1,5 +1,5 @@
 <?php
-return array( 'channel' => array( array( 'about' => 'Channel about' ) ),
+return array( 'about' => 'Channel about',
               'title' => 'Feed title',
               'link' => 'Feed link',
               'description' => 'Feed description',


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

Reply via email to