Author: as
Date: Thu Nov  1 15:42:26 2007
New Revision: 6663

Log:
- Added support for generating 'image' RSS1 feed element.

Added:
    trunk/Feed/tests/rss1/regression/generate/optional/
    trunk/Feed/tests/rss1/regression/generate/optional/image/
    
trunk/Feed/tests/rss1/regression/generate/optional/image/image_about+title+url+link.in
    
trunk/Feed/tests/rss1/regression/generate/optional/image/image_about+title+url+link.out
    
trunk/Feed/tests/rss1/regression/generate/optional/image/image_about+title+url.in
    
trunk/Feed/tests/rss1/regression/generate/optional/image/image_about+title+url.out
    
trunk/Feed/tests/rss1/regression/generate/optional/image/image_about+title.in
    
trunk/Feed/tests/rss1/regression/generate/optional/image/image_about+title.out
    trunk/Feed/tests/rss1/regression/generate/optional/image/image_about.in
    trunk/Feed/tests/rss1/regression/generate/optional/image/image_about.out
    trunk/Feed/tests/rss1/regression/generate/optional/image/image_empty.in
    trunk/Feed/tests/rss1/regression/generate/optional/image/image_empty.out
Modified:
    trunk/Feed/src/processors/rss1.php

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 15:42:26 2007
@@ -107,6 +107,7 @@
 
         $this->generateChannel();
         $this->generateItems();
+        $this->generateImage();
 
         return $this->xml->saveXML();
     }
@@ -196,6 +197,25 @@
             $liTag->appendChild( $resourceAttr );
             $seqTag->appendChild( $liTag );
         }
+
+        $image = $this->get( 'image' );
+        if ( $image !== null )
+        {
+            $imageTag = $this->xml->createElement( 'image' );
+
+            $about = $image->about;
+            if ( is_null( $data ) )
+            {
+                throw new ezcFeedRequiredMetaDataMissingException( 'about' );
+            }
+
+            $resourceAttr = $this->xml->createAttribute( 'rdf:resource' );
+            $resourceVal = $this->xml->createTextNode( $about );
+            $resourceAttr->appendChild( $resourceVal );
+            $imageTag->appendChild( $resourceAttr );
+
+            $this->channel->appendChild( $imageTag );
+        }
     }
 
     /**
@@ -235,6 +255,47 @@
 
                 $attributes = array();
                 $this->generateMetaData( $itemTag, $attribute, $data );
+            }
+        }
+    }
+
+    /**
+     * Adds the feed image to the XML document being generated.
+     *
+     * @ignore
+     */
+    protected function generateImage()
+    {
+        $image = $this->get( 'image' );
+        if ( $image !== null )
+        {
+            $imageTag = $this->xml->createElement( 'image' );
+            $this->root->appendChild( $imageTag );
+
+            $data = $image->about;
+            if ( is_null( $data ) )
+            {
+                throw new ezcFeedRequiredMetaDataMissingException( 'about' );
+            }
+
+            $aboutAttr = $this->xml->createAttribute( 'rdf:about' );
+            $aboutVal = $this->xml->createTextNode( $data );
+            $aboutAttr->appendChild( $aboutVal );
+            $imageTag->appendChild( $aboutAttr );
+
+            foreach ( $this->schema->getRequired( 'image' ) as $attribute )
+            {
+                $data = $image->$attribute;
+                if ( is_null( $data ) )
+                {
+                    throw new ezcFeedRequiredMetaDataMissingException( 
$attribute );
+                }
+
+                $data = ( $data instanceof ezcFeedElement ) ? 
$data->__toString() : $data;
+                $normalizedAttribute = ezcFeedTools::normalizeName( 
$attribute, $this->schema->getItemsMap() );
+
+                $attributes = array();
+                $this->generateMetaData( $imageTag, $attribute, $data );
             }
         }
     }

Added: 
trunk/Feed/tests/rss1/regression/generate/optional/image/image_about+title+url+link.in
==============================================================================
--- 
trunk/Feed/tests/rss1/regression/generate/optional/image/image_about+title+url+link.in
 (added)
+++ 
trunk/Feed/tests/rss1/regression/generate/optional/image/image_about+title+url+link.in
 [iso-8859-1] Thu Nov  1 15:42:26 2007
@@ -1,0 +1,14 @@
+<?php
+return array( 'about' => 'Channel about',
+              'title' => 'Feed title',
+              'link' => 'Feed link',
+              'description' => 'Feed description',
+                         'item' => array( array( 'about' => 'Item about',
+                                      'title' => 'Item title',
+                                      'link' => 'Item link' ) ),
+              'image' => array( array( 'about' => 'Image about',
+                                       'title' => 'Image title',
+                                       'url' => 'Image url',
+                                       'link' => 'Image link' ) ),
+            );
+?>

Added: 
trunk/Feed/tests/rss1/regression/generate/optional/image/image_about+title+url+link.out
==============================================================================
--- 
trunk/Feed/tests/rss1/regression/generate/optional/image/image_about+title+url+link.out
 (added)
+++ 
trunk/Feed/tests/rss1/regression/generate/optional/image/image_about+title+url+link.out
 [iso-8859-1] Thu Nov  1 15:42:26 2007
@@ -1,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";>
+  <channel rdf:about="Channel about">
+    <title>Feed title</title>
+    <link>Feed link</link>
+    <description>Feed description</description>
+    <items>
+      <rdf:Seq>
+        <rdf:li resource="Item about"/>
+      </rdf:Seq>
+    </items>
+    <image rdf:resource="Image about"/>
+  </channel>
+  <item rdf:about="Item about">
+    <title>Item title</title>
+    <link>Item link</link>
+  </item>
+  <image rdf:about="Image about">
+    <title>Image title</title>
+    <url>Image url</url>
+    <link>Image link</link>
+  </image>
+</rdf:RDF>

Added: 
trunk/Feed/tests/rss1/regression/generate/optional/image/image_about+title+url.in
==============================================================================
--- 
trunk/Feed/tests/rss1/regression/generate/optional/image/image_about+title+url.in
 (added)
+++ 
trunk/Feed/tests/rss1/regression/generate/optional/image/image_about+title+url.in
 [iso-8859-1] Thu Nov  1 15:42:26 2007
@@ -1,0 +1,13 @@
+<?php
+return array( 'about' => 'Channel about',
+              'title' => 'Feed title',
+              'link' => 'Feed link',
+              'description' => 'Feed description',
+                         'item' => array( array( 'about' => 'Item about',
+                                      'title' => 'Item title',
+                                      'link' => 'Item link' ) ),
+              'image' => array( array( 'about' => 'Image about',
+                                       'title' => 'Image title',
+                                       'url' => 'Image url' ) ),
+            );
+?>

Added: 
trunk/Feed/tests/rss1/regression/generate/optional/image/image_about+title+url.out
==============================================================================
--- 
trunk/Feed/tests/rss1/regression/generate/optional/image/image_about+title+url.out
 (added)
+++ 
trunk/Feed/tests/rss1/regression/generate/optional/image/image_about+title+url.out
 [iso-8859-1] Thu Nov  1 15:42:26 2007
@@ -1,0 +1,1 @@
+There was no data submitted for required channel attribute 'link'.

Added: 
trunk/Feed/tests/rss1/regression/generate/optional/image/image_about+title.in
==============================================================================
--- 
trunk/Feed/tests/rss1/regression/generate/optional/image/image_about+title.in 
(added)
+++ 
trunk/Feed/tests/rss1/regression/generate/optional/image/image_about+title.in 
[iso-8859-1] Thu Nov  1 15:42:26 2007
@@ -1,0 +1,12 @@
+<?php
+return array( 'about' => 'Channel about',
+              'title' => 'Feed title',
+              'link' => 'Feed link',
+              'description' => 'Feed description',
+                         'item' => array( array( 'about' => 'Item about',
+                                      'title' => 'Item title',
+                                      'link' => 'Item link' ) ),
+              'image' => array( array( 'about' => 'Image about',
+                                       'title' => 'Image title' ) ),
+            );
+?>

Added: 
trunk/Feed/tests/rss1/regression/generate/optional/image/image_about+title.out
==============================================================================
--- 
trunk/Feed/tests/rss1/regression/generate/optional/image/image_about+title.out 
(added)
+++ 
trunk/Feed/tests/rss1/regression/generate/optional/image/image_about+title.out 
[iso-8859-1] Thu Nov  1 15:42:26 2007
@@ -1,0 +1,1 @@
+There was no data submitted for required channel attribute 'url'.

Added: trunk/Feed/tests/rss1/regression/generate/optional/image/image_about.in
==============================================================================
--- trunk/Feed/tests/rss1/regression/generate/optional/image/image_about.in 
(added)
+++ trunk/Feed/tests/rss1/regression/generate/optional/image/image_about.in 
[iso-8859-1] Thu Nov  1 15:42:26 2007
@@ -1,0 +1,11 @@
+<?php
+return array( 'about' => 'Channel about',
+              'title' => 'Feed title',
+              'link' => 'Feed link',
+              'description' => 'Feed description',
+                         'item' => array( array( 'about' => 'Item about',
+                                      'title' => 'Item title',
+                                      'link' => 'Item link' ) ),
+              'image' => array( array( 'about' => 'Image about' ) ),
+            );
+?>

Added: trunk/Feed/tests/rss1/regression/generate/optional/image/image_about.out
==============================================================================
--- trunk/Feed/tests/rss1/regression/generate/optional/image/image_about.out 
(added)
+++ trunk/Feed/tests/rss1/regression/generate/optional/image/image_about.out 
[iso-8859-1] Thu Nov  1 15:42:26 2007
@@ -1,0 +1,1 @@
+There was no data submitted for required channel attribute 'title'.

Added: trunk/Feed/tests/rss1/regression/generate/optional/image/image_empty.in
==============================================================================
--- trunk/Feed/tests/rss1/regression/generate/optional/image/image_empty.in 
(added)
+++ trunk/Feed/tests/rss1/regression/generate/optional/image/image_empty.in 
[iso-8859-1] Thu Nov  1 15:42:26 2007
@@ -1,0 +1,11 @@
+<?php
+return array( 'about' => 'Channel about',
+              'title' => 'Feed title',
+              'link' => 'Feed link',
+              'description' => 'Feed description',
+                         'item' => array( array( 'about' => 'Item about',
+                                      'title' => 'Item title',
+                                      'link' => 'Item link' ) ),
+              'image' => array( array() ),
+            );
+?>

Added: trunk/Feed/tests/rss1/regression/generate/optional/image/image_empty.out
==============================================================================
--- trunk/Feed/tests/rss1/regression/generate/optional/image/image_empty.out 
(added)
+++ trunk/Feed/tests/rss1/regression/generate/optional/image/image_empty.out 
[iso-8859-1] Thu Nov  1 15:42:26 2007
@@ -1,0 +1,1 @@
+There was no data submitted for required channel attribute 'about'.


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

Reply via email to