diff --git a/core/modules/language/language.admin.inc b/core/modules/language/language.admin.inc
index e740342..50f6204 100644
--- a/core/modules/language/language.admin.inc
+++ b/core/modules/language/language.admin.inc
@@ -165,37 +165,41 @@ function language_negotiation_configure_form_table(&$form, $type) {
}
/**
- * 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) {
+function template_preprocess_language_negotiation_configure_form(&$variables) {
$form = $variables['form'];
- $output = '';
+ $form_items = array();
foreach ($form['#language_types'] as $type) {
$rows = array();
- $title = '
' . $form[$type]['#title'] . '
';
- $description = '' . $form[$type]['#description'] . '
';
+ $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]),
+ array('data' => array(
+ '#prefix' => '',
+ $form[$type]['title'][$id]),
+ '#suffix' => '',
+ ),
+ array('data' => drupal_render($form[$type]['description'][$id])),
+ array('data' => drupal_render($form[$type]['enabled'][$id])),
+ array('data' => drupal_render($form[$type]['weight'][$id])),
),
'class' => array('draggable'),
);
if ($form[$type]['#show_operations']) {
- $row['data'][] = drupal_render($form[$type]['operation'][$id]);
+ $row['data'][]['data'] = drupal_render($form[$type]['operation'][$id]);
}
$rows[] = $row;
}
@@ -213,23 +217,32 @@ function theme_language_negotiation_configure_form($variables) {
$header[] = array('data' => t('Operations'));
}
- $build = array(
- '#theme' => 'table',
+ $table = array(
+ '#type' => 'table',
'#header' => $header,
'#rows' => $rows,
'#attributes' => array('id' => "language-negotiation-methods-$type"),
+ '#tabledrag' => array(
+ array('order', 'sibling', "language-method-weight-$type"),
+ ),
);
- $table = drupal_render($form[$type]['configurable']);
- $table .= drupal_render($build);
- $table .= drupal_render_children($form[$type]);
-
- drupal_add_tabledrag("language-negotiation-methods-$type", 'order', 'sibling', "language-method-weight-$type");
- $output .= '' . $title . $description . $table . '
';
+ $form_items[] = array(
+ 'type' => $type,
+ 'title' => $title,
+ 'description' => $description,
+ 'configurable' => drupal_render($form[$type]['configurable']),
+ 'table' => drupal_render($table),
+ 'children' => drupal_render_children($form[$type]),
+ );
+ unset($form[$type]);
}
- $output .= drupal_render_children($form);
- return $output;
+ $variables['form_items'] = $form_items;
+
+ // Remove elements from the 'children' render array.
+ // @todo Refactor when http://drupal.org/node/1920886 is resolved.
+ $variables['children'] = drupal_render_children($form);
}
/**
@@ -286,57 +299,6 @@ function language_negotiation_configure_form_submit($form, &$form_state) {
}
/**
- * Theme browser configuration form as table.
- *
- * @param $variables
- * An associative array containing:
- * - form: A render element representing the form.
- *
- * @ingroup themeable
- */
-function theme_language_negotiation_configure_browser_form_table($variables) {
- $form = $variables['form'];
- $rows = array();
- foreach (element_children($form, TRUE) as $key) {
- $row = array();
- $row[] = drupal_render($form[$key]['browser_langcode']);
- $row[] = drupal_render($form[$key]['drupal_langcode']);
- $links = array();
- $links['delete'] = array(
- 'title' => t('Delete'),
- 'href' => "admin/config/regional/language/detection/browser/delete/$key",
- 'attributes' => array(
- 'class' => array('image-style-link'),
- ),
- );
- $row[] = array(
- 'data' => array(
- '#type' => 'operations',
- '#links' => $links,
- ),
- );
-
- $rows[] = $row;
- }
-
- $header = array(
- t('Browser language code'),
- t('Drupal language'),
- t('Operations'),
- );
-
- $table = array(
- '#theme' => 'table',
- '#header' => $header,
- '#rows' => $rows,
- '#attributes' => array('id' => 'lang-neg-browser'),
- );
- $output = drupal_render($table);
-
- return $output;
-}
-
-/**
* Returns the content language settings form.
*
* @deprecated Use \Drupal\language\Controller\LanguageController::contentSettings()
@@ -435,7 +397,13 @@ function language_content_settings_form(array $form, array $form_state, array $s
}
/**
- * Implements hook_preprocess_HOOK() for theme_language_content_settings_table().
+ * Prepares variables for language content settings table templates.
+ *
+ * Default template: language-content-settings-table.html.twig.
+ *
+ * @param array $variables
+ * An associative array containing:
+ * - @todo list variables.
*/
function template_preprocess_language_content_settings_table(&$variables) {
// Add a render element representing the bundle language settings table.
@@ -473,29 +441,15 @@ function template_preprocess_language_content_settings_table(&$variables) {
);
}
- $variables['build'] = array(
- '#title' => $element['#title'],
+ $variables['title'] = $element['#title'];
+ $variables['table'] = array(
+ '#type' => 'table',
'#header' => $header,
'#rows' => $rows,
- '#theme' => 'table',
);
}
/**
- * Returns HTML for an administration settings table.
- *
- * @param array $variables
- * An associative array containing:
- * - build: A render element representing a table of bundle content language
- * settings for a particular entity type.
- *
- * @ingroup themable
- */
-function theme_language_content_settings_table($variables) {
- return '' . $variables['build']['#title'] . '
' . drupal_render($variables['build']);
-}
-
-/**
* Form submission handler for language_content_settings_form().
*/
function language_content_settings_form_submit(array $form, array &$form_state) {
diff --git a/core/modules/language/language.module b/core/modules/language/language.module
index 05e3776..605c443 100644
--- a/core/modules/language/language.module
+++ b/core/modules/language/language.module
@@ -156,14 +156,12 @@ function language_theme() {
return array(
'language_negotiation_configure_form' => array(
'render element' => 'form',
- ),
- 'language_negotiation_configure_browser_form_table' => array(
- 'render element' => 'form',
- 'file' => 'language.admin.inc',
+ 'template' => 'language-negotiation-configure-form',
),
'language_content_settings_table' => array(
'render element' => 'element',
'file' => 'language.admin.inc',
+ 'template' => 'language-content-settings-table',
),
);
}
diff --git a/core/modules/language/lib/Drupal/language/Form/NegotiationBrowserForm.php b/core/modules/language/lib/Drupal/language/Form/NegotiationBrowserForm.php
index 5cc3c4b..5dfad09 100644
--- a/core/modules/language/lib/Drupal/language/Form/NegotiationBrowserForm.php
+++ b/core/modules/language/lib/Drupal/language/Form/NegotiationBrowserForm.php
@@ -84,11 +84,25 @@ public function buildForm(array $form, array &$form_state) {
$form['mappings'] = array(
'#tree' => TRUE,
- '#theme' => 'language_negotiation_configure_browser_form_table',
+ '#type' => 'table',
+ '#header' => array(
+ t('Browser language code'),
+ t('Drupal language'),
+ t('Operations'),
+ ),
+ '#attributes' => array('id' => 'lang-neg-browser'),
);
$mappings = $this->language_get_browser_drupal_langcode_mappings();
foreach ($mappings as $browser_langcode => $drupal_langcode) {
+ $links = array();
+ $links['delete'] = array(
+ 'title' => t('Delete'),
+ 'href' => 'admin/config/regional/language/detection/browser/delete/' . $browser_langcode,
+ 'attributes' => array(
+ 'class' => array('image-style-link'),
+ ),
+ );
$form['mappings'][$browser_langcode] = array(
'browser_langcode' => array(
'#type' => 'textfield',
@@ -102,6 +116,10 @@ public function buildForm(array $form, array &$form_state) {
'#default_value' => $drupal_langcode,
'#required' => TRUE,
),
+ 'operations' => array(
+ '#type' => 'operations',
+ '#links' => $links,
+ ),
);
}
diff --git a/core/modules/language/templates/language-content-settings-table.html.twig b/core/modules/language/templates/language-content-settings-table.html.twig
new file mode 100644
index 0000000..68ac6c4
--- /dev/null
+++ b/core/modules/language/templates/language-content-settings-table.html.twig
@@ -0,0 +1,19 @@
+{#
+/**
+* @file
+* Default theme implementation for an administration settings table.
+*
+* Available variables:
+* - title: A title for the table
+* - attributes: Remaining HTML attributes for the element.
+* - table: A render element representing a table of bundle content language
+* settings for a particular entity type.
+*
+* @see template_preprocess()
+* @see template_preprocess_language_content_settings_table()
+*
+* @ingroup themeable
+*/
+#}
+{{ title }}
+{{ table }}
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..da09b77
--- /dev/null
+++ b/core/modules/language/templates/language-negotiation-configure-form.html.twig
@@ -0,0 +1,30 @@
+{#
+/**
+* @file
+* Default theme implementation for a language negotiation configuration form.
+*
+* Available variables:
+* - form_items: @todo.
+* - children: @todo.
+*
+* @see template_preprocess()
+* @see template_preprocess_language_negotiation_configure_form()
+*
+* @ingroup themeable
+*/
+#}
+{% for form_item in form_items %}
+
+{% endfor %}
+{# Render any remaining form items like the save button.
+{% if children %}
+ {{ children }}
+{% endif %}
+
+ #}
+{{ form.children }}
\ No newline at end of file