From 4d612fa6f06d9d1c1e68806aef607a36a04f4f38 Mon Sep 17 00:00:00 2001 From: Alessandro Cosentino Date: Thu, 17 May 2012 22:59:49 -0400 Subject: new classes for the data mapping --- lib/feed.php | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'lib/feed.php') diff --git a/lib/feed.php b/lib/feed.php index bd2e3b1e4..215ac7c1f 100644 --- a/lib/feed.php +++ b/lib/feed.php @@ -26,18 +26,35 @@ class OC_News_Feed { private $url; - private $spfeed; //we encapsulate a SimplePie_Core object + private $feedid; //id of the feed in the database + private $spfeed; //encapsulate a SimplePie_Core object + private $items; //array that contains all the items of the feed + private $fetched; public function __construct($url){ $this->url = $url; $this->spfeed = new SimplePie_Core(); - $this->spfeed->set_item_class('OC_News_Item'); $this->spfeed->set_feed_url( $url ); $this->spfeed->enable_cache( false ); + $this->fetched = false; + } - //FIXME: figure out if constructor is the right place for these + public function fetch(){ $this->spfeed->init(); $this->spfeed->handle_content_type(); + $this->fetched = true; + } + + public function isFetched(){ + return $this->fetched; + } + + public function getId(){ + return $this->feedid; + } + + public function setId($id){ + $this->feedid = $id; } public function getUrl(){ @@ -45,6 +62,13 @@ class OC_News_Feed { } public function getTitle(){ + if (!$this->isFetched()) { + $this->fetch(); + } return $this->spfeed->get_title(); } + + public function getItems(){ + return $this->items; + } } -- cgit v1.2.3