summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDries2013-08-15 15:28:57 (GMT)
committerDries2013-08-15 15:28:57 (GMT)
commitd6ba81b6d5f8445abd71b96db4760e68739f424d (patch)
tree13074bb76f3d4ff70ed72614f06fe8bfcdd2d26a
parentcd15b235db7353771053ad56018e4a65abffdd6f (diff)
Issue #2058321 by tim.plunkett, pameeela: Move the 'place block' UI into the block listing.
-rw-r--r--core/modules/block/block.admin.inc4
-rw-r--r--core/modules/block/block.module23
-rw-r--r--core/modules/block/block.routing.yml7
-rw-r--r--core/modules/block/css/block.admin.css84
-rw-r--r--core/modules/block/custom_block/custom_block.local_actions.yml6
-rw-r--r--core/modules/block/custom_block/custom_block.module47
-rw-r--r--core/modules/block/lib/Drupal/block/BlockListController.php164
-rw-r--r--core/modules/block/lib/Drupal/block/Controller/BlockAutocompleteController.php78
-rw-r--r--core/modules/block/lib/Drupal/block/Form/PlaceBlocksForm.php157
-rw-r--r--core/modules/block/lib/Drupal/block/Routing/RouteSubscriber.php12
-rw-r--r--core/modules/block/lib/Drupal/block/Tests/BlockLanguageCacheTest.php2
-rw-r--r--core/modules/block/lib/Drupal/block/Tests/BlockLibrarySearchTest.php60
-rw-r--r--core/modules/block/lib/Drupal/block/Tests/BlockTest.php2
-rw-r--r--core/modules/block/lib/Drupal/block/Tests/BlockTitleXSSTest.php2
-rw-r--r--core/modules/block/lib/Drupal/block/Tests/BlockUiTest.php25
-rw-r--r--core/modules/block/tests/modules/block_test/block_test.module9
-rw-r--r--core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php4
-rw-r--r--core/modules/system/css/system.plugin.ui.css29
-rw-r--r--core/modules/system/lib/Drupal/system/Plugin/Block/SystemMenuBlock.php1
-rw-r--r--core/modules/system/system.module17
-rw-r--r--core/modules/system/templates/system-plugin-ui-form.html.twig30
-rw-r--r--core/modules/views/lib/Drupal/views/Tests/Wizard/BasicTest.php2
-rw-r--r--core/modules/views/lib/Drupal/views/Tests/Wizard/ItemsPerPageTest.php2
-rw-r--r--core/modules/views_ui/lib/Drupal/views_ui/Tests/OverrideDisplaysTest.php4
-rw-r--r--core/themes/seven/style.css6
25 files changed, 303 insertions, 474 deletions
diff --git a/core/modules/block/block.admin.inc b/core/modules/block/block.admin.inc
index 093769e..f849833 100644
--- a/core/modules/block/block.admin.inc
+++ b/core/modules/block/block.admin.inc
@@ -16,7 +16,9 @@ use Drupal\Core\Template\Attribute;
function block_admin_demo($theme = NULL) {
return array(
'#attached' => array(
- 'css' => array(drupal_get_path('module', 'block') . '/css/block.admin.css'),
+ 'library' => array(
+ array('block', 'drupal.block.admin'),
+ ),
),
);
}
diff --git a/core/modules/block/block.module b/core/modules/block/block.module
index db3a82a..361a33a 100644
--- a/core/modules/block/block.module
+++ b/core/modules/block/block.module
@@ -61,7 +61,7 @@ function block_help($path, $arg) {
$output .= '<dd>' . t('Blocks can be configured to be visible only on certain pages, only to users of certain roles, or only on pages displaying certain <a href="@content-type">content types</a>. Some dynamic blocks, such as those generated by modules, will be displayed only on certain pages.', array('@content-type' => url('admin/structure/types'), '@user' => url('user'))) . '</dd>';
if (module_exists('custom_block')) {
$output .= '<dt>' . t('Creating custom blocks') . '</dt>';
- $output .= '<dd>' . t('Users with the <em>Administer blocks</em> permission can <a href="@block-add">add custom blocks</a>, which are then listed on the <a href="@blocks">Blocks administration page</a>. Once created, custom blocks behave just like default and module-generated blocks.', array('@blocks' => url('admin/structure/block'), '@block-add' => url('admin/structure/block/list/' . Drupal::config('system.theme')->get('default') . '/add/custom_blocks'))) . '</dd>';
+ $output .= '<dd>' . t('Users with the <em>Administer blocks</em> permission can add custom blocks, which are then listed on the <a href="@blocks">Blocks administration page</a>. Once created, custom blocks behave just like default and module-generated blocks.', array('@blocks' => url('admin/structure/block'))) . '</dd>';
}
$output .= '</dl>';
return $output;
@@ -74,7 +74,7 @@ function block_help($path, $arg) {
$demo_theme = Drupal::config('system.theme')->get('default');
}
$themes = list_themes();
- $output = '<p>' . t('This page provides a drag-and-drop interface for assigning a block to a region, and for controlling the order of blocks within regions. Since not all themes implement the same regions, or display regions in the same way, blocks are positioned on a per-theme basis. Remember that your changes will not be saved until you click the <em>Save blocks</em> button at the bottom of the page. Click the <em>configure</em> link next to each block to configure its specific title and visibility settings.') . '</p>';
+ $output = '<p>' . t('This page provides a drag-and-drop interface for adding a block to a region, and for controlling the order of blocks within regions. To add a block to a region, or to configure its specific title and visibility settings, click the block title under <em>Place blocks</em>. Since not all themes implement the same regions, or display regions in the same way, blocks are positioned on a per-theme basis. Remember that your changes will not be saved until you click the <em>Save blocks</em> button at the bottom of the page.') . '</p>';
$output .= '<p>' . l(t('Demonstrate block regions (@theme)', array('@theme' => $themes[$demo_theme]->info['name'])), 'admin/structure/block/demo/' . $demo_theme) . '</p>';
return $output;
}
@@ -147,11 +147,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',
@@ -636,6 +631,20 @@ function block_library_info() {
array('system', 'drupal'),
),
);
+ $libraries['drupal.block.admin'] = array(
+ 'title' => 'Block admin',
+ 'version' => VERSION,
+ 'js' => array(
+ drupal_get_path('module', 'block') . '/js/block.admin.js' => array(),
+ ),
+ 'css' => array(
+ drupal_get_path('module', 'block') . '/css/block.admin.css' => array(),
+ ),
+ 'dependencies' => array(
+ array('system', 'jquery'),
+ array('system', 'drupal'),
+ ),
+ );
return $libraries;
}
diff --git a/core/modules/block/block.routing.yml b/core/modules/block/block.routing.yml
index 669e0a2..cabd4cb 100644
--- a/core/modules/block/block.routing.yml
+++ b/core/modules/block/block.routing.yml
@@ -26,10 +26,3 @@ block_admin_add:
_content: '\Drupal\block\Controller\BlockAddController::blockAddConfigureForm'
requirements:
_permission: 'administer blocks'
-
-block_autocomplete:
- pattern: '/block/autocomplete'
- defaults:
- _controller: '\Drupal\block\Controller\BlockAutocompleteController::autocomplete'
- requirements:
- _permission: 'administer blocks'
diff --git a/core/modules/block/css/block.admin.css b/core/modules/block/css/block.admin.css
index 831ad44..7cd9233 100644
--- a/core/modules/block/css/block.admin.css
+++ b/core/modules/block/css/block.admin.css
@@ -31,3 +31,87 @@ 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-right {
+ border: 1px solid #bfbfbf;
+ border-bottom-width: 0;
+}
+.block-list {
+ padding: 0 0.75em;
+ margin: 0;
+}
+.block-list li {
+ list-style: none;
+ padding: 0.1em 0;
+}
+.block-list a:before {
+ content: '+ ';
+}
+.block-list-right .form-type-search {
+ padding: 0 1em;
+}
+
+/* Wide screens */
+@media
+screen and (min-width: 780px),
+(orientation: landscape) and (min-device-height: 780px) {
+
+ .block-list-left {
+ float: left; /* LTR */
+ width: 75%;
+ padding-right: 2em;
+ }
+ [dir="rtl"] .block-list-left {
+ float: right;
+ padding-left: 2em;
+ padding-right: 0;
+ }
+
+ .block-list-right {
+ float: right; /* LTR */
+ width: 25%;
+ }
+ [dir="rtl"] .block-list-right {
+ float: left;
+ }
+
+ /* @todo File an issue to add a standard class to all text-like inputs */
+ .block-list-right .form-autocomplete,
+ .block-list-right .form-text,
+ .block-list-right .form-tel,
+ .block-list-right .form-email,
+ .block-list-right .form-url,
+ .block-list-right .form-search,
+ .block-list-right .form-number,
+ .block-list-right .form-color,
+ .block-list-right textarea {
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+ width: 100%;
+ max-width: 100%;
+ }
+}
+
+/**
+ * The vertical toolbar mode gets triggered for narrow screens, which throws off
+ * the intent of media queries written for the viewport width. When the vertical
+ * toolbar is on, we need to suppress layout for the original media width + the
+ * toolbar width (240px). In this case, 240px + 780px.
+ */
+@media
+screen and (max-width: 1020px),
+(orientation: landscape) and (max-device-height: 1020px) {
+
+ .toolbar-vertical .block-list-left,
+ .toolbar-vertical .block-list-right {
+ float: none;
+ width: auto;
+ padding-right: 0;
+ }
+}
diff --git a/core/modules/block/custom_block/custom_block.local_actions.yml b/core/modules/block/custom_block/custom_block.local_actions.yml
index b272691..8331445 100644
--- a/core/modules/block/custom_block/custom_block.local_actions.yml
+++ b/core/modules/block/custom_block/custom_block.local_actions.yml
@@ -3,3 +3,9 @@ custom_block_type_add:
title: 'Add custom block type'
appears_on:
- custom_block_type_list
+
+custom_block_add_action:
+ route_name: custom_block_add_page
+ title: 'Add custom block'
+ appears_on:
+ - block_admin_display
diff --git a/core/modules/block/custom_block/custom_block.module b/core/modules/block/custom_block/custom_block.module
index e7d96f4..0af9077 100644
--- a/core/modules/block/custom_block/custom_block.module
+++ b/core/modules/block/custom_block/custom_block.module
@@ -31,19 +31,6 @@ function custom_block_help($path, $arg) {
* Implements hook_menu_local_tasks().
*/
function custom_block_menu_local_tasks(&$data, $router_item, $root_path) {
- // Add the "Add custom block" action link to the theme-specific block library
- // 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)) {
- $item = menu_get_item('block/add');
- if ($item['access']) {
- $data['actions']['block/add'] = array(
- '#theme' => 'menu_local_action',
- '#link' => $item,
- );
- }
- }
if ($router_item['route_name'] == 'custom_block_list') {
// @todo Move to a LocalAction plugin when https://drupal.org/node/2045267
// allows local actions to work with query strings.
@@ -60,6 +47,19 @@ function custom_block_menu_local_tasks(&$data, $router_item, $root_path) {
}
/**
+ * Implements hook_menu_local_actions_alter().
+ */
+function custom_block_menu_local_actions_alter(&$actions) {
+ if (isset($actions['local_action_static:custom_block_add_action'])) {
+ foreach (list_themes() as $theme => $theme_info) {
+ if ($theme_info->status) {
+ $actions['local_action_static:custom_block_add_action']['appears_on'][] = "block_admin_display.$theme";
+ }
+ }
+ }
+}
+
+/**
* Implements hook_menu().
*/
function custom_block_menu() {
@@ -247,27 +247,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 8452eb4..b222fb6 100644
--- a/core/modules/block/lib/Drupal/block/BlockListController.php
+++ b/core/modules/block/lib/Drupal/block/BlockListController.php
@@ -7,15 +7,20 @@
namespace Drupal\block;
+use Drupal\Component\Plugin\PluginManagerInterface;
+use Drupal\Component\Utility\Json;
use Drupal\Core\Config\Entity\ConfigEntityListController;
-use Drupal\block\Plugin\Core\Entity\Block;
+use Drupal\Core\Entity\EntityControllerInterface;
use Drupal\Core\Entity\EntityInterface;
+use Drupal\Core\Entity\EntityStorageControllerInterface;
+use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Form\FormInterface;
+use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Defines the block list controller.
*/
-class BlockListController extends ConfigEntityListController implements FormInterface {
+class BlockListController extends ConfigEntityListController implements FormInterface, EntityControllerInterface {
/**
* The regions containing the blocks.
@@ -32,6 +37,46 @@ class BlockListController extends ConfigEntityListController implements FormInte
protected $theme;
/**
+ * The block manager.
+ *
+ * @var \Drupal\Component\Plugin\PluginManagerInterface
+ */
+ protected $blockManager;
+
+ /**
+ * Constructs a new BlockListController object.
+ *
+ * @param string $entity_type
+ * The type of entity to be listed.
+ * @param array $entity_info
+ * An array of entity info for the entity type.
+ * @param \Drupal\Core\Entity\EntityStorageControllerInterface $storage
+ * The entity storage controller class.
+ * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
+ * The module handler to invoke hooks on.
+ * @param \Drupal\Component\Plugin\PluginManagerInterface $block_manager
+ * The block manager.
+ */
+ public function __construct($entity_type, array $entity_info, EntityStorageControllerInterface $storage, ModuleHandlerInterface $module_handler, PluginManagerInterface $block_manager) {
+ parent::__construct($entity_type, $entity_info, $storage, $module_handler);
+
+ $this->blockManager = $block_manager;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) {
+ return new static(
+ $entity_type,
+ $entity_info,
+ $container->get('plugin.manager.entity')->getStorageController($entity_type),
+ $container->get('module_handler'),
+ $container->get('plugin.manager.block')
+ );
+ }
+
+ /**
* Overrides \Drupal\Core\Config\Entity\ConfigEntityListController::load().
*/
public function load() {
@@ -75,14 +120,20 @@ class BlockListController extends ConfigEntityListController implements FormInte
*/
public function buildForm(array $form, array &$form_state) {
$entities = $this->load();
- $form['#attached']['css'][] = drupal_get_path('module', 'block') . '/css/block.admin.css';
$form['#attached']['library'][] = array('system', 'drupal.tableheader');
$form['#attached']['library'][] = array('block', 'drupal.block');
+ $form['#attached']['library'][] = array('block', 'drupal.block.admin');
+ $form['#attributes']['class'][] = 'clearfix';
// 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']['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 +144,11 @@ class BlockListController extends ConfigEntityListController implements FormInte
$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 +174,7 @@ class BlockListController extends ConfigEntityListController implements FormInte
// 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 +182,27 @@ class BlockListController extends ConfigEntityListController implements FormInte
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 +211,7 @@ class BlockListController extends ConfigEntityListController implements FormInte
),
),
);
- $form['blocks'][$region . '-message']['message'] = array(
+ $form['left']['blocks'][$region . '-message']['message'] = array(
'#markup' => '<em>' . t('No blocks in this region') . '</em>',
'#wrapper_attributes' => array(
'colspan' => 5,
@@ -171,19 +222,19 @@ class BlockListController extends ConfigEntityListController implements FormInte
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 +246,12 @@ class BlockListController extends ConfigEntityListController implements FormInte
),
'#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,25 +261,94 @@ class BlockListController extends ConfigEntityListController implements FormInte
'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']['class'] = array(
+ 'block-list-region',
+ 'block-list-right',
+ );
+
+ $form['right']['list']['#type'] = 'container';
+ $form['right']['list']['#attributes']['class'][] = 'entity-meta';
+
+ $form['right']['list']['title'] = array(
+ '#type' => 'container',
+ '#children' => '<h3>' . t('Place blocks') . '</h3>',
+ '#attributes' => array(
+ 'class' => array(
+ 'entity-meta-header',
+ ),
+ ),
+ );
+ $form['right']['list']['search'] = array(
+ '#type' => 'search',
+ '#title' => t('Filter'),
+ '#title_display' => 'invisible',
+ '#size' => 30,
+ '#placeholder' => t('Filter by block name'),
+ '#attributes' => array(
+ 'class' => array('block-filter-text'),
+ 'data-element' => '.entity-meta',
+ 'title' => t('Enter a part of the block name to filter by.'),
+ ),
+ );
+
+ // Sort the plugins first by category, then by label.
+ $plugins = $this->blockManager->getDefinitions();
+ uasort($plugins, function ($a, $b) {
+ if ($a['category'] != $b['category']) {
+ return strnatcasecmp($a['category'], $b['category']);
+ }
+ return strnatcasecmp($a['admin_label'], $b['admin_label']);
+ });
+ foreach ($plugins as $plugin_id => $plugin_definition) {
+ $category = $plugin_definition['category'];
+ if (!isset($form['right']['list'][$category])) {
+ $form['right']['list'][$category] = array(
+ '#type' => 'details',
+ '#title' => $category,
+ 'content' => array(
+ '#theme' => 'links',
+ '#links' => array(),
+ '#attributes' => array(
+ 'class' => array(
+ 'block-list',
+ ),
+ ),
+ ),
+ );
+ }
+ $form['right']['list'][$category]['content']['#links'][$plugin_id] = array(
+ 'title' => $plugin_definition['admin_label'],
+ 'href' => 'admin/structure/block/add/' . $plugin_id . '/' . $this->theme,
+ 'attributes' => array(
+ 'class' => array('use-ajax', 'block-filter-text-source'),
+ 'data-accepts' => 'application/vnd.drupal-modal',
+ 'data-dialog-options' => Json::encode(array(
+ 'width' => 700,
+ )),
+ ),
+ );
+ }
return $form;
}
diff --git a/core/modules/block/lib/Drupal/block/Controller/BlockAutocompleteController.php b/core/modules/block/lib/Drupal/block/Controller/BlockAutocompleteController.php
deleted file mode 100644
index 539a8c1..0000000
--- a/core/modules/block/lib/Drupal/block/Controller/BlockAutocompleteController.php
+++ /dev/null
@@ -1,78 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \Drupal\block\Controller\BlockAutocompleteController.
- */
-
-namespace Drupal\block\Controller;
-
-use Drupal\Component\Plugin\PluginManagerInterface;
-use Drupal\Component\Utility\Tags;
-use Drupal\Component\Utility\Unicode;
-use Drupal\Core\Controller\ControllerInterface;
-use Symfony\Component\DependencyInjection\ContainerInterface;
-use Symfony\Component\HttpFoundation\JsonResponse;
-use Symfony\Component\HttpFoundation\Request;
-
-/**
- * Provides an autocomplete for blocks.
- */
-class BlockAutocompleteController implements ControllerInterface {
-
- /**
- * The block plugin manager.
- *
- * @var \Drupal\Component\Plugin\PluginManagerInterface
- */
- protected $manager;
-
- /**
- * Constructs a new BlockAutocompleteController object.
- *
- * @param \Drupal\Component\Plugin\PluginManagerInterface $manager
- * The block plugin manager.
- */
- public function __construct(PluginManagerInterface $manager) {
- $this->manager = $manager;
- }
-
- /**
- * {@inheritdoc}
- */
- public static function create(ContainerInterface $container) {
- return new static(
- $container->get('plugin.manager.block')
- );
- }
-
- /**
- * Autocompletes a block plugin ID.
- *
- * @param \Symfony\Component\HttpFoundation\Request $request
- * The request object.
- *
- * @return \Symfony\Component\HttpFoundation\JsonResponse
- * The matched plugins as JSON.
- */
- public function autocomplete(Request $request) {
- $string_typed = $request->query->get('q');
- // The passed string may be comma or space separated.
- $string_typed = Tags::explode($string_typed);
- // Take the last result and lowercase it.
- $string = Unicode::strtolower(array_pop($string_typed));
- $matches = array();
- if ($string) {
- $titles = array();
- // Gather all block plugins and their admin titles.
- foreach($this->manager->getDefinitions() as $plugin_id => $plugin) {
- $titles[$plugin_id] = $plugin['admin_label'];
- }
- // Find any matching block plugin IDs.
- $matches = preg_grep("/\b". $string . "/i", $titles);
- }
-
- return new JsonResponse($matches);
- }
-
-}
diff --git a/core/modules/block/lib/Drupal/block/Form/PlaceBlocksForm.php b/core/modules/block/lib/Drupal/block/Form/PlaceBlocksForm.php
deleted file mode 100644
index ffc4b9e..0000000
--- a/core/modules/block/lib/Drupal/block/Form/PlaceBlocksForm.php
+++ /dev/null
@@ -1,157 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \Drupal\block\Form\PlaceBlocksForm.
- */
-
-namespace Drupal\block\Form;
-
-use Drupal\Component\Plugin\PluginManagerInterface;
-use Drupal\Component\Utility\String;
-use Drupal\Core\Controller\ControllerInterface;
-use Drupal\Core\Form\FormInterface;
-use Symfony\Component\DependencyInjection\ContainerInterface;
-
-/**
- * Provides the 'Place blocks' form.
- */
-class PlaceBlocksForm implements FormInterface, ControllerInterface {
-
- /**
- * The block plugin manager.
- *
- * @var \Drupal\Component\Plugin\PluginManagerInterface
- */
- protected $manager;
-
- /**
- * The theme this block will be placed into.
- *
- * @var string
- */
- protected $theme;
-
- /**
- * Constructs a new PlaceBlocksForm object.
- *
- * @param \Drupal\Component\Plugin\PluginManagerInterface $manager
- * The block plugin manager.
- */
- public function __construct(PluginManagerInterface $manager) {
- $this->manager = $manager;
- }
-
- /**
- * {@inheritdoc}
- */
- public static function create(ContainerInterface $container) {
- return new static(
- $container->get('plugin.manager.block')
- );
- }
-
- /**
- * {@inheritdoc}
- */
- public function getFormID() {
- return 'block_plugin_ui';
- }
-
- /**
- * {@inheritdoc}
- */
- public function buildForm(array $form, array &$form_state, $theme = NULL, $category = NULL) {
- $this->theme = $theme;
- $form['#theme'] = 'system_plugin_ui_form';
- $rows = array();
- $categories = array();
- foreach ($this->manager->getDefinitions() as $plugin_id => $plugin_definition) {
- if (empty($category) || $plugin_definition['category'] == $category) {
- $rows[$plugin_id] = $this->row($plugin_id, $plugin_definition);
- }
- $categories[$plugin_definition['category']] = array(
- 'title' => $plugin_definition['category'],
- 'href' => 'admin/structure/block/list/' . $this->theme . '/add/' . $plugin_definition['category'],
- );
- }
-
- $form['right']['block'] = array(
- '#type' => 'textfield',
- '#title' => t('Search'),
- '#autocomplete_path' => 'block/autocomplete',
- );
- $form['right']['submit'] = array(
- '#type' => 'submit',
- '#button_type' => 'primary',
- '#value' => t('Next'),
- );
- $form['right']['all_plugins'] = array(
- '#type' => 'link',
- '#title' => t('All blocks'),
- '#href' => 'admin/structure/block/list/' . $this->theme . '/add',
- );
- if (!empty($categories)) {
- $form['right']['categories'] = array(
- '#theme' => 'links',
- '#heading' => array(
- 'text' => t('Categories'),
- 'level' => 'h3',
- ),
- '#links' => $categories,
- );
- }
-
- // Sort rows alphabetically.
- asort($rows);
- $form['left']['plugin_library'] = array(
- '#theme' => 'table',
- '#header' => array(t('Subject'), t('Operations')),
- '#rows' => $rows,
- );
- return $form;
- }
-
- /**
- * Generates the row data for a single block plugin.
- *
- * @param string $plugin_id
- * The plugin ID.
- * @param array $plugin_definition
- * The plugin definition.
- *
- * @return array
- * The row data for a single block plugin.
- */
- protected function row($plugin_id, array $plugin_definition) {
- $row = array();
- $row[] = String::checkPlain($plugin_definition['admin_label']);
- $row[] = array('data' => array(
- '#type' => 'operations',
- '#links' => array(
- 'configure' => array(
- 'title' => t('Place block'),
- 'href' => 'admin/structure/block/add/' . $plugin_id . '/' . $this->theme,
- ),
- ),
- ));
- return $row;
- }
-
- /**
- * {@inheritdoc}
- */
- public function validateForm(array &$form, array &$form_state) {
- if (!$this->manager->getDefinition($form_state['values']['block'])) {
- form_set_error('block', t('You must select a valid block.'));
- }
- }
-
- /**
- * {@inheritdoc}
- */
- public function submitForm(array &$form, array &$form_state) {
- $form_state['redirect'] = 'admin/structure/block/add/' . $form_state['values']['block'] . '/' . $this->theme;
- }
-
-}
diff --git a/core/modules/block/lib/Drupal/block/Routing/RouteSubscriber.php b/core/modules/block/lib/Drupal/block/Routing/RouteSubscriber.php
index de32cd1..576ea80 100644
--- a/core/modules/block/lib/Drupal/block/Routing/RouteSubscriber.php
+++ b/core/modules/block/lib/Drupal/block/Routing/RouteSubscriber.php
@@ -50,18 +50,6 @@ class RouteSubscriber implements EventSubscriberInterface {
)
);
$collection->add("block_admin_display.$key", $route);
-
- // The block plugin listing page.
- $route = new Route(
- "admin/structure/block/list/$key/add/{category}",
- array(
- '_form' => '\Drupal\block\Form\PlaceBlocksForm',
- 'category' => NULL,
- 'theme' => $key,
- ),
- array('_block_themes_access' => 'TRUE')
- );
- $collection->add("block_plugin_ui.$key", $route);
}
}
diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockLanguageCacheTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockLanguageCacheTest.php
index 126aff0..91ee298 100644
--- a/core/modules/block/lib/Drupal/block/Tests/BlockLanguageCacheTest.php
+++ b/core/modules/block/lib/Drupal/block/Tests/BlockLanguageCacheTest.php
@@ -70,7 +70,6 @@ class BlockLanguageCacheTest extends AggregatorTestBase {
// Create the block cache for all languages.
foreach ($this->langcodes as $langcode) {
$this->drupalGet('admin/structure/block', array('language' => $langcode));
- $this->clickLink(t('Place blocks'));
}
// Create a feed in the default language.
@@ -80,7 +79,6 @@ class BlockLanguageCacheTest extends AggregatorTestBase {
// Check that the block is listed for all languages.
foreach ($this->langcodes as $langcode) {
$this->drupalGet('admin/structure/block', array('language' => $langcode));
- $this->clickLink(t('Place blocks'));
$this->assertText($feed->label());
}
}
diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockLibrarySearchTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockLibrarySearchTest.php
deleted file mode 100644
index 8dcfeaa..0000000
--- a/core/modules/block/lib/Drupal/block/Tests/BlockLibrarySearchTest.php
+++ /dev/null
@@ -1,60 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \Drupal\block\Tests\BlockLibrarySearchTest.
- */
-
-namespace Drupal\block\Tests;
-
-use Drupal\simpletest\WebTestBase;
-
-/**
- * Tests the block library search.
- */
-class BlockLibrarySearchTest extends WebTestBase {
-
- /**
- * Modules to enable.
- *
- * @var array
- */
- public static $modules = array('block');
-
- /**
- * An administrative user to configure the test environment.
- */
- protected $adminUser;
-
- public static function getInfo() {
- return array(
- 'name' => 'Block library search',
- 'description' => 'Checks that the block library search works correctly.',
- 'group' => 'Block',
- );
- }
-
- protected function setUp() {
- parent::setUp();
- // Create and log in an administrative user.
- $this->adminUser = $this->drupalCreateUser(array(
- 'administer blocks',
- 'access administration pages',
- ));
- $this->drupalLogin($this->adminUser);
- }
-
- /**
- * Test block library search.
- */
- function testBlockLibrarySearch() {
- // Check that the block plugin is valid.
- $this->drupalPost('admin/structure/block/list/stark/add', array('block' => 'invalid_block'), t('Next'));
- $this->assertText('You must select a valid block.');
-
- // Check that the block search form redirects to the correct block form.
- $this->drupalPost('admin/structure/block/list/stark/add', array('block' => 'system_main_block'), t('Next'));
- $this->assertUrl('admin/structure/block/add/system_main_block/stark');
- }
-
-}
diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockTest.php
index 9ed99f1..7ef3176 100644
--- a/core/modules/block/lib/Drupal/block/Tests/BlockTest.php
+++ b/core/modules/block/lib/Drupal/block/Tests/BlockTest.php
@@ -274,7 +274,7 @@ class BlockTest extends BlockTestBase {
}
// Ensure that the disabled module's block plugin is no longer available.
- $this->drupalGet('admin/structure/block/list/' . \Drupal::config('system.theme')->get('default') . '/add');
+ $this->drupalGet('admin/structure/block/list/' . \Drupal::config('system.theme')->get('default'));
$this->assertNoText(t('Test block caching'));
// Confirm that the block is no longer displayed on the front page.
diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockTitleXSSTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockTitleXSSTest.php
index c17de30..f185f58 100644
--- a/core/modules/block/lib/Drupal/block/Tests/BlockTitleXSSTest.php
+++ b/core/modules/block/lib/Drupal/block/Tests/BlockTitleXSSTest.php
@@ -45,7 +45,7 @@ class BlockTitleXSSTest extends WebTestBase {
$this->drupalLogin($this->drupalCreateUser(array('administer blocks', 'access administration pages')));
$default_theme = \Drupal::config('system.theme')->get('default');
- $this->drupalGet('admin/structure/block/list/' . $default_theme . '/add');
+ $this->drupalGet('admin/structure/block/list/' . $default_theme);
$this->assertNoRaw("<script>alert('XSS subject');</script>", 'The block title was properly sanitized in Block Plugin UI Admin page.');
}
diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockUiTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockUiTest.php
index 62d2498..95cab30 100644
--- a/core/modules/block/lib/Drupal/block/Tests/BlockUiTest.php
+++ b/core/modules/block/lib/Drupal/block/Tests/BlockUiTest.php
@@ -106,12 +106,27 @@ class BlockUiTest extends WebTestBase {
}
/**
- * Test block search.
+ * Tests the block categories on the listing page.
*/
- function testBlockSearch() {
- $block = t('Administration');
- $blocks = drupal_json_decode($this->drupalGet('block/autocomplete', array('query' => array('q' => $block))));
- $this->assertEqual($blocks['system_menu_block:menu-admin'], $block, t('Can search for block with name !block.', array('!block' => $block)));
+ public function testCandidateBlockList() {
+ $arguments = array(
+ ':ul_class' => 'block-list',
+ ':li_class' => 'test-block-instantiation',
+ ':href' => 'admin/structure/block/add/test_block_instantiation/stark',
+ ':text' => 'Display message',
+ );
+
+ $this->drupalGet('admin/structure/block');
+ $elements = $this->xpath('//details[@id="edit-block-test"]//ul[contains(@class, :ul_class)]/li[contains(@class, :li_class)]/a[contains(@href, :href) and text()=:text]', $arguments);
+ $this->assertTrue(!empty($elements), 'The test block appears in the category for its module.');
+
+ // Trigger the custom category addition in block_test_block_alter().
+ $this->container->get('state')->set('block_test_info_alter', TRUE);
+ $this->container->get('plugin.manager.block')->clearCachedDefinitions();
+
+ $this->drupalGet('admin/structure/block');
+ $elements = $this->xpath('//details[@id="edit-custom-category"]//ul[contains(@class, :ul_class)]/li[contains(@class, :li_class)]/a[contains(@href, :href) and text()=:text]', $arguments);
+ $this->assertTrue(!empty($elements), 'The test block appears in a custom category controlled by block_test_block_alter().');
}
/**
diff --git a/core/modules/block/tests/modules/block_test/block_test.module b/core/modules/block/tests/modules/block_test/block_test.module
index 6abb95f..5184454 100644
--- a/core/modules/block/tests/modules/block_test/block_test.module
+++ b/core/modules/block/tests/modules/block_test/block_test.module
@@ -12,3 +12,12 @@ function block_test_system_theme_info() {
$themes['block_test_theme'] = drupal_get_path('module', 'block_test') . '/themes/block_test_theme/block_test_theme.info.yml';
return $themes;
}
+
+/**
+ * Implements hook_block_alter().
+ */
+function block_test_block_alter(&$block_info) {
+ if (Drupal::state()->get('block_test_info_alter') && isset($block_info['test_block_instantiation'])) {
+ $block_info['test_block_instantiation']['category'] = t('Custom category');
+ }
+}
diff --git a/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php b/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php
index df81981..83f2bc3 100644
--- a/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php
+++ b/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php
@@ -161,7 +161,7 @@ class MenuTest extends MenuWebTestBase {
// Enable the custom menu block.
$menu_name = 'menu-' . $menu_name; // Drupal prepends the name with 'menu-'.
// Confirm that the custom menu block is available.
- $this->drupalGet('admin/structure/block/list/' . \Drupal::config('system.theme')->get('default') . '/add');
+ $this->drupalGet('admin/structure/block/list/' . \Drupal::config('system.theme')->get('default'));
$this->assertText($label);
// Enable the block.
@@ -379,7 +379,7 @@ class MenuTest extends MenuWebTestBase {
// Make sure menu shows up with new name in block addition.
$default_theme = variable_get('theme_default', 'stark');
- $this->drupalget('admin/structure/block/list/' . $default_theme . '/add');
+ $this->drupalget('admin/structure/block/list/' . $default_theme);
$this->assertText($edit['label']);
}
diff --git a/core/modules/system/css/system.plugin.ui.css b/core/modules/system/css/system.plugin.ui.css
deleted file mode 100644
index c932788..0000000
--- a/core/modules/system/css/system.plugin.ui.css
+++ /dev/null
@@ -1,29 +0,0 @@
-#block-library .left-col,
-#block-library .right-col {
- float:left;
- width:66%;
- height:100%;
- background-color:#ffffff;
-}
-
-#block-library .right-col {
- width:34%;
- background-color:#f7f7f7;
-}
-
-#block-library .right-col h3 {
- margin: 1em -20px;
- background-color:#d7d7d7;
- color:#333333;
- padding:8px 15px;
- font-size:1.1em;
-}
-
-#block-library .inside {
- margin:0 20px;
-}
-
-#block-library .bottom-bar {
- width:100%;
- clear:both;
-}
diff --git a/core/modules/system/lib/Drupal/system/Plugin/Block/SystemMenuBlock.php b/core/modules/system/lib/Drupal/system/Plugin/Block/SystemMenuBlock.php
index 1daf4bf..d636ea3 100644
--- a/core/modules/system/lib/Drupal/system/Plugin/Block/SystemMenuBlock.php
+++ b/core/modules/system/lib/Drupal/system/Plugin/Block/SystemMenuBlock.php
@@ -18,6 +18,7 @@ use Drupal\Core\Annotation\Translation;
* id = "system_menu_block",
* admin_label = @Translation("System Menu"),
* module = "system",
+ * category = "menu",
* derivative = "Drupal\system\Plugin\Derivative\SystemMenuBlock"
* )
*/
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index 5297fe0..6a8478f 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -190,10 +190,6 @@ function system_theme() {
'system_date_format_localize_form' => array(
'render element' => 'form',
),
- 'system_plugin_ui_form' => array(
- 'template' => 'system-plugin-ui-form',
- 'render element' => 'form',
- ),
));
}
@@ -2337,19 +2333,6 @@ function system_preprocess_block(&$variables) {
}
/**
- * Prepares variables for system plugin UI form templates.
- *
- * Default template: system-plugin-ui-form.html.twig.
- *
- * @param array $variables
- * An associative array containing:
- * - form: The plugin form elements.
-*/
-function template_preprocess_system_plugin_ui_form(&$variables) {
- drupal_add_css(drupal_get_path('module', 'system') . '/css/system.plugin.ui.css');
-}
-
-/**
* Provide a single block on the administration overview page.
*
* @param $item
diff --git a/core/modules/system/templates/system-plugin-ui-form.html.twig b/core/modules/system/templates/system-plugin-ui-form.html.twig
deleted file mode 100644
index 5987888..0000000
--- a/core/modules/system/templates/system-plugin-ui-form.html.twig
+++ /dev/null
@@ -1,30 +0,0 @@
-{#
-/**
- * @file
- * Default theme implementation to configure blocks.
- *
- * Available variables:
- * - form: The form elements which contains:
- * - left: Form elements that appear in the left column.
- * - right: Form elements that appear in the right column.
- *
- * @see template_preprocess_system_plugin_ui_form()
- *
- * @ingroup themeable
- */
-#}
-<div id="block-library" class="container">
- <div class="left-col">
- <div class="inside">
- {{ form.left }}
- </div>
- </div>
- <div class="right-col">
- <div class="inside">
- {{ form.right }}
- </div>
- </div>
- {% if form -%}
- <div class="bottom-bar">{{ form }}</div>
- {%- endif -%}
-</div>
diff --git a/core/modules/views/lib/Drupal/views/Tests/Wizard/BasicTest.php b/core/modules/views/lib/Drupal/views/Tests/Wizard/BasicTest.php
index cefd1dd..42e2c80 100644
--- a/core/modules/views/lib/Drupal/views/Tests/Wizard/BasicTest.php
+++ b/core/modules/views/lib/Drupal/views/Tests/Wizard/BasicTest.php
@@ -122,7 +122,7 @@ class BasicTest extends WizardTestBase {
$this->assertLinkByHref(url($view3['page[path]']));
// Confirm that the block is available in the block administration UI.
- $this->drupalGet('admin/structure/block/list/' . \Drupal::config('system.theme')->get('default') . '/add');
+ $this->drupalGet('admin/structure/block/list/' . \Drupal::config('system.theme')->get('default'));
$this->assertText('View: ' . $view3['label']);
// Place the block.
diff --git a/core/modules/views/lib/Drupal/views/Tests/Wizard/ItemsPerPageTest.php b/core/modules/views/lib/Drupal/views/Tests/Wizard/ItemsPerPageTest.php
index d613698..275b4f4 100644
--- a/core/modules/views/lib/Drupal/views/Tests/Wizard/ItemsPerPageTest.php
+++ b/core/modules/views/lib/Drupal/views/Tests/Wizard/ItemsPerPageTest.php
@@ -75,7 +75,7 @@ class ItemsPerPageTest extends WizardTestBase {
$this->assertTrue($pos5 < $pos4 && $pos4 < $pos3 && $pos3 < $pos2, 'The nodes appear in the expected order in the page display.');
// Confirm that the block is listed in the block administration UI.
- $this->drupalGet('admin/structure/block/list/' . \Drupal::config('system.theme')->get('default') . '/add');
+ $this->drupalGet('admin/structure/block/list/' . \Drupal::config('system.theme')->get('default'));
$this->assertText('View: ' . $view['label']);
// Place the block, visit a page that displays the block, and check that the
diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Tests/OverrideDisplaysTest.php b/core/modules/views_ui/lib/Drupal/views_ui/Tests/OverrideDisplaysTest.php
index 87e52e1..ee26506 100644
--- a/core/modules/views_ui/lib/Drupal/views_ui/Tests/OverrideDisplaysTest.php
+++ b/core/modules/views_ui/lib/Drupal/views_ui/Tests/OverrideDisplaysTest.php
@@ -54,7 +54,7 @@ class OverrideDisplaysTest extends UITestBase {
$this->assertText($original_title);
// Confirm that the view block is available in the block administration UI.
- $this->drupalGet('admin/structure/block/list/' . \Drupal::config('system.theme')->get('default') . '/add');
+ $this->drupalGet('admin/structure/block/list/' . \Drupal::config('system.theme')->get('default'));
$this->assertText('View: ' . $view['label']);
// Place the block.
@@ -112,7 +112,7 @@ class OverrideDisplaysTest extends UITestBase {
$this->assertNoText($view['block[title]']);
// Confirm that the block is available in the block administration UI.
- $this->drupalGet('admin/structure/block/list/' . \Drupal::config('system.theme')->get('default') . '/add');
+ $this->drupalGet('admin/structure/block/list/' . \Drupal::config('system.theme')->get('default'));
$this->assertText('View: ' . $view['label']);
// Put the block into the first sidebar region, and make sure it will not
diff --git a/core/themes/seven/style.css b/core/themes/seven/style.css
index 619c605..b0da782 100644
--- a/core/themes/seven/style.css
+++ b/core/themes/seven/style.css
@@ -1763,11 +1763,7 @@ details.fieldset-no-legend {
screen and (max-width: 1020px),
(orientation: landscape) and (max-device-height: 1020px) {
- .toolbar-vertical .layout-region-node-secondary {
- margin-bottom: 0;
- padding-bottom: 0;
- display: block;
- }
+ .toolbar-vertical .block-list-right,
.toolbar-vertical .layout-region-node-secondary {
margin-bottom: 0;
padding-bottom: 0;