/** * Returns the currently available feed items. * Does not modify the database in any way. * * @return Item[] The feed items */ public function queryItems() { $parser = Parsers\ParserLoader::getParser($this->url); return $parser->parseItems(); }
} else { $app->render('error.php', array('errorMessage' => 'An unexpected error occured.'), 500); } }); // Main endpoint for the feed readers $app->get('/feeds/:id', function ($id) use($app) { $feed = FeedQuery::create()->findPk($id); if ($feed == null) { throw new PageNotFoundException(); } $items = ItemQuery::create()->filterByFeed($feed)->orderByPublishedDate(\Propel\Runtime\ActiveQuery\Criteria::DESC)->limit(20)->find(); $app->render('atom.php', array('feed' => $feed, 'items' => $items)); })->name('feed'); $app->post('/feeds', function () use($app) { $rootUrl = $app->urlFor('root') . '?apikey=' . $GLOBALS['config']['apikey']; $url = $app->request->post('url'); print 'Submitted url ' . $url; if (empty($url)) { return; } $parser = \Level14\Website2Feed\Model\Parsers\ParserLoader::getParser($url); $feed = $parser->parseMetadata(); $feed->save(); $app->redirect($rootUrl); })->name('newfeed'); // Main endpoint for users, list feeds $app->get('/', function () use($app) { $feeds = FeedQuery::create()->find(); $app->render('listFeeds.php', array('feeds' => $feeds)); })->name('root'); $app->run();