private static function updateFeed($feedmapper, $feed) { $newfeed = null; $newfeed = Utils::fetch($feed['url']); if ($newfeed !== null) { $feedmapper = new FeedMapper(); $newfeedid = $feedmapper->save($newfeed, $feed['folderid']); } }
/** * @brief Retrieve all the item corresponding to a feed from the database * @param feedid The id of the feed in the database table. */ public function findByFeedId($feedid) { $stmt = \OCP\DB::prepare('SELECT * FROM ' . self::tableName . ' WHERE feed_id = ? ORDER BY pub_date DESC'); $result = $stmt->execute(array($feedid)); $feedmapper = new FeedMapper($this->userid); $feed = $feedmapper->findById($feedid); $items = array(); while ($row = $result->fetchRow()) { $item = $this->fromRow($row); $item->setFeedTitle($feed->getTitle()); $items[] = $item; } return $items; }
static function instance() { if (!isset(self::$instance)) { self::$instance = new self(); } return self::$instance; }
/** * @brief Delete the folder and all its feeds from the database * @param folder the folder to be deleted (an instance of OCA\News\Folder) * @returns true if the folder has been deleted, false if an error occurred */ public function deleteById($folderid) { if ($folderid == null) { return false; } // delete child folders $stmt = \OCP\DB::prepare('SELECT id FROM ' . self::tableName . ' WHERE parent_id = ? AND user_id = ?'); $result = $stmt->execute(array($folderid, $this->userid)); while ($row = $result->fetchRow()) { if (!self::deleteById($row['id'])) { return false; } } $stmt = \OCP\DB::prepare('DELETE FROM ' . self::tableName . ' WHERE id = ? AND user_id = ?'); $result = $stmt->execute(array($folderid, $this->userid)); $feedMapper = new FeedMapper($this->userid); //TODO: handle the value that the execute returns if (!$feedMapper->deleteAll($folderid)) { return false; } return true; }
<?php include 'header.php'; $feed = FeedMapper::instance()->find($_GET['id']); $item_helper = new ItemHelper(); ?> <table> <th>id</th><th>title</th> <?php foreach ($feed->items() as $item) { ?> <tr> <td><?php echo $item->id(); ?> </td> <td><?php echo $item_helper->link($item); ?> </td> </tr> <?php } ?>
function feed() { return FeedMapper::instance()->find($this->feed_id()); }
function mapper() { return FeedMapper::instance(); }
<?php include 'header.php'; $feeds = FeedMapper::instance()->find_all(); $feed_helper = new FeedHelper(); ?> <table> <tr><th>id</th><th>title</th><th>feed url</th><th>time to live</th> <tr> <?php foreach ($feeds as $feed) { ?> <tr> <td><?php echo $feed->id(); ?> </td> <td><?php echo $feed_helper->link($feed); ?> </td> <td><?php echo $feed->feed_url(); ?> </td> <td><?php echo $feed->time_to_live();