mirror of
https://github.com/friendica/friendica
synced 2024-11-18 02:23:40 +00:00
Allow setting & saving storages per type
This commit is contained in:
parent
2fe28af74f
commit
e19b9824cd
4 changed files with 36 additions and 32 deletions
|
@ -35,7 +35,8 @@ class Storage extends BaseAdmin
|
|||
|
||||
self::checkFormSecurityTokenRedirectOnError('/admin/storage', 'admin_storage');
|
||||
|
||||
$storagebackend = Strings::escapeTags(trim($_POST['storagebackend'] ?? ''));
|
||||
$storagebackend = Strings::escapeTags(trim($parameters['name'] ?? ''));
|
||||
|
||||
/** @var IStorage $newstorage */
|
||||
$newstorage = DI::storageManager()->getByName($storagebackend);
|
||||
|
||||
|
@ -66,8 +67,10 @@ class Storage extends BaseAdmin
|
|||
DI::baseUrl()->redirect('admin/storage');
|
||||
}
|
||||
|
||||
if (empty($storagebackend) || !DI::storageManager()->setBackend($storagebackend)) {
|
||||
notice(DI::l10n()->t('Invalid storage backend setting value.'));
|
||||
if (!empty($_POST['submit_save_set'])) {
|
||||
if (empty($storagebackend) || !DI::storageManager()->setBackend($storagebackend)) {
|
||||
notice(DI::l10n()->t('Invalid storage backend setting value.'));
|
||||
}
|
||||
}
|
||||
|
||||
DI::baseUrl()->redirect('admin/storage');
|
||||
|
@ -109,13 +112,11 @@ class Storage extends BaseAdmin
|
|||
$storage_form[$option] = $info;
|
||||
}
|
||||
|
||||
if (count($storage_form) > 0) {
|
||||
$available_storage_forms[] = [
|
||||
'name' => $name,
|
||||
'prefix' => $storage_form_prefix,
|
||||
'form' => $storage_form,
|
||||
];
|
||||
}
|
||||
$available_storage_forms[] = [
|
||||
'name' => $name,
|
||||
'prefix' => $storage_form_prefix,
|
||||
'form' => $storage_form,
|
||||
];
|
||||
}
|
||||
|
||||
$t = Renderer::getMarkupTemplate('admin/storage.tpl');
|
||||
|
@ -123,11 +124,12 @@ class Storage extends BaseAdmin
|
|||
return Renderer::replaceMacros($t, [
|
||||
'$title' => DI::l10n()->t('Administration'),
|
||||
'$page' => DI::l10n()->t('Storage'),
|
||||
'$submit' => DI::l10n()->t('Save Settings'),
|
||||
'$save' => DI::l10n()->t('Save Settings'),
|
||||
'$save_set' => DI::l10n()->t('Set Backend'),
|
||||
'$clear' => DI::l10n()->t('Clear'),
|
||||
'$baseurl' => DI::baseUrl()->get(true),
|
||||
'$form_security_token' => self::getFormSecurityToken("admin_storage"),
|
||||
'$storagebackend' => ['storagebackend', DI::l10n()->t('File storage backend'), $current_storage_backend, DI::l10n()->t('The backend used to store uploaded data. If you change the storage backend, you can manually move the existing files. If you do not do so, the files uploaded before the change will still be available at the old backend. Please see <a href="/help/Settings#1_2_3_1">the settings documentation</a> for more information about the choices and the moving procedure.'), $available_storage_backends],
|
||||
'$storagebackend' => $current_storage_backend,
|
||||
'$availablestorageforms' => $available_storage_forms,
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -198,7 +198,8 @@ return [
|
|||
|
||||
'/site' => [Module\Admin\Site::class, [R::GET, R::POST]],
|
||||
|
||||
'/storage' => [Module\Admin\Storage::class, [R::GET, R::POST]],
|
||||
'/storage' => [Module\Admin\Storage::class, [R::GET, R::POST]],
|
||||
'/storage/{name}' => [Module\Admin\Storage::class, [ R::POST]],
|
||||
|
||||
'/themes' => [Module\Admin\Themes\Index::class, [R::GET, R::POST]],
|
||||
'/themes/{theme}' => [Module\Admin\Themes\Details::class, [R::GET, R::POST]],
|
||||
|
|
|
@ -1,24 +1,23 @@
|
|||
<div id='adminpage'>
|
||||
<h1>{{$title}} - {{$page}}</h1>
|
||||
|
||||
<form action="{{$baseurl}}/admin/storage" method="post">
|
||||
<input type='hidden' name='form_security_token' value="{{$form_security_token}}">
|
||||
|
||||
<h2>Storage Backend</h2>
|
||||
|
||||
{{include file="field_select.tpl" field=$storagebackend}}
|
||||
<div class="submit"><input type="submit" name="page_storage" value="{{$submit}}" /></div>
|
||||
<h2>Current Storage Backend: <b>{{$storagebackend}}</b></h2>
|
||||
|
||||
<h2>Storage Configuration</h2>
|
||||
|
||||
{{foreach from=$availablestorageforms item=$storage}}
|
||||
<form action="{{$baseurl}}/admin/storage/{{$storage.prefix}}" method="post">
|
||||
<input type='hidden' name='form_security_token' value="{{$form_security_token}}">
|
||||
<h3>{{$storage.name}}</h3>
|
||||
{{foreach from=$storage.form item=$field}}
|
||||
{{include file=$field.field field=$field}}
|
||||
{{/foreach}}
|
||||
|
||||
{{if $storage.form}}
|
||||
<div class="submit"><input type="submit" name="submit_save" value="{{$save}}" /></div>
|
||||
{{/if}}
|
||||
<div class="submit"><input type="submit" name="submit_save_set" value="{{$save_set}}" /></div>
|
||||
</form>
|
||||
{{/foreach}}
|
||||
|
||||
<div class="submit"><input type="submit" name="page_storage" value="{{$submit}}" /></div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
@ -3,19 +3,17 @@
|
|||
<div id="adminpage" class="adminpage generic-page-wrapper">
|
||||
<h1>{{$title}} - {{$page}}</h1>
|
||||
|
||||
<form action="{{$baseurl}}/admin/storage" method="post">
|
||||
<input type='hidden' name='form_security_token' value="{{$form_security_token}}">
|
||||
|
||||
<h2>Storage Backend</h2>
|
||||
|
||||
{{include file="field_select.tpl" field=$storagebackend}}
|
||||
<input type="submit" name="page_storage" class="btn btn-primary" value="{{$submit}}"/>
|
||||
<div class="well well-lg">
|
||||
Current Storage Backend: <b>{{$storagebackend}}</b>
|
||||
</div>
|
||||
|
||||
<h2>Storage Configuration</h2>
|
||||
|
||||
{{foreach from=$availablestorageforms item=$storage}}
|
||||
<form action="{{$baseurl}}/admin/storage/{{$storage.prefix}}" method="post">
|
||||
<input type='hidden' name='form_security_token' value="{{$form_security_token}}">
|
||||
<div class="panel">
|
||||
<div class="section-subtitle-wrapper panel-heading" role="tab" id="admin-settings-{{$storage.prefix}}">
|
||||
<div class="section-subtitle-wrapper panel-title" role="tab" id="admin-settings-{{$storage.prefix}}">
|
||||
<h3>
|
||||
<a class="accordion-toggle collapsed" data-toggle="collapse" data-parent="#admin-settings" href="#admin-settings-{{$storage.prefix}}-collapse" aria-expanded="false" aria-controls="admin-settings-{{$storage.prefix}}-collapse">
|
||||
{{$storage.name}}
|
||||
|
@ -29,10 +27,14 @@
|
|||
{{/foreach}}
|
||||
</div>
|
||||
<div class="panel-footer">
|
||||
<input type="submit" name="page_storage" class="btn btn-primary" value="{{$submit}}"/>
|
||||
{{if $storage.form}}
|
||||
<input type="submit" name="submit_save" class="btn btn-primary" value="{{$save}}"/>
|
||||
{{/if}}
|
||||
<input type="submit" name="submit_save_set" class="btn btn-primary" value="{{$save_set}}"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
{{/foreach}}
|
||||
|
||||
|
|
Loading…
Reference in a new issue