Issue #1591806 by tim.plunkett, ryanissamson, jenlampton, Risse, psynaptic, Gábor Hojtsy, kmcculloch, pakmanlh, Rob Loach: Change block 'subject' so that it's called (admin_)label like everything else on the theme layer.

8.0.x
webchick 2013-03-04 21:25:53 -05:00
parent 570433156d
commit c6b2c725e7
43 changed files with 52 additions and 53 deletions

View File

@ -33,7 +33,7 @@ class AggregatorCategoryBlock implements DerivativeInterface {
$result = db_query('SELECT cid, title FROM {aggregator_category} ORDER BY title WHERE cid = :cid', array(':cid' => $derivative_id))->fetchObject();
$this->derivatives[$derivative_id] = $base_plugin_definition;
$this->derivatives[$derivative_id]['delta'] = $result->cid;
$this->derivatives[$derivative_id]['subject'] = t('@title category latest items', array('@title' => $result->title));
$this->derivatives[$derivative_id]['admin_label'] = t('@title category latest items', array('@title' => $result->title));
return $this->derivatives[$derivative_id];
}
@ -46,7 +46,7 @@ class AggregatorCategoryBlock implements DerivativeInterface {
foreach ($result as $category) {
$this->derivatives[$category->cid] = $base_plugin_definition;
$this->derivatives[$category->cid]['delta'] = $category->cid;
$this->derivatives[$category->cid]['subject'] = t('@title category latest items', array('@title' => $category->title));
$this->derivatives[$category->cid]['admin_label'] = t('@title category latest items', array('@title' => $category->title));
}
return $this->derivatives;
}

View File

@ -33,7 +33,7 @@ class AggregatorFeedBlock implements DerivativeInterface {
$result = db_query('SELECT fid, title, block FROM {aggregator_feed} WHERE block <> 0 AND fid = :fid', array(':fid' => $derivative_id))->fetchObject();
$this->derivatives[$derivative_id] = $base_plugin_definition;
$this->derivatives[$derivative_id]['delta'] = $result->fid;
$this->derivatives[$derivative_id]['subject'] = t('@title feed latest items', array('@title' => $result->title));
$this->derivatives[$derivative_id]['admin_label'] = t('@title feed latest items', array('@title' => $result->title));
return $this->derivatives[$derivative_id];
}
@ -46,7 +46,7 @@ class AggregatorFeedBlock implements DerivativeInterface {
foreach ($result as $feed) {
$this->derivatives[$feed->fid] = $base_plugin_definition;
$this->derivatives[$feed->fid]['delta'] = $feed->fid;
$this->derivatives[$feed->fid]['subject'] = t('@title feed latest items', array('@title' => $feed->title));
$this->derivatives[$feed->fid]['admin_label'] = t('@title feed latest items', array('@title' => $feed->title));
}
return $this->derivatives;
}

View File

@ -16,7 +16,7 @@ use Drupal\Core\Annotation\Translation;
*
* @Plugin(
* id = "aggregator_category_block",
* subject = @Translation("Aggregator category"),
* admin_label = @Translation("Aggregator category"),
* module = "aggregator",
* derivative = "Drupal\aggregator\Plugin\Derivative\AggregatorCategoryBlock"
* )

View File

@ -16,7 +16,7 @@ use Drupal\Core\Annotation\Translation;
*
* @Plugin(
* id = "aggregator_feed_block",
* subject = @Translation("Aggregator feed"),
* admin_label = @Translation("Aggregator feed"),
* module = "aggregator",
* derivative = "Drupal\aggregator\Plugin\Derivative\AggregatorFeedBlock"
* )

View File

@ -77,7 +77,7 @@ function block_admin_edit(Block $entity) {
$theme_title = t('!theme (administration theme)', array('!theme' => $theme_title));
}
// Get the block subject for the page title.
// Get the block label for the page title.
drupal_set_title(t("Configure %label block in %theme", array('%label' => $entity->label(), '%theme' => $theme_title)), PASS_THROUGH);
return entity_get_form($entity);

View File

@ -477,7 +477,7 @@ function block_load($entity_id) {
}
/**
* Builds the content and subject for a block.
* Builds the content and label for a block.
*
* For cacheable blocks, this is called during #pre_render.
*

View File

@ -46,7 +46,7 @@ class CustomBlock implements DerivativeInterface {
$this->derivatives[$custom_block->uuid->value]['settings'] = array(
'info' => $custom_block->info->value,
) + $base_plugin_definition['settings'];
$this->derivatives[$custom_block->uuid->value]['subject'] = $custom_block->info->value;
$this->derivatives[$custom_block->uuid->value]['admin_label'] = $custom_block->info->value;
}
return $this->derivatives;
}

View File

@ -16,7 +16,7 @@ use Drupal\Core\Annotation\Translation;
*
* @Plugin(
* id = "custom_block",
* subject = @Translation("Custom Block"),
* admin_label = @Translation("Custom block"),
* module = "custom_block",
* derivative = "Drupal\custom_block\Plugin\Derivative\CustomBlock",
* settings = {

View File

@ -70,10 +70,9 @@ abstract class BlockBase extends PluginBase implements BlockInterface {
// default settings for the block plugin.
$this->configuration = $this->settings();
// @todo This loads the default subject. Is this the right place to do so?
$definition = $this->getDefinition();
if (isset($definition['subject'])) {
$this->configuration += array('subject' => $definition['subject']);
if (isset($definition['admin_label'])) {
$this->configuration += array('admin_label' => $definition['admin_label']);
}
}
// Ensure that the default cache mode is set.
@ -238,7 +237,7 @@ abstract class BlockBase extends PluginBase implements BlockInterface {
'#type' => 'textfield',
'#title' => t('Title'),
'#maxlength' => 255,
'#default_value' => !$entity->isNew() ? $entity->label() : $definition['subject'],
'#default_value' => !$entity->isNew() ? $entity->label() : $definition['admin_label'],
);
$form['machine_name'] = array(
'#type' => 'machine_name',

View File

@ -138,7 +138,7 @@ class BlockListController extends ConfigEntityListController implements FormInte
foreach ($entities as $entity_id => $entity) {
$info = $entity->getPlugin()->getDefinition();
$form['blocks'][$entity_id]['info'] = array(
'#markup' => check_plain($info['subject']),
'#markup' => check_plain($info['admin_label']),
);
$form['blocks'][$entity_id]['theme'] = array(
'#type' => 'hidden',
@ -149,14 +149,14 @@ class BlockListController extends ConfigEntityListController implements FormInte
'#default_value' => $entity->get('weight'),
'#delta' => $weight_delta,
'#title_display' => 'invisible',
'#title' => t('Weight for @block block', array('@block' => $info['subject'])),
'#title' => t('Weight for @block block', array('@block' => $info['admin_label'])),
);
$form['blocks'][$entity_id]['region'] = array(
'#type' => 'select',
'#default_value' => $entity->get('region') != BLOCK_REGION_NONE ? $entity->get('region') : NULL,
'#empty_value' => BLOCK_REGION_NONE,
'#title_display' => 'invisible',
'#title' => t('Region for @block block', array('@block' => $info['subject'])),
'#title' => t('Region for @block block', array('@block' => $info['admin_label'])),
'#options' => $this->regions,
);
$links['configure'] = array(

View File

@ -53,7 +53,7 @@ class BlockRenderController implements EntityRenderControllerInterface {
'id' => $entity->get('plugin'),
'region' => $entity->get('region'),
'module' => $entity->get('module'),
'subject' => check_plain($entity->label()),
'label' => check_plain($entity->label()),
),
);
}

View File

@ -31,7 +31,7 @@ use Drupal\Core\Annotation\Translation;
* task_suffix = "library",
* task_title = @Translation("Library"),
* title = @Translation("Add block"),
* title_attribute = "subject",
* title_attribute = "admin_label",
* type = MENU_LOCAL_ACTION
* )
*/
@ -144,7 +144,7 @@ class BlockPluginUI extends PluginUIBase {
$plugin_definition = $this->getDefinition();
list($plugin, $theme) = explode(':', $this->getPluginId());
$row = array();
$row[] = check_plain($display_plugin_definition['subject']);
$row[] = check_plain($display_plugin_definition['admin_label']);
$row[] = array('data' => array(
'#type' => 'operations',
'#links' => array(

View File

@ -101,7 +101,7 @@ class BlockStorageUnitTest extends DrupalUnitTestBase {
'plugin' => 'test_html_id',
'settings' => array(
'cache' => '1',
'subject' => t('Test block html id'),
'admin_label' => t('Test block html id'),
),
);
$this->assertIdentical($actual_properties, $expected_properties, 'The block properties are exported correctly.');

View File

@ -5,7 +5,7 @@
* Default theme implementation to display a block.
*
* Available variables:
* - $block->subject: Block title.
* - $block->label: Block title.
* - $content: Block content.
* - $block->module: Module that generated the block.
* - $block->delta: An ID for the block, unique within each module.
@ -48,8 +48,8 @@
<?php endif; ?>
<?php print render($title_prefix); ?>
<?php if ($block->subject): ?>
<h2<?php print $title_attributes; ?>><?php print $block->subject ?></h2>
<?php if ($block->label): ?>
<h2<?php print $title_attributes; ?>><?php print $block->label; ?></h2>
<?php endif;?>
<?php print render($title_suffix); ?>

View File

@ -8,4 +8,4 @@ visibility: { }
plugin: test_html_id
settings:
cache: '1'
subject: 'Test block html id'
admin_label: 'Test block html id'

View File

@ -16,7 +16,7 @@ use Drupal\Core\Annotation\Translation;
*
* @Plugin(
* id = "test_cache",
* subject = @Translation("Test block caching"),
* admin_label = @Translation("Test block caching"),
* module = "block_test"
* )
*/

View File

@ -16,7 +16,7 @@ use Drupal\Core\Annotation\Translation;
*
* @Plugin(
* id = "test_html_id",
* subject = @Translation("Test block html id"),
* admin_label = @Translation("Test block html id"),
* module = "block_test"
* )
*/

View File

@ -14,7 +14,7 @@ use Drupal\Core\Annotation\Plugin;
*
* @Plugin(
* id = "test_xss_title",
* subject = "<script>alert('XSS subject');</script>",
* admin_label = "<script>alert('XSS subject');</script>",
* module = "block_test"
* )
*/

View File

@ -16,7 +16,7 @@ use Drupal\Core\Annotation\Translation;
*
* @Plugin(
* id = "book_navigation",
* subject = @Translation("Book navigation"),
* admin_label = @Translation("Book navigation"),
* module = "book"
* )
*/

View File

@ -16,7 +16,7 @@ use Drupal\Core\Annotation\Translation;
*
* @Plugin(
* id = "recent_comments",
* subject = @Translation("Recent comments"),
* admin_label = @Translation("Recent comments"),
* module = "comment"
* )
*/

View File

@ -15,7 +15,7 @@ use Drupal\Core\Annotation\Translation;
*
* @Plugin(
* id = "forum_active_block",
* subject = @Translation("Active forum topics"),
* admin_label = @Translation("Active forum topics"),
* module = "forum"
* )
*/

View File

@ -15,7 +15,7 @@ use Drupal\Core\Annotation\Translation;
*
* @Plugin(
* id = "forum_new_block",
* subject = @Translation("New forum topics"),
* admin_label = @Translation("New forum topics"),
* module = "forum"
* )
*/

View File

@ -40,7 +40,7 @@ class LanguageBlock implements DerivativeInterface {
$info = language_types_info();
foreach (language_types_get_configurable(FALSE) as $type) {
$this->derivatives[$type] = $base_plugin_definition;
$this->derivatives[$type]['subject'] = t('Language switcher (!type)', array('!type' => $info[$type]['name']));
$this->derivatives[$type]['admin_label'] = t('Language switcher (!type)', array('!type' => $info[$type]['name']));
$this->derivatives[$type]['cache'] = DRUPAL_NO_CACHE;
}
return $this->derivatives;

View File

@ -16,7 +16,7 @@ use Drupal\Core\Annotation\Translation;
*
* @Plugin(
* id = "language_block",
* subject = @Translation("Language switcher"),
* admin_label = @Translation("Language switcher"),
* module = "language",
* derivative = "Drupal\language\Plugin\Derivative\LanguageBlock"
* )

View File

@ -23,7 +23,7 @@ class MenuBlock extends SystemMenuBlock {
// Provide block plugin definitions for all user-defined (custom) menus.
foreach (menu_get_menus(FALSE) as $menu => $name) {
$this->derivatives[$menu] = $base_plugin_definition;
$this->derivatives[$menu]['subject'] = $name;
$this->derivatives[$menu]['admin_label'] = $name;
$this->derivatives[$menu]['cache'] = DRUPAL_NO_CACHE;
}
return $this->derivatives;

View File

@ -16,7 +16,7 @@ use Drupal\Core\Annotation\Translation;
*
* @Plugin(
* id = "menu_menu_block",
* subject = @Translation("Menu"),
* admin_label = @Translation("Menu"),
* module = "menu",
* derivative = "Drupal\menu\Plugin\Derivative\MenuBlock"
* )

View File

@ -16,7 +16,7 @@ use Drupal\Core\Annotation\Translation;
*
* @Plugin(
* id = "node_recent_block",
* subject = @Translation("Recent content"),
* admin_label = @Translation("Recent content"),
* module = "node"
* )
*/

View File

@ -16,7 +16,7 @@ use Drupal\Core\Annotation\Translation;
*
* @Plugin(
* id = "node_syndicate_block",
* subject = @Translation("Syndicate"),
* admin_label = @Translation("Syndicate"),
* module = "node"
* )
*/

View File

@ -16,7 +16,7 @@ use Drupal\Core\Annotation\Translation;
*
* @Plugin(
* id = "search_form_block",
* subject = @Translation("Search form"),
* admin_label = @Translation("Search form"),
* module = "search"
* )
*/

View File

@ -16,7 +16,7 @@ use Drupal\Core\Annotation\Translation;
*
* @Plugin(
* id = "shortcuts",
* subject = @Translation("Shortcuts"),
* admin_label = @Translation("Shortcuts"),
* module = "shortcut"
* )
*/

View File

@ -16,7 +16,7 @@ use Drupal\Core\Annotation\Translation;
*
* @Plugin(
* id = "statistics_popular_block",
* subject = @Translation("Popular content"),
* admin_label = @Translation("Popular content"),
* module = "statistics"
* )
*/

View File

@ -45,7 +45,7 @@ class SystemMenuBlock implements DerivativeInterface {
$menu = "menu-$menu";
$this->derivatives[$menu] = $base_plugin_definition;
$this->derivatives[$menu]['delta'] = $menu;
$this->derivatives[$menu]['subject'] = $name;
$this->derivatives[$menu]['admin_label'] = $name;
$this->derivatives[$menu]['cache'] = DRUPAL_NO_CACHE;
}
return $this->derivatives;

View File

@ -16,7 +16,7 @@ use Drupal\Core\Annotation\Translation;
*
* @Plugin(
* id = "system_help_block",
* subject = @Translation("System Help"),
* admin_label = @Translation("System Help"),
* module = "system"
* )
*/

View File

@ -16,7 +16,7 @@ use Drupal\Core\Annotation\Translation;
*
* @Plugin(
* id = "system_main_block",
* subject = @Translation("Main page content"),
* admin_label = @Translation("Main page content"),
* module = "system"
* )
*/

View File

@ -16,7 +16,7 @@ use Drupal\Core\Annotation\Translation;
*
* @Plugin(
* id = "system_menu_block",
* subject = @Translation("System Menu"),
* admin_label = @Translation("System Menu"),
* module = "system",
* derivative = "Drupal\system\Plugin\Derivative\SystemMenuBlock"
* )

View File

@ -16,7 +16,7 @@ use Drupal\Core\Annotation\Translation;
*
* @Plugin(
* id = "system_powered_by_block",
* subject = @Translation("Powered by Drupal"),
* admin_label = @Translation("Powered by Drupal"),
* module = "system"
* )
*/

View File

@ -16,7 +16,7 @@ use Drupal\Core\Annotation\Translation;
*
* @Plugin(
* id = "user_login_block",
* subject = @Translation("User login"),
* admin_label = @Translation("User login"),
* module = "user"
* )
*/

View File

@ -16,7 +16,7 @@ use Drupal\Core\Annotation\Translation;
*
* @Plugin(
* id = "user_new_block",
* subject = @Translation("Who's new"),
* admin_label = @Translation("Who's new"),
* module = "user"
* )
*/

View File

@ -19,7 +19,7 @@ use Drupal\Core\Annotation\Translation;
*
* @Plugin(
* id = "user_online_block",
* subject = @Translation("Who's online"),
* admin_label = @Translation("Who's online"),
* module = "user"
* )
*/

View File

@ -61,7 +61,7 @@ class ViewsBlock implements DerivativeInterface {
}
}
$this->derivatives[$delta] = array(
'subject' => $desc,
'admin_label' => $desc,
'cache' => $display->getCacheType()
);
$this->derivatives[$delta] += $base_plugin_definition;

View File

@ -53,7 +53,7 @@ class ViewsExposedFilterBlock implements DerivativeInterface {
$delta = $view->id() . '-' . $display->display['id'];
$desc = t('Exposed form: @view-@display_id', array('@view' => $view->id(), '@display_id' => $display->display['id']));
$this->derivatives[$delta] = array(
'subject' => $desc,
'admin_label' => $desc,
'cache' => DRUPAL_NO_CACHE,
);
$this->derivatives[$delta] += $base_plugin_definition;

View File

@ -18,7 +18,7 @@ use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
*
* @Plugin(
* id = "views_block",
* subject = @Translation("Views Block"),
* admin_label = @Translation("Views Block"),
* module = "views",
* derivative = "Drupal\views\Plugin\Derivative\ViewsBlock"
* )

View File

@ -15,7 +15,7 @@ use Drupal\Core\Annotation\Translation;
*
* @Plugin(
* id = "views_exposed_filter_block",
* subject = @Translation("Views Exposed Filter Block"),
* admin_label = @Translation("Views Exposed Filter Block"),
* module = "views",
* derivative = "Drupal\views\Plugin\Derivative\ViewsExposedFilterBlock"
* )