diff --git a/phpBB/adm/style/acp_storage.html b/phpBB/adm/style/acp_storage.html index f064438aca..f3b93020f8 100644 --- a/phpBB/adm/style/acp_storage.html +++ b/phpBB/adm/style/acp_storage.html @@ -47,7 +47,7 @@ {% for provider in PROVIDERS %} {% if provider.is_available %} {% endif %} {% endfor %} @@ -59,43 +59,42 @@ {% for provider in PROVIDERS %} {% if provider.is_available %}
- {{ lang('STORAGE_' ~ storage.get_name | upper ~ '_TITLE') }} - {{ lang('STORAGE_ADAPTER_' ~ provider.get_name | upper ~ '_NAME') }} + {{ lang('STORAGE_' ~ storage.get_name | upper ~ '_TITLE') }} - {{ provider.get_title }} {% for name, options in provider.get_options %}
- {% set title = 'STORAGE_ADAPTER_' ~ provider.get_name | upper ~ '_OPTION_' ~ name | upper %} - {% set description = 'STORAGE_ADAPTER_' ~ provider.get_name | upper ~ '_OPTION_' ~ name | upper ~ '_EXPLAIN' %} - - {% if lang_defined(description) %} -
{{ lang(description) }} + + {% if options.description %} +
{{ options.description }} {% endif %}
{% set input_name = storage.get_name ~ '[' ~ name ~ ']' %} {% set input_value = attribute(config, 'storage\\' ~ storage.get_name ~ '\\config\\' ~ name) %} + {% set form_macro = options.form_macro %} - {% if options.tag == 'input' %} - {{ FormsInput(options | merge({"name": input_name, "value": input_value})) }} - {% elseif options.tag == 'textarea' %} - {{ FormsTextarea(options | merge({"name": input_name, "content": input_value})) }} - {% elseif options.tag == 'radio' %} + {% if form_macro.tag == 'input' %} + {{ FormsInput(form_macro | merge({"name": input_name, "value": input_value})) }} + {% elseif form_macro.tag == 'textarea' %} + {{ FormsTextarea(form_macro | merge({"name": input_name, "content": input_value})) }} + {% elseif form_macro.tag == 'radio' %} {% set buttons = [] %} - {% for button in options.buttons %} - {% set new_button = button | merge({"name": input_name, "label": lang(button.label), "checked": button.value == input_value}) %} + {% for button in form_macro.buttons %} + {% set new_button = button | merge({"name": input_name, "checked": button.value == input_value}) %} {% set buttons = buttons | merge([new_button]) %} {% endfor %} - {{ FormsRadioButtons(options | merge({"buttons": buttons})) }} - {% elseif options.tag == 'select' %} + {{ FormsRadioButtons(form_macro | merge({"buttons": buttons})) }} + {% elseif form_macro.tag == 'select' %} {% set select_options = [] %} - {% for option in options.options %} + {% for option in form_macro.options %} {% set new_option = option | merge({"selected": option.value == input_value}) %} {% set select_options = select_options | merge([new_option]) %} {% endfor %} - {{ FormsSelect(options | merge({"name": input_name, "options": select_options})) }} + {{ FormsSelect(form_macro | merge({"name": input_name, "options": select_options})) }} {% endif %}
@@ -109,9 +108,9 @@
- + - +
diff --git a/phpBB/config/default/container/services_storage.yml b/phpBB/config/default/container/services_storage.yml index 1109aa626b..8db8ceaede 100644 --- a/phpBB/config/default/container/services_storage.yml +++ b/phpBB/config/default/container/services_storage.yml @@ -72,6 +72,7 @@ services: storage.provider.local: class: phpbb\storage\provider\local arguments: + - '@language' tags: - { name: storage.provider } diff --git a/phpBB/language/en/acp/storage.php b/phpBB/language/en/acp/storage.php index 9f928ee58e..575805e650 100644 --- a/phpBB/language/en/acp/storage.php +++ b/phpBB/language/en/acp/storage.php @@ -65,6 +65,7 @@ $lang = array_merge($lang, [ // Local adapter 'STORAGE_ADAPTER_LOCAL_NAME' => 'Local', 'STORAGE_ADAPTER_LOCAL_OPTION_PATH' => 'Path', + 'STORAGE_ADAPTER_LOCAL_OPTION_PATH_EXPLAIN' => 'Storage path for files.
For example: files, images/avatars/upload or store.', // Form validation 'STORAGE_UPDATE_SUCCESSFUL' => 'All storage types were successfully updated.', diff --git a/phpBB/phpbb/storage/provider/local.php b/phpBB/phpbb/storage/provider/local.php index 67a1789434..11bca055ce 100644 --- a/phpBB/phpbb/storage/provider/local.php +++ b/phpBB/phpbb/storage/provider/local.php @@ -13,8 +13,25 @@ namespace phpbb\storage\provider; +use phpbb\language\language; + class local implements provider_interface { + /** + * @var language + */ + protected $language; + + /** + * Constructor + * + * @param language $language + */ + public function __construct(language $language) + { + $this->language = $language; + } + /** * {@inheritdoc} */ @@ -23,6 +40,11 @@ class local implements provider_interface return 'local'; } + public function get_title(): string + { + return $this->language->lang('STORAGE_ADAPTER_LOCAL_NAME'); + } + /** * {@inheritdoc} */ @@ -38,8 +60,12 @@ class local implements provider_interface { return [ 'path' => [ - 'tag' => 'input', - 'type' => 'text', + 'title' => $this->language->lang('STORAGE_ADAPTER_LOCAL_OPTION_PATH'), + 'description' => $this->language->lang('STORAGE_ADAPTER_LOCAL_OPTION_PATH_EXPLAIN'), + 'form_macro' => [ + 'tag' => 'input', + 'type' => 'text', + ], ], ]; } diff --git a/phpBB/phpbb/storage/provider/provider_interface.php b/phpBB/phpbb/storage/provider/provider_interface.php index aa01a51e37..7baac79f72 100644 --- a/phpBB/phpbb/storage/provider/provider_interface.php +++ b/phpBB/phpbb/storage/provider/provider_interface.php @@ -22,6 +22,13 @@ interface provider_interface */ public function get_name(): string; + /** + * Gets adapter title for acp + * + * @return string + */ + public function get_title(): string; + /** * Gets adapter class * @@ -32,7 +39,67 @@ interface provider_interface /** * Gets adapter options * - * @return array Configuration keys + * Example: + * public function get_options() + * { + * return [ + * 'text-test' => [ + * 'title' => $this->language->lang('STORAGE_ADAPTER_DEMO_OPTION_TEXT_TEST'), + * 'description' => $this->language->lang('STORAGE_ADAPTER_DEMO_OPTION_TEXT_TEST_EXPLAIN'), + * 'form_macro' => [ + * 'tag' => 'input', + * 'type' => 'text', + * ], + * ], + * 'password-test' => [ + * 'title' => $this->language->lang('STORAGE_ADAPTER_DEMO_OPTION_PASSWORD_TEST'), + * 'description' => $this->language->lang('STORAGE_ADAPTER_DEMO_OPTION_PASSWORD_TEST_EXPLAIN'), + * 'form_macro' => [ + * 'tag' => 'input', + * 'type' => 'password', + * ], + * ], + * 'radio-test' => [ + * 'title' => $this->language->lang('STORAGE_ADAPTER_DEMO_OPTION_RADIO_TEST'), + * 'description' => $this->language->lang('STORAGE_ADAPTER_DEMO_OPTION_RADIO_TEST_EXPLAIN'), + * 'form_macro' => [ + * 'tag' => 'radio', + * 'buttons' => [ + * [ + * 'type' => 'radio', + * 'value' => '1', + * 'label' => $this->language->lang('STORAGE_ADAPTER_DEMO_OPTION_RADIO_TEST_LABEL_ONE'), + * ], + * [ + * 'type' => 'radio', + * 'value' => '2', + * 'label' => $this->language->lang('STORAGE_ADAPTER_DEMO_OPTION_RADIO_TEST_LABEL_TWO'), + * ], + * ], + * ], + * ], + * 'select-test' => [ + * 'title' => $this->language->lang('STORAGE_ADAPTER_DEMO_OPTION_SELECT_TEST'), + * 'description' => $this->language->lang('STORAGE_ADAPTER_DEMO_OPTION_SELECT_TEST_EXPLAIN'), + * 'form_macro' => [ + * 'tag' => 'select', + * 'options' => [ + * ['value' => 'one', 'label' => $this->language->lang('STORAGE_ADAPTER_DEMO_OPTION_SELECT_TEST_LABEL_ONE')], + * ['value' => 'two', 'label' => $this->language->lang('STORAGE_ADAPTER_DEMO_OPTION_SELECT_TEST_LABEL_TWO')], + * ], + * ], + * ], + * 'textarea-test' => [ + * 'title' => $this->language->lang('STORAGE_ADAPTER_DEMO_OPTION_TEXTAREA_TEST'), + * 'description' => $this->language->lang('STORAGE_ADAPTER_DEMO_OPTION_TEXTAREA_TEST_EXPLAIN'), + * 'form_macro' => [ + * 'tag' => 'textarea', + * ] + * ], + * ]; + * } + * + * @return array Configuration keys */ public function get_options(): array; diff --git a/phpBB/phpbb/template/twig/extension/forms.php b/phpBB/phpbb/template/twig/extension/forms.php index b146aacfb9..bf1bed006e 100644 --- a/phpBB/phpbb/template/twig/extension/forms.php +++ b/phpBB/phpbb/template/twig/extension/forms.php @@ -206,7 +206,7 @@ class forms extends AbstractExtension { return $environment->render('macros/forms/textarea.twig', [ 'CLASS' => (string) ($form_data['class'] ?? ''), - 'ID' => (string) $form_data['id'], + 'ID' => (string) ($form_data['id'] ?? ''), 'DATA' => $form_data['data'] ?? [], 'NAME' => (string) $form_data['name'], 'ROWS' => (int) ($form_data['rows'] ?? ''),