diff --git a/core/modules/block/block.admin.inc b/core/modules/block/block.admin.inc index e5e8d76..297f780 100644 --- a/core/modules/block/block.admin.inc +++ b/core/modules/block/block.admin.inc @@ -6,6 +6,7 @@ */ use Drupal\block\Plugin\Core\Entity\Block; +use Drupal\Core\Template\Attribute; /** * Page callback: Attaches CSS for the block region demo. @@ -111,15 +112,19 @@ function block_admin_block_delete_submit($form, &$form_state) { } /** - * Processes variables for block-admin-display-form.tpl.php. + * Prepares variables for block admin display form templates. * - * The $variables array contains the following arguments: - * - $form + * Default template: block-admin-display-form.html.twig. * - * @see block-admin-display.tpl.php - * @see theme_block_admin_display() + * @param array $variables + * An associative array containing: + * - form: A render element representing the form. */ function template_preprocess_block_admin_display_form(&$variables) { + $header = array(t('Block'), t('Region'), t('Weight'), t('Operations')); + // @todo Remove/refactor pending http://drupal.org/node/1920886. + $children = $variables['form']; + $variables['block_regions'] = $variables['form']['block_regions']['#value']; if (isset($variables['block_regions'][BLOCK_REGION_NONE])) { $variables['block_regions'][BLOCK_REGION_NONE] = t('Disabled'); @@ -127,11 +132,11 @@ function template_preprocess_block_admin_display_form(&$variables) { foreach ($variables['block_regions'] as $key => $value) { // Initialize an empty array for the region. - $variables['block_listing'][$key] = array(); + $block_listing[$key] = array(); } // Initialize disabled blocks array. - $variables['block_listing'][BLOCK_REGION_NONE] = array(); + $block_listing[BLOCK_REGION_NONE] = array(); // Add each block in the form to the appropriate place in the block listing. foreach (element_children($variables['form']['blocks']) as $i) { @@ -144,15 +149,53 @@ function template_preprocess_block_admin_display_form(&$variables) { $block['region']['#attributes']['class'] = array('block-region-select', 'block-region-' . $region); $block['weight']['#attributes']['class'] = array('block-weight', 'block-weight-' . $region); - $variables['block_listing'][$region][$i] = new stdClass(); - $variables['block_listing'][$region][$i]->row_class = !empty($block['#attributes']['class']) ? implode(' ', $block['#attributes']['class']) : ''; - $variables['block_listing'][$region][$i]->block_modified = !empty($block['#attributes']['class']) && in_array('block-modified', $block['#attributes']['class']); - $variables['block_listing'][$region][$i]->block_title = drupal_render($block['info']); - $variables['block_listing'][$region][$i]->region_select = drupal_render($block['region']) . drupal_render($block['theme']); - $variables['block_listing'][$region][$i]->weight_select = drupal_render($block['weight']); - $variables['block_listing'][$region][$i]->operations = drupal_render($block['operations']); - $variables['block_listing'][$region][$i]->printed = FALSE; + $block_listing[$region][$i] = new stdClass(); + $block_listing[$region][$i]->row_class = !empty($block['#attributes']['class']) ? implode(' ', $block['#attributes']['class']) : ''; + $block_listing[$region][$i]->block_modified = !empty($block['#attributes']['class']) && in_array('block-modified', $block['#attributes']['class']); + $block_listing[$region][$i]->block_title = $block['info']; + // @todo Remove these drupal_render() calls. + $block_listing[$region][$i]->region_select = drupal_render($block['region']) . drupal_render($block['theme']); + $block_listing[$region][$i]->weight_select = $block['weight']; + $block_listing[$region][$i]->operations = $block['operations']; + $block_listing[$region][$i]->printed = FALSE; } - $variables['form_submit'] = drupal_render_children($variables['form']); + $rows = array(); + foreach ($block_listing as $region => $block_list) { + $rows[] = array( + 'data' => array( + array('data' => t($variables['block_regions'][$region]), 'colspan' => 4), + ), + 'class' => array('region-title region-title-' . $region) + ); + $rows[] = array( + 'data' => array( + array('data' => ''. t('No blocks in this region ') . '', 'colspan' => 4), + ), + 'class' => array('region-message', 'region-' . $region . '-message', empty($block_listing[$region]) ? 'region-empty' : 'region-populated') + ); + foreach ($block_list as $key => $block) { + $rows[] = array( + 'data' => array( + array('data' => $block->block_title), + array('data' => $block->region_select), + array('data' => $block->weight_select), + array('data' => $block->operations), + ), + 'class' => array('draggable'), + ); + } + } + $attributes = new Attribute(array('id' => 'blocks')); + drupal_add_tabledrag('blocks', 'order', 'sibling', 'block-weight'); + $variables['table'] = array( + '#theme' => 'table', + '#header' => $header, + '#rows' => $rows, + '#attributes' => $attributes, + ); + // Remove elements from the 'children' render array. + // @todo Refactor when http://drupal.org/node/1920886 is resolved. + unset($children['blocks'], $children['block_regions']); + $variables['children'] = drupal_render_children($children); } diff --git a/core/modules/block/block.module b/core/modules/block/block.module index ff804b2..cbf907c 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -535,6 +535,7 @@ function template_preprocess_block(&$variables) { $block_counter = &drupal_static(__FUNCTION__, array()); $variables['block'] = (object) $variables['elements']['#block_config']; + $variables['subject'] = $variables['block']->subject; // All blocks get an independent counter for each region. if (!isset($block_counter[$variables['block']->region])) { @@ -549,9 +550,6 @@ function template_preprocess_block(&$variables) { $variables['attributes']['class'][] = drupal_html_class('block-' . $variables['block']->module); - // Add default class for block content. - $variables['content_attributes']['class'][] = 'content'; - $variables['theme_hook_suggestions'][] = 'block__' . $variables['block']->region; $variables['theme_hook_suggestions'][] = 'block__' . $variables['block']->module; // Hyphens (-) and underscores (_) play a special role in theme suggestions. diff --git a/core/modules/block/templates/block-admin-display-form.html.twig b/core/modules/block/templates/block-admin-display-form.html.twig index 23d7064..0a9fbc9 100644 --- a/core/modules/block/templates/block-admin-display-form.html.twig +++ b/core/modules/block/templates/block-admin-display-form.html.twig @@ -4,54 +4,14 @@ * Default theme implementation to configure blocks. * * Available variables: - * - block_regions: An array of regions. Keyed by name with the title as value. - * - block_listing: An array of blocks keyed by region and then delta. - * - form_submit: A renderable form submit button. - * - * Each block_listing[region] contains an array of blocks for that region. - * - * Each data in block_listing[region] contains: - * - data.region_title: Region title for the listed block. - * - data.block_title: Block title. - * - data.region_select: Drop-down menu for assigning a region. - * - data.weight_select: Drop-down menu for setting weights. - * - data.configure_link: Block configuration link. - * - data.delete_link: For deleting user added blocks. + * - table: Draggable table containing blocks. + * - children: Child elements of the form that still need to be printed. * * @see template_preprocess() * @see template_preprocess_block_admin_display_form() - * @see theme_block_admin_display() * * @ingroup themeable */ #} - - - - - - - - - - - {% for region, title in block_regions %} - - - - - - - {% for delta, data in block_listing[region] %} - - - - - - - - {% endfor %} - {% endfor %} - -
{{ 'Block' | t }}{{ 'Region' | t }}{{ 'Weight' | t }}{{ 'Operations' | t }}
{{ title }}
{{ 'No blocks in this region' | t }}
{{ data.block_title }}{{ data.region_select }}{{ data.weight_select }}{{ data.configure_link }}{{ data.delete_link }}
-{{ render_var(form_submit) }} +{{ table }} +{{ children }} diff --git a/core/modules/block/templates/block.html.twig b/core/modules/block/templates/block.html.twig index 3da287c..1fc3256 100644 --- a/core/modules/block/templates/block.html.twig +++ b/core/modules/block/templates/block.html.twig @@ -33,18 +33,18 @@ * * @ingroup themeable */ - @todo: remove the ID since blocks can be added more than once on a page. - @todo: remove the div around content - and make sure this doesn't break any + @todo Remove the ID since blocks can be added more than once on a page. + @todo Remove the div around content - and make sure this doesn't break any CSS defined in modules. #} -
+
{{ title_prefix }} {% if subject %} {{ subject }} {% endif %} {{ title_suffix }} -
+
{{ content }}