diff options
author | Alessandro Cosentino <cosenal@gmail.com> | 2012-07-30 14:08:36 -0400 |
---|---|---|
committer | Alessandro Cosentino <cosenal@gmail.com> | 2012-07-30 14:08:36 -0400 |
commit | fd5b815e587ccc3642995346cd03eca4e0a0707f (patch) | |
tree | 2cc9bdf3de5e45b8f23e96673f4d8625651f81df /lib | |
parent | a5438863a4e88fb5c9e166e8810f493a1feb2cf0 (diff) |
opml parser completed; still needs testing
Diffstat (limited to 'lib')
-rw-r--r-- | lib/feed.php | 20 | ||||
-rw-r--r-- | lib/folder.php | 6 | ||||
-rw-r--r-- | lib/importopml.php | 0 | ||||
-rw-r--r-- | lib/utils.php | 12 |
4 files changed, 26 insertions, 12 deletions
diff --git a/lib/feed.php b/lib/feed.php index 59db6f7cc..6b1409440 100644 --- a/lib/feed.php +++ b/lib/feed.php @@ -20,36 +20,40 @@ class OC_News_Feed extends OC_News_Collection { private $items; //array that contains all the items of the feed private $favicon; - public function __construct($url, $title, $items, $id = null){ + public function __construct($url, $title, $items, $id = null) { $this->url = $url; $this->title = $title; $this->items = $items; - if ($id !== null){ + if ($id !== null) { parent::__construct($id); } } - public function getUrl(){ + public function getUrl() { return $this->url; } - public function getTitle(){ + public function getTitle() { return $this->title; } + + public function setTitle($title) { + $this->title = $title; + } - public function getFavicon(){ + public function getFavicon() { return $this->favicon; } - public function setFavicon($favicon){ + public function setFavicon($favicon) { $this->favicon = $favicon; } - public function setItems($items){ + public function setItems($items) { $this->items = $items; } - public function getItems(){ + public function getItems() { return $this->items; } diff --git a/lib/folder.php b/lib/folder.php index 6654b2f5e..14951d57c 100644 --- a/lib/folder.php +++ b/lib/folder.php @@ -48,7 +48,11 @@ class OC_News_Folder extends OC_News_Collection { public function addChild(OC_News_Collection $child){ $this->children[] = $child; } - + + public function addChildren($children){ + $this->children = $children; + } + public function getChildren(){ return $this->children; } diff --git a/lib/importopml.php b/lib/importopml.php deleted file mode 100644 index e69de29bb..000000000 --- a/lib/importopml.php +++ /dev/null diff --git a/lib/utils.php b/lib/utils.php index 6735c3f60..12a9506ec 100644 --- a/lib/utils.php +++ b/lib/utils.php @@ -22,12 +22,17 @@ class OC_News_Utils { * @returns */ public static function fetch($url){ - //TODO: handle the case where fetching of the feed fails $spfeed = new SimplePie_Core(); $spfeed->set_feed_url( $url ); $spfeed->enable_cache( false ); - $spfeed->init(); - $spfeed->handle_content_type(); + + if (!$spfeed->init()) { + return null; + } + + if (!$spfeed->handle_content_type()) { + return null; + } $title = $spfeed->get_title(); $spitems = $spfeed->get_items(); @@ -53,6 +58,7 @@ class OC_News_Utils { $feed->setFavicon($webFavicon); } return $feed; + } public static function checkFavicon($favicon) { |