diff --git a/phpBB/adm/style/acp_storage.html b/phpBB/adm/style/acp_storage.html index b486223cfe..4146d50d03 100644 --- a/phpBB/adm/style/acp_storage.html +++ b/phpBB/adm/style/acp_storage.html @@ -1,3 +1,4 @@ +{% import 'forms.html' as forms %} @@ -29,13 +30,16 @@
{{ lang('STORAGE_' ~ storage.get_name | upper ~ '_TITLE') }} - {{ lang('STORAGE_ADAPTER_' ~ provider.get_name | upper ~ '_NAME') }} {% for name, options in provider.get_options %} - {% set lang_name = 'STORAGE_ADAPTER_' ~ provider.get_name | upper ~ '_OPTION_' ~ name | upper %} - {% set options = options|merge({'name': storage.get_name ~ '[' ~ name ~ ']'}) %} - {{ adm_block(lang(lang_name), '', input(options, attribute(CONFIG, 'storage\\' ~ storage.get_name ~ '\\config\\' ~ name))) }} + {% set l_name = 'STORAGE_ADAPTER_' ~ provider.get_name | upper ~ '_OPTION_' ~ name | upper %} + {% set options = options|merge({'name': storage.get_name ~ '[' ~ name ~ ']'}) %} + {% set options = options|merge({'value': attribute(CONFIG, 'storage\\' ~ storage.get_name ~ '\\config\\' ~ name)}) %} + {{ forms.form_row( + forms.form_label(l_name), + forms.form_control(options) + ) }} {% endfor %}
{% endfor %} - {% endfor %}
diff --git a/phpBB/adm/style/forms.html b/phpBB/adm/style/forms.html new file mode 100644 index 0000000000..d3e10f563b --- /dev/null +++ b/phpBB/adm/style/forms.html @@ -0,0 +1,28 @@ +{% macro input(name, value, type, size) %} + +{% endmacro %} + +{% macro textarea(name, value, rows, cols) %} + +{% endmacro %} + +{% macro form_control(params) %} + {% if params['type'] == 'text' %} + {{ _self.input(params['name'], params['value'], params['type']) }} + {% endif %} +{% endmacro %} + +{% macro form_label(name, description = '') %} + {% if description is not empty %}
{{ lang(description) }}{% endif %} +{% endmacro %} + +{% macro form_row(left_content, right_content) %} +
+
+ {{ left_content }} +
+
+ {{ right_content}} +
+
+{% endmacro %} diff --git a/phpBB/config/default/container/services_twig.yml b/phpBB/config/default/container/services_twig.yml index 11df56a21c..c7ce82632a 100644 --- a/phpBB/config/default/container/services_twig.yml +++ b/phpBB/config/default/container/services_twig.yml @@ -48,12 +48,6 @@ services: tags: - { name: twig.extension } - template.twig.extensions.form: - class: phpbb\template\twig\extension\form - arguments: - tags: - - { name: twig.extension } - template.twig.extensions.debug: class: Twig_Extension_Debug diff --git a/phpBB/phpbb/template/twig/extension/form.php b/phpBB/phpbb/template/twig/extension/form.php deleted file mode 100644 index 4cd39058f3..0000000000 --- a/phpBB/phpbb/template/twig/extension/form.php +++ /dev/null @@ -1,71 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -namespace phpbb\template\twig\extension; - -// I will use this to generate forms in twig until there is something better -class form extends \Twig_Extension -{ - - /** - * Constructor - */ - public function __construct() - { - } - - public function getFunctions() - { - return [ - new \Twig_SimpleFunction('input', '\\phpbb\\template\\twig\\extension\\form::generate_input'), - new \Twig_SimpleFunction('adm_block', '\\phpbb\\template\\twig\\extension\\form::generate_block'), - ]; - } - - public static function generate_input($options, $value = '') - { - $input = ' $value) - { - if (in_array($key, ['lang'])) - continue; - - $input .= "$key=\"$value\" "; - } - break; - } - - $input .= '>'; - - return $input; - } - - public static function generate_block($name, $description = '', $content) - { - return << -

$description
-
- $content -
- -EOF; - } -}