summaryrefslogtreecommitdiffstats
path: root/lib/feed.php
diff options
context:
space:
mode:
authorAlessandro Cosentino <cosenal@gmail.com>2012-05-23 15:14:10 -0400
committerAlessandro Cosentino <cosenal@gmail.com>2012-05-23 15:14:10 -0400
commitd8a193119f442c92bd47f150d149a5d1caf44a7e (patch)
tree4929cd74ec0489d8d8475fffca8620899a03ef84 /lib/feed.php
parent97f76e8cc62ede53709539595e835c4900f44d0c (diff)
separates fetching/importing from the modelling classes
Diffstat (limited to 'lib/feed.php')
-rw-r--r--lib/feed.php37
1 files changed, 5 insertions, 32 deletions
diff --git a/lib/feed.php b/lib/feed.php
index e095cfa99..311068463 100644
--- a/lib/feed.php
+++ b/lib/feed.php
@@ -29,29 +29,15 @@ class OC_News_Feed {
private $id; //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, $id = null){
+ public function __construct($url, $title, $items, $id = null){
$this->url = $url;
- $this->spfeed = new SimplePie_Core();
- $this->spfeed->set_feed_url( $url );
- $this->spfeed->enable_cache( false );
- $this->fetched = false;
+ $this->title = $title;
+ $this->items = $items;
if ($id !== null){
- self::setId($id);
+ $this->id = $id;
}
}
-
- 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->id;
@@ -66,10 +52,7 @@ class OC_News_Feed {
}
public function getTitle(){
- if (!$this->isFetched()) {
- $this->fetch();
- }
- return $this->spfeed->get_title();
+ return $this->title;
}
public function setItems($items){
@@ -77,16 +60,6 @@ class OC_News_Feed {
}
public function getItems(){
- if (!isset($this->items)){
- if (!$this->isFetched()) {
- $this->fetch();
- }
- $spitems = $this->spfeed->get_items();
- $this->items = array();
- foreach($spitems as $spitem) { //FIXME: maybe we can avoid this loop
- $this->items[] = new OC_News_Item($spitem);
- }
- }
return $this->items;
}
}