Add conditional help text for disabled fields

This commit is contained in:
Philipp 2023-03-26 13:39:11 +02:00
parent 76f3b07033
commit fa9c3d40be
No known key found for this signature in database
GPG Key ID: 24A7501396EB5432
6 changed files with 11 additions and 6 deletions

View File

@ -83,7 +83,7 @@ class DatabaseConfig implements IManageConfigValues
/** {@inheritDoc} */ /** {@inheritDoc} */
public function isSetDisabled(string $cat, string $key): bool public function isSetDisabled(string $cat, string $key): bool
{ {
return $this->cache->getSource($cat, $key) >= Cache::SOURCE_ENV; return $this->cache->getSource($cat, $key) >= 0;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */

View File

@ -88,9 +88,9 @@ class Settings extends BaseAdmin
'$clear' => DI::l10n()->t('Clear'), '$clear' => DI::l10n()->t('Clear'),
'$logname' => DI::config()->get('system', 'logfile'), '$logname' => DI::config()->get('system', 'logfile'),
// see /help/smarty3-templates#1_1 on any Friendica node // see /help/smarty3-templates#1_1 on any Friendica node
'$debugging' => ['debugging', DI::l10n()->t("Enable Debugging"), DI::config()->get('system', 'debugging'), "", DI::config()->isSetDisabled('system', 'debugging') ? 'disabled' : ''], '$debugging' => ['debugging', DI::l10n()->t("Enable Debugging"), DI::config()->get('system', 'debugging'), DI::config()->isSetDisabled('system', 'debugging') ? DI::l10n()->t("<strong>Readonly</strong> because set by an environment variable") : '', DI::config()->isSetDisabled('system', 'debugging') ? 'disabled' : ''],
'$logfile' => ['logfile', DI::l10n()->t("Log file"), DI::config()->get('system', 'logfile'), DI::l10n()->t("Must be writable by web server. Relative to your Friendica top-level directory."), "", DI::config()->isSetDisabled('system', 'logfile') ? 'disabled' : ''], '$logfile' => ['logfile', DI::l10n()->t("Log file"), DI::config()->get('system', 'logfile'), DI::l10n()->t("Must be writable by web server. Relative to your Friendica top-level directory.") . (DI::config()->isSetDisabled('system', 'logfile') ? '<br>' . DI::l10n()->t("<strong>Readonly</strong> because set by an environment variable") : ''), "", DI::config()->isSetDisabled('system', 'logfile') ? 'disabled' : ''],
'$loglevel' => ['loglevel', DI::l10n()->t("Log level"), DI::config()->get('system', 'loglevel'), "", $log_choices, DI::config()->isSetDisabled('system', 'loglevel') ? 'disabled' : ''], '$loglevel' => ['loglevel', DI::l10n()->t("Log level"), DI::config()->get('system', 'loglevel'), DI::config()->isSetDisabled('system', 'loglevel') ? DI::l10n()->t("<strong>Readonly</strong> because set by an environment variable") : '', $log_choices, DI::config()->isSetDisabled('system', 'loglevel') ? 'disabled' : ''],
'$form_security_token' => self::getFormSecurityToken("admin_logs"), '$form_security_token' => self::getFormSecurityToken("admin_logs"),
'$phpheader' => DI::l10n()->t("PHP logging"), '$phpheader' => DI::l10n()->t("PHP logging"),
'$phphint' => DI::l10n()->t("To temporarily enable logging of PHP errors and warnings you can prepend the following to the index.php file of your installation. The filename set in the 'error_log' line is relative to the friendica top-level directory and must be writeable by the web server. The option '1' for 'log_errors' and 'display_errors' is to enable these options, set to '0' to disable them."), '$phphint' => DI::l10n()->t("To temporarily enable logging of PHP errors and warnings you can prepend the following to the index.php file of your installation. The filename set in the 'error_log' line is relative to the friendica top-level directory and must be writeable by the web server. The option '1' for 'log_errors' and 'display_errors' is to enable these options, set to '0' to disable them."),

View File

@ -417,7 +417,7 @@ class Site extends BaseAdmin
'$relocate_cmd' => DI::l10n()->t('(Friendica directory)# bin/console relocate https://newdomain.com'), '$relocate_cmd' => DI::l10n()->t('(Friendica directory)# bin/console relocate https://newdomain.com'),
// name, label, value, help string, extra data... // name, label, value, help string, extra data...
'$sitename' => ['sitename', DI::l10n()->t('Site name'), DI::config()->get('config', 'sitename'), '', '', DI::config()->isSetDisabled('config', 'sitename') ? 'disabled' : ''], '$sitename' => ['sitename', DI::l10n()->t('Site name'), DI::config()->get('config', 'sitename'), DI::config()->isSetDisabled('config', 'sitename') ? DI::l10n()->t("<strong>Readonly</strong> because set by an environment variable") : '', '', DI::config()->isSetDisabled('config', 'sitename') ? 'disabled' : ''],
'$sender_email' => ['sender_email', DI::l10n()->t('Sender Email'), DI::config()->get('config', 'sender_email'), DI::l10n()->t('The email address your server shall use to send notification emails from.'), '', '', 'email'], '$sender_email' => ['sender_email', DI::l10n()->t('Sender Email'), DI::config()->get('config', 'sender_email'), DI::l10n()->t('The email address your server shall use to send notification emails from.'), '', '', 'email'],
'$system_actor_name' => ['system_actor_name', DI::l10n()->t('Name of the system actor'), User::getActorName(), DI::l10n()->t("Name of the internal system account that is used to perform ActivityPub requests. This must be an unused username. If set, this can't be changed again.")], '$system_actor_name' => ['system_actor_name', DI::l10n()->t('Name of the system actor'), User::getActorName(), DI::l10n()->t("Name of the internal system account that is used to perform ActivityPub requests. This must be an unused username. If set, this can't be changed again.")],
'$banner' => ['banner', DI::l10n()->t('Banner/Logo'), $banner, ''], '$banner' => ['banner', DI::l10n()->t('Banner/Logo'), $banner, ''],
@ -425,7 +425,7 @@ class Site extends BaseAdmin
'$shortcut_icon' => ['shortcut_icon', DI::l10n()->t('Shortcut icon'), DI::config()->get('system', 'shortcut_icon'), DI::l10n()->t('Link to an icon that will be used for browsers.')], '$shortcut_icon' => ['shortcut_icon', DI::l10n()->t('Shortcut icon'), DI::config()->get('system', 'shortcut_icon'), DI::l10n()->t('Link to an icon that will be used for browsers.')],
'$touch_icon' => ['touch_icon', DI::l10n()->t('Touch icon'), DI::config()->get('system', 'touch_icon'), DI::l10n()->t('Link to an icon that will be used for tablets and mobiles.')], '$touch_icon' => ['touch_icon', DI::l10n()->t('Touch icon'), DI::config()->get('system', 'touch_icon'), DI::l10n()->t('Link to an icon that will be used for tablets and mobiles.')],
'$additional_info' => ['additional_info', DI::l10n()->t('Additional Info'), $additional_info, DI::l10n()->t('For public servers: you can add additional information here that will be listed at %s/servers.', Search::getGlobalDirectory())], '$additional_info' => ['additional_info', DI::l10n()->t('Additional Info'), $additional_info, DI::l10n()->t('For public servers: you can add additional information here that will be listed at %s/servers.', Search::getGlobalDirectory())],
'$language' => ['language', DI::l10n()->t('System language'), DI::config()->get('system', 'language'), '', $lang_choices, DI::config()->isSetDisabled('system', 'language') ? 'disabled' : ''], '$language' => ['language', DI::l10n()->t('System language'), DI::config()->get('system', 'language'), DI::config()->isSetDisabled('system', 'language') ? DI::l10n()->t("<strong>Readonly</strong> because set by an environment variable") : '', $lang_choices, DI::config()->isSetDisabled('system', 'language') ? 'disabled' : ''],
'$theme' => ['theme', DI::l10n()->t('System theme'), DI::config()->get('system', 'theme'), DI::l10n()->t('Default system theme - may be over-ridden by user profiles - <a href="%s" id="cnftheme">Change default theme settings</a>', DI::baseUrl() . '/admin/themes'), $theme_choices], '$theme' => ['theme', DI::l10n()->t('System theme'), DI::config()->get('system', 'theme'), DI::l10n()->t('Default system theme - may be over-ridden by user profiles - <a href="%s" id="cnftheme">Change default theme settings</a>', DI::baseUrl() . '/admin/themes'), $theme_choices],
'$theme_mobile' => ['theme_mobile', DI::l10n()->t('Mobile system theme'), DI::config()->get('system', 'mobile-theme', '---'), DI::l10n()->t('Theme for mobile devices'), $theme_choices_mobile], '$theme_mobile' => ['theme_mobile', DI::l10n()->t('Mobile system theme'), DI::config()->get('system', 'mobile-theme', '---'), DI::l10n()->t('Theme for mobile devices'), $theme_choices_mobile],
'$force_ssl' => ['force_ssl', DI::l10n()->t('Force SSL'), DI::config()->get('system', 'force_ssl'), DI::l10n()->t('Force all Non-SSL requests to SSL - Attention: on some systems it could lead to endless loops.')], '$force_ssl' => ['force_ssl', DI::l10n()->t('Force SSL'), DI::config()->get('system', 'force_ssl'), DI::l10n()->t('Force all Non-SSL requests to SSL - Attention: on some systems it could lead to endless loops.')],

View File

@ -146,6 +146,7 @@ class Storage extends BaseAdmin
'$save_reload' => DI::l10n()->t('Save & Reload'), '$save_reload' => DI::l10n()->t('Save & Reload'),
'$noconfig' => DI::l10n()->t('This backend doesn\'t have custom settings'), '$noconfig' => DI::l10n()->t('This backend doesn\'t have custom settings'),
'$form_security_token' => self::getFormSecurityToken("admin_storage"), '$form_security_token' => self::getFormSecurityToken("admin_storage"),
'$storagebackend_ro_txt' => DI::config()->isSetDisabled('storage', 'name') ? DI::l10n()->t("Changing the current backend is prohibited because it is set by an environment variable") : '',
'$storagebackend' => $current_storage_backend instanceof ICanWriteToStorage ? $current_storage_backend::getName() : DI::l10n()->t('Database (legacy)'), '$storagebackend' => $current_storage_backend instanceof ICanWriteToStorage ? $current_storage_backend::getName() : DI::l10n()->t('Database (legacy)'),
'$availablestorageforms' => $available_storage_forms, '$availablestorageforms' => $available_storage_forms,
]); ]);

View File

@ -2,6 +2,7 @@
<h1>{{$title}} - {{$page}}</h1> <h1>{{$title}} - {{$page}}</h1>
<h2>{{$label_current}}: <b>{{$storagebackend}}</b></h2> <h2>{{$label_current}}: <b>{{$storagebackend}}</b></h2>
{{$storagebackend_ro_txt nofilter}}
<h2>{{$label_config}}</h2> <h2>{{$label_config}}</h2>

View File

@ -5,6 +5,9 @@
<div class="well well-lg"> <div class="well well-lg">
{{$label_current}}: <b>{{$storagebackend}}</b> {{$label_current}}: <b>{{$storagebackend}}</b>
{{if $storagebackend_ro_txt}}
<p><p><i>{{$storagebackend_ro_txt nofilter}}</i>
{{/if}}
</div> </div>
<h2>{{$label_config}}</h2> <h2>{{$label_config}}</h2>