diff --git a/core/modules/block/css/block.admin.css b/core/modules/block/css/block.admin.css index 2c703a0..9d4c405 100644 --- a/core/modules/block/css/block.admin.css +++ b/core/modules/block/css/block.admin.css @@ -48,15 +48,11 @@ a.block-demo-backlink:hover { padding-right: 0; } .block-list-right { - border-left: 1px solid #bfbfbf; /* LTR */ + border: 1px solid #bfbfbf; + border-bottom-width: 0; float: right; /* LTR */ width: 25%; } -[dir="rtl"] .block-list-right { - border-left-width: 0; - border-right: 1px solid #bfbfbf; - float: left; -} .block-list { padding-left: 0.75em; /* LTR */ @@ -73,7 +69,6 @@ a.block-demo-backlink:hover { .block-list a:before { content: '+ '; } -input.block-filter-text[type="search"] { - margin: 0 1.25em; - padding: 0.333em; +.block-list-right .form-type-search { + padding: 0 1em; } diff --git a/core/modules/block/custom_block/custom_block.module b/core/modules/block/custom_block/custom_block.module index fa1e415..d013c7c 100644 --- a/core/modules/block/custom_block/custom_block.module +++ b/core/modules/block/custom_block/custom_block.module @@ -9,6 +9,19 @@ use Drupal\custom_block\Plugin\Core\Entity\CustomBlock; /** + * Implements hook_menu_local_actions_alter(). + */ +function custom_block_menu_local_actions_alter(&$actions) { + if (isset($actions['custom_block_add_action'])) { + foreach (list_themes() as $theme => $theme_info) { + if ($theme_info->status) { + $actions['custom_block_add_action']['appears_on'][] = "block_admin_display.$theme"; + } + } + } +} + +/** * Implements hook_menu(). */ function custom_block_menu() { diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Menu/LocalAction/CustomBlockAddLocalAction.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Menu/LocalAction/CustomBlockAddLocalAction.php index 76eca54..212c799 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Menu/LocalAction/CustomBlockAddLocalAction.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Menu/LocalAction/CustomBlockAddLocalAction.php @@ -16,10 +16,7 @@ * id = "custom_block_add_action", * route_name = "custom_block_add_page", * title = @Translation("Add custom block"), - * derivative = "Drupal\custom_block\Plugin\Menu\LocalAction\CustomBlockAddLocalActionDeriver", - * appears_on = { - * "block_admin_display", - * } + * appears_on = {"block_admin_display"} * ) */ class CustomBlockAddLocalAction extends LocalActionBase { diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Menu/LocalAction/CustomBlockAddLocalActionDeriver.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Menu/LocalAction/CustomBlockAddLocalActionDeriver.php deleted file mode 100644 index 1375b48..0000000 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Menu/LocalAction/CustomBlockAddLocalActionDeriver.php +++ /dev/null @@ -1,33 +0,0 @@ - $theme_info) { - if ($theme_info->status) { - $derivative['appears_on'][] = "block_admin_display.$theme"; - } - } - $this->derivatives = array($derivative); - return parent::getDerivativeDefinitions($base_plugin_definition); - } - -} diff --git a/core/modules/block/js/block.admin.js b/core/modules/block/js/block.admin.js index a6d0bcd..5c866c0 100644 --- a/core/modules/block/js/block.admin.js +++ b/core/modules/block/js/block.admin.js @@ -15,15 +15,24 @@ var $element = $($input.attr('data-element')); var $blocks, $details; - function hidePackageDetails(index, element) { + /** + * Hides the
element for a category if it has no visible blocks. + */ + function hideCategoryDetails(index, element) { var $details = $(element); $details.toggle($details.find('li:visible').length > 0); } - function filterModuleList (e) { + /** + * Filters the block list. + */ + function filterBlockList (e) { var query = $(e.target).val().toLowerCase(); - function showModuleRow (index, block) { + /** + * Shows or hides the block entry based on the query. + */ + function showBlockEntry (index, block) { var $block = $(block); var $sources = $block.find('.block-filter-text-source'); var textMatch = $sources.text().toLowerCase().indexOf(query) !== -1; @@ -32,11 +41,11 @@ function showModuleRow (index, block) { // Filter if the length of the query is at least 2 characters. if (query.length >= 2) { - $blocks.each(showModuleRow); + $blocks.each(showBlockEntry); - // Hide the package
if they don't have any visible rows. - // Note that we first show() all
to be able to use ':visible'. - $details.attr('open', 'open').each(hidePackageDetails); + // Hide the category
if they don't have any visible rows. + // Note that we first open all
to be able to use ':visible'. + $details.attr('open').each(hideCategoryDetails); } else { $blocks.show(); @@ -52,7 +61,7 @@ function showModuleRow (index, block) { $details = $element.find('details'); $blocks = $details.find('li'); - $input.on('keyup', filterModuleList); + $input.on('keyup', filterBlockList); } } }; diff --git a/core/modules/block/lib/Drupal/block/BlockListController.php b/core/modules/block/lib/Drupal/block/BlockListController.php index f7802bd..618b901 100644 --- a/core/modules/block/lib/Drupal/block/BlockListController.php +++ b/core/modules/block/lib/Drupal/block/BlockListController.php @@ -8,7 +8,7 @@ namespace Drupal\block; use Drupal\Component\Plugin\PluginManagerInterface; -use Drupal\Core\Cache\Cache; +use Drupal\Component\Utility\Json; use Drupal\Core\Config\Entity\ConfigEntityListController; use Drupal\Core\Entity\EntityControllerInterface; use Drupal\Core\Entity\EntityInterface; @@ -77,7 +77,7 @@ public static function createInstance(ContainerInterface $container, $entity_typ } /** - * {@inheritdoc} + * Overrides \Drupal\Core\Config\Entity\ConfigEntityListController::load(). */ public function load() { // If no theme was specified, use the current theme. @@ -97,7 +97,7 @@ public function load() { } /** - * {@inheritdoc} + * Overrides \Drupal\Core\Entity\EntityListController::render(). */ public function render($theme = NULL) { // If no theme was specified, use the current theme. @@ -107,14 +107,16 @@ public function render($theme = NULL) { } /** - * {@inheritdoc} + * Implements \Drupal\Core\Form\FormInterface::getFormID(). */ public function getFormID() { return 'block_admin_display_form'; } /** - * {@inheritdoc} + * Implements \Drupal\Core\Form\FormInterface::buildForm(). + * + * Form constructor for the main block administration form. */ public function buildForm(array $form, array &$form_state) { $entities = $this->load(); @@ -342,7 +344,7 @@ public function buildForm(array $form, array &$form_state) { 'attributes' => array( 'class' => array('use-ajax', 'block-filter-text-source'), 'data-accepts' => 'application/vnd.drupal-modal', - 'data-dialog-options' => json_encode(array( + 'data-dialog-options' => Json::encode(array( 'width' => 700, )), ), @@ -372,17 +374,19 @@ public function getOperations(EntityInterface $entity) { } /** - * {@inheritdoc} + * Implements \Drupal\Core\Form\FormInterface::validateForm(). */ public function validateForm(array &$form, array &$form_state) { // No validation. } /** - * {@inheritdoc} + * Implements \Drupal\Core\Form\FormInterface::submitForm(). + * + * Form submission handler for the main block administration form. */ public function submitForm(array &$form, array &$form_state) { - $entities = $this->storage->loadMultiple(array_keys($form_state['values']['blocks'])); + $entities = entity_load_multiple('block', array_keys($form_state['values']['blocks'])); foreach ($entities as $entity_id => $entity) { $entity->set('weight', $form_state['values']['blocks'][$entity_id]['weight']); $entity->set('region', $form_state['values']['blocks'][$entity_id]['region']); @@ -395,7 +399,7 @@ public function submitForm(array &$form, array &$form_state) { $entity->save(); } drupal_set_message(t('The block settings have been updated.')); - Cache::invalidateTags(array('content' => TRUE)); + cache_invalidate_tags(array('content' => TRUE)); } }