From 51298cd6bc100b1cc6508abb602a59c01a9e2c04 Mon Sep 17 00:00:00 2001 From: Stefan <11146296+tryallthethings@users.noreply.github.com> Date: Sun, 22 Jun 2025 00:36:32 +0200 Subject: Exposed the reading modes for extensions through Minz (#7668) * + Exposed the reading modes for extensions through Minz. Now extensions can add a custom view mode. Graceful fallback to normal view in case the extension was disabled without resetting the view_mode through the uninstall method. In that case the user will be informed via Minz_Request::setBadNotification that the view has been reset to normal. + Added translation strings for de, en and en-us for the notification * + Added missing, generated translations * Simplify indexAction, performance * Minor settings htmlspecialchars * i18n: fr * Minor wording * Doc * Fix i18n --------- Co-authored-by: Alexandre Alapetite --- app/Controllers/configureController.php | 1 + app/Controllers/indexController.php | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php index 4f448c5e0..59845d710 100644 --- a/app/Controllers/configureController.php +++ b/app/Controllers/configureController.php @@ -160,6 +160,7 @@ class FreshRSS_configure_Controller extends FreshRSS_ActionController { Minz_Request::good(_t('feedback.conf.updated'), [ 'c' => 'configure', 'a' => 'reading' ]); } + $this->view->viewModes = FreshRSS_ViewMode::getAllModes(); FreshRSS_View::prependTitle(_t('conf.reading.title') . ' ยท '); } diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index 661e8300b..d5d9db778 100644 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -16,9 +16,17 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController { */ public function indexAction(): void { $preferred_output = FreshRSS_Context::userConf()->view_mode; + $viewMode = FreshRSS_ViewMode::getAllModes()[$preferred_output] ?? null; + + // Fallback to 'normal' if the preferred mode was not found + if ($viewMode === null) { + Minz_Request::setBadNotification(_t('feedback.extensions.invalid_view_mode', $preferred_output)); + $viewMode = FreshRSS_ViewMode::getAllModes()['normal']; + } + Minz_Request::forward([ - 'c' => 'index', - 'a' => $preferred_output, + 'c' => $viewMode->controller(), + 'a' => $viewMode->action(), ]); } -- cgit v1.2.3