summaryrefslogtreecommitdiffstats
path: root/lib/feed.php
diff options
context:
space:
mode:
authorAlessandro Cosentino <cosenal@gmail.com>2012-05-23 13:02:27 -0400
committerAlessandro Cosentino <cosenal@gmail.com>2012-05-23 13:02:27 -0400
commit97f76e8cc62ede53709539595e835c4900f44d0c (patch)
tree90e9d84ac2fb3b04cda8561e7bc7f3b2f21d9612 /lib/feed.php
parent5940e12a707e05aa458e96126da23e8bd8c3fdca (diff)
adds method to retrieve feed with all items from db
Diffstat (limited to 'lib/feed.php')
-rw-r--r--lib/feed.php16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/feed.php b/lib/feed.php
index ce1cc956a..e095cfa99 100644
--- a/lib/feed.php
+++ b/lib/feed.php
@@ -26,22 +26,26 @@
class OC_News_Feed {
private $url;
- private $feedid; //id of the feed in the database
+ 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){
+ public function __construct($url, $id = null){
$this->url = $url;
$this->spfeed = new SimplePie_Core();
$this->spfeed->set_feed_url( $url );
$this->spfeed->enable_cache( false );
$this->fetched = false;
+ if ($id !== null){
+ self::setId($id);
+ }
}
public function fetch(){
$this->spfeed->init();
$this->spfeed->handle_content_type();
+
$this->fetched = true;
}
@@ -50,11 +54,11 @@ class OC_News_Feed {
}
public function getId(){
- return $this->feedid;
+ return $this->id;
}
public function setId($id){
- $this->feedid = $id;
+ $this->id = $id;
}
public function getUrl(){
@@ -68,6 +72,10 @@ class OC_News_Feed {
return $this->spfeed->get_title();
}
+ public function setItems($items){
+ $this->items = $items;
+ }
+
public function getItems(){
if (!isset($this->items)){
if (!$this->isFetched()) {