cvs: pear /XML_Feed_Parser Parser.php package.xml /XML_Feed_Parser/Parser RSS2.php /XML_Feed_Parser/samples rss091-complete.xml rss092-sample.xml
/XML_Feed_Parser/tests rss091Values.php
| From: | James Stewart | Date: | Sat, 22 Oct 2005 17:57:10 +0000 |
| Subject: | cvs: pear /XML_Feed_Parser Parser.php package.xml /XML_Feed_Parser/Parser RSS2.php /XML_Feed_Parser/samples rss091-complete.xml rss092-sample.xml /XML_Feed_Parser/tests rss091Values.php |
||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-35796@lists.php.net to get a copy of this message | ||
jystewart Sat Oct 22 13:57:10 2005 EDT
Added files:
/pear/XML_Feed_Parser/samples rss091-complete.xml rss092-sample.xml
/pear/XML_Feed_Parser/tests rss091Values.php
Modified files:
/pear/XML_Feed_Parser Parser.php package.xml
/pear/XML_Feed_Parser/Parser RSS2.php
Log:
Adding experimental support for RSS0.91 and RSS0.92
Fixed bug where no error thrown for unrecognised versions of RSS by restructuring switch slightly
Added test for RSS0.91
Added sample RSS0.91 and RSS0.92 files
http://cvs.php.net/diff.php/pear/XML_Feed_Parser/Parser.php?r1=1.5&r2=1.6&ty=u Index: pear/XML_Feed_Parser/Parser.php diff -u pear/XML_Feed_Parser/Parser.php:1.5 pear/XML_Feed_Parser/Parser.php:1.6 --- pear/XML_Feed_Parser/Parser.php:1.5 Sat Oct 22 13:20:34 2005 +++ pear/XML_Feed_Parser/Parser.php Sat Oct 22 13:57:06 2005 @@ -17,7 +17,7 @@ * @author James Stewart <james@jystewart.net> * @copyright 2005 James Stewart <james@jystewart.net> * @license http://www.gnu.org/copyleft/lesser.html GNU LGPL - * @version CVS: $Id: Parser.php,v 1.5 2005/10/22 17:20:34 jystewart Exp $ + * @version CVS: $Id: Parser.php,v 1.6 2005/10/22 17:57:06 jystewart Exp $ * @link http://dev.jystewart.net/XML_Feed_Parser/ */ @@ -106,13 +106,32 @@ require_once 'Parser/RSS09Element.php'; $class = 'XML_Feed_Parser_RSS09'; break; - case ($doc_element->tagName == 'rss'): - if ($doc_element->hasAttribute('version') and - $doc_element->getAttribute('version') == 2) { - require_once 'Parser/RSS2.php'; - require_once 'Parser/RSS2Element.php'; - $class = 'XML_Feed_Parser_RSS2'; - } + case ($doc_element->tagName == 'rss' and + $doc_element->hasAttribute('version') and + $doc_element->getAttribute('version') == 2): + require_once 'Parser/RSS2.php'; + require_once 'Parser/RSS2Element.php'; + $class = 'XML_Feed_Parser_RSS2'; + break; + case ($doc_element->tagName == 'rss' and + $doc_element->hasAttribute('version') and + $doc_element->getAttribute('version') == 0.91): + trigger_error( + 'RSS 0.91 has been superceded by RSS2.0. Using RSS2.0 parser.', + E_USER_WARNING); + require_once 'Parser/RSS2.php'; + require_once 'Parser/RSS2Element.php'; + $class = 'XML_Feed_Parser_RSS2'; + break; + case ($doc_element->tagName == 'rss' and + $doc_element->hasAttribute('version') and + $doc_element->getAttribute('version') == 0.92): + trigger_error( + 'RSS 0.92 has been superceded by RSS2.0. Using RSS2.0 parser.', + E_USER_WARNING); + require_once 'Parser/RSS2.php'; + require_once 'Parser/RSS2Element.php'; + $class = 'XML_Feed_Parser_RSS2'; break; default: throw new XML_Feed_Parser_Exception('Feed type unknown'); http://cvs.php.net/diff.php/pear/XML_Feed_Parser/package.xml?r1=1.4&r2=1.5&ty=u Index: pear/XML_Feed_Parser/package.xml diff -u pear/XML_Feed_Parser/package.xml:1.4 pear/XML_Feed_Parser/package.xml:1.5 --- pear/XML_Feed_Parser/package.xml:1.4 Sat Oct 22 13:20:34 2005 +++ pear/XML_Feed_Parser/package.xml Sat Oct 22 13:57:06 2005 @@ -68,6 +68,7 @@ <file name="japanese.php"/> <file name="farsi.php"/> <file name="errors.php"/> + <file name="rss091Values.php"/> </dir> <dir name="samples" role="data"> <file name="atom10-example1.xml"/> @@ -82,6 +83,10 @@ <file name="technorati.feed"/> <file name="hoder.xml"/> <file name="sixapart-jp.xml"/> + <file name="rss091-complete.xml"/> + <file name="rss091-international.xml"/> + <file name="rss091-simple.xml"/> + <file name="rss092-sample.xml"/> </dir> </dir> </filelist> http://cvs.php.net/diff.php/pear/XML_Feed_Parser/Parser/RSS2.php?r1=1.2&r2=1.3&ty=u Index: pear/XML_Feed_Parser/Parser/RSS2.php diff -u pear/XML_Feed_Parser/Parser/RSS2.php:1.2 pear/XML_Feed_Parser/Parser/RSS2.php:1.3 --- pear/XML_Feed_Parser/Parser/RSS2.php:1.2 Sat Oct 15 11:06:22 2005 +++ pear/XML_Feed_Parser/Parser/RSS2.php Sat Oct 22 13:57:10 2005 @@ -17,7 +17,7 @@ * @author James Stewart <james@jystewart.net> * @copyright 2005 James Stewart <james@jystewart.net> * @license http://www.gnu.org/copyleft/lesser.html GNU LGPL 2.1 - * @version CVS: $Id: RSS2.php,v 1.2 2005/10/15 15:06:22 jystewart Exp $ + * @version CVS: $Id: RSS2.php,v 1.3 2005/10/22 17:57:10 jystewart Exp $ * @link http://dev.jystewart.net/XML_Feed_Parser/ */ @@ -82,7 +82,10 @@ 'category' => array('Text'), 'generator' => array('Text'), 'docs' => array('Text'), - 'ttl' => array('Text')); + 'ttl' => array('Text'), + 'image' => array('Image'), + 'skipDays' => array('skipDays'), + 'skipHours' => array('skipHours')); /** * Here we map some elements to their atom equivalents. This is going to be @@ -176,15 +179,15 @@ if ($images->length > 0) { $image = $images->item(0); $desc = $image->getElementsByTagName('description'); - $description = $desc->length ? $desc->item(0)->value : false; + $description = $desc->length ? $desc->item(0)->nodeValue : false; $heigh = $image->getElementsByTagName('height'); - $height = $heigh->length ? $heigh->item(0)->value : false; + $height = $heigh->length ? $heigh->item(0)->nodeValue : false; $widt = $image->getElementsByTagName('width'); - $width = $widt->length ? $widt->item(0)->value : false; + $width = $widt->length ? $widt->item(0)->nodeValue : false; return array( - 'title' => $image->getElementsByTagName('title')->item(0)->value, - 'link' => $image->getElementsByTagName('link')->item(0)->value, - 'url' => $image->getElementsByTagName('url')->item(0)->value, + 'title' => $image->getElementsByTagName('title')->item(0)->nodeValue, + 'link' => $image->getElementsByTagName('link')->item(0)->nodeValue, + 'url' => $image->getElementsByTagName('url')->item(0)->nodeValue, 'description' => $description, 'height' => $height, 'width' => $width); http://cvs.php.net/co.php/pear/XML_Feed_Parser/samples/rss091-complete.xml?r=1.1&p=1 Index: pear/XML_Feed_Parser/samples/rss091-complete.xml +++ pear/XML_Feed_Parser/samples/rss091-complete.xml <?xml version="1.0"?> <!DOCTYPE rss SYSTEM "http://my.netscape.com/publish/formats/rss-0.91.dtd"> <rss version="0.91"> <channel> <copyright>Copyright 1997-1999 UserLand Software, Inc.</copyright> <pubDate>Thu, 08 Jul 1999 07:00:00 GMT</pubDate> <lastBuildDate>Thu, 08 Jul 1999 16:20:26 GMT</lastBuildDate> <docs>http://my.userland.com/stories/storyReader$11</docs> <description>News and commentary from the cross-platform scripting community.</description> <link>http://www.scripting.com/</link> <title>Scripting News</title> <image> <link>http://www.scripting.com/</link> <title>Scripting News</title> <url>http://www.scripting.com/gifs/tinyScriptingNews.gif</url> <height>40</height> <width>78</width> <description>What is this used for?</description> </image> <managingEditor>dave@userland.com (Dave Winer)</managingEditor> <webMaster>dave@userland.com (Dave Winer)</webMaster> <language>en-us</language> <skipHours> <hour>6</hour> <hour>7</hour> <hour>8</hour> <hour>9</hour> <hour>10</hour> <hour>11</hour> </skipHours> <skipDays> <day>Sunday</day> </skipDays> <rating>(PICS-1.1 "http://www.rsac.org/ratingsv01.html" l gen true comment "RSACi North America Server" for "http://www.rsac.org" on "1996.04.16T08:15-0500" r (n 0 s 0 v 0 l 0))</rating> <item> <title>stuff</title> <link>http://bar</link> <description>This is an article about some stuff</description> </item> <textinput> <title>Search Now!</title> <description>Enter your search <terms></description> <name>find</name> <link>http://my.site.com/search.cgi</link> </textinput> </channel> </rss> http://cvs.php.net/co.php/pear/XML_Feed_Parser/samples/rss092-sample.xml?r=1.1&p=1 Index: pear/XML_Feed_Parser/samples/rss092-sample.xml +++ pear/XML_Feed_Parser/samples/rss092-sample.xml <?xml version="1.0"?> <!-- RSS generation done by 'Radio UserLand' on Fri, 13 Apr 2001 19:23:02 GMT --> <rss version="0.92"> <channel> <title>Dave Winer: Grateful Dead</title> <link>http://www.scripting.com/blog/categories/gratefulDead.html</link> <description>A high-fidelity Grateful Dead song every day. This is where we're experimenting with enclosures on RSS news items that download when you're not using your computer. If it works (it will) it will be the end of the Click-And-Wait multimedia experience on the Internet. </description> <lastBuildDate>Fri, 13 Apr 2001 19:23:02 GMT</lastBuildDate> <docs>http://backend.userland.com/rss092</docs> <managingEditor>dave@userland.com (Dave Winer)</managingEditor> <webMaster>dave@userland.com (Dave Winer)</webMaster> <cloud domain="data.ourfavoritesongs.com" port="80" path="/RPC2" registerProcedure="ourFavoriteSongs.rssPleaseNotify" protocol="xml-rpc"/> <item> <description>It's been a few days since I added a song to the Grateful Dead channel. Now that there are all these new Radio users, many of whom are tuned into this channel (it's #16 on the hotlist of upstreaming Radio users, there's no way of knowing how many non-upstreaming users are subscribing, have to do something about this..). Anyway, tonight's song is a live version of Weather Report Suite from Dick's Picks Volume 7. It's wistful music. Of course a beautiful song, oft-quoted here on Scripting News. <i>A little change, the wind and rain.</i> </description> <enclosure url="http://www.scripting.com/mp3s/weatherReportDicksPicsVol7.mp3" length="6182912" type="audio/mpeg"/> </item> <item> <description>Kevin Drennan started a <a href="http://deadend.editthispage.com/">Grateful Dead Weblog</a>. Hey it's cool, he even has a <a href="http://deadend.editthispage.com/directory/61">directory</a>. <i>A Frontier 7 feature.</i></description> <source url="http://scriptingnews.userland.com/xml/scriptingNews2.xml">Scripting News</source> </item> <item> <description><a href="http://arts.ucsc.edu/GDead/AGDL/other1.html">The Other One</a>, live instrumental, One From The Vault. Very rhythmic very spacy, you can listen to it many times, and enjoy something new every time.</description> <enclosure url="http://www.scripting.com/mp3s/theOtherOne.mp3" length="6666097" type="audio/mpeg"/> </item> <item> <description>This is a test of a change I just made. Still diggin..</description> </item> <item> <description>The HTML rendering almost <a href="http://validator.w3.org/check/referer">validates</a>. Close. Hey I wonder if anyone has ever published a style guide for ALT attributes on images? What are you supposed to say in the ALT attribute? I sure don't know. If you're blind send me an email if u cn rd ths. </description> </item> <item> <description><a href="http://www.cs.cmu.edu/~mleone/gdead/dead-lyrics/Franklin's_Tower.txt">Franklin's Tower</a>, a live version from One From The Vault.</description> <enclosure url="http://www.scripting.com/mp3s/franklinsTower.mp3" length="6701402" type="audio/mpeg"/> </item> <item> <description>Moshe Weitzman says Shakedown Street is what I'm lookin for for tonight. I'm listening right now. It's one of my favorites. "Don't tell me this town ain't got no heart." Too bright. I like the jazziness of Weather Report Suite. Dreamy and soft. How about The Other One? "Spanish lady come to me.."</description> <source url="http://scriptingnews.userland.com/xml/scriptingNews2.xml">Scripting News</source> </item> <item> <description><a href="http://www.scripting.com/mp3s/youWinAgain.mp3">The news is out</a>, all over town..<p> You've been seen, out runnin round. <p> The lyrics are <a href="http://www.cs.cmu.edu/~mleone/gdead/dead-lyrics/You_Win_Again.txt">here</a>, short and sweet. <p> <i>You win again!</i> </description> <enclosure url="http://www.scripting.com/mp3s/youWinAgain.mp3" length="3874816" type="audio/mpeg"/> </item> <item> <description><a href="http://www.getlyrics.com/lyrics/grateful-dead/wake-of-the-flood/07.htm">Weather Report Suite</a>: "Winter rain, now tell me why, summers fade, and roses die? The answer came. The wind and rain. Golden hills, now veiled in grey, summer leaves have blown away. Now what remains? The wind and rain."</description> <enclosure url="http://www.scripting.com/mp3s/weatherReportSuite.mp3" length="12216320" type="audio/mpeg"/> </item> <item> <description><a href="http://arts.ucsc.edu/gdead/agdl/darkstar.html">Dark Star</a> crashes, pouring its light into ashes.</description> <enclosure url="http://www.scripting.com/mp3s/darkStar.mp3" length="10889216" type="audio/mpeg"/> </item> <item> <description>DaveNet: <a href="http://davenet.userland.com/2001/01/21/theUsBlues">The U.S. Blues</a>.</description> </item> <item> <description>Still listening to the US Blues. <i>"Wave that flag, wave it wide and high.."</i> Mistake made in the 60s. We gave our country to the assholes. Ah ah. Let's take it back. Hey I'm still a hippie. <i>"You could call this song The United States Blues."</i></description> </item> <item> <description><a href="http://www.sixties.com/html/garcia_stack_0.html"><img src="http://www.scripting.com/images/captainTripsSmall.gif" height="51" width="42" border="0" hspace="10" vspace="10" align="right"></a>In celebration of today's inauguration, after hearing all those great patriotic songs, America the Beautiful, even The Star Spangled Banner made my eyes mist up. It made my choice of Grateful Dead song of the night realllly easy. Here are the <a href="http://searchlyrics2.homestead.com/gd_usblues.html">lyrics</a>. Click on the audio icon to the left to give it a listen. "Red and white, blue suede shoes, I'm Uncle Sam, how do you do?" It's a different kind of patriotic music, but man I love my country and I love Jerry and the band. <i>I truly do!</i></description> <enclosure url="http://www.scripting.com/mp3s/usBlues.mp3" length="5272510" type="audio/mpeg"/> </item> <item> <description>Grateful Dead: "Tennessee, Tennessee, ain't no place I'd rather be."</description> <enclosure url="http://www.scripting.com/mp3s/tennesseeJed.mp3" length="3442648" type="audio/mpeg"/> </item> <item> <description>Ed Cone: "Had a nice Deadhead experience with my wife, who never was one but gets the vibe and knows and likes a lot of the music. Somehow she made it to the age of 40 without ever hearing Wharf Rat. We drove to Jersey and back over Christmas with the live album commonly known as Skull and Roses in the CD player much of the way, and it was cool to see her discover one the band's finest moments. That song is unique and underappreciated. Fun to hear that disc again after a few years off -- you get Jerry as blues-guitar hero on Big Railroad Blues and a nice version of Bertha."</description> <enclosure url="http://www.scripting.com/mp3s/darkStarWharfRat.mp3" length="27503386" type="audio/mpeg"/> </item> <item> <description><a href="http://arts.ucsc.edu/GDead/AGDL/fotd.html">Tonight's Song</a>: "If I get home before daylight I just might get some sleep tonight." </description> <enclosure url="http://www.scripting.com/mp3s/friendOfTheDevil.mp3" length="3219742" type="audio/mpeg"/> </item> <item> <description><a href="http://arts.ucsc.edu/GDead/AGDL/uncle.html">Tonight's song</a>: "Come hear Uncle John's Band by the river side. Got some things to talk about here beside the rising tide."</description> <enclosure url="http://www.scripting.com/mp3s/uncleJohnsBand.mp3" length="4587102" type="audio/mpeg"/> </item> <item> <description><a href="http://www.cs.cmu.edu/~mleone/gdead/dead-lyrics/Me_and_My_Uncle.txt">Me and My Uncle</a>: "I loved my uncle, God rest his soul, taught me good, Lord, taught me all I know. Taught me so well, I grabbed that gold and I left his dead ass there by the side of the road." </description> <enclosure url="http://www.scripting.com/mp3s/meAndMyUncle.mp3" length="2949248" type="audio/mpeg"/> </item> <item> <description>Truckin, like the doo-dah man, once told me gotta play your hand. Sometimes the cards ain't worth a dime, if you don't lay em down.</description> <enclosure url="http://www.scripting.com/mp3s/truckin.mp3" length="4847908" type="audio/mpeg"/> </item> <item> <description>Two-Way-Web: <a href="http://www.thetwowayweb.com/payloadsForRss">Payloads for RSS</a>. "When I started talking with Adam late last year, he wanted me to think about high quality video on the Internet, and I totally didn't want to hear about it."</description> </item> <item> <description>A touch of gray, kinda suits you anyway..</description> <enclosure url="http://www.scripting.com/mp3s/touchOfGrey.mp3" length="5588242" type="audio/mpeg"/> </item> <item> <description><a href="http://www.sixties.com/html/garcia_stack_0.html"><img src="http://www.scripting.com/images/captainTripsSmall.gif" height="51" width="42" border="0" hspace="10" vspace="10" align="right"></a>In celebration of today's inauguration, after hearing all those great patriotic songs, America the Beautiful, even The Star Spangled Banner made my eyes mist up. It made my choice of Grateful Dead song of the night realllly easy. Here are the <a href="http://searchlyrics2.homestead.com/gd_usblues.html">lyrics</a>. Click on the audio icon to the left to give it a listen. "Red and white, blue suede shoes, I'm Uncle Sam, how do you do?" It's a different kind of patriotic music, but man I love my country and I love Jerry and the band. <i>I truly do!</i></description> <enclosure url="http://www.scripting.com/mp3s/usBlues.mp3" length="5272510" type="audio/mpeg"/> </item> </channel> </rss> http://cvs.php.net/co.php/pear/XML_Feed_Parser/tests/rss091Values.php?r=1.1&p=1 Index: pear/XML_Feed_Parser/tests/rss091Values.php +++ pear/XML_Feed_Parser/tests/rss091Values.php <?php require_once '../Parser.php'; require_once 'PHPUnit.php'; class XML_Feed_Parser_RSS091_valueValidity_TestCase extends PHPUnit_TestCase { function __construct($name) { $this->PHPUnit_TestCase($name); $this->file = file_get_contents("../samples/rss091-complete.xml"); $this->feed = new XML_Feed_Parser($this->file); $this->entry = $this->feed->getEntryByOffset(0); } function test_feedRights() { $value = "Copyright 1997-1999 UserLand Software, Inc."; $this->assertEquals($value, $this->feed->rights); $this->assertEquals($value, $this->feed->copyright); } function test_feedNumberItems() { $value = 1; $this->assertEquals($value, $this->feed->numberEntries); } function test_feedTitle() { $value = "Scripting News"; $this->assertEquals($value, $this->feed->title); } function test_feedLink() { $value = "http://www.scripting.com/"; $this->assertEquals($value, $this->feed->link); } function test_feedImage() { $value = array( "title" => "Scripting News", "link" => "http://www.scripting.com/", "url" => "http://www.scripting.com/gifs/tinyScriptingNews.gif", "description" => "What is this used for?", 'height' => "40", 'width' => "78"); $this->assertEquals($value, $this->feed->image); } function test_feedDescription() { $value = "News and commentary from the cross-platform scripting community."; $this->assertEquals($value, $this->feed->description); } function test_feedSubtitleEquivalence() { $value = "News and commentary from the cross-platform scripting community."; $this->assertEquals($value, $this->feed->subtitle); } function test_feedDate() { $value = strtotime("Thu, 08 Jul 1999 07:00:00 GMT"); $this->assertEquals($value, $this->feed->date); } function test_feedLastBuildDate() { $value = strtotime("Thu, 08 Jul 1999 16:20:26 GMT"); $this->assertEquals($value, $this->feed->lastBuildDate); } function test_feedUpdatedEquivalence() { $value = strtotime("Thu, 08 Jul 1999 16:20:26 GMT"); $this->assertEquals($value, $this->feed->updated); } function test_feedLanguage() { $value = "en-us"; $this->assertEquals($value, $this->feed->language); } function test_feedSkipHours() { $value = array("6", "7", "8", "9", "10", "11"); $this->assertEquals($value, $this->feed->skipHours); } function test_feedSkipDays() { $value = array("Sunday"); $this->assertEquals($value, $this->feed->skipDays); } function test_feedDocs() { $value = "http://my.userland.com/stories/storyReader$11"; $this->assertEquals($value, $this->feed->docs); } function test_feedManagingEditor() { $value = "dave@userland.com (Dave Winer)"; $this->assertEquals($value, $this->feed->managingEditor); } function test_feedAuthorEquivalence() { $value = "dave@userland.com (Dave Winer)"; $this->assertEquals($value, $this->feed->author); } function test_feedWebmaster() { $value = "dave@userland.com (Dave Winer)"; $this->assertEquals($value, $this->feed->webMaster); } function test_entryTitle() { $value = "stuff"; $this->assertEquals($value, $this->entry->title); } function test_entryLink() { $value = "http://bar"; $this->assertEquals($value, $this->entry->link); } function test_entryDescription() { $value = "This is an article about some stuff"; $this->assertEquals($value, $this->entry->description); } } $suite = new PHPUnit_TestSuite; $suite->addTestSuite("XML_Feed_Parser_RSS091_valueValidity_TestCase"); $result = PHPUnit::run($suite, "123"); echo $result->toString(); ?>
http://cvs.php.net/diff.php/pear/XML_Feed_Parser/Parser.php?r1=1.5&r2=1.6&ty=u Index: pear/XML_Feed_Parser/Parser.php diff -u pear/XML_Feed_Parser/Parser.php:1.5 pear/XML_Feed_Parser/Parser.php:1.6 --- pear/XML_Feed_Parser/Parser.php:1.5 Sat Oct 22 13:20:34 2005 +++ pear/XML_Feed_Parser/Parser.php Sat Oct 22 13:57:06 2005 @@ -17,7 +17,7 @@ * @author James Stewart <james@jystewart.net> * @copyright 2005 James Stewart <james@jystewart.net> * @license http://www.gnu.org/copyleft/lesser.html GNU LGPL - * @version CVS: $Id: Parser.php,v 1.5 2005/10/22 17:20:34 jystewart Exp $ + * @version CVS: $Id: Parser.php,v 1.6 2005/10/22 17:57:06 jystewart Exp $ * @link http://dev.jystewart.net/XML_Feed_Parser/ */ @@ -106,13 +106,32 @@ require_once 'Parser/RSS09Element.php'; $class = 'XML_Feed_Parser_RSS09'; break; - case ($doc_element->tagName == 'rss'): - if ($doc_element->hasAttribute('version') and - $doc_element->getAttribute('version') == 2) { - require_once 'Parser/RSS2.php'; - require_once 'Parser/RSS2Element.php'; - $class = 'XML_Feed_Parser_RSS2'; - } + case ($doc_element->tagName == 'rss' and + $doc_element->hasAttribute('version') and + $doc_element->getAttribute('version') == 2): + require_once 'Parser/RSS2.php'; + require_once 'Parser/RSS2Element.php'; + $class = 'XML_Feed_Parser_RSS2'; + break; + case ($doc_element->tagName == 'rss' and + $doc_element->hasAttribute('version') and + $doc_element->getAttribute('version') == 0.91): + trigger_error( + 'RSS 0.91 has been superceded by RSS2.0. Using RSS2.0 parser.', + E_USER_WARNING); + require_once 'Parser/RSS2.php'; + require_once 'Parser/RSS2Element.php'; + $class = 'XML_Feed_Parser_RSS2'; + break; + case ($doc_element->tagName == 'rss' and + $doc_element->hasAttribute('version') and + $doc_element->getAttribute('version') == 0.92): + trigger_error( + 'RSS 0.92 has been superceded by RSS2.0. Using RSS2.0 parser.', + E_USER_WARNING); + require_once 'Parser/RSS2.php'; + require_once 'Parser/RSS2Element.php'; + $class = 'XML_Feed_Parser_RSS2'; break; default: throw new XML_Feed_Parser_Exception('Feed type unknown'); http://cvs.php.net/diff.php/pear/XML_Feed_Parser/package.xml?r1=1.4&r2=1.5&ty=u Index: pear/XML_Feed_Parser/package.xml diff -u pear/XML_Feed_Parser/package.xml:1.4 pear/XML_Feed_Parser/package.xml:1.5 --- pear/XML_Feed_Parser/package.xml:1.4 Sat Oct 22 13:20:34 2005 +++ pear/XML_Feed_Parser/package.xml Sat Oct 22 13:57:06 2005 @@ -68,6 +68,7 @@ <file name="japanese.php"/> <file name="farsi.php"/> <file name="errors.php"/> + <file name="rss091Values.php"/> </dir> <dir name="samples" role="data"> <file name="atom10-example1.xml"/> @@ -82,6 +83,10 @@ <file name="technorati.feed"/> <file name="hoder.xml"/> <file name="sixapart-jp.xml"/> + <file name="rss091-complete.xml"/> + <file name="rss091-international.xml"/> + <file name="rss091-simple.xml"/> + <file name="rss092-sample.xml"/> </dir> </dir> </filelist> http://cvs.php.net/diff.php/pear/XML_Feed_Parser/Parser/RSS2.php?r1=1.2&r2=1.3&ty=u Index: pear/XML_Feed_Parser/Parser/RSS2.php diff -u pear/XML_Feed_Parser/Parser/RSS2.php:1.2 pear/XML_Feed_Parser/Parser/RSS2.php:1.3 --- pear/XML_Feed_Parser/Parser/RSS2.php:1.2 Sat Oct 15 11:06:22 2005 +++ pear/XML_Feed_Parser/Parser/RSS2.php Sat Oct 22 13:57:10 2005 @@ -17,7 +17,7 @@ * @author James Stewart <james@jystewart.net> * @copyright 2005 James Stewart <james@jystewart.net> * @license http://www.gnu.org/copyleft/lesser.html GNU LGPL 2.1 - * @version CVS: $Id: RSS2.php,v 1.2 2005/10/15 15:06:22 jystewart Exp $ + * @version CVS: $Id: RSS2.php,v 1.3 2005/10/22 17:57:10 jystewart Exp $ * @link http://dev.jystewart.net/XML_Feed_Parser/ */ @@ -82,7 +82,10 @@ 'category' => array('Text'), 'generator' => array('Text'), 'docs' => array('Text'), - 'ttl' => array('Text')); + 'ttl' => array('Text'), + 'image' => array('Image'), + 'skipDays' => array('skipDays'), + 'skipHours' => array('skipHours')); /** * Here we map some elements to their atom equivalents. This is going to be @@ -176,15 +179,15 @@ if ($images->length > 0) { $image = $images->item(0); $desc = $image->getElementsByTagName('description'); - $description = $desc->length ? $desc->item(0)->value : false; + $description = $desc->length ? $desc->item(0)->nodeValue : false; $heigh = $image->getElementsByTagName('height'); - $height = $heigh->length ? $heigh->item(0)->value : false; + $height = $heigh->length ? $heigh->item(0)->nodeValue : false; $widt = $image->getElementsByTagName('width'); - $width = $widt->length ? $widt->item(0)->value : false; + $width = $widt->length ? $widt->item(0)->nodeValue : false; return array( - 'title' => $image->getElementsByTagName('title')->item(0)->value, - 'link' => $image->getElementsByTagName('link')->item(0)->value, - 'url' => $image->getElementsByTagName('url')->item(0)->value, + 'title' => $image->getElementsByTagName('title')->item(0)->nodeValue, + 'link' => $image->getElementsByTagName('link')->item(0)->nodeValue, + 'url' => $image->getElementsByTagName('url')->item(0)->nodeValue, 'description' => $description, 'height' => $height, 'width' => $width); http://cvs.php.net/co.php/pear/XML_Feed_Parser/samples/rss091-complete.xml?r=1.1&p=1 Index: pear/XML_Feed_Parser/samples/rss091-complete.xml +++ pear/XML_Feed_Parser/samples/rss091-complete.xml <?xml version="1.0"?> <!DOCTYPE rss SYSTEM "http://my.netscape.com/publish/formats/rss-0.91.dtd"> <rss version="0.91"> <channel> <copyright>Copyright 1997-1999 UserLand Software, Inc.</copyright> <pubDate>Thu, 08 Jul 1999 07:00:00 GMT</pubDate> <lastBuildDate>Thu, 08 Jul 1999 16:20:26 GMT</lastBuildDate> <docs>http://my.userland.com/stories/storyReader$11</docs> <description>News and commentary from the cross-platform scripting community.</description> <link>http://www.scripting.com/</link> <title>Scripting News</title> <image> <link>http://www.scripting.com/</link> <title>Scripting News</title> <url>http://www.scripting.com/gifs/tinyScriptingNews.gif</url> <height>40</height> <width>78</width> <description>What is this used for?</description> </image> <managingEditor>dave@userland.com (Dave Winer)</managingEditor> <webMaster>dave@userland.com (Dave Winer)</webMaster> <language>en-us</language> <skipHours> <hour>6</hour> <hour>7</hour> <hour>8</hour> <hour>9</hour> <hour>10</hour> <hour>11</hour> </skipHours> <skipDays> <day>Sunday</day> </skipDays> <rating>(PICS-1.1 "http://www.rsac.org/ratingsv01.html" l gen true comment "RSACi North America Server" for "http://www.rsac.org" on "1996.04.16T08:15-0500" r (n 0 s 0 v 0 l 0))</rating> <item> <title>stuff</title> <link>http://bar</link> <description>This is an article about some stuff</description> </item> <textinput> <title>Search Now!</title> <description>Enter your search <terms></description> <name>find</name> <link>http://my.site.com/search.cgi</link> </textinput> </channel> </rss> http://cvs.php.net/co.php/pear/XML_Feed_Parser/samples/rss092-sample.xml?r=1.1&p=1 Index: pear/XML_Feed_Parser/samples/rss092-sample.xml +++ pear/XML_Feed_Parser/samples/rss092-sample.xml <?xml version="1.0"?> <!-- RSS generation done by 'Radio UserLand' on Fri, 13 Apr 2001 19:23:02 GMT --> <rss version="0.92"> <channel> <title>Dave Winer: Grateful Dead</title> <link>http://www.scripting.com/blog/categories/gratefulDead.html</link> <description>A high-fidelity Grateful Dead song every day. This is where we're experimenting with enclosures on RSS news items that download when you're not using your computer. If it works (it will) it will be the end of the Click-And-Wait multimedia experience on the Internet. </description> <lastBuildDate>Fri, 13 Apr 2001 19:23:02 GMT</lastBuildDate> <docs>http://backend.userland.com/rss092</docs> <managingEditor>dave@userland.com (Dave Winer)</managingEditor> <webMaster>dave@userland.com (Dave Winer)</webMaster> <cloud domain="data.ourfavoritesongs.com" port="80" path="/RPC2" registerProcedure="ourFavoriteSongs.rssPleaseNotify" protocol="xml-rpc"/> <item> <description>It's been a few days since I added a song to the Grateful Dead channel. Now that there are all these new Radio users, many of whom are tuned into this channel (it's #16 on the hotlist of upstreaming Radio users, there's no way of knowing how many non-upstreaming users are subscribing, have to do something about this..). Anyway, tonight's song is a live version of Weather Report Suite from Dick's Picks Volume 7. It's wistful music. Of course a beautiful song, oft-quoted here on Scripting News. <i>A little change, the wind and rain.</i> </description> <enclosure url="http://www.scripting.com/mp3s/weatherReportDicksPicsVol7.mp3" length="6182912" type="audio/mpeg"/> </item> <item> <description>Kevin Drennan started a <a href="http://deadend.editthispage.com/">Grateful Dead Weblog</a>. Hey it's cool, he even has a <a href="http://deadend.editthispage.com/directory/61">directory</a>. <i>A Frontier 7 feature.</i></description> <source url="http://scriptingnews.userland.com/xml/scriptingNews2.xml">Scripting News</source> </item> <item> <description><a href="http://arts.ucsc.edu/GDead/AGDL/other1.html">The Other One</a>, live instrumental, One From The Vault. Very rhythmic very spacy, you can listen to it many times, and enjoy something new every time.</description> <enclosure url="http://www.scripting.com/mp3s/theOtherOne.mp3" length="6666097" type="audio/mpeg"/> </item> <item> <description>This is a test of a change I just made. Still diggin..</description> </item> <item> <description>The HTML rendering almost <a href="http://validator.w3.org/check/referer">validates</a>. Close. Hey I wonder if anyone has ever published a style guide for ALT attributes on images? What are you supposed to say in the ALT attribute? I sure don't know. If you're blind send me an email if u cn rd ths. </description> </item> <item> <description><a href="http://www.cs.cmu.edu/~mleone/gdead/dead-lyrics/Franklin's_Tower.txt">Franklin's Tower</a>, a live version from One From The Vault.</description> <enclosure url="http://www.scripting.com/mp3s/franklinsTower.mp3" length="6701402" type="audio/mpeg"/> </item> <item> <description>Moshe Weitzman says Shakedown Street is what I'm lookin for for tonight. I'm listening right now. It's one of my favorites. "Don't tell me this town ain't got no heart." Too bright. I like the jazziness of Weather Report Suite. Dreamy and soft. How about The Other One? "Spanish lady come to me.."</description> <source url="http://scriptingnews.userland.com/xml/scriptingNews2.xml">Scripting News</source> </item> <item> <description><a href="http://www.scripting.com/mp3s/youWinAgain.mp3">The news is out</a>, all over town..<p> You've been seen, out runnin round. <p> The lyrics are <a href="http://www.cs.cmu.edu/~mleone/gdead/dead-lyrics/You_Win_Again.txt">here</a>, short and sweet. <p> <i>You win again!</i> </description> <enclosure url="http://www.scripting.com/mp3s/youWinAgain.mp3" length="3874816" type="audio/mpeg"/> </item> <item> <description><a href="http://www.getlyrics.com/lyrics/grateful-dead/wake-of-the-flood/07.htm">Weather Report Suite</a>: "Winter rain, now tell me why, summers fade, and roses die? The answer came. The wind and rain. Golden hills, now veiled in grey, summer leaves have blown away. Now what remains? The wind and rain."</description> <enclosure url="http://www.scripting.com/mp3s/weatherReportSuite.mp3" length="12216320" type="audio/mpeg"/> </item> <item> <description><a href="http://arts.ucsc.edu/gdead/agdl/darkstar.html">Dark Star</a> crashes, pouring its light into ashes.</description> <enclosure url="http://www.scripting.com/mp3s/darkStar.mp3" length="10889216" type="audio/mpeg"/> </item> <item> <description>DaveNet: <a href="http://davenet.userland.com/2001/01/21/theUsBlues">The U.S. Blues</a>.</description> </item> <item> <description>Still listening to the US Blues. <i>"Wave that flag, wave it wide and high.."</i> Mistake made in the 60s. We gave our country to the assholes. Ah ah. Let's take it back. Hey I'm still a hippie. <i>"You could call this song The United States Blues."</i></description> </item> <item> <description><a href="http://www.sixties.com/html/garcia_stack_0.html"><img src="http://www.scripting.com/images/captainTripsSmall.gif" height="51" width="42" border="0" hspace="10" vspace="10" align="right"></a>In celebration of today's inauguration, after hearing all those great patriotic songs, America the Beautiful, even The Star Spangled Banner made my eyes mist up. It made my choice of Grateful Dead song of the night realllly easy. Here are the <a href="http://searchlyrics2.homestead.com/gd_usblues.html">lyrics</a>. Click on the audio icon to the left to give it a listen. "Red and white, blue suede shoes, I'm Uncle Sam, how do you do?" It's a different kind of patriotic music, but man I love my country and I love Jerry and the band. <i>I truly do!</i></description> <enclosure url="http://www.scripting.com/mp3s/usBlues.mp3" length="5272510" type="audio/mpeg"/> </item> <item> <description>Grateful Dead: "Tennessee, Tennessee, ain't no place I'd rather be."</description> <enclosure url="http://www.scripting.com/mp3s/tennesseeJed.mp3" length="3442648" type="audio/mpeg"/> </item> <item> <description>Ed Cone: "Had a nice Deadhead experience with my wife, who never was one but gets the vibe and knows and likes a lot of the music. Somehow she made it to the age of 40 without ever hearing Wharf Rat. We drove to Jersey and back over Christmas with the live album commonly known as Skull and Roses in the CD player much of the way, and it was cool to see her discover one the band's finest moments. That song is unique and underappreciated. Fun to hear that disc again after a few years off -- you get Jerry as blues-guitar hero on Big Railroad Blues and a nice version of Bertha."</description> <enclosure url="http://www.scripting.com/mp3s/darkStarWharfRat.mp3" length="27503386" type="audio/mpeg"/> </item> <item> <description><a href="http://arts.ucsc.edu/GDead/AGDL/fotd.html">Tonight's Song</a>: "If I get home before daylight I just might get some sleep tonight." </description> <enclosure url="http://www.scripting.com/mp3s/friendOfTheDevil.mp3" length="3219742" type="audio/mpeg"/> </item> <item> <description><a href="http://arts.ucsc.edu/GDead/AGDL/uncle.html">Tonight's song</a>: "Come hear Uncle John's Band by the river side. Got some things to talk about here beside the rising tide."</description> <enclosure url="http://www.scripting.com/mp3s/uncleJohnsBand.mp3" length="4587102" type="audio/mpeg"/> </item> <item> <description><a href="http://www.cs.cmu.edu/~mleone/gdead/dead-lyrics/Me_and_My_Uncle.txt">Me and My Uncle</a>: "I loved my uncle, God rest his soul, taught me good, Lord, taught me all I know. Taught me so well, I grabbed that gold and I left his dead ass there by the side of the road." </description> <enclosure url="http://www.scripting.com/mp3s/meAndMyUncle.mp3" length="2949248" type="audio/mpeg"/> </item> <item> <description>Truckin, like the doo-dah man, once told me gotta play your hand. Sometimes the cards ain't worth a dime, if you don't lay em down.</description> <enclosure url="http://www.scripting.com/mp3s/truckin.mp3" length="4847908" type="audio/mpeg"/> </item> <item> <description>Two-Way-Web: <a href="http://www.thetwowayweb.com/payloadsForRss">Payloads for RSS</a>. "When I started talking with Adam late last year, he wanted me to think about high quality video on the Internet, and I totally didn't want to hear about it."</description> </item> <item> <description>A touch of gray, kinda suits you anyway..</description> <enclosure url="http://www.scripting.com/mp3s/touchOfGrey.mp3" length="5588242" type="audio/mpeg"/> </item> <item> <description><a href="http://www.sixties.com/html/garcia_stack_0.html"><img src="http://www.scripting.com/images/captainTripsSmall.gif" height="51" width="42" border="0" hspace="10" vspace="10" align="right"></a>In celebration of today's inauguration, after hearing all those great patriotic songs, America the Beautiful, even The Star Spangled Banner made my eyes mist up. It made my choice of Grateful Dead song of the night realllly easy. Here are the <a href="http://searchlyrics2.homestead.com/gd_usblues.html">lyrics</a>. Click on the audio icon to the left to give it a listen. "Red and white, blue suede shoes, I'm Uncle Sam, how do you do?" It's a different kind of patriotic music, but man I love my country and I love Jerry and the band. <i>I truly do!</i></description> <enclosure url="http://www.scripting.com/mp3s/usBlues.mp3" length="5272510" type="audio/mpeg"/> </item> </channel> </rss> http://cvs.php.net/co.php/pear/XML_Feed_Parser/tests/rss091Values.php?r=1.1&p=1 Index: pear/XML_Feed_Parser/tests/rss091Values.php +++ pear/XML_Feed_Parser/tests/rss091Values.php <?php require_once '../Parser.php'; require_once 'PHPUnit.php'; class XML_Feed_Parser_RSS091_valueValidity_TestCase extends PHPUnit_TestCase { function __construct($name) { $this->PHPUnit_TestCase($name); $this->file = file_get_contents("../samples/rss091-complete.xml"); $this->feed = new XML_Feed_Parser($this->file); $this->entry = $this->feed->getEntryByOffset(0); } function test_feedRights() { $value = "Copyright 1997-1999 UserLand Software, Inc."; $this->assertEquals($value, $this->feed->rights); $this->assertEquals($value, $this->feed->copyright); } function test_feedNumberItems() { $value = 1; $this->assertEquals($value, $this->feed->numberEntries); } function test_feedTitle() { $value = "Scripting News"; $this->assertEquals($value, $this->feed->title); } function test_feedLink() { $value = "http://www.scripting.com/"; $this->assertEquals($value, $this->feed->link); } function test_feedImage() { $value = array( "title" => "Scripting News", "link" => "http://www.scripting.com/", "url" => "http://www.scripting.com/gifs/tinyScriptingNews.gif", "description" => "What is this used for?", 'height' => "40", 'width' => "78"); $this->assertEquals($value, $this->feed->image); } function test_feedDescription() { $value = "News and commentary from the cross-platform scripting community."; $this->assertEquals($value, $this->feed->description); } function test_feedSubtitleEquivalence() { $value = "News and commentary from the cross-platform scripting community."; $this->assertEquals($value, $this->feed->subtitle); } function test_feedDate() { $value = strtotime("Thu, 08 Jul 1999 07:00:00 GMT"); $this->assertEquals($value, $this->feed->date); } function test_feedLastBuildDate() { $value = strtotime("Thu, 08 Jul 1999 16:20:26 GMT"); $this->assertEquals($value, $this->feed->lastBuildDate); } function test_feedUpdatedEquivalence() { $value = strtotime("Thu, 08 Jul 1999 16:20:26 GMT"); $this->assertEquals($value, $this->feed->updated); } function test_feedLanguage() { $value = "en-us"; $this->assertEquals($value, $this->feed->language); } function test_feedSkipHours() { $value = array("6", "7", "8", "9", "10", "11"); $this->assertEquals($value, $this->feed->skipHours); } function test_feedSkipDays() { $value = array("Sunday"); $this->assertEquals($value, $this->feed->skipDays); } function test_feedDocs() { $value = "http://my.userland.com/stories/storyReader$11"; $this->assertEquals($value, $this->feed->docs); } function test_feedManagingEditor() { $value = "dave@userland.com (Dave Winer)"; $this->assertEquals($value, $this->feed->managingEditor); } function test_feedAuthorEquivalence() { $value = "dave@userland.com (Dave Winer)"; $this->assertEquals($value, $this->feed->author); } function test_feedWebmaster() { $value = "dave@userland.com (Dave Winer)"; $this->assertEquals($value, $this->feed->webMaster); } function test_entryTitle() { $value = "stuff"; $this->assertEquals($value, $this->entry->title); } function test_entryLink() { $value = "http://bar"; $this->assertEquals($value, $this->entry->link); } function test_entryDescription() { $value = "This is an article about some stuff"; $this->assertEquals($value, $this->entry->description); } } $suite = new PHPUnit_TestSuite; $suite->addTestSuite("XML_Feed_Parser_RSS091_valueValidity_TestCase"); $result = PHPUnit::run($suite, "123"); echo $result->toString(); ?>