Merge pull request #10440 from MrPetovan/bug/10439-addon-settings-forms

Wrap each addon settings form in their own form tag
This commit is contained in:
Tobias Diekershoff 2021-06-29 07:24:23 +02:00 committed by GitHub
commit a44a9e73c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 391 additions and 383 deletions

View file

@ -502,21 +502,20 @@ function settings_content(App $a)
} }
if (($a->argc > 1) && ($a->argv[1] === 'addon')) { if (($a->argc > 1) && ($a->argv[1] === 'addon')) {
$settings_addons = ""; $addon_settings_forms = [];
$r = q("SELECT * FROM `hook` WHERE `hook` = 'addon_settings' "); foreach (DI::dba()->select('hook', ['file', 'function'], ['hook' => 'addon_settings']) as $hook) {
if (!DBA::isResult($r)) { $data = '';
$settings_addons = DI::l10n()->t('No Addon settings configured'); Hook::callSingle(DI::app(), 'addon_settings', [$hook['file'], $hook['function']], $data);
$addon_settings_forms[] = $data;
} }
Hook::callAll('addon_settings', $settings_addons);
$tpl = Renderer::getMarkupTemplate('settings/addons.tpl'); $tpl = Renderer::getMarkupTemplate('settings/addons.tpl');
$o .= Renderer::replaceMacros($tpl, [ $o .= Renderer::replaceMacros($tpl, [
'$form_security_token' => BaseModule::getFormSecurityToken("settings_addon"), '$form_security_token' => BaseModule::getFormSecurityToken("settings_addon"),
'$title' => DI::l10n()->t('Addon Settings'), '$title' => DI::l10n()->t('Addon Settings'),
'$settings_addons' => $settings_addons '$no_addons_settings_configured' => DI::l10n()->t('No Addon settings configured'),
'$addon_settings_forms' => $addon_settings_forms,
]); ]);
return $o; return $o;
} }

File diff suppressed because it is too large Load diff

View file

@ -1,11 +1,14 @@
<h1>{{$title}}</h1> <h1>{{$title}}</h1>
{{foreach $addon_settings_forms as $addon_settings_form}}
<form action="settings/addon" method="post" autocomplete="off"> <form action="settings/addon" method="post" autocomplete="off">
<input type='hidden' name='form_security_token' value='{{$form_security_token}}'> <input type="hidden" name="form_security_token" value="{{$form_security_token}}">
{{$addon_settings_form nofilter}}
{{$settings_addons nofilter}}
</form> </form>
{{foreachelse}}
<p>{{$no_addon_settings_configured}}</p>
{{/foreach}}

View file

@ -2,11 +2,17 @@
{{* include the title template for the settings title *}} {{* include the title template for the settings title *}}
{{include file="section_title.tpl" title=$title}} {{include file="section_title.tpl" title=$title}}
{{foreach $addon_settings_forms as $addon_settings_form}}
<form action="settings/addon" method="post" autocomplete="off"> <form action="settings/addon" method="post" autocomplete="off">
<input type="hidden" name="form_security_token" value="{{$form_security_token}}"> <input type="hidden" name="form_security_token" value="{{$form_security_token}}">
{{$addon_settings_form nofilter}}
{{$settings_addons nofilter}}
</form> </form>
{{foreachelse}}
<div class="alert alert-info" role="alert">{{$no_addon_settings_configured}}</div>
{{/foreach}}
</div> </div>