- $active_panel = (!empty($_POST['active_panel']) ? "#" . Strings::escapeTags(trim($_POST['active_panel'])) : '');
-
- $storagebackend = Strings::escapeTags(trim($_POST['storagebackend'] ?? ''));
-
- // save storage backend form
- if (DI::storageManager()->setBackend($storagebackend)) {
- $storage_opts = DI::storage()->getOptions();
- $storage_form_prefix = preg_replace('|[^a-zA-Z0-9]|', '', $storagebackend);
- $storage_opts_data = [];
- foreach ($storage_opts as $name => $info) {
- $fieldname = $storage_form_prefix . '_' . $name;
- switch ($info[0]) { // type
- case 'checkbox':
- case 'yesno':
- $value = !empty($_POST[$fieldname]);
- break;
- default:
- $value = $_POST[$fieldname] ?? '';
- }
- $storage_opts_data[$name] = $value;
- }
- unset($name);
- unset($info);
-
- $storage_form_errors = DI::storage()->saveOptions($storage_opts_data);
- if (count($storage_form_errors)) {
- foreach ($storage_form_errors as $name => $err) {
- notice('Storage backend, ' . $storage_opts[$name][1] . ': ' . $err);
- }
- DI::baseUrl()->redirect('admin/site' . $active_panel);
- }
- } else {
- notice(DI::l10n()->t('Invalid storage backend setting value.'));
- }