Issue #2009008 by pplantinga, InternetDevels, duckx, benjifisher: Replace theme() with drupal_render() in field and field_ui() modules.

8.0.x
Alex Pott 2013-07-24 00:21:55 +02:00
parent 96868e967e
commit 2a1e1472c1
5 changed files with 38 additions and 19 deletions

View File

@ -25,9 +25,10 @@ function theme_field_multiple_value_form($variables) {
$output = ''; $output = '';
if ($element['#cardinality'] > 1 || $element['#cardinality'] == FIELD_CARDINALITY_UNLIMITED) { if ($element['#cardinality'] > 1 || $element['#cardinality'] == FIELD_CARDINALITY_UNLIMITED) {
$form_required_marker = array('#theme' => 'form_required_marker');
$required = !empty($element['#required']) ? drupal_render($form_required_marker) : '';
$table_id = drupal_html_id($element['#field_name'] . '_values'); $table_id = drupal_html_id($element['#field_name'] . '_values');
$order_class = $element['#field_name'] . '-delta-order'; $order_class = $element['#field_name'] . '-delta-order';
$required = !empty($element['#required']) ? theme('form_required_marker', $variables) : '';
$header = array( $header = array(
array( array(
@ -67,8 +68,17 @@ function theme_field_multiple_value_form($variables) {
); );
} }
$table = array(
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
'#attributes' => array(
'id' => $table_id,
'class' => array('field-multiple-table'),
),
);
$output = '<div class="form-item">'; $output = '<div class="form-item">';
$output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => $table_id, 'class' => array('field-multiple-table')))); $output .= drupal_render($table);
$output .= $element['#description'] ? '<div class="description">' . $element['#description'] . '</div>' : ''; $output .= $element['#description'] ? '<div class="description">' . $element['#description'] . '</div>' : '';
$output .= '<div class="clearfix">' . drupal_render($add_more_button) . '</div>'; $output .= '<div class="clearfix">' . drupal_render($add_more_button) . '</div>';
$output .= '</div>'; $output .= '</div>';

View File

@ -157,7 +157,11 @@ function field_help($path, $arg) {
$items['items'][] = $display; $items['items'][] = $display;
} }
} }
$output .= theme('item_list', $items) . '</dd>'; $item_list = array(
'#theme' => 'item_list',
'#items' => $items['items'],
);
$output .= drupal_render($item_list) . '</dd>';
$output .= '<dt>' . t('Managing field data storage') . '</dt>'; $output .= '<dt>' . t('Managing field data storage') . '</dt>';
$output .= '<dd>' . t('Developers of field modules can either use the default <a href="@sql-store">Field SQL Storage module</a> to store data for their fields, or a contributed or custom module developed using the <a href="@storage-api">field storage API</a>.', array('@storage-api' => 'http://api.drupal.org/api/group/field_storage/8', '@sql-store' => url('admin/help/field_sql_storage'))) . '</dd>'; $output .= '<dd>' . t('Developers of field modules can either use the default <a href="@sql-store">Field SQL Storage module</a> to store data for their fields, or a contributed or custom module developed using the <a href="@storage-api">field storage API</a>.', array('@storage-api' => 'http://api.drupal.org/api/group/field_storage/8', '@sql-store' => url('admin/help/field_sql_storage'))) . '</dd>';
$output .= '</dl>'; $output .= '</dl>';

View File

@ -624,12 +624,13 @@ class Field extends FieldPluginBase {
return implode(filter_xss_admin($this->options['separator']), $items); return implode(filter_xss_admin($this->options['separator']), $items);
} }
else { else {
return theme('item_list', $item_list = array(
array( '#theme' => 'item_list',
'items' => $items, '#items' => $items,
'title' => NULL, '#title' => NULL,
'list_type' => $this->options['multi_type'], '#list_type' => $this->options['multi_type'],
)); );
return drupal_render($item_list);
} }
} }
} }

View File

@ -355,19 +355,19 @@ function field_ui_view_mode_delete(EntityViewModeInterface $view_mode) {
*/ */
function theme_field_ui_table($variables) { function theme_field_ui_table($variables) {
$elements = $variables['elements']; $elements = $variables['elements'];
$table = array(); $table = array('#theme' => 'table');
// Add table headers and attributes. // Add table headers and attributes.
foreach (array('header', 'attributes') as $key) { foreach (array('#header', '#attributes') as $key) {
if (isset($elements["#$key"])) { if (isset($elements[$key])) {
$table[$key] = $elements["#$key"]; $table[$key] = $elements[$key];
} }
} }
// Determine the colspan to use for region rows, by checking the number of // Determine the colspan to use for region rows, by checking the number of
// columns in the headers. // columns in the headers.
$columns_count = 0; $columns_count = 0;
foreach ($table['header'] as $header) { foreach ($table['#header'] as $header) {
$columns_count += (is_array($header) && isset($header['colspan']) ? $header['colspan'] : 1); $columns_count += (is_array($header) && isset($header['colspan']) ? $header['colspan'] : 1);
} }
@ -377,7 +377,7 @@ function theme_field_ui_table($variables) {
// Add region rows. // Add region rows.
if (isset($region['title']) && empty($region['invisible'])) { if (isset($region['title']) && empty($region['invisible'])) {
$table['rows'][] = array( $table['#rows'][] = array(
'class' => array('region-title', 'region-' . $region_name_class . '-title'), 'class' => array('region-title', 'region-' . $region_name_class . '-title'),
'no_striping' => TRUE, 'no_striping' => TRUE,
'data' => array( 'data' => array(
@ -387,7 +387,7 @@ function theme_field_ui_table($variables) {
} }
if (isset($region['message'])) { if (isset($region['message'])) {
$class = (empty($region['rows_order']) ? 'region-empty' : 'region-populated'); $class = (empty($region['rows_order']) ? 'region-empty' : 'region-populated');
$table['rows'][] = array( $table['#rows'][] = array(
'class' => array('region-message', 'region-' . $region_name_class . '-message', $class), 'class' => array('region-message', 'region-' . $region_name_class . '-message', $class),
'no_striping' => TRUE, 'no_striping' => TRUE,
'data' => array( 'data' => array(
@ -417,10 +417,10 @@ function theme_field_ui_table($variables) {
$row['data'][] = $cell; $row['data'][] = $cell;
} }
} }
$table['rows'][] = $row; $table['#rows'][] = $row;
} }
} }
return theme('table', $table); return drupal_render($table);
} }

View File

@ -180,7 +180,11 @@ abstract class OverviewBase implements FormInterface, ControllerInterface {
if ($depth = count($parents[$name])) { if ($depth = count($parents[$name])) {
$children = element_children($row); $children = element_children($row);
$cell = current($children); $cell = current($children);
$row[$cell]['#prefix'] = theme('indentation', array('size' => $depth)) . (isset($row[$cell]['#prefix']) ? $row[$cell]['#prefix'] : ''); $indentation = array(
'#theme' => 'indentation',
'#size' => $depth,
);
$row[$cell]['#prefix'] = drupal_render($indentation) . (isset($row[$cell]['#prefix']) ? $row[$cell]['#prefix'] : '');
} }
// Add row id and associate JS settings. // Add row id and associate JS settings.