diff --git a/core/modules/block/block.admin.inc b/core/modules/block/block.admin.inc index 7e6bcdb..b438c1f 100644 --- a/core/modules/block/block.admin.inc +++ b/core/modules/block/block.admin.inc @@ -153,8 +153,16 @@ function template_preprocess_block_admin_display_form(&$variables) { $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]->region_select = array( + 'region' => array( + 'data' => $block['region'], + '#weight' => 1, + ), + 'theme' => array( + 'data' => $block['theme'], + '#weight' => 2, + ), + ); $block_listing[$region][$i]->weight_select = $block['weight']; $block_listing[$region][$i]->operations = $block['operations']; $block_listing[$region][$i]->printed = FALSE; diff --git a/core/modules/block/block.module b/core/modules/block/block.module index 72f8200..c0d8c9e 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -6,6 +6,7 @@ */ use Drupal\Component\Plugin\Exception\PluginException; +use Drupal\Core\Template\Attribute; /** * Denotes that a block is not enabled in any region and should not be shown. @@ -515,27 +516,29 @@ function block_rebuild() { } /** - * Processes variables for block.tpl.php. + * Prepares variables for block templates. + * + * Default template: block.html.twig. * * Prepares the values passed to the theme_block function to be passed * into a pluggable template engine. Uses block properties to generate a * series of template file suggestions. If none are found, the default - * block.tpl.php is used. + * block.html.twig is used. * - * Most themes utilize their own copy of block.tpl.php. The default is located - * inside "modules/block/block.tpl.php". Look in there for the full list of + * Most themes utilize their own copy of block.html.twig. The default is located + * inside "modules/block/block.html.twig". Look in there for the full list of * variables. * - * The $variables array contains the following arguments: - * - $block - * - * @see block.tpl.php + * @param array $variables + * An associative array containing: + * - elements: An associative array containing the properties of the element. + * Properties used: #block, #block_config, #children. */ function template_preprocess_block(&$variables) { $block_counter = &drupal_static(__FUNCTION__, array()); $variables['block'] = (object) $variables['elements']['#block_config']; - $variables['subject'] = $variables['block']->subject; + $variables['label'] = check_plain($variables['elements']['#block']->label); // All blocks get an independent counter for each region. if (!isset($block_counter[$variables['block']->region])) { @@ -548,6 +551,9 @@ function template_preprocess_block(&$variables) { // Create the $content variable that templates expect. $variables['content'] = $variables['elements']['#children']; + $variables['attributes'] = new Attribute; + $variables['attributes']['class'] = array(); + $variables['attributes']['class'][] = 'block'; $variables['attributes']['class'][] = drupal_html_class('block-' . $variables['block']->module); $variables['theme_hook_suggestions'][] = 'block__' . $variables['block']->region; @@ -572,7 +578,7 @@ function template_preprocess_block(&$variables) { if ($id = $variables['elements']['#block']->id()) { $config_id = explode('.', $id); $machine_name = array_pop($config_id); - $variables['block_html_id'] = drupal_html_id('block-' . $machine_name); + $variables['attributes']['id'] = drupal_html_id('block-' . $machine_name); $variables['theme_hook_suggestions'][] = 'block__' . $machine_name; } } diff --git a/core/modules/block/templates/block.html.twig b/core/modules/block/templates/block.html.twig index 08eda19..01eb3c9 100644 --- a/core/modules/block/templates/block.html.twig +++ b/core/modules/block/templates/block.html.twig @@ -4,10 +4,10 @@ * Default theme implementation to display a container. * * Available variables: - * - subject: Block subject. + * - label: Block title. * - contents: The contents of this block. - * - attributes: Remaining html attributes for the containing element. - * - attributes.id: A valid html ID and guaranteed unique. + * - attributes: Remaining HTML attributes for the containing element. + * - attributes.id: A valid HTML ID and guaranteed unique. * - attributes.class: Classes that can be used to style contextually through * CSS. These can be manipulated through from preprocess functions. The * default values can be one or more of the following: @@ -37,10 +37,10 @@ @todo Remove the div around content - and make sure this doesn't break any CSS defined in modules. #} -