diff --git a/core/modules/block/block.module b/core/modules/block/block.module index a08254a..3cc1482 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -89,6 +89,10 @@ function block_theme() { 'render element' => 'elements', 'template' => 'block', ), + 'block_list' => array( + 'render element' => 'form', + 'template' => 'block-list', + ), ); } diff --git a/core/modules/block/css/block.admin.css b/core/modules/block/css/block.admin.css index 97581f3..fe1ef3e 100644 --- a/core/modules/block/css/block.admin.css +++ b/core/modules/block/css/block.admin.css @@ -32,7 +32,7 @@ a.block-demo-backlink:hover { text-decoration: underline; } -.block-list-region { +.layout-region { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; diff --git a/core/modules/block/lib/Drupal/block/BlockListController.php b/core/modules/block/lib/Drupal/block/BlockListController.php index 0d03d91..9d2ed6a 100644 --- a/core/modules/block/lib/Drupal/block/BlockListController.php +++ b/core/modules/block/lib/Drupal/block/BlockListController.php @@ -120,6 +120,7 @@ public function getFormID() { */ public function buildForm(array $form, array &$form_state) { $entities = $this->load(); + $form['#theme'] = array('block_list'); $form['#attached']['library'][] = array('system', 'drupal.tableheader'); $form['#attached']['library'][] = array('block', 'drupal.block'); $form['#attached']['library'][] = array('block', 'drupal.block.admin'); @@ -127,13 +128,7 @@ public function buildForm(array $form, array &$form_state) { // Add a last region for disabled blocks. $block_regions_with_disabled = $this->regions + array(BLOCK_REGION_NONE => BLOCK_REGION_NONE); - $form['primary']['#type'] = 'container'; - $form['primary']['#attributes']['class'] = array( - 'block-list-region', - 'block-list-primary', - ); - - $form['primary']['block_regions'] = array( + $form['block_regions'] = array( '#type' => 'value', '#value' => $block_regions_with_disabled, ); @@ -144,11 +139,11 @@ public function buildForm(array $form, array &$form_state) { $weight_delta = round(count($entities) / 2); // Build the form tree. - $form['primary']['edited_theme'] = array( + $form['edited_theme'] = array( '#type' => 'value', '#value' => $this->theme, ); - $form['primary']['blocks'] = array( + $form['blocks'] = array( '#type' => 'table', '#header' => array( t('Block'), @@ -174,7 +169,7 @@ public function buildForm(array $form, array &$form_state) { // Loop over each region and build blocks. foreach ($block_regions_with_disabled as $region => $title) { - $form['primary']['blocks']['#tabledrag'][] = array( + $form['blocks']['#tabledrag'][] = array( 'match', 'sibling', 'block-region-select', @@ -182,27 +177,27 @@ public function buildForm(array $form, array &$form_state) { NULL, FALSE, ); - $form['primary']['blocks']['#tabledrag'][] = array( + $form['blocks']['#tabledrag'][] = array( 'order', 'sibling', 'block-weight', 'block-weight-' . $region, ); - $form['primary']['blocks'][$region] = array( + $form['blocks'][$region] = array( '#attributes' => array( 'class' => array('region-title', 'region-title-' . $region, 'odd'), 'no_striping' => TRUE, ), ); - $form['primary']['blocks'][$region]['title'] = array( + $form['blocks'][$region]['title'] = array( '#markup' => $region != BLOCK_REGION_NONE ? $title : t('Disabled'), '#wrapper_attributes' => array( 'colspan' => 5, ), ); - $form['primary']['blocks'][$region . '-message'] = array( + $form['blocks'][$region . '-message'] = array( '#attributes' => array( 'class' => array( 'region-message', @@ -211,7 +206,7 @@ public function buildForm(array $form, array &$form_state) { ), ), ); - $form['primary']['blocks'][$region . '-message']['message'] = array( + $form['blocks'][$region . '-message']['message'] = array( '#markup' => '' . t('No blocks in this region') . '', '#wrapper_attributes' => array( 'colspan' => 5, @@ -222,19 +217,19 @@ public function buildForm(array $form, array &$form_state) { foreach ($blocks[$region] as $info) { $entity_id = $info['entity_id']; - $form['primary']['blocks'][$entity_id] = array( + $form['blocks'][$entity_id] = array( '#attributes' => array( 'class' => array('draggable'), ), ); - $form['primary']['blocks'][$entity_id]['info'] = array( + $form['blocks'][$entity_id]['info'] = array( '#markup' => check_plain($info['admin_label']), '#wrapper_attributes' => array( 'class' => array('block'), ), ); - $form['primary']['blocks'][$entity_id]['region-theme']['region'] = array( + $form['blocks'][$entity_id]['region-theme']['region'] = array( '#type' => 'select', '#default_value' => $region, '#empty_value' => BLOCK_REGION_NONE, @@ -246,12 +241,12 @@ public function buildForm(array $form, array &$form_state) { ), '#parents' => array('blocks', $entity_id, 'region'), ); - $form['primary']['blocks'][$entity_id]['region-theme']['theme'] = array( + $form['blocks'][$entity_id]['region-theme']['theme'] = array( '#type' => 'hidden', '#value' => $this->theme, '#parents' => array('blocks', $entity_id, 'theme'), ); - $form['primary']['blocks'][$entity_id]['weight'] = array( + $form['blocks'][$entity_id]['weight'] = array( '#type' => 'weight', '#default_value' => $info['weight'], '#delta' => $weight_delta, @@ -261,33 +256,27 @@ public function buildForm(array $form, array &$form_state) { 'class' => array('block-weight', 'block-weight-' . $region), ), ); - $form['primary']['blocks'][$entity_id]['operations'] = $this->buildOperations($info['entity']); + $form['blocks'][$entity_id]['operations'] = $this->buildOperations($info['entity']); } } } // Do not allow disabling the main system content block when it is present. - if (isset($form['primary']['blocks']['system_main']['region'])) { - $form['primary']['blocks']['system_main']['region']['#required'] = TRUE; + if (isset($form['blocks']['system_main']['region'])) { + $form['blocks']['system_main']['region']['#required'] = TRUE; } - $form['primary']['actions'] = array( + $form['actions'] = array( '#tree' => FALSE, '#type' => 'actions', ); - $form['primary']['actions']['submit'] = array( + $form['actions']['submit'] = array( '#type' => 'submit', '#value' => t('Save blocks'), '#button_type' => 'primary', ); - $form['secondary']['#type'] = 'container'; - $form['secondary']['#attributes']['class'] = array( - 'block-list-region', - 'block-list-secondary', - ); - - $form['secondary']['title'] = array( + $form['place_blocks']['title'] = array( '#type' => 'container', '#children' => '

' . t('Place blocks') . '

', '#attributes' => array( @@ -297,7 +286,7 @@ public function buildForm(array $form, array &$form_state) { ), ); - $form['secondary']['filter'] = array( + $form['place_blocks']['filter'] = array( '#type' => 'search', '#title' => t('Filter'), '#title_display' => 'invisible', @@ -310,8 +299,8 @@ public function buildForm(array $form, array &$form_state) { ), ); - $form['secondary']['list']['#type'] = 'container'; - $form['secondary']['list']['#attributes']['class'][] = 'entity-meta'; + $form['place_blocks']['list']['#type'] = 'container'; + $form['place_blocks']['list']['#attributes']['class'][] = 'entity-meta'; // Sort the plugins first by category, then by label. $plugins = $this->blockManager->getDefinitions(); @@ -323,8 +312,8 @@ public function buildForm(array $form, array &$form_state) { }); foreach ($plugins as $plugin_id => $plugin_definition) { $category = $plugin_definition['category']; - if (!isset($form['secondary']['list'][$category])) { - $form['secondary']['list'][$category] = array( + if (!isset($form['place_blocks']['list'][$category])) { + $form['place_blocks']['list'][$category] = array( '#type' => 'details', '#title' => $category, '#collapsed' => TRUE, @@ -339,7 +328,7 @@ public function buildForm(array $form, array &$form_state) { ), ); } - $form['secondary']['list'][$category]['content']['#links'][$plugin_id] = array( + $form['place_blocks']['list'][$category]['content']['#links'][$plugin_id] = array( 'title' => $plugin_definition['admin_label'], 'href' => 'admin/structure/block/add/' . $plugin_id . '/' . $this->theme, 'attributes' => array( diff --git a/core/modules/block/templates/block-list.html.twig b/core/modules/block/templates/block-list.html.twig new file mode 100644 index 0000000..873d192 --- /dev/null +++ b/core/modules/block/templates/block-list.html.twig @@ -0,0 +1,24 @@ +{# +/** + * @file + * Two column template for the block add/edit form. + * + * This template will be used when a block edit form specifies 'block_edit_form' + * as its #theme callback. Otherwise, by default, block add/edit forms will be + * themed by theme_form(). + * + * Available variables: + * - form: The block add/edit form. + * + * @ingroup themeable + */ +#} +{% hide(form.place_blocks) %} +
+
+ {{ form }} +
+
+ {{ form.place_blocks }} +
+