From 5d789602126ed72f05fe644163239d65bad053f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Guillot?= Date: Thu, 15 Aug 2013 20:22:56 -0400 Subject: [PATCH] Update PicoFeed (improve feed writers and opml import) --- vendor/PicoFeed/Import.php | 1 + vendor/PicoFeed/Writers/Atom.php | 35 ++++++++++++++++++------------- vendor/PicoFeed/Writers/Rss20.php | 33 +++++++++++++++++++++-------- 3 files changed, 46 insertions(+), 23 deletions(-) diff --git a/vendor/PicoFeed/Import.php b/vendor/PicoFeed/Import.php index 4685012..f2a0ab4 100644 --- a/vendor/PicoFeed/Import.php +++ b/vendor/PicoFeed/Import.php @@ -51,6 +51,7 @@ class Import else if ((isset($item['text']) || isset($item['title'])) && isset($item['xmlUrl'])) { $entry = new \StdClass; + $entry->category = isset($tree['title']) ? (string) $tree['title'] : (string) $tree['text']; $entry->title = isset($item['title']) ? (string) $item['title'] : (string) $item['text']; $entry->feed_url = (string) $item['xmlUrl']; $entry->site_url = isset($item['htmlUrl']) ? (string) $item['htmlUrl'] : $entry->feed_url; diff --git a/vendor/PicoFeed/Writers/Atom.php b/vendor/PicoFeed/Writers/Atom.php index 5fbc4d9..8c59f5e 100644 --- a/vendor/PicoFeed/Writers/Atom.php +++ b/vendor/PicoFeed/Writers/Atom.php @@ -35,10 +35,14 @@ class Atom extends \PicoFeed\Writer $feed->appendChild($generator); // - $feed->appendChild($this->dom->createElement('title', $this->title)); + $title = $this->dom->createElement('title'); + $title->appendChild($this->dom->createTextNode($this->title)); + $feed->appendChild($title); // <id/> - $feed->appendChild($this->dom->createElement('id', $this->site_url)); + $id = $this->dom->createElement('id'); + $id->appendChild($this->dom->createTextNode($this->site_url)); + $feed->appendChild($id); // <updated/> $this->addUpdated($feed, isset($this->updated) ? $this->updated : ''); @@ -60,16 +64,14 @@ class Atom extends \PicoFeed\Writer $entry = $this->dom->createElement('entry'); // <title/> - $entry->appendChild($this->dom->createElement('title', $item['title'])); + $title = $this->dom->createElement('title'); + $title->appendChild($this->dom->createTextNode($item['title'])); + $entry->appendChild($title); // <id/> - if (isset($item['id'])) { - $entry->appendChild($this->dom->createElement('id', $item['id'])); - } - else { - $entry->appendChild($this->dom->createElement('id', $item['url'])); - } - + $id = $this->dom->createElement('id'); + $id->appendChild($this->dom->createTextNode(isset($item['id']) ? $item['id'] : $item['url'])); + $entry->appendChild($id); // <updated/> $this->addUpdated($entry, isset($item['updated']) ? $item['updated'] : ''); @@ -84,7 +86,9 @@ class Atom extends \PicoFeed\Writer // <summary/> if (isset($item['summary'])) { - $entry->appendChild($this->dom->createElement('summary', $item['summary'])); + $summary = $this->dom->createElement('summary'); + $summary->appendChild($this->dom->createTextNode($item['summary'])); + $entry->appendChild($summary); } // <content/> @@ -136,17 +140,20 @@ class Atom extends \PicoFeed\Writer $author = $this->dom->createElement('author'); if (isset($values['name'])) { - $name = $this->dom->createElement('name', $values['name']); + $name = $this->dom->createElement('name'); + $name->appendChild($this->dom->createTextNode($values['name'])); $author->appendChild($name); } if (isset($values['email'])) { - $email = $this->dom->createElement('email', $values['email']); + $email = $this->dom->createElement('email'); + $email->appendChild($this->dom->createTextNode($values['email'])); $author->appendChild($email); } if (isset($values['url'])) { - $uri = $this->dom->createElement('uri', $values['url']); + $uri = $this->dom->createElement('uri'); + $uri->appendChild($this->dom->createTextNode($values['url'])); $author->appendChild($uri); } diff --git a/vendor/PicoFeed/Writers/Rss20.php b/vendor/PicoFeed/Writers/Rss20.php index 3a06b17..e20a552 100644 --- a/vendor/PicoFeed/Writers/Rss20.php +++ b/vendor/PicoFeed/Writers/Rss20.php @@ -38,10 +38,14 @@ class Rss20 extends \PicoFeed\Writer $channel->appendChild($generator); // <title/> - $channel->appendChild($this->dom->createElement('title', $this->title)); + $title = $this->dom->createElement('title'); + $title->appendChild($this->dom->createTextNode($this->title)); + $channel->appendChild($title); // <description/> - $channel->appendChild($this->dom->createElement('description', isset($this->description) ? $this->description : $this->title)); + $description = $this->dom->createElement('description'); + $description->appendChild($this->dom->createTextNode(isset($this->description) ? $this->description : $this->title)); + $channel->appendChild($description); // <pubDate/> $this->addPubDate($channel, isset($this->updated) ? $this->updated : ''); @@ -54,7 +58,9 @@ class Rss20 extends \PicoFeed\Writer $channel->appendChild($link); // <link/> - $channel->appendChild($this->dom->createElement('link', $this->site_url)); + $link = $this->dom->createElement('link'); + $link->appendChild($this->dom->createTextNode($this->site_url)); + $channel->appendChild($link); // <webMaster/> if (isset($this->author)) $this->addAuthor($channel, 'webMaster', $this->author); @@ -67,20 +73,26 @@ class Rss20 extends \PicoFeed\Writer $entry = $this->dom->createElement('item'); // <title/> - $entry->appendChild($this->dom->createElement('title', $item['title'])); + $title = $this->dom->createElement('title'); + $title->appendChild($this->dom->createTextNode($item['title'])); + $entry->appendChild($title); // <link/> - $entry->appendChild($this->dom->createElement('link', $item['url'])); + $link = $this->dom->createElement('link'); + $link->appendChild($this->dom->createTextNode($item['url'])); + $entry->appendChild($link); // <guid/> if (isset($item['id'])) { - $guid = $this->dom->createElement('guid', $item['id']); + $guid = $this->dom->createElement('guid'); $guid->setAttribute('isPermaLink', 'false'); + $guid->appendChild($this->dom->createTextNode($item['id'])); $entry->appendChild($guid); } else { - $guid = $this->dom->createElement('guid', $item['url']); + $guid = $this->dom->createElement('guid'); $guid->setAttribute('isPermaLink', 'true'); + $guid->appendChild($this->dom->createTextNode($item['url'])); $entry->appendChild($guid); } @@ -89,7 +101,9 @@ class Rss20 extends \PicoFeed\Writer // <description/> if (isset($item['summary'])) { - $entry->appendChild($this->dom->createElement('description', $item['summary'])); + $description = $this->dom->createElement('description'); + $description->appendChild($this->dom->createTextNode($item['summary'])); + $entry->appendChild($description); } // <content/> @@ -134,7 +148,8 @@ class Rss20 extends \PicoFeed\Writer if ($value && isset($values['name'])) $value .= ' ('.$values['name'].')'; if ($value) { - $author = $this->dom->createElement($tag, $value); + $author = $this->dom->createElement($tag); + $author->appendChild($this->dom->createTextNode($value)); $xml->appendChild($author); } }