/** * @brief serve opds feed for given directory * * @param string $dir full path to directory * @param int $id requested id */ public static function serveFeed($dir, $id) { if (isset($_SERVER['HTTP_ACCEPT']) && stristr($_SERVER['HTTP_ACCEPT'], 'application/atom+xml')) { header('Content-Type: application/atom+xml'); } else { header('Content-Type: text/xml; charset=UTF-8'); } $sortAttribute = 'name'; $sortDirection = false; $defaults = new \OC_Defaults(); $tmpl = new \OCP\Template('files_opds', 'feed'); $tmpl->assign('files', Files::formatFileInfos(Files::getFiles($dir, $sortAttribute, $sortDirection))); $tmpl->assign('bookshelf', Files::formatFileInfos(Bookshelf::get())); $tmpl->assign('bookshelf-count', Bookshelf::count()); $tmpl->assign('feed_id', self::getFeedId()); $tmpl->assign('id', $id); $tmpl->assign('dir', $dir); $tmpl->assign('user', \OCP\User::getDisplayName()); $tmpl->assign('feed_title', Config::get('feed_title', \OCP\User::getDisplayName() . "'s Library")); $tmpl->assign('feed_subtitle', Config::getApp('feed_subtitle', $defaults->getName() . " OPDS catalog")); $tmpl->assign('feed_updated', time()); $tmpl->printPage(); }