Example #1
0
 private function createImportItem($isRead)
 {
     $item = new Item();
     $item->setGuid('guid');
     $item->setGuidHash('guid');
     $item->setUrl('https://google');
     $item->setTitle('title');
     $item->setAuthor('author');
     $item->setPubDate(123);
     $item->setBody('body');
     $item->setEnclosureMime('audio/ogg');
     $item->setEnclosureLink('enclink');
     $item->setStarred();
     $item->setRtl(true);
     if ($isRead) {
         $item->setUnread();
     } else {
         $item->setRead();
     }
     return $item;
 }
Example #2
0
    // the whole channel element
    $channelTitle = $channel->getElementsByTagName('link')->item(0)->nodeValue;
    // channel title
    $items = $feed->getElementsByTagName('item');
    // All items in this feed
    foreach ($items as $key) {
        $title = $key->getElementsByTagName('title')->item(0)->nodeValue;
        $link = $key->getElementsByTagName('link')->item(0)->nodeValue;
        $description = $key->getElementsByTagName('description')->item(0)->nodeValue;
        $pubDate = $key->getElementsByTagName('pubDate')->item(0)->nodeValue;
        $item = new Item();
        $item->setMedia($channelTitle);
        $item->setTitle($title);
        $item->setLink($link);
        $item->setDescription($description);
        $item->setPubDate($pubDate);
        $result[] = $item;
    }
}
usort($result, 'compareByDate');
function compareByDate(Item $a, Item $b)
{
    $a = strtotime($a->getPubDate());
    $b = strtotime($b->getPubDate());
    if ($a == $b) {
        return 0;
    }
    return $a < $b ? 1 : -1;
}
foreach ($result as $val) {
    echo '<div class="feedItem">';
Example #3
0
									category_id, 
									category_name 
								FROM post 
								LEFT JOIN category ON category_id = post_category_id 
								WHERE post_valid=1 
								LIMIT 10');
    while ($row = mysql_fetch_object($request)) {
        // Creating a new feed item
        $rssItem = new Item();
        $rssItem->setTitle($row->post_title);
        $rssItem->setDescription($row->post_description);
        $rssItem->setLink('http://www.mywebsite.com/blog/post.php?id=' . $row->post_id);
        $rssItem->setGuid('http://www.mywebsite.com/blog/post.php?id=' . $row->post_id, true);
        $rssItem->setComments('http://www.mywebsite.com/blog/post.php?id=' . $row->post_id . '#comments');
        $rssItem->setAuthor($row->post_author_email, $row->post_author_name);
        $rssItem->setPubDate($row->post_date);
        $rssItem->setSource($row->post_source_uri, $row->post_source_name);
        $rssItem->setEnclosure('http://www.mywebsite.com/blog/images/nopicture.jpg', 2800, 'image/jpg');
        $rssItem->setCategory('http://www.mywebsite.com/blog/category.php.idCat=' . $row->category_id, $row->category_name);
        // Add the item to the feed
        $rssFeed->appendItem($rssItem);
    }
    // Save the feed
    $rssFeed->save();
    // SQL connection closing
    mysql_close();
    // Send headers to the browser
    header('Content-Type: text/xml; charset=utf-8');
    // Display the feed
    $rssFeed->display();
} catch (RSSFeedException $e) {
Example #4
0
 public function testFromImport()
 {
     $item = new Item();
     $item->setGuid('guid');
     $item->setUrl('https://google');
     $item->setTitle('title');
     $item->setAuthor('author');
     $item->setPubDate(123);
     $item->setBody('body');
     $item->setEnclosureMime('audio/ogg');
     $item->setEnclosureLink('enclink');
     $item->setFeedId(1);
     $item->setUnread();
     $item->setStarred();
     $feed = new Feed();
     $feed->setLink('http://test');
     $feeds = array("feed1" => $feed);
     $compareWith = Item::fromImport($item->toExport($feeds));
     $item->setFeedId(null);
     $this->assertEquals($item, $compareWith);
 }