diff options
author | Alessandro Cosentino <cosenal@gmail.com> | 2012-07-02 23:39:19 -0400 |
---|---|---|
committer | Alessandro Cosentino <cosenal@gmail.com> | 2012-07-02 23:39:19 -0400 |
commit | 72c730bf5fb21f58589a836483585dabd6866520 (patch) | |
tree | a57dab8dcf88ce5a4f1172ba89663aa52947fdb8 /lib | |
parent | f8f6fd3d778fe95bac15e52747ff5b1f6461c136 (diff) |
button to add feed; selection of a feed
Diffstat (limited to 'lib')
-rw-r--r-- | lib/feed.php | 4 | ||||
-rw-r--r-- | lib/feedmapper.php | 22 | ||||
-rw-r--r-- | lib/foldermapper.php | 8 | ||||
-rw-r--r-- | lib/utils.php | 5 |
4 files changed, 35 insertions, 4 deletions
diff --git a/lib/feed.php b/lib/feed.php index 281a968f0..bbed8d598 100644 --- a/lib/feed.php +++ b/lib/feed.php @@ -24,10 +24,10 @@ class OC_News_Feed extends OC_News_Collection { $this->title = $title; $this->items = $items; if ($id !== null){ - $this->id = $id; + parent::__construct($id); } } - + public function getUrl(){ return $this->url; } diff --git a/lib/feedmapper.php b/lib/feedmapper.php index e64316d0c..1073bd288 100644 --- a/lib/feedmapper.php +++ b/lib/feedmapper.php @@ -16,7 +16,7 @@ class OC_News_FeedMapper { const tableName = '*PREFIX*news_feeds'; - + /** * @brief Retrieve a feed from the database * @param id The id of the feed in the database table. @@ -33,6 +33,26 @@ class OC_News_FeedMapper { } /** + * @brief Retrieve a feed from the database + * @param id The id of the feed in the database table. + * @returns + */ + public function findByFolderId($folderid){ + $stmt = OCP\DB::prepare('SELECT * FROM ' . self::tableName . ' WHERE folder_id = ?'); + $result = $stmt->execute(array($folderid)); + $feeds = array(); + while ($row = $result->fetchRow()) { + $url = $row['url']; + $title = $row['title']; + $id = $row['id']; + $feed = new OC_News_Feed($url, $title, null, $id); + $feeds[] = $feed; + } + return $feeds; + } + + + /** * @brief Retrieve a feed and all its items from the database * @param id The id of the feed in the database table. * @returns diff --git a/lib/foldermapper.php b/lib/foldermapper.php index 925726ab8..5a37fe20a 100644 --- a/lib/foldermapper.php +++ b/lib/foldermapper.php @@ -34,7 +34,13 @@ class OC_News_FolderMapper { $child = new OC_News_Folder($row['name'], $row['id']); $root->addChild($child); } - + + $feedmapper = new OC_News_FeedMapper(); + $feeds = $feedmapper->findByFolderId(0); + foreach ($feeds as $feed){ + $root->addChild($feed); + } + return $root; } diff --git a/lib/utils.php b/lib/utils.php index e7122bf69..16f39f413 100644 --- a/lib/utils.php +++ b/lib/utils.php @@ -10,6 +10,10 @@ * */ +// load SimplePie library +//TODO: is this file a suitable place for the following require? +require_once(OC::$APPSROOT . '/apps/news/3rdparty/SimplePie/SimplePieAutoloader.php'); + class OC_News_Utils { /** @@ -18,6 +22,7 @@ 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 ); |