diff options
-rw-r--r-- | lib/item.php | 17 | ||||
-rw-r--r-- | templates/main.php | 10 |
2 files changed, 14 insertions, 13 deletions
diff --git a/lib/item.php b/lib/item.php index 6a18ded1c..528dd5487 100644 --- a/lib/item.php +++ b/lib/item.php @@ -22,25 +22,24 @@ class StatusFlag{ - const Unread = 0x02; + const Unread = 0x02; const Important = 0x04; - const Deleted = 0x08; - const Updated = 0x16; + const Deleted = 0x08; + const Updated = 0x16; } /* -* This class models an item +* This class models an item. * -* It wraps a SimplePie item and adds a status flag to it +* It extends the SimplePie_Item class by adding a status flag to it */ -class OC_News_Item{ +class OC_News_Item extends SimplePie_Item { - private $spitem; //the SimplePie item private $status; //a bit-field set with status flags - public function __construct($spitem){ - $this->spitem = $spitem; + public function __construct($feed, $data){ $this->status |= StatusFlag::Unread; + parent::__construct($feed, $data); } public function setRead(){ diff --git a/templates/main.php b/templates/main.php index 986b46748..499483875 100644 --- a/templates/main.php +++ b/templates/main.php @@ -1,12 +1,13 @@ <?php -$feed = new SimplePie_Core(); +$feed = new SimplePie_Core(); +$feed->set_item_class('OC_News_Item'); $feed->set_feed_url( 'http://algorithmsforthekitchen.com/blog/?feed=rss2' ); $feed->enable_cache( false ); $feed->init(); $feed->handle_content_type(); -$item = new OC_News_Item($feed->get_item(1)); +$item = $feed->get_item(1); if ($item->isRead()) echo $l->t('Read'); @@ -17,10 +18,11 @@ $item->setRead(); $item->setUnread(); $item->setRead(); -echo "<br>"; +echo "<br>" . $item->get_title() . "<br>"; -if ($item->isRead()) +if ($item->isRead()) { echo $l->t('Read'); +} else echo $l->t('Unread'); |