diff --git a/FeedExpander.md b/FeedExpander.md index 4fc1a2e..a675f89 100644 --- a/FeedExpander.md +++ b/FeedExpander.md @@ -4,29 +4,28 @@ To create a new Bridge extending `FeedExpander` you must implement all required functions of [`BridgeAbstract`](BridgeAbstract). `FeedExpander` additionally provides following functions: -* [`parseItem`](#the-parseItem-function) (**required**) +* [`parseItem`](#the-parseItem-function) * [`getName`](#the-getName-function) * [`getURI`](#the-getURI-function) * [`getDescription`](#the-getDescription-function) Find a [template](#template) at the end of this file. -**Notice:** For a standard feed only `collectData` and [`parseItem`](#the-parseItem-function) need to be implemented. `collectData` should call `$this->collectExpandableDatas('your URI here');` to automatically load feed items and header data (will subsequently call `parseItem` for each item in the feed). You can limit the number of items to fetch by specifying an additional parameter for: `$this->collectExpandableDatas('your URI here', 10)` (limited to 10 items). +**Notice:** For a standard feed only `collectData` need to be implemented. `collectData` should call `$this->collectExpandableDatas('your URI here');` to automatically load feed items and header data (will subsequently call `parseItem` for each item in the feed). You can limit the number of items to fetch by specifying an additional parameter for: `$this->collectExpandableDatas('your URI here', 10)` (limited to 10 items). ## The `parseItem` function This function receives one item from the current feed and should return one **RSS-Bridge** item. +The default function does all the work to get the item data from the feed, whether it is RSS 1.0, +RSS 2.0 or ATOM 1.0. If you have to redefine this function in your **RSS-Bridge** for whatever reason, +you should call the parent function to initialize the item, then apply the changes that you require. **Notice:** The following code sample is just an example. Implementation depends on your requirements! ```PHP protected function parseItem($feedItem){ - $item = array(); - $item['title'] = $feedItem->title; - $item['uri'] = $feedItem->link; - $item['author'] = $feedItem->autor; - $item['timestamp'] = $this->RSS_2_0_time_to_timestamp($feedItem); - $item['content'] = $feedItem->content; + $item = parent::parseItem($feedItem); + $item['content'] = str_replace('rssbridge','RSS-Bridge',$feedItem->content); return $item; } @@ -50,7 +49,7 @@ Function | uri | title | timestamp | author | content `parseATOMItem` | id | title | updated | author | content `parseRSS_0_9_1_Item` | link | title | | | description `parseRSS_1_0_Item` | link | title | dc:date | dc:creator | description -`parseRSS_2_0_Item` | link | title | pubDate, dc:date | author, dc:creator | description +`parseRSS_2_0_Item` | link, guid | title | pubDate, dc:date | author, dc:creator | description ## The `getName` function @@ -99,10 +98,6 @@ class MySiteBridge extends FeedExpander { public function collectData(){ $this->collectExpandableDatas('your feed URI'); } - - protected function parseItem($feedItem){ - return $this->parseRSS_2_0_Item($feedItem); - } } // Imaginary empty line! ``` \ No newline at end of file