Issue #1918648 by mr.baileys, chrisjlee, steveoliver, joelpittet, jenlampton, Cottser: Convert theme_views_ui_style_plugin_table() to Twig .

8.0.x
webchick 2013-08-12 00:22:49 -07:00
parent 509c2b2d8b
commit 31a50d5be5
3 changed files with 49 additions and 20 deletions

View File

@ -0,0 +1,18 @@
{#
/**
* @file
* Default template for the settings of a table style views display.
*
* Available variables:
* - table: A table of options for each field in this display.
* - form: Any remaining form fields not included in the table.
* - description_markup: An overview for the settings of this display.
*
* @see template_preprocess_views_ui_style_plugin_table()
*
* @ingroup themeable
*/
#}
{{ form.description_markup }}
{{ table }}
{{ form }}

View File

@ -150,6 +150,7 @@ function views_ui_theme() {
'views_ui_style_plugin_table' => array( 'views_ui_style_plugin_table' => array(
'render element' => 'form', 'render element' => 'form',
'file' => 'views_ui.theme.inc', 'file' => 'views_ui.theme.inc',
'template' => 'views-ui-style-plugin-table',
), ),
// When previewing a view. // When previewing a view.

View File

@ -323,13 +323,17 @@ function theme_views_ui_rearrange_filter_form(&$variables) {
} }
/** /**
* Theme the form for the table style plugin * Prepares variables for style plugin table templates.
*/ *
function theme_views_ui_style_plugin_table($variables) { * Default template: views-ui-style-plugin-table.html.twig.
*
* @param array $variables
* An associative array containing:
* - form: A render element representing the form.
*/
function template_preprocess_views_ui_style_plugin_table(&$variables) {
$form = $variables['form']; $form = $variables['form'];
$output = drupal_render($form['description_markup']);
$header = array( $header = array(
t('Field'), t('Field'),
t('Column'), t('Column'),
@ -359,21 +363,22 @@ function theme_views_ui_style_plugin_table($variables) {
$rows = array(); $rows = array();
foreach (element_children($form['columns']) as $id) { foreach (element_children($form['columns']) as $id) {
$row = array(); $row = array();
$row[] = drupal_render($form['info'][$id]['name']); $row[]['data'] = $form['info'][$id]['name'];
$row[] = drupal_render($form['columns'][$id]); $row[]['data'] = $form['columns'][$id];
$row[] = drupal_render($form['info'][$id]['align']); $row[]['data'] = $form['info'][$id]['align'];
$row[] = drupal_render($form['info'][$id]['separator']); $row[]['data'] = $form['info'][$id]['separator'];
if (!empty($form['info'][$id]['sortable'])) { if (!empty($form['info'][$id]['sortable'])) {
$row[] = array( $row[] = array(
'data' => drupal_render($form['info'][$id]['sortable']), 'data' => $form['info'][$id]['sortable'],
'align' => 'center', 'align' => 'center',
); );
$row[] = array( $row[] = array(
'data' => drupal_render($form['info'][$id]['default_sort_order']), 'data' => $form['info'][$id]['default_sort_order'],
'align' => 'center', 'align' => 'center',
); );
$row[] = array( $row[] = array(
'data' => drupal_render($form['default'][$id]), 'data' => $form['default'][$id],
'align' => 'center', 'align' => 'center',
); );
} }
@ -383,27 +388,32 @@ function theme_views_ui_style_plugin_table($variables) {
$row[] = ''; $row[] = '';
} }
$row[] = array( $row[] = array(
'data' => drupal_render($form['info'][$id]['empty_column']), 'data' => $form['info'][$id]['empty_column'],
'align' => 'center', 'align' => 'center',
); );
$row[] = array( $row[] = array(
'data' => drupal_render($form['info'][$id]['responsive']), 'data' => $form['info'][$id]['responsive'],
'align' => 'center', 'align' => 'center',
); );
$rows[] = $row; $rows[] = $row;
} }
// Add the special 'None' row. // Add the special 'None' row.
$rows[] = array(t('None'), '', '', '', '', '', array('align' => 'center', 'data' => drupal_render($form['default'][-1])), '', ''); $rows[] = array(array('data' => t('None'), 'colspan' => 6), array('align' => 'center', 'data' => $form['default'][-1]), array('colspan' => 2));
$table = array( // Unset elements from the form array that are used to build the table so that
'#theme' => 'table', // they are not rendered twice.
unset($form['default']);
unset($form['info']);
unset($form['columns']);
$variables['table'] = array(
'#type' => 'table',
'#theme' => 'table__views_ui_style_plugin_table',
'#header' => $header, '#header' => $header,
'#rows' => $rows, '#rows' => $rows,
); );
$output .= drupal_render($table); $variables['form'] = $form;
$output .= drupal_render_children($form);
return $output;
} }
/** /**