Author: as Date: Thu Nov 15 11:29:33 2007 New Revision: 6736 Log: - Added support for parsing 'author' ATOM feed entry sub-element. # Support for generating it will come later, as it is intricately dependent on other ATOM feed entry sub-elements.
Added: trunk/Feed/tests/atom/regression/parse/entry/author/ trunk/Feed/tests/atom/regression/parse/entry/author/author_empty.in trunk/Feed/tests/atom/regression/parse/entry/author/author_empty.out trunk/Feed/tests/atom/regression/parse/entry/author/author_name+email+uri.in trunk/Feed/tests/atom/regression/parse/entry/author/author_name+email+uri.out trunk/Feed/tests/atom/regression/parse/entry/author/author_name+email.in trunk/Feed/tests/atom/regression/parse/entry/author/author_name+email.out trunk/Feed/tests/atom/regression/parse/entry/author/author_name.in trunk/Feed/tests/atom/regression/parse/entry/author/author_name.out Modified: trunk/Feed/src/processors/atom.php 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] Thu Nov 15 11:29:33 2007 @@ -662,6 +662,21 @@ case 'updated': $element->$tagName = ezcFeedTools::prepareDate( $itemChild->textContent ); break; + + case 'author': + $subElement = $element->add( $tagName ); + foreach ( $itemChild->childNodes as $subChild ) + { + if ( $subChild->nodeType === XML_ELEMENT_NODE ) + { + $subTagName = $subChild->tagName; + if ( in_array( $subTagName, array( 'name', 'email', 'uri' ) ) ) + { + $subElement->$subTagName = $subChild->textContent; + } + } + } + break; } } } Added: trunk/Feed/tests/atom/regression/parse/entry/author/author_empty.in ============================================================================== --- trunk/Feed/tests/atom/regression/parse/entry/author/author_empty.in (added) +++ trunk/Feed/tests/atom/regression/parse/entry/author/author_empty.in [iso-8859-1] Thu Nov 15 11:29:33 2007 @@ -1,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<feed xmlns="http://www.w3.org/2005/Atom"> + <id>Feed id</id> + <title type="text">Feed title</title> + <updated>Feed updated</updated> + <entry> + <id>Entry id</id> + <title>Entry title</title> + <updated>2007-11-14T16:23:40+01:00</updated> + <author/> + </entry> +</feed> Added: trunk/Feed/tests/atom/regression/parse/entry/author/author_empty.out ============================================================================== --- trunk/Feed/tests/atom/regression/parse/entry/author/author_empty.out (added) +++ trunk/Feed/tests/atom/regression/parse/entry/author/author_empty.out [iso-8859-1] Thu Nov 15 11:29:33 2007 @@ -1,0 +1,17 @@ +<?php +$feed = new ezcFeed( 'atom' ); + +$feed->id = 'Feed id'; +$feed->title = 'Feed title'; +$feed->title->type = 'text'; +$feed->updated = 'Feed updated'; + +$entry = $feed->add( 'entry' ); +$entry->id = 'Entry id'; +$entry->title = 'Entry title'; +$entry->updated = 1195053820; + +$author = $entry->add( 'author' ); + +return $feed; +?> Added: trunk/Feed/tests/atom/regression/parse/entry/author/author_name+email+uri.in ============================================================================== --- trunk/Feed/tests/atom/regression/parse/entry/author/author_name+email+uri.in (added) +++ trunk/Feed/tests/atom/regression/parse/entry/author/author_name+email+uri.in [iso-8859-1] Thu Nov 15 11:29:33 2007 @@ -1,0 +1,16 @@ +<?xml version="1.0" encoding="utf-8"?> +<feed xmlns="http://www.w3.org/2005/Atom"> + <id>Feed id</id> + <title type="text">Feed title</title> + <updated>Feed updated</updated> + <entry> + <id>Entry id</id> + <title>Entry title</title> + <updated>2007-11-14T16:23:40+01:00</updated> + <author> + <name>Entry author name</name> + <email>Entry author email</email> + <uri>Entry author uri</uri> + </author> + </entry> +</feed> Added: trunk/Feed/tests/atom/regression/parse/entry/author/author_name+email+uri.out ============================================================================== --- trunk/Feed/tests/atom/regression/parse/entry/author/author_name+email+uri.out (added) +++ trunk/Feed/tests/atom/regression/parse/entry/author/author_name+email+uri.out [iso-8859-1] Thu Nov 15 11:29:33 2007 @@ -1,0 +1,20 @@ +<?php +$feed = new ezcFeed( 'atom' ); + +$feed->id = 'Feed id'; +$feed->title = 'Feed title'; +$feed->title->type = 'text'; +$feed->updated = 'Feed updated'; + +$entry = $feed->add( 'entry' ); +$entry->id = 'Entry id'; +$entry->title = 'Entry title'; +$entry->updated = 1195053820; + +$author = $entry->add( 'author' ); +$author->name = 'Entry author name'; +$author->email = 'Entry author email'; +$author->uri = 'Entry author uri'; + +return $feed; +?> Added: trunk/Feed/tests/atom/regression/parse/entry/author/author_name+email.in ============================================================================== --- trunk/Feed/tests/atom/regression/parse/entry/author/author_name+email.in (added) +++ trunk/Feed/tests/atom/regression/parse/entry/author/author_name+email.in [iso-8859-1] Thu Nov 15 11:29:33 2007 @@ -1,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> +<feed xmlns="http://www.w3.org/2005/Atom"> + <id>Feed id</id> + <title type="text">Feed title</title> + <updated>Feed updated</updated> + <entry> + <id>Entry id</id> + <title>Entry title</title> + <updated>2007-11-14T16:23:40+01:00</updated> + <author> + <name>Entry author name</name> + <email>Entry author email</email> + </author> + </entry> +</feed> Added: trunk/Feed/tests/atom/regression/parse/entry/author/author_name+email.out ============================================================================== --- trunk/Feed/tests/atom/regression/parse/entry/author/author_name+email.out (added) +++ trunk/Feed/tests/atom/regression/parse/entry/author/author_name+email.out [iso-8859-1] Thu Nov 15 11:29:33 2007 @@ -1,0 +1,19 @@ +<?php +$feed = new ezcFeed( 'atom' ); + +$feed->id = 'Feed id'; +$feed->title = 'Feed title'; +$feed->title->type = 'text'; +$feed->updated = 'Feed updated'; + +$entry = $feed->add( 'entry' ); +$entry->id = 'Entry id'; +$entry->title = 'Entry title'; +$entry->updated = 1195053820; + +$author = $entry->add( 'author' ); +$author->name = 'Entry author name'; +$author->email = 'Entry author email'; + +return $feed; +?> Added: trunk/Feed/tests/atom/regression/parse/entry/author/author_name.in ============================================================================== --- trunk/Feed/tests/atom/regression/parse/entry/author/author_name.in (added) +++ trunk/Feed/tests/atom/regression/parse/entry/author/author_name.in [iso-8859-1] Thu Nov 15 11:29:33 2007 @@ -1,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8"?> +<feed xmlns="http://www.w3.org/2005/Atom"> + <id>Feed id</id> + <title type="text">Feed title</title> + <updated>Feed updated</updated> + <entry> + <id>Entry id</id> + <title>Entry title</title> + <updated>2007-11-14T16:23:40+01:00</updated> + <author> + <name>Entry author name</name> + </author> + </entry> +</feed> Added: trunk/Feed/tests/atom/regression/parse/entry/author/author_name.out ============================================================================== --- trunk/Feed/tests/atom/regression/parse/entry/author/author_name.out (added) +++ trunk/Feed/tests/atom/regression/parse/entry/author/author_name.out [iso-8859-1] Thu Nov 15 11:29:33 2007 @@ -1,0 +1,18 @@ +<?php +$feed = new ezcFeed( 'atom' ); + +$feed->id = 'Feed id'; +$feed->title = 'Feed title'; +$feed->title->type = 'text'; +$feed->updated = 'Feed updated'; + +$entry = $feed->add( 'entry' ); +$entry->id = 'Entry id'; +$entry->title = 'Entry title'; +$entry->updated = 1195053820; + +$author = $entry->add( 'author' ); +$author->name = 'Entry author name'; + +return $feed; +?> -- svn-components mailing list svn-components@lists.ez.no http://lists.ez.no/mailman/listinfo/svn-components