diff --git a/core/modules/language/language.admin.inc b/core/modules/language/language.admin.inc
index 475eba2..7594476 100644
--- a/core/modules/language/language.admin.inc
+++ b/core/modules/language/language.admin.inc
@@ -27,77 +27,87 @@ function language_admin_predefined_list() {
}
/**
- * Returns HTML for the language negotiation configuration form.
+ * Prepares variables for language negotiation configuration form.
*
- * @param $variables
+ * Default template: language-content-configuration-form.html.twig.
+ *
+ * @param array $variables
* An associative array containing:
* - form: A render element representing the form.
- *
- * @ingroup themeable
*/
-function theme_language_negotiation_configure_form($variables) {
- $form = $variables['form'];
- $output = '';
+function template_preprocess_language_negotiation_configure_form(&$variables) {
+ $form =& $variables['form'];
+ $variables['language_types'] = array();
foreach ($form['#language_types'] as $type) {
- $rows = array();
- $title = '
' . $form[$type]['#title'] . '
';
- $description = '' . $form[$type]['#description'] . '
';
-
- foreach ($form[$type]['title'] as $id => $element) {
- // Do not take form control structures.
- if (is_array($element) && Element::child($id)) {
- $row = array(
- 'data' => array(
- '' . drupal_render($form[$type]['title'][$id]) . '',
- drupal_render($form[$type]['description'][$id]),
- drupal_render($form[$type]['enabled'][$id]),
- drupal_render($form[$type]['weight'][$id]),
- ),
- 'class' => array('draggable'),
- );
- if ($form[$type]['#show_operations']) {
- $row['data'][] = drupal_render($form[$type]['operation'][$id]);
- }
- $rows[] = $row;
- }
- }
-
$header = array(
- array('data' => t('Detection method')),
- array('data' => t('Description')),
- array('data' => t('Enabled')),
- array('data' => t('Weight')),
+ t('Detection method'),
+ t('Description'),
+ t('Enabled'),
+ t('Weight'),
);
// If there is at least one operation enabled show the operation column.
if ($form[$type]['#show_operations']) {
- $header[] = array('data' => t('Operations'));
+ $header[] = t('Operations');
}
- $build = array(
+ $table = array(
'#type' => 'table',
'#header' => $header,
- '#rows' => $rows,
- '#attributes' => array('id' => "language-negotiation-methods-$type"),
+ '#attributes' => array('id' => 'language-negotiation-methods-' . $type),
'#tabledrag' => array(
array(
'action' => 'order',
'relationship' => 'sibling',
- 'group' => "language-method-weight-$type",
+ 'group' => 'language-method-weight-' . $type,
),
),
);
- $table = drupal_render($form[$type]['configurable']);
- $table .= drupal_render($build);
- $table .= drupal_render_children($form[$type]);
+ foreach ($form[$type]['title'] as $id => $element) {
+ // Do not take form control structures.
+ if (is_array($element) && element_child($id)) {
+ $table[$id]['#attributes']['class'][] = 'draggable';
+ $table[$id]['#weight'] = $element['#weight'];
+
+ $table[$id]['title'] = array(
+ '#prefix' => '',
+ $form[$type]['title'][$id],
+ '#suffix' => '',
+ );
+ $table[$id]['description'] = $form[$type]['description'][$id];
+ $table[$id]['enabled'] = $form[$type]['enabled'][$id];
+ $table[$id]['weight'] = $form[$type]['weight'][$id];
+ if ($form[$type]['#show_operations']) {
+ $table[$id]['operation'] = $form[$type]['operation'][$id];
+ }
+ // Unset to prevent rendering along with children.
+ unset($form[$type]['title'][$id]);
+ unset($form[$type]['description'][$id]);
+ unset($form[$type]['enabled'][$id]);
+ unset($form[$type]['weight'][$id]);
+ unset($form[$type]['operation'][$id]);
+ }
+ }
- $output .= '' . $title . $description . $table . '
';
+ // Unset configurable to prevent rendering twice with children.
+ $configurable = isset($form[$type]['configurable']) ? $form[$type]['configurable'] : NULL;
+ unset($form[$type]['configurable']);
+
+ $variables['language_types'][] = array(
+ 'type' => $type,
+ 'title' => $form[$type]['#title'],
+ 'description' => $form[$type]['#description'],
+ 'configurable' => $configurable,
+ 'table' => $table,
+ 'children' => $form[$type],
+ );
+ // Prevent the type from rendering with the remaining form child elements.
+ unset($form[$type]);
}
- $output .= drupal_render_children($form);
- return $output;
+ $variables['children'] = $form;
}
/**
diff --git a/core/modules/language/language.module b/core/modules/language/language.module
index 6a17f73..ad6956c 100644
--- a/core/modules/language/language.module
+++ b/core/modules/language/language.module
@@ -98,6 +98,7 @@ function language_theme() {
'language_negotiation_configure_form' => array(
'render element' => 'form',
'file' => 'language.admin.inc',
+ 'template' => 'language-negotiation-configure-form',
),
'language_negotiation_configure_browser_form_table' => array(
'render element' => 'form',
diff --git a/core/modules/language/templates/language-negotiation-configure-form.html.twig b/core/modules/language/templates/language-negotiation-configure-form.html.twig
new file mode 100644
index 0000000..67ddda4
--- /dev/null
+++ b/core/modules/language/templates/language-negotiation-configure-form.html.twig
@@ -0,0 +1,31 @@
+{#
+/**
+* @file
+* Default theme implementation for a language negotiation configuration form.
+*
+* Available variables:
+* - language_types: A list of language negotiation types. Each language type
+* contains the following:
+* - type: The machine name for the negotation type.
+* - title: The language negotation type name.
+* - description: A description for how the language negotation type operates.
+* - configurable: A radio element to toggle the table.
+* - table: A draggable table for the language detection methods of this type.
+* - children: Remaining form items for the group.
+* - children: Remaining form items for all groups.
+*
+* @see template_preprocess_language_negotiation_configure_form()
+*
+* @ingroup themeable
+*/
+#}
+{% for language_type in language_types %}
+
+{% endfor %}
+{{ children }}