From 1d94e2866afc6e5fd829f04209a7752364c1ce75 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Tue, 12 Jul 2022 19:48:36 -0400 Subject: [PATCH] Enable the view module in maintenance mode - This allows to load the default theme CSS - Theme scripts have been updated to reflect the possibility they will be included in maintenance mode --- src/App.php | 3 +- view/theme/duepuntozero/style.php | 13 +++-- view/theme/duepuntozero/theme.php | 47 +++++++++------- view/theme/frio/style.php | 89 +++++++++++++++++++------------ view/theme/frio/theme.php | 86 +++++++++++++++-------------- view/theme/quattro/style.php | 49 ++++++----------- view/theme/quattro/theme.php | 4 ++ view/theme/smoothly/theme.php | 4 ++ view/theme/vier/style.php | 16 +++--- view/theme/vier/theme.php | 11 +++- 10 files changed, 179 insertions(+), 143 deletions(-) diff --git a/src/App.php b/src/App.php index 400ea15b19..f59b15d1db 100644 --- a/src/App.php +++ b/src/App.php @@ -705,7 +705,8 @@ class App // Initialize module that can set the current theme in the init() method, either directly or via App->setProfileOwner $page['page_title'] = $moduleName; - if (!$this->mode->isInstall() && !$this->mode->has(App\Mode::MAINTENANCEDISABLED)) { + // The "view" module is required to show the theme CSS + if (!$this->mode->isInstall() && !$this->mode->has(App\Mode::MAINTENANCEDISABLED) && $moduleName !== 'view') { $module = $router->getModule(Maintenance::class); } else { // determine the module class and save it to the module instance diff --git a/view/theme/duepuntozero/style.php b/view/theme/duepuntozero/style.php index a56a012825..575f0dff58 100644 --- a/view/theme/duepuntozero/style.php +++ b/view/theme/duepuntozero/style.php @@ -25,13 +25,12 @@ if (file_exists("$THEMEPATH/style.css")) { echo file_get_contents("$THEMEPATH/style.css"); } -$uid = $_REQUEST['puid'] ?? 0; - -$s_colorset = DI::config()->get('duepuntozero', 'colorset'); -$colorset = DI::pConfig()->get($uid, 'duepuntozero', 'colorset'); - -if (empty($colorset)) { - $colorset = $s_colorset; +/* + * This script can be included when the maintenance mode is on, which requires us to avoid any config call + */ +if (DI::mode()->has(\Friendica\App\Mode::MAINTENANCEDISABLED)) { + $s_colorset = DI::config()->get('duepuntozero', 'colorset'); + $colorset = DI::pConfig()->get($_REQUEST['puid'] ?? 0, 'duepuntozero', 'colorset', $s_colorset); } $setcss = ''; diff --git a/view/theme/duepuntozero/theme.php b/view/theme/duepuntozero/theme.php index cc77e781bf..327a1e73ba 100644 --- a/view/theme/duepuntozero/theme.php +++ b/view/theme/duepuntozero/theme.php @@ -23,27 +23,36 @@ use Friendica\App; use Friendica\Core\Renderer; use Friendica\DI; +/* + * This script can be included even when the app is in maintenance mode which requires us to avoid any config call + */ + function duepuntozero_init(App $a) { -Renderer::setActiveTemplateEngine('smarty3'); - - $colorset = DI::pConfig()->get( local_user(), 'duepuntozero','colorset'); - if (!$colorset) - $colorset = DI::config()->get('duepuntozero', 'colorset'); // user setting have priority, then node settings - if ($colorset) { - if ($colorset == 'greenzero') - DI::page()['htmlhead'] .= ''."\n"; - if ($colorset == 'purplezero') - DI::page()['htmlhead'] .= ''."\n"; - if ($colorset == 'easterbunny') - DI::page()['htmlhead'] .= ''."\n"; - if ($colorset == 'darkzero') - DI::page()['htmlhead'] .= ''."\n"; - if ($colorset == 'comix') - DI::page()['htmlhead'] .= ''."\n"; - if ($colorset == 'slackr') - DI::page()['htmlhead'] .= ''."\n"; - } + Renderer::setActiveTemplateEngine('smarty3'); + + $colorset = null; + + if (DI::mode()->has(App\Mode::MAINTENANCEDISABLED)) { + $colorset = DI::pConfig()->get(local_user(), 'duepuntozero', 'colorset'); + if (!$colorset) + $colorset = DI::config()->get('duepuntozero', 'colorset'); // user setting have priority, then node settings + } + + if ($colorset) { + if ($colorset == 'greenzero') + DI::page()['htmlhead'] .= '' . "\n"; + if ($colorset == 'purplezero') + DI::page()['htmlhead'] .= '' . "\n"; + if ($colorset == 'easterbunny') + DI::page()['htmlhead'] .= '' . "\n"; + if ($colorset == 'darkzero') + DI::page()['htmlhead'] .= '' . "\n"; + if ($colorset == 'comix') + DI::page()['htmlhead'] .= '' . "\n"; + if ($colorset == 'slackr') + DI::page()['htmlhead'] .= '' . "\n"; + } DI::page()['htmlhead'] .= <<< EOT '; DI::page()['htmlhead'] .= '';; diff --git a/view/theme/smoothly/theme.php b/view/theme/smoothly/theme.php index e20e9003f9..9cc5b4a224 100644 --- a/view/theme/smoothly/theme.php +++ b/view/theme/smoothly/theme.php @@ -14,6 +14,10 @@ use Friendica\App; use Friendica\Core\Renderer; use Friendica\DI; +/* + * This script can be included even when the app is in maintenance mode which requires us to avoid any config call + */ + function smoothly_init(App $a) { Renderer::setActiveTemplateEngine('smarty3'); diff --git a/view/theme/vier/style.php b/view/theme/vier/style.php index 8e31a14bfc..ff888dac61 100644 --- a/view/theme/vier/style.php +++ b/view/theme/vier/style.php @@ -23,16 +23,16 @@ use Friendica\Core\Logger; use Friendica\DI; use Friendica\Network\HTTPException\NotModifiedException; -$uid = $_REQUEST['puid'] ?? 0; - -$style = DI::pConfig()->get($uid, 'vier', 'style'); +/* + * This script can be included when the maintenance mode is on, which requires us to avoid any config call and + * use the following hardcoded default + */ +$style = 'plus'; -if (empty($style)) { - $style = DI::config()->get('vier', 'style'); -} +if (DI::mode()->has(\Friendica\App\Mode::MAINTENANCEDISABLED)) { + $uid = $_REQUEST['puid'] ?? 0; -if (empty($style)) { - $style = "plus"; + $style = DI::pConfig()->get($uid, 'vier', 'style', DI::config()->get('vier', 'style', $style)); } $stylecss = ''; diff --git a/view/theme/vier/theme.php b/view/theme/vier/theme.php index c156298381..a548d0a7dc 100644 --- a/view/theme/vier/theme.php +++ b/view/theme/vier/theme.php @@ -19,6 +19,10 @@ use Friendica\DI; use Friendica\Model\Contact; use Friendica\Util\Strings; +/* + * This script can be included even when the app is in maintenance mode which requires us to avoid any config call + */ + function vier_init(App $a) { $a->setThemeInfoValue('events_in_profile', false); @@ -27,7 +31,12 @@ function vier_init(App $a) $args = DI::args(); - if ($args->get(0) === 'profile' && $args->get(1) === ($a->getLoggedInUserNickname() ?? '') || $args->get(0) === 'network' && local_user() + if ( + DI::mode()->has(App\Mode::MAINTENANCEDISABLED) + && ( + $args->get(0) === 'profile' && $args->get(1) === ($a->getLoggedInUserNickname() ?? '') + || $args->get(0) === 'network' && local_user() + ) ) { vier_community_info(); -- 2.39.5