diff --cc core/modules/block/block.admin.inc
index d217012,995b5d4..0000000
--- a/core/modules/block/block.admin.inc
+++ b/core/modules/block/block.admin.inc
@@@ -268,249 -250,21 +251,148 @@@ function _block_compare($ainstance, $bi
* @see block_admin_configure_submit()
* @ingroup forms
*/
++<<<<<<< HEAD
+function block_admin_configure($form, &$form_state, $module, $delta) {
+ $block = block_load($module, $delta);
+ $form['module'] = array(
+ '#type' => 'value',
+ '#value' => $block->module,
+ );
+ $form['delta'] = array(
+ '#type' => 'value',
+ '#value' => $block->delta,
+ );
+
+ // Get the block subject for the page title.
+ $info = module_invoke($block->module, 'block_info');
+ if (isset($info[$block->delta])) {
+ drupal_set_title(t("'%name' block", array('%name' => $info[$block->delta]['info'])), PASS_THROUGH);
+ }
+
+ $form['settings']['title'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Block title'),
+ '#maxlength' => 255,
+ '#size' => 60,
+ '#description' => $block->module == 'block' ? t('The title of the block as shown to the user.') : t('Override the default title for the block. Use !placeholder to display no title, or leave blank to use the default block title.', array('!placeholder' => '<none>')),
+ '#default_value' => isset($block->title) ? $block->title : '',
+ '#weight' => -19,
+ );
+
+ // Module-specific block configuration.
+ if ($settings = module_invoke($block->module, 'block_configure', $block->delta)) {
+ foreach ($settings as $k => $v) {
+ $form['settings'][$k] = $v;
+ }
+ }
+
+ // Region settings.
+ $form['regions'] = array(
+ '#type' => 'details',
+ '#title' => t('Region settings'),
+ '#collapsible' => FALSE,
+ '#description' => t('Specify in which themes and regions this block is displayed.'),
+ '#tree' => TRUE,
+ );
+
+ $theme_default = variable_get('theme_default', 'stark');
+ $admin_theme = config('system.site')->get('admin_theme');
+ foreach (list_themes() as $key => $theme) {
+ // Only display enabled themes
+ if ($theme->status) {
+ $region = db_query("SELECT region FROM {block} WHERE module = :module AND delta = :delta AND theme = :theme", array(
+ ':module' => $block->module,
+ ':delta' => $block->delta,
+ ':theme' => $key,
+ ))->fetchField();
+
+ // Use a meaningful title for the main site theme and administrative
+ // theme.
+ $theme_title = $theme->info['name'];
+ if ($key == $theme_default) {
+ $theme_title = t('!theme (default theme)', array('!theme' => $theme_title));
+ }
+ elseif ($admin_theme && $key == $admin_theme) {
+ $theme_title = t('!theme (administration theme)', array('!theme' => $theme_title));
+ }
+ $form['regions'][$key] = array(
+ '#type' => 'select',
+ '#title' => $theme_title,
+ '#default_value' => !empty($region) && $region != -1 ? $region : NULL,
+ '#empty_value' => BLOCK_REGION_NONE,
+ '#options' => system_region_list($key, REGIONS_VISIBLE),
+ '#weight' => ($key == $theme_default ? 9 : 10),
+ );
+ }
++=======
+ function block_admin_configure($form, &$form_state, $plugin_id, $theme = NULL) {
+ $instance = block_load($plugin_id);
+ $form['#instance'] = $instance;
+ $config = $instance->getConfig();
+ if (!isset($config['config_id']) && !$theme) {
+ $theme = variable_get('theme_default', 'stark');
++>>>>>>> Issue #1535868 by Jody Lynn, EclipseGc, tim.plunkett, naxoc, sdboyer, tizzo, sun, effulgentsia: Convert all blocks into plugins.
}
-
- // Visibility settings.
- $form['visibility_title'] = array(
- '#type' => 'item',
- '#title' => t('Visibility settings'),
- );
- $form['visibility'] = array(
- '#type' => 'vertical_tabs',
- '#attached' => array(
- 'library' => array(array('block', 'drupal.block')),
- ),
- );
-
- // Per-path visibility.
- $form['visibility']['path'] = array(
- '#type' => 'details',
- '#title' => t('Pages'),
- '#collapsible' => TRUE,
- '#collapsed' => TRUE,
- '#group' => 'visibility',
- '#weight' => 0,
- );
-
- $access = user_access('use PHP for settings');
- if (isset($block->visibility) && $block->visibility == BLOCK_VISIBILITY_PHP && !$access) {
- $form['visibility']['path']['visibility'] = array(
- '#type' => 'value',
- '#value' => BLOCK_VISIBILITY_PHP,
- );
- $form['visibility']['path']['pages'] = array(
- '#type' => 'value',
- '#value' => isset($block->pages) ? $block->pages : '',
- );
- }
- else {
- $options = array(
- BLOCK_VISIBILITY_NOTLISTED => t('All pages except those listed'),
- BLOCK_VISIBILITY_LISTED => t('Only the listed pages'),
- );
- $description = t("Specify pages by using their paths. Enter one path per line. The '*' character is a wildcard. Example paths are %user for the current user's page and %user-wildcard for every user page. %front is the front page.", array('%user' => 'user', '%user-wildcard' => 'user/*', '%front' => ''));
-
- if (module_exists('php') && $access) {
- $options += array(BLOCK_VISIBILITY_PHP => t('Pages on which this PHP code returns TRUE
(experts only)'));
- $title = t('Pages or PHP code');
- $description .= ' ' . t('If the PHP option is chosen, enter PHP code between %php. Note that executing incorrect PHP code can break your Drupal site.', array('%php' => ''));
- }
- else {
- $title = t('Pages');
- }
- $form['visibility']['path']['visibility'] = array(
- '#type' => 'radios',
- '#title' => t('Show block on specific pages'),
- '#options' => $options,
- '#default_value' => isset($block->visibility) ? $block->visibility : BLOCK_VISIBILITY_NOTLISTED,
- );
- $form['visibility']['path']['pages'] = array(
- '#type' => 'textarea',
- '#title' => '' . $title . '',
- '#default_value' => isset($block->pages) ? $block->pages : '',
- '#description' => $description,
- );
- }
-
- // Configure the block visibility per language.
- if (module_exists('language') && language_multilingual()) {
- $configurable_language_types = language_types_get_configurable();
- $existing_language_settings = db_query("SELECT type, langcode FROM {block_language} WHERE module = :module AND delta = :delta", array(
- ':module' => $form['module']['#value'],
- ':delta' => $form['delta']['#value'],
- ))->fetchAll();
- $default_langcode_options = array();
- $default_language_type = $configurable_language_types[0];
- foreach ($existing_language_settings as $setting) {
- $default_langcode_options[] = $setting->langcode;
- // Overwrite default language type if we have it set. Although this
- // theoretically would allow per language type association, our UI
- // only allows language type association overall for a block, so we
- // only need a single value.
- $default_language_type = $setting->type;
- }
-
- // Fetch languages.
- $languages = language_list(LANGUAGE_ALL);
- foreach ($languages as $language) {
- // @TODO $language->name is not wrapped with t(), it should be replaced
- // by CMI translation implementation.
- $langcodes_options[$language->langcode] = $language->name;
- }
- $form['visibility']['language'] = array(
- '#type' => 'details',
- '#title' => t('Languages'),
- '#collapsible' => TRUE,
- '#collapsed' => TRUE,
- '#group' => 'visibility',
- '#weight' => 5,
- );
- // If there are multiple configurable language types, let the user pick
- // which one should be applied to this visibility setting. This way users
- // can limit blocks by interface language or content language for exmaple.
- $language_types = language_types_info();
- $language_type_options = array();
- foreach ($configurable_language_types as $type_key) {
- $language_type_options[$type_key] = $language_types[$type_key]['name'];
- }
- $form['visibility']['language']['language_type'] = array(
- '#type' => 'radios',
- '#title' => t('Language type'),
- '#options' => $language_type_options,
- '#default_value' => $default_language_type,
- '#access' => count($language_type_options) > 1,
- );
- $form['visibility']['language']['langcodes'] = array(
- '#type' => 'checkboxes',
- '#title' => t('Show this block only for specific languages'),
- '#default_value' => $default_langcode_options,
- '#options' => $langcodes_options,
- '#description' => t('Show this block only for the selected language(s). If you select no languages, the block will be visibile in all languages.'),
- );
+ elseif (!$theme && isset($config['config_id'])) {
+ list(, , , $theme) = explode('.', $config['config_id']);
}
++<<<<<<< HEAD
+
+ // Per-role visibility.
+ $default_role_options = db_query("SELECT rid FROM {block_role} WHERE module = :module AND delta = :delta", array(
+ ':module' => $block->module,
+ ':delta' => $block->delta,
+ ))->fetchCol();
+ $role_options = array_map('check_plain', user_roles());
+ $form['visibility']['role'] = array(
+ '#type' => 'details',
+ '#title' => t('Roles'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ '#group' => 'visibility',
+ '#weight' => 10,
+ );
+ $form['visibility']['role']['roles'] = array(
+ '#type' => 'checkboxes',
+ '#title' => t('Show block for specific roles'),
+ '#default_value' => $default_role_options,
+ '#options' => $role_options,
+ '#description' => t('Show this block only for the selected role(s). If you select no roles, the block will be visible to all users.'),
+ );
+
+ // Per-user visibility.
+ $form['visibility']['user'] = array(
+ '#type' => 'details',
+ '#title' => t('Users'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ '#group' => 'visibility',
+ '#weight' => 20,
+ );
+ $form['visibility']['user']['custom'] = array(
+ '#type' => 'radios',
+ '#title' => t('Customizable per user'),
+ '#options' => array(
+ BLOCK_CUSTOM_FIXED => t('Not customizable'),
+ BLOCK_CUSTOM_ENABLED => t('Customizable, visible by default'),
+ BLOCK_CUSTOM_DISABLED => t('Customizable, hidden by default'),
+ ),
+ '#description' => t('Allow individual users to customize the visibility of this block in their account settings.'),
+ '#default_value' => isset($block->custom) ? $block->custom : BLOCK_CUSTOM_FIXED,
+ );
+
+ $form['actions'] = array('#type' => 'actions');
+ $form['actions']['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Save block'),
+ '#button_type' => 'primary',
++=======
+ $form['theme'] = array(
+ '#type' => 'value',
+ '#value' => $theme,
++>>>>>>> Issue #1535868 by Jody Lynn, EclipseGc, tim.plunkett, naxoc, sdboyer, tizzo, sun, effulgentsia: Convert all blocks into plugins.
);
-
+ $form += $instance->configureWrapper($form, $form_state);
return $form;
}
diff --cc core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php
index 9533a1c,19d5d53..0000000
--- a/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php
@@@ -122,20 -126,27 +126,44 @@@ class NodeBlockFunctionalTest extends N
$this->assertText($node3->label(), 'Node found in block.');
$this->assertText($node4->label(), 'Node found in block.');
++<<<<<<< HEAD
+ // Create the custom block.
+ $custom_block = array();
+ $custom_block['info'] = $this->randomName();
+ $custom_block['title'] = $this->randomName();
+ $custom_block['types[article]'] = TRUE;
+ $custom_block['body[value]'] = $this->randomName(32);
+ $custom_block['regions[' . variable_get('theme_default', 'stark') . ']'] = 'content';
+ if ($admin_theme = config('system.site')->get('admin_theme')) {
+ $custom_block['regions[' . $admin_theme . ']'] = 'content';
+ }
+ $this->drupalPost('admin/structure/block/add', $custom_block, t('Save block'));
+
+ $bid = db_query("SELECT bid FROM {block_custom} WHERE info = :info", array(':info' => $custom_block['info']))->fetchField();
+ $this->assertTrue($bid, 'Custom block with visibility rule was created.');
++=======
+ // Enable the "Powered by Drupal" block and test the visibility by node
+ // type functionality.
+ $block_name = 'system_powered_by_block';
+ $block = array(
+ 'machine_name' => $this->randomName(8),
+ 'region' => 'sidebar_first',
+ 'title' => $this->randomName(8),
+ 'visibility[node_type][types][article]' => TRUE,
+ );
+ // Set the block to be shown only on node/xx if node is an article.
+ $this->drupalPost('admin/structure/block/manage/' . $block_name . '/' . $default_theme, $block, t('Save block'));
+ $this->assertText('The block configuration has been saved.', 'Block was saved');
+
+ // Configure the new forum topics block to only show 2 topics.
+ $block['config_id'] = 'plugin.core.block.' . $default_theme . '.' . $block['machine_name'];
+ $config = config($block['config_id']);
+ $node_type_visibility = $config->get('visibility.node_type.types.article');
+ $this->assertEqual($node_type_visibility, 'article', 'Visibility settings were saved to configuration');
+
+ // Create a page node.
+ $node5 = $this->drupalCreateNode(array('uid' => $this->adminUser->uid, 'type' => 'page'));
++>>>>>>> Issue #1535868 by Jody Lynn, EclipseGc, tim.plunkett, naxoc, sdboyer, tizzo, sun, effulgentsia: Convert all blocks into plugins.
// Verify visibility rules.
$this->drupalGet('');