From 509c8cae6381ec46af7c8303eb92fda6ce496a4a Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Mon, 4 Jul 2022 09:53:26 +0200 Subject: Dynamic OPML (#4407) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Dynamic OPML draft #fix https://github.com/FreshRSS/FreshRSS/issues/4191 * Export dynamic OPML http://opml.org/spec2.opml#1629043127000 * Restart with simpler approach * Minor revert * Export dynamic OPML also for single feeds * Special category type for importing dynamic OPML * Parameter for excludeMutedFeeds * Details * More draft * i18n * Fix update * Draft manual import working * Working manual refresh * Draft automatic update * Working Web refresh + fixes * Import/export dynamic OPML settings * Annoying numerous lines in SQL logs * Fix minor JavaScript error * Fix auto adding new columns * Add require * Add missing 🗲 * Missing space * Disable adding new feeds to dynamic categories * Link from import * i18n typo * Improve theme icon function * Fix pink-dark --- app/Controllers/indexController.php | 70 +++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) (limited to 'app/Controllers/indexController.php') diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index 34770fffb..70b8824c3 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -174,6 +174,76 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController { header('Content-Type: application/rss+xml; charset=utf-8'); } + public function opmlAction() { + $allow_anonymous = FreshRSS_Context::$system_conf->allow_anonymous; + $token = FreshRSS_Context::$user_conf->token; + $token_param = Minz_Request::param('token', ''); + $token_is_ok = ($token != '' && $token === $token_param); + + // Check if user has access. + if (!FreshRSS_Auth::hasAccess() && !$allow_anonymous && !$token_is_ok) { + Minz_Error::error(403); + } + + try { + $this->updateContext(); + } catch (FreshRSS_Context_Exception $e) { + Minz_Error::error(404); + } + + $get = FreshRSS_Context::currentGet(true); + if (is_array($get)) { + $type = $get[0]; + $id = $get[1]; + } else { + $type = $get; + $id = ''; + } + + $catDAO = FreshRSS_Factory::createCategoryDao(); + $categories = $catDAO->listCategories(true, true); + $this->view->excludeMutedFeeds = true; + + switch ($type) { + case 'a': + $this->view->categories = $categories; + break; + case 'c': + $cat = $categories[$id] ?? null; + if ($cat == null) { + Minz_Error::error(404); + return; + } + $this->view->categories = [ $cat ]; + break; + case 'f': + // We most likely already have the feed object in cache + $feed = FreshRSS_CategoryDAO::findFeed($categories, $id); + if ($feed == null) { + $feedDAO = FreshRSS_Factory::createFeedDao(); + $feed = $feedDAO->searchById($id); + if ($feed == null) { + Minz_Error::error(404); + return; + } + } + $this->view->feeds = [ $feed ]; + break; + case 's': + case 't': + case 'T': + default: + Minz_Error::error(404); + return; + } + + require_once(LIB_PATH . '/lib_opml.php'); + + // No layout for OPML output. + $this->view->_layout(false); + header('Content-Type: application/xml; charset=utf-8'); + } + /** * This action updates the Context object by using request parameters. * -- cgit v1.2.3