diff --git a/core/modules/block/block.module b/core/modules/block/block.module index 8eeb57f..f865060 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -142,11 +142,6 @@ function block_menu() { 'type' => $key == $default_theme ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK, 'route_name' => "block_admin_display.$key", ); - $items["admin/structure/block/list/$key/add"] = array( - 'title' => 'Place blocks', - 'type' => MENU_LOCAL_ACTION, - 'route_name' => "block_plugin_ui.$key", - ); $items["admin/structure/block/demo/$key"] = array( 'title' => check_plain($theme->info['name']), 'page callback' => 'block_admin_demo', diff --git a/core/modules/block/css/block.admin.css b/core/modules/block/css/block.admin.css index 831ad44..40c7a04 100644 --- a/core/modules/block/css/block.admin.css +++ b/core/modules/block/css/block.admin.css @@ -31,3 +31,20 @@ a.block-demo-backlink:visited { a.block-demo-backlink:hover { text-decoration: underline; } + +.block-list-region { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} +.block-list-left { + float: left; + width: 65%; + padding-right: 2em; +} +.block-list-right { + float: right; + width: 35%; + background-color: #f7f7f7; + border-left: 1px solid #bfbfbf; +} diff --git a/core/modules/block/custom_block/custom_block.module b/core/modules/block/custom_block/custom_block.module index 2752ee8..985a977 100644 --- a/core/modules/block/custom_block/custom_block.module +++ b/core/modules/block/custom_block/custom_block.module @@ -16,7 +16,7 @@ function custom_block_menu_local_tasks(&$data, $router_item, $root_path) { // listing page. // @todo This should just be $root_path == 'admin/structure/block/list/%/add' // but block_menu() registers static router paths instead of dynamic ones. - if (preg_match('@^admin/structure/block/list/(.*)/add$@', $root_path)) { + if ($root_path == 'admin/structure/block' || preg_match('@^admin/structure/block/list/(.*)$@', $root_path)) { $item = menu_get_item('block/add'); if ($item['access']) { $data['actions']['block/add'] = array( @@ -93,21 +93,6 @@ function custom_block_menu() { } /** - * Implements hook_local_actions(). - */ -function custom_block_local_actions() { - return array( - array( - 'route_name' => 'custom_block_type_add', - 'title' => t('Add custom block type'), - 'appears_on' => array( - 'custom_block_type_list', - ), - ), - ); -} - -/** * Implements hook_theme(). */ function custom_block_theme($existing, $type, $theme, $path) { @@ -221,27 +206,6 @@ function custom_block_add_body_field($block_type_id, $label = 'Block body') { } /** - * Implements hook_form_FORM_ID_alter() for block_plugin_ui(). - */ -function custom_block_form_block_plugin_ui_alter(&$form, $form_state) { - foreach ($form['left']['plugin_library']['#rows'] as $plugin_id => &$row) { - // @todo Clean up when http://drupal.org/node/1874498 lands. - if (strpos($plugin_id, ':') === FALSE) { - continue; - } - list($base, $derivative) = explode(':', $plugin_id); - if ($base !== 'custom_block') { - continue; - } - $custom_block = entity_load_by_uuid('custom_block', $derivative); - $row['1']['data']['#links']['edit'] = array( - 'title' => t('Edit'), - 'href' => 'block/' . $custom_block->id(), - ); - } -} - -/** * Implements hook_admin_paths(). */ function custom_block_admin_paths() { diff --git a/core/modules/block/lib/Drupal/block/BlockListController.php b/core/modules/block/lib/Drupal/block/BlockListController.php index 9ba757b..57d93d4 100644 --- a/core/modules/block/lib/Drupal/block/BlockListController.php +++ b/core/modules/block/lib/Drupal/block/BlockListController.php @@ -81,8 +81,15 @@ 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['left']['#type'] = 'container'; + $form['left']['#attributes'] = array( + 'class' => array( + 'block-list-region', + 'block-list-left', + ), + ); - $form['block_regions'] = array( + $form['left']['block_regions'] = array( '#type' => 'value', '#value' => $block_regions_with_disabled, ); @@ -93,11 +100,11 @@ public function buildForm(array $form, array &$form_state) { $weight_delta = round(count($entities) / 2); // Build the form tree. - $form['edited_theme'] = array( + $form['left']['edited_theme'] = array( '#type' => 'value', '#value' => $this->theme, ); - $form['blocks'] = array( + $form['left']['blocks'] = array( '#type' => 'table', '#header' => array( t('Block'), @@ -123,7 +130,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['blocks']['#tabledrag'][] = array( + $form['left']['blocks']['#tabledrag'][] = array( 'match', 'sibling', 'block-region-select', @@ -131,27 +138,27 @@ public function buildForm(array $form, array &$form_state) { NULL, FALSE, ); - $form['blocks']['#tabledrag'][] = array( + $form['left']['blocks']['#tabledrag'][] = array( 'order', 'sibling', 'block-weight', 'block-weight-' . $region, ); - $form['blocks'][$region] = array( + $form['left']['blocks'][$region] = array( '#attributes' => array( 'class' => array('region-title', 'region-title-' . $region, 'odd'), 'no_striping' => TRUE, ), ); - $form['blocks'][$region]['title'] = array( + $form['left']['blocks'][$region]['title'] = array( '#markup' => $region != BLOCK_REGION_NONE ? $title : t('Disabled'), '#wrapper_attributes' => array( 'colspan' => 5, ), ); - $form['blocks'][$region . '-message'] = array( + $form['left']['blocks'][$region . '-message'] = array( '#attributes' => array( 'class' => array( 'region-message', @@ -160,7 +167,7 @@ public function buildForm(array $form, array &$form_state) { ), ), ); - $form['blocks'][$region . '-message']['message'] = array( + $form['left']['blocks'][$region . '-message']['message'] = array( '#markup' => '' . t('No blocks in this region') . '', '#wrapper_attributes' => array( 'colspan' => 5, @@ -171,19 +178,19 @@ public function buildForm(array $form, array &$form_state) { foreach ($blocks[$region] as $info) { $entity_id = $info['entity_id']; - $form['blocks'][$entity_id] = array( + $form['left']['blocks'][$entity_id] = array( '#attributes' => array( 'class' => array('draggable'), ), ); - $form['blocks'][$entity_id]['info'] = array( + $form['left']['blocks'][$entity_id]['info'] = array( '#markup' => check_plain($info['admin_label']), '#wrapper_attributes' => array( 'class' => array('block'), ), ); - $form['blocks'][$entity_id]['region-theme']['region'] = array( + $form['left']['blocks'][$entity_id]['region-theme']['region'] = array( '#type' => 'select', '#default_value' => $region, '#empty_value' => BLOCK_REGION_NONE, @@ -195,12 +202,12 @@ public function buildForm(array $form, array &$form_state) { ), '#parents' => array('blocks', $entity_id, 'region'), ); - $form['blocks'][$entity_id]['region-theme']['theme'] = array( + $form['left']['blocks'][$entity_id]['region-theme']['theme'] = array( '#type' => 'hidden', '#value' => $this->theme, '#parents' => array('blocks', $entity_id, 'theme'), ); - $form['blocks'][$entity_id]['weight'] = array( + $form['left']['blocks'][$entity_id]['weight'] = array( '#type' => 'weight', '#default_value' => $info['weight'], '#delta' => $weight_delta, @@ -210,29 +217,91 @@ public function buildForm(array $form, array &$form_state) { 'class' => array('block-weight', 'block-weight-' . $region), ), ); - $form['blocks'][$entity_id]['operations'] = $this->buildOperations($info['entity']); + $form['left']['blocks'][$entity_id]['operations'] = $this->buildOperations($info['entity']); } } } // Do not allow disabling the main system content block when it is present. - if (isset($form['blocks']['system_main']['region'])) { - $form['blocks']['system_main']['region']['#required'] = TRUE; + if (isset($form['left']['blocks']['system_main']['region'])) { + $form['left']['blocks']['system_main']['region']['#required'] = TRUE; } - $form['actions'] = array( + $form['left']['actions'] = array( '#tree' => FALSE, '#type' => 'actions', ); - $form['actions']['submit'] = array( + $form['left']['actions']['submit'] = array( '#type' => 'submit', '#value' => t('Save blocks'), '#button_type' => 'primary', ); + + $form['right']['#type'] = 'container'; + $form['right']['#attributes'] = array( + 'class' => array( + 'block-list-region', + 'block-list-right', + ), + ); + $form['right']['candidate_list'] = $this->getCandidateList(); return $form; } /** + * @todo. + * + * @return array + */ + protected function getCandidateList() { + $list['#type'] = 'container'; + $list['#attributes']['class'][] = 'entity-meta'; + + $list['title']['#type'] = 'container'; + $list['title']['#attributes']['class'][] = 'entity-meta-header'; + $list['title']['#children'] = '