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' => !empty($this->configuration['visibility']['path']['visibility']) ? $this->configuration['visibility']['path']['visibility'] : BLOCK_VISIBILITY_NOTLISTED,
+ );
+ $form['visibility']['path']['pages'] = array(
+ '#type' => 'textarea',
+ '#title' => '' . $title . '',
+ '#default_value' => !empty($this->configuration['visibility']['path']['pages']) ? $this->configuration['visibility']['path']['pages'] : '',
+ '#description' => $description,
+ );
+ }
+
+ // Configure the block visibility per language.
+ if (module_exists('language') && language_multilingual()) {
+ $configurable_language_types = language_types_get_configurable();
+
+ // 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' => 'fieldset',
+ '#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' => !empty($this->configuration['visibility']['language']['language_type']) ? $this->configuration['visibility']['language']['language_type'] : $configurable_language_types[0],
+ '#access' => count($language_type_options) > 1,
+ );
+ $form['visibility']['language']['langcodes'] = array(
+ '#type' => 'checkboxes',
+ '#title' => t('Show this block only for specific languages'),
+ '#default_value' => !empty($this->configuration['visibility']['language']['langcodes']) ? $this->configuration['visibility']['language']['langcodes'] : array(),
+ '#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.'),
+ );
+ }
+
+ // Per-role visibility.
+ $role_options = array_map('check_plain', user_roles());
+ $form['visibility']['role'] = array(
+ '#type' => 'fieldset',
+ '#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' => !empty($this->configuration['visibility']['role']['roles']) ? $this->configuration['visibility']['role']['roles'] : array(),
+ '#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.'),
+ );
+
+ $form += $this->configure($form, $form_state);
+
+ $form['actions'] = array('#type' => 'actions');
+ $form['actions']['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Save block'),
+ );
+
+ return $form;
+ }
+
+ /**
+ * Implements BlockInterface::configure().
+ */
+ public function configure($form, &$form_state) {
+ return array();
+ }
+
+ /**
+ * Implements BlockInterface::configureValidateWrapper().
+ */
+ public function configureValidateWrapper($form, &$form_state) {
+ if (empty($form['settings']['machine_name']['#disabled'])) {
+ if (preg_match('/[^a-zA-Z0-9_]/', $form_state['values']['machine_name'])) {
+ form_set_error('machine_name', t('Block name must be alphanumeric or underscores only.'));
+ }
+ if (in_array('plugin.core.block.' . $form_state['values']['machine_name'], config_get_storage_names_with_prefix('plugin.core.block'))) {
+ form_set_error('machine_name', t('Block name must be unique.'));
+ }
+ }
+ else {
+ $config_id = explode('.', $form_state['values']['machine_name']);
+ $form_state['values']['machine_name'] = array_pop($config_id);
+ }
+ if ($form_state['values']['module'] == 'block') {
+ $custom_block_exists = (bool) db_query_range('SELECT 1 FROM {block_custom} WHERE bid <> :bid AND info = :info', 0, 1, array(
+ ':bid' => $form_state['values']['delta'],
+ ':info' => $form_state['values']['info'],
+ ))->fetchField();
+ if (empty($form_state['values']['info']) || $custom_block_exists) {
+ form_set_error('info', t('Ensure that each block description is unique.'));
+ }
+ }
+ $form_state['values']['visibility']['role']['roles'] = array_filter($form_state['values']['visibility']['role']['roles']);
+ $this->configureValidate($form, $form_state);
+ }
+
+ /**
+ * Implements BlockInterface::configureValidate().
+ */
+ public function configureValidate($form, &$form_state) {}
+
+ /**
+ * Implements BlockInterface::configureSubmitWrapper().
+ */
+ public function configureSubmitWrapper($form, &$form_state) {
+ if (!form_get_errors()) {
+ $transaction = db_transaction();
+ try {
+ $keys = array(
+ 'visibility' => 'visibility',
+ 'pages' => 'pages',
+ 'custom' => 'custom',
+ 'title' => 'subject',
+ 'module' => 'module',
+ 'region' => 'region',
+ );
+ foreach ($keys as $key => $new_key) {
+ if (isset($form_state['values'][$key])) {
+ $this->configuration[$new_key] = $form_state['values'][$key];
+ }
+ }
+ }
+ catch (Exception $e) {
+ $transaction->rollback();
+ watchdog_exception('block', $e);
+ throw $e;
+ }
+ if (empty($this->configuration['weight'])) {
+ $this->configuration['weight'] = 0;
+ }
+ drupal_set_message(t('The block configuration has been saved.'));
+ drupal_flush_all_caches();
+ $this->configureSubmit($form, $form_state);
+ }
+ }
+
+ /**
+ * Implements BlockInterface::configureSubmit().
+ */
+ public function configureSubmit($form, &$form_state) {}
+}
diff --git a/core/modules/block/lib/Drupal/block/BlockBundle.php b/core/modules/block/lib/Drupal/block/BlockBundle.php
new file mode 100755
index 0000000..5ea31a3
--- /dev/null
+++ b/core/modules/block/lib/Drupal/block/BlockBundle.php
@@ -0,0 +1,24 @@
+register('plugin.manager.block', 'Drupal\block\Plugin\Type\BlockManager');
+ }
+}
\ No newline at end of file
diff --git a/core/modules/block/lib/Drupal/block/BlockInterface.php b/core/modules/block/lib/Drupal/block/BlockInterface.php
new file mode 100755
index 0000000..b6a50b0
--- /dev/null
+++ b/core/modules/block/lib/Drupal/block/BlockInterface.php
@@ -0,0 +1,86 @@
+derivatives) && !empty($this->derivatives[$derivative_id])) {
+ return $this->derivatives[$derivative_id];
+ }
+ $this->getDerivativeDefinitions($base_plugin_definition);
+ return $this->derivatives[$derivative_id];
+ }
+
+ /**
+ * Implements DerivativeInterface::getDerivativeDefinitions().
+ */
+ public function getDerivativeDefinitions(array $base_plugin_definition) {
+ foreach (list_themes() as $key => $theme) {
+ $this->derivatives[$key] = $base_plugin_definition;
+ }
+ return $this->derivatives;
+ }
+}
\ No newline at end of file
diff --git a/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php b/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php
new file mode 100755
index 0000000..6ffb31f
--- /dev/null
+++ b/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php
@@ -0,0 +1,18 @@
+discovery = new AlterDecorator(new DerivativeDiscoveryDecorator(new AnnotatedClassDiscovery('block', 'block')), 'block');
+ $this->factory = new DefaultFactory($this);
+ $this->mapper = new ConfigMapper($this);
+ }
+}
\ No newline at end of file
diff --git a/core/modules/block/lib/Drupal/block/Plugin/system/plugin_ui/BlockPluginUI.php b/core/modules/block/lib/Drupal/block/Plugin/system/plugin_ui/BlockPluginUI.php
new file mode 100755
index 0000000..edf0351
--- /dev/null
+++ b/core/modules/block/lib/Drupal/block/Plugin/system/plugin_ui/BlockPluginUI.php
@@ -0,0 +1,67 @@
+ 'value',
+ '#value' => $theme,
+ );
+ return parent::form($form, $form_state, $plugin, $facet);
+ }
+
+ public function excludeDefinitions($definitions) {
+ foreach ($definitions as $key => $definition) {
+ if (!empty($definition['custom'])) {
+ unset($definitions[$key]);
+ }
+ }
+ return $definitions;
+ }
+
+ public function formSubmit($form, &$form_state) {
+ $form_state['redirect'] = 'admin/structure/block/manage/' . $form_state['values']['block'] . '/' . $form_state['values']['theme'];
+ }
+
+ public function access($plugin_id) {
+ list($plugin, $theme) = explode(':', $plugin_id);
+ return _block_themes_access($theme);
+ }
+
+ public function tableHeader() {
+ return array(t('Subject'), t('Operations'));
+ }
+
+ public function row($plugin, $plugin_definition, $plugin_id, $config) {
+ list($plugin, $theme) = explode(':', $plugin);
+ return array($config['subject'], l($plugin_definition['link_title'], $plugin_definition['config_path'] . '/' . $plugin_id . '/' . $theme));
+ }
+}
\ No newline at end of file
diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockUiTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockUiTest.php
new file mode 100755
index 0000000..179464c
--- /dev/null
+++ b/core/modules/block/lib/Drupal/block/Tests/BlockUiTest.php
@@ -0,0 +1,46 @@
+ 'Block UI',
+ 'description' => 'Checks that the block configuration UI stores data correctly.',
+ 'group' => 'Block',
+ );
+ }
+ 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 visibility.
+ */
+ function testBlockVisibility() {
+ }
+}
diff --git a/core/modules/block/tests/lib/Drupal/block_test/Plugin/block/block/TestCacheBlock.php b/core/modules/block/tests/lib/Drupal/block_test/Plugin/block/block/TestCacheBlock.php
new file mode 100755
index 0000000..c07bdba
--- /dev/null
+++ b/core/modules/block/tests/lib/Drupal/block_test/Plugin/block/block/TestCacheBlock.php
@@ -0,0 +1,33 @@
+ DRUPAL_CACHE_PER_ROLE,
+ );
+ }
+
+ /**
+ * Implements BlockInterface::build().
+ */
+ public function build() {
+ return array('#children' => variable_get('block_test_content', ''));
+ }
+}
diff --git a/core/modules/block/tests/lib/Drupal/block_test/Plugin/block/block/TestHtmlIdBlock.php b/core/modules/block/tests/lib/Drupal/block_test/Plugin/block/block/TestHtmlIdBlock.php
new file mode 100755
index 0000000..e7ca2f7
--- /dev/null
+++ b/core/modules/block/tests/lib/Drupal/block_test/Plugin/block/block/TestHtmlIdBlock.php
@@ -0,0 +1,16 @@
+ DRUPAL_CACHE_PER_PAGE | DRUPAL_CACHE_PER_ROLE,
+ 'block_mode' => "all pages",
+ );
+ }
+
+ /**
+ * Implements BlockInterface::configure()
+ */
+ function configure($form, &$form_state) {
+ $options = array(
+ 'all pages' => t('Show block on all pages'),
+ 'book pages' => t('Show block only on book pages'),
+ );
+ $form['book_block_mode'] = array(
+ '#type' => 'radios',
+ '#title' => t('Book navigation block display'),
+ '#options' => $options,
+ '#default_value' => $this->configuration['block_mode'],
+ '#description' => t("If Show block on all pages is selected, the block will contain the automatically generated menus for all of the site's books. If Show block only on book pages is selected, the block will contain only the one menu corresponding to the current page's book. In this case, if the current page is not in a book, no block will be displayed. The Page specific visibility settings or other visibility settings can be used in addition to selectively display this block."),
+ );
+
+ return $form;
+ }
+
+ /**
+ * Implements BlockInterface::configureSubmit().
+ */
+ public function configureSubmit($form, &$form_state) {
+ $this->configuration['block_mode'] = $form_state['values']['book_block_mode'];
+ }
+
+ /**
+ * Implements BlockInterface::build().
+ */
+ public function build() {
+ $current_bid = 0;
+ if ($node = menu_get_object()) {
+ $current_bid = empty($node->book['bid']) ? 0 : $node->book['bid'];
+ }
+ if ($this->configuration['block_mode'] == 'all pages') {
+ $book_menus = array();
+ $pseudo_tree = array(0 => array('below' => FALSE));
+ foreach (book_get_books() as $book_id => $book) {
+ if ($book['bid'] == $current_bid) {
+ // If the current page is a node associated with a book, the menu
+ // needs to be retrieved.
+ $book_menus[$book_id] = menu_tree_output(menu_tree_all_data($node->book['menu_name'], $node->book));
+ }
+ else {
+ // Since we know we will only display a link to the top node, there
+ // is no reason to run an additional menu tree query for each book.
+ $book['in_active_trail'] = FALSE;
+ // Check whether user can access the book link.
+ $book_node = node_load($book['nid']);
+ $book['access'] = node_access('view', $book_node);
+ $pseudo_tree[0]['link'] = $book;
+ $book_menus[$book_id] = menu_tree_output($pseudo_tree);
+ }
+ }
+ if ($book_menus) {
+ return array(
+ '#theme' => 'book_all_books_block',
+ $book_menus
+ );
+ }
+ }
+ elseif ($current_bid) {
+ // Only display this block when the user is browsing a book.
+ $select = db_select('node', 'n')
+ ->fields('n', array('title'))
+ ->condition('n.nid', $node->book['bid'])
+ ->addTag('node_access');
+ $title = $select->execute()->fetchField();
+ // Only show the block if the user has view access for the top-level node.
+ if ($title) {
+ $tree = menu_tree_all_data($node->book['menu_name'], $node->book);
+ // There should only be one element at the top level.
+ $data = array_shift($tree);
+ $below = menu_tree_output($data['below']);
+ if (!empty($below)) {
+ return array(
+ '#title' => theme('book_title_link', array('link' => $data['link'])),
+ $below,
+ );
+ }
+ }
+ }
+ return array();
+ }
+}
diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/block/block/RecentBlock.php b/core/modules/comment/lib/Drupal/comment/Plugin/block/block/RecentBlock.php
new file mode 100755
index 0000000..6f151fc
--- /dev/null
+++ b/core/modules/comment/lib/Drupal/comment/Plugin/block/block/RecentBlock.php
@@ -0,0 +1,60 @@
+ 10,
+ );
+ }
+
+ /**
+ * Implements BlockInterface::access().
+ */
+ public function access() {
+ return user_access('access comments');
+ }
+
+ /**
+ * Implements BlockInterface::configure().
+ */
+ public function configure($form, &$form_state) {
+ $form['block_count'] = array(
+ '#type' => 'select',
+ '#title' => t('Number of recent comments'),
+ '#default_value' => $this->configuration['block_count'],
+ '#options' => drupal_map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 30)),
+ );
+ return $form;
+ }
+
+ /**
+ * Implements BlockInterface::configureSubmit().
+ */
+ public function configureSubmit($form, &$form_state) {
+ $this->configuration['block_count'] = $form_state['values']['block_count'];
+ }
+
+ /**
+ * Implements BlockInterface::build();
+ */
+ public function build() {
+ return array(
+ '#theme' => 'comment_block',
+ '#number' => $this->configuration['block_count'],
+ );
+ }
+}
diff --git a/core/modules/forum/lib/Drupal/forum/Plugin/block/block/ActiveBlock.php b/core/modules/forum/lib/Drupal/forum/Plugin/block/block/ActiveBlock.php
new file mode 100755
index 0000000..709659d
--- /dev/null
+++ b/core/modules/forum/lib/Drupal/forum/Plugin/block/block/ActiveBlock.php
@@ -0,0 +1,71 @@
+ DRUPAL_CACHE_CUSTOM,
+ 'properties' => array(
+ 'administrative' => TRUE,
+ ),
+ 'block_count' => 5,
+ );
+ }
+
+ /**
+ * Implements BlockInterface::access().
+ */
+ public function access() {
+ return user_access('access content');
+ }
+
+ /**
+ * Implements BlockInterface::configure().
+ */
+ public function configure($form, &$form_state) {
+ $form['block_count'] = array(
+ '#type' => 'select',
+ '#title' => t('Number of topics'),
+ '#default_value' => $this->configuration['block_count'],
+ '#options' => drupal_map_assoc(range(2, 20)));
+ return $form;
+ }
+
+ /**
+ * Implements BlockInterface::configureSubmit().
+ */
+ public function configureSubmit($form, &$form_state) {
+ $this->configuration['block_count'] = $form_state['values']['block_count'];
+ }
+
+ /**
+ * Implements BlockInterface::build().
+ */
+ public function build() {
+ $query = db_select('forum_index', 'f')
+ ->fields('f')
+ ->addTag('node_access')
+ ->orderBy('f.last_comment_timestamp', 'DESC')
+ ->range(0, $this->configuration['block_count']);
+
+ return array(
+ drupal_render_cache_by_query($query, 'forum_block_view'),
+ );
+ }
+}
diff --git a/core/modules/forum/lib/Drupal/forum/Plugin/block/block/NewBlock.php b/core/modules/forum/lib/Drupal/forum/Plugin/block/block/NewBlock.php
new file mode 100755
index 0000000..0174f32
--- /dev/null
+++ b/core/modules/forum/lib/Drupal/forum/Plugin/block/block/NewBlock.php
@@ -0,0 +1,71 @@
+ DRUPAL_CACHE_CUSTOM,
+ 'properties' => array(
+ 'administrative' => TRUE,
+ ),
+ 'block_count' => 5,
+ );
+ }
+
+ /**
+ * Implements BlockInterface::access().
+ */
+ public function access() {
+ return user_access('access content');
+ }
+
+ /**
+ * Implements BlockInterface::configure().
+ */
+ public function configure($form, &$form_state) {
+ $form['block_count'] = array(
+ '#type' => 'select',
+ '#title' => t('Number of topics'),
+ '#default_value' => $this->configuration['block_count'],
+ '#options' => drupal_map_assoc(range(2, 20)));
+ return $form;
+ }
+
+ /**
+ * Implements BlockInterface::configureSubmit().
+ */
+ public function configureSubmit($form, &$form_state) {
+ $this->configuration['block_count'] = $form_state['values']['block_count'];
+ }
+
+ /**
+ * Implements BlockInterface::build().
+ */
+ public function build() {
+ $query = db_select('forum_index', 'f')
+ ->fields('f')
+ ->addTag('node_access')
+ ->orderBy('f.created', 'DESC')
+ ->range(0, $this->configuration['block_count']);
+
+ return array(
+ drupal_render_cache_by_query($query, 'forum_block_view'),
+ );
+ }
+}
diff --git a/core/modules/language/lib/Drupal/language/Plugin/Derivative/LanguageBlock.php b/core/modules/language/lib/Drupal/language/Plugin/Derivative/LanguageBlock.php
new file mode 100755
index 0000000..0dff21a
--- /dev/null
+++ b/core/modules/language/lib/Drupal/language/Plugin/Derivative/LanguageBlock.php
@@ -0,0 +1,34 @@
+derivatives) && !empty($this->derivatives[$derivative_id])) {
+ return $this->derivatives[$derivative_id];
+ }
+ $this->getDerivativeDefinitions($base_plugin_definition);
+ return $this->derivatives[$derivative_id];
+ }
+
+ /**
+ * Implements DerivativeInterface::getDerivativeDefinitions().
+ */
+ public function getDerivativeDefinitions(array $base_plugin_definition) {
+ include_once DRUPAL_ROOT . '/core/includes/language.inc';
+ $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]['cache'] = DRUPAL_NO_CACHE;
+ }
+ return $this->derivatives;
+ }
+}
diff --git a/core/modules/language/lib/Drupal/language/Plugin/block/block/LanguageBlock.php b/core/modules/language/lib/Drupal/language/Plugin/block/block/LanguageBlock.php
new file mode 100755
index 0000000..a4d689c
--- /dev/null
+++ b/core/modules/language/lib/Drupal/language/Plugin/block/block/LanguageBlock.php
@@ -0,0 +1,42 @@
+' : current_path();
+ list($plugin_id, $type) = explode(':', $this->getPluginId());
+ $links = language_negotiation_get_switch_links($type, $path);
+
+ if (isset($links->links)) {
+ $class = "language-switcher-{$links->method_id}";
+ $variables = array('links' => $links->links, 'attributes' => array('class' => array($class)));
+ return array(
+ '#children' => theme('links__language_block', $variables)
+ );
+ }
+ }
+}
diff --git a/core/modules/menu/lib/Drupal/menu/Plugin/Derivative/MenuBlock.php b/core/modules/menu/lib/Drupal/menu/Plugin/Derivative/MenuBlock.php
new file mode 100755
index 0000000..04a4c34
--- /dev/null
+++ b/core/modules/menu/lib/Drupal/menu/Plugin/Derivative/MenuBlock.php
@@ -0,0 +1,25 @@
+ $name) {
+ $this->derivatives[$menu] = $base_plugin_definition;
+ $this->derivatives[$menu]['delta'] = $menu;
+ $this->derivatives[$menu]['subject'] = t('Menu: @menu', array('@menu' => $name));
+ $this->derivatives[$menu]['cache'] = DRUPAL_NO_CACHE;
+ }
+ return $this->derivatives;
+ }
+}
diff --git a/core/modules/menu/lib/Drupal/menu/Plugin/block/block/MenuBlock.php b/core/modules/menu/lib/Drupal/menu/Plugin/block/block/MenuBlock.php
new file mode 100755
index 0000000..154106a
--- /dev/null
+++ b/core/modules/menu/lib/Drupal/menu/Plugin/block/block/MenuBlock.php
@@ -0,0 +1,18 @@
+ 10,
+ );
+ }
+
+ /**
+ * Implements BlockInterface::access().
+ */
+ public function access() {
+ return user_access('access content');
+ }
+
+ /**
+ * Implements BlockInterface::configure().
+ */
+ public function configure($form, &$form_state) {
+ $form['block_count'] = array(
+ '#type' => 'select',
+ '#title' => t('Number of recent content items to display'),
+ '#default_value' => $this->configuration['block_count'],
+ '#options' => drupal_map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 30)),
+ );
+ return $form;
+ }
+
+ /**
+ * Implements BlockInterface::configureSubmit().
+ */
+ public function configureSubmit($form, &$form_state) {
+ $this->configuration['block_count'] = $form_state['values']['block_count'];
+ }
+
+ /**
+ * Implements BlockInterface::build();
+ */
+ public function build() {
+ if ($nodes = node_get_recent($this->configuration['block_count'])) {
+ return array(
+ '#theme' => 'node_recent_block',
+ '#nodes' => $nodes,
+ );
+ }
+ else {
+ return array(
+ '#children' => t('No content available.'),
+ );
+ }
+ }
+}
diff --git a/core/modules/node/lib/Drupal/node/Plugin/block/block/SyndicateBlock.php b/core/modules/node/lib/Drupal/node/Plugin/block/block/SyndicateBlock.php
new file mode 100755
index 0000000..524b945
--- /dev/null
+++ b/core/modules/node/lib/Drupal/node/Plugin/block/block/SyndicateBlock.php
@@ -0,0 +1,43 @@
+ 10,
+ );
+ }
+
+ /**
+ * Implements BlockInterface::access().
+ */
+ public function access() {
+ return user_access('access content');
+ }
+
+ /**
+ * Implements BlockInterface::build();
+ */
+ public function build() {
+ return array(
+ '#theme' => 'feed_icon',
+ '#url' => 'rss.xml',
+ );
+ }
+}
diff --git a/core/modules/openid/lib/Drupal/openid/Tests/OpenIDTestBase.php b/core/modules/openid/lib/Drupal/openid/Tests/OpenIDTestBase.php
index f88ba92..a56f265 100644
--- a/core/modules/openid/lib/Drupal/openid/Tests/OpenIDTestBase.php
+++ b/core/modules/openid/lib/Drupal/openid/Tests/OpenIDTestBase.php
@@ -24,21 +24,18 @@
function setUp() {
parent::setUp();
+ // Login as a user that can configure blocks.
+ $this->block_user = $this->drupalCreateUser(array('administer blocks'));
+ $this->drupalLogin($this->block_user);
+
// Enable user login block.
- db_merge('block')
- ->key(array(
- 'module' => 'user',
- 'delta' => 'login',
- 'theme' => variable_get('theme_default', 'stark'),
- ))
- ->fields(array(
- 'status' => 1,
- 'weight' => 0,
- 'region' => 'sidebar_first',
- 'pages' => '',
- 'cache' => -1,
- ))
- ->execute();
+ $edit = array(
+ 'machine_name' => 'login',
+ 'region' => 'sidebar_first',
+ );
+ $this->drupalPost('admin/structure/block/manage/user_login_block/stark', $edit, t('Save block'));
+
+ $this->drupalLogout();
// Use a different front page than login page for testing OpenID login from
// the user login block.
diff --git a/core/modules/openid/openid.css b/core/modules/openid/openid.css
index f96058e..6d9dd8c 100644
--- a/core/modules/openid/openid.css
+++ b/core/modules/openid/openid.css
@@ -5,11 +5,11 @@
padding-left: 20px; /* LTR */
}
-#block-user-login #openid-login-form {
+.user-login-form #openid-login-form {
display: none;
}
-#block-user-login .openid-link {
+.user-login-form .openid-link {
background-image: url("login-bg.png");
background-position: left top; /* LTR */
background-repeat: no-repeat;
diff --git a/core/modules/openid/openid.js b/core/modules/openid/openid.js
index 716d36d..91f0102 100644
--- a/core/modules/openid/openid.js
+++ b/core/modules/openid/openid.js
@@ -16,23 +16,24 @@ Drupal.behaviors.openid = {
$.cookie('Drupal.visitor.openid_identifier', null);
}
- if ($('#block-user-login').length) {
- var $login_form = $('#user-login-form');
+ if ($('.user-login-form').length) {
+ var $login_form = $('.user-login-form');
var $openid_form = $('#openid-login-form');
// Change link text and triggers loginchange event.
- $('#block-user-login .openid-link').toggle(
+ $('.user-login-form .openid-link').toggle(
function() {
$(this).html(Drupal.t('Cancel OpenID login'));
- $login_form.hide();
+ $('.user-login-form > div > :not(#openid-login-form)').hide();
+ $('.user-login-form .item-list').show();
$openid_form.show();
clearStatus($login_form);
// Move focus to OpenID input.
- $('#edit-openid-identifier').focus();
+ $('.form-item-openid-identifier').focus();
},
function() {
$(this).html(Drupal.t('Log in using OpenID'));
- $login_form.show();
+ $('.user-login-form > div > :not(#openid-login-form)').show();
$openid_form.hide();
clearStatus($openid_form);
}
diff --git a/core/modules/openid/openid.module b/core/modules/openid/openid.module
index 5071793..8941b7f 100644
--- a/core/modules/openid/openid.module
+++ b/core/modules/openid/openid.module
@@ -127,23 +127,26 @@ function openid_user_logout($account) {
}
/**
- * Implements hook_block_view_MODULE_DELTA_alter().
+ * Implements hook_form_FORM_ID_alter().
*
- * Adds the OpenID login form to the user login block.
+ * Adds the OpenID login form to the user login form.
*
* @see user_login_block()
*/
-function openid_block_view_user_login_alter(&$block) {
- // Only alter the block when it is non-empty, i.e. when no user is logged in.
- if (!isset($block['content'])) {
- return;
- }
+function openid_form_user_login_form_alter(&$form) {
- $block['content']['openid_login_form'] = drupal_get_form('openid_login_form');
- $block['content']['openid_login_form']['openid_identifier']['#size'] = $block['content']['user_login_form']['name']['#size'];
+ $form['openid_login_form'] = drupal_get_form('openid_login_form');
+ $form['openid_login_form']['#prefix'] = '' . format_plural($authenticated_count, 'There is currently 1 user online.', 'There are currently @count users online.') . '
', + ); + + // Display a list of currently online users. + $max_users = $this->configuration['max_list_count']; + if ($authenticated_count && $max_users) { + $build['#users'] = db_query_range('SELECT u.uid, u.name, MAX(s.timestamp) AS max_timestamp FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.timestamp >= :interval AND s.uid > 0 GROUP BY u.uid, u.name ORDER BY max_timestamp DESC', 0, $max_users, array(':interval' => $interval))->fetchAll(); + } + + return $build; + } +} diff --git a/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsBlock.php b/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsBlock.php new file mode 100755 index 0000000..f39b5ed --- /dev/null +++ b/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsBlock.php @@ -0,0 +1,55 @@ +derivatives) && !empty($this->derivatives[$derivative_id])) { + return $this->derivatives[$derivative_id]; + } + $this->getDerivativeDefinitions($base_plugin_definition); + return $this->derivatives[$derivative_id]; + } + + /** + * Implements DerivativeInterface::getDerivativeDefinitions(). + */ + public function getDerivativeDefinitions(array $base_plugin_definition) { + foreach (views_get_all_views() as $view) { + // disabled views get nothing. + if (!$view->isEnabled()) { + continue; + } + $executable = $view->get('executable'); + $executable->initDisplay(); + foreach ($executable->displayHandlers as $display) { + if (isset($display) && !empty($display->definition['uses_hook_block'])) { + $delta = $view->get('name') . '-' . $display->display['id']; + $desc = $display->getOption('block_description'); + + if (empty($desc)) { + if ($display->display['display_title'] == $display->definition['title']) { + $desc = t('View: !view', array('!view' => $view->getHumanName())); + } + else { + $desc = t('View: !view: !display', array('!view' => $view->getHumanName(), '!display' => $display->display['display_title'])); + } + } + $this->derivatives[$delta] = array( + 'subject' => $desc, + 'cache' => $display->getCacheType() + ); + $this->derivatives[$delta] += $base_plugin_definition; + } + } + } + return $this->derivatives; + } +} diff --git a/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsExposedFilterBlock.php b/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsExposedFilterBlock.php new file mode 100755 index 0000000..98e67bd --- /dev/null +++ b/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsExposedFilterBlock.php @@ -0,0 +1,48 @@ +derivatives) && !empty($this->derivatives[$derivative_id])) { + return $this->derivatives[$derivative_id]; + } + $this->getDerivativeDefinitions($base_plugin_definition); + return $this->derivatives[$derivative_id]; + } + + /** + * Implements DerivativeInterface::getDerivativeDefinitions(). + */ + public function getDerivativeDefinitions(array $base_plugin_definition) { + foreach (views_get_all_views() as $view) { + // disabled views get nothing. + if (!$view->isEnabled()) { + continue; + } + $executable = $view->get('executable'); + $executable->initDisplay(); + foreach ($executable->displayHandlers as $display) { + if (isset($display) && $display->getOption('exposed_block')) { + if ($display->usesExposedFormInBlock()) { + $delta = $view->get('name') . '-' . $display->display['id']; + $desc = t('Exposed form: @view-@display_id', array('@view' => $view->get('name'), '@display_id' => $display->display['id'])); + $this->derivatives[$delta] = array( + 'subject' => $desc, + 'cache' => DRUPAL_NO_CACHE, + ); + $this->derivatives[$delta] += $base_plugin_definition; + } + } + } + } + return $this->derivatives; + } +} diff --git a/core/modules/views/lib/Drupal/views/Plugin/block/block/ViewsBlock.php b/core/modules/views/lib/Drupal/views/Plugin/block/block/ViewsBlock.php new file mode 100755 index 0000000..09a6c01 --- /dev/null +++ b/core/modules/views/lib/Drupal/views/Plugin/block/block/ViewsBlock.php @@ -0,0 +1,57 @@ +getPluginId()); + + $start = microtime(TRUE); + + list($name, $display_id) = explode('-', $delta, 2); + $this->display_id = $display_id; + // Load the view + $this->view = views_get_view($name); + $this->view->setDisplay($display_id); + } + + /** + * Implements BlockInterface::access(). + */ + public function access() { + return $this->view->access($this->display_id); + } + + /** + * Implements BlockInterface::build(). + */ + public function build() { + $output = $this->view->executeDisplay($this->display_id); + // Before returning the block output, convert it to a renderable array + // with contextual links. + views_add_block_contextual_links($output, $this->view, $this->display_id); + $this->view->destroy(); + return $output; + } +} diff --git a/core/modules/views/lib/Drupal/views/Plugin/block/block/ViewsExposedFilterBlock.php b/core/modules/views/lib/Drupal/views/Plugin/block/block/ViewsExposedFilterBlock.php new file mode 100755 index 0000000..ef9feae --- /dev/null +++ b/core/modules/views/lib/Drupal/views/Plugin/block/block/ViewsExposedFilterBlock.php @@ -0,0 +1,30 @@ +view->display_handler->viewSpecialBlocks($type); + // Before returning the block output, convert it to a renderable + // array with contextual links. + views_add_block_contextual_links($output, $this->view, $this->display_id, 'special_block_' . $type); + $this->view->destroy(); + return $output; + } +} diff --git a/core/profiles/standard/config/plugin.core.block.bartik.content.yml b/core/profiles/standard/config/plugin.core.block.bartik.content.yml new file mode 100755 index 0000000..e10f903 --- /dev/null +++ b/core/profiles/standard/config/plugin.core.block.bartik.content.yml @@ -0,0 +1,18 @@ +id: system_main_block +status: '1' +cache: '-1' +visibility: + path: + visibility: '0' + pages: '' + role: + roles: { } + node_type: + types: + article: '0' + page: '0' + visibility__active_tab: edit-visibility-path +subject: '' +module: system +region: content +weight: '0' diff --git a/core/profiles/standard/config/plugin.core.block.bartik.help.yml b/core/profiles/standard/config/plugin.core.block.bartik.help.yml new file mode 100755 index 0000000..a5c4467 --- /dev/null +++ b/core/profiles/standard/config/plugin.core.block.bartik.help.yml @@ -0,0 +1,18 @@ +id: system_help_block +status: '1' +cache: '-1' +visibility: + path: + visibility: '0' + pages: '' + role: + roles: { } + node_type: + types: + article: '0' + page: '0' + visibility__active_tab: edit-visibility-path +subject: '' +module: system +region: help +weight: '0' diff --git a/core/profiles/standard/config/plugin.core.block.bartik.login.yml b/core/profiles/standard/config/plugin.core.block.bartik.login.yml new file mode 100755 index 0000000..6eeeb34 --- /dev/null +++ b/core/profiles/standard/config/plugin.core.block.bartik.login.yml @@ -0,0 +1,19 @@ +id: user_login_block +whois_new_count: '5' +status: '1' +cache: '-1' +visibility: + path: + visibility: '0' + pages: '' + role: + roles: { } + node_type: + types: + article: '0' + page: '0' + visibility__active_tab: edit-visibility-path +subject: '' +module: user +region: sidebar_first +weight: '0' diff --git a/core/profiles/standard/config/plugin.core.block.bartik.navigation.yml b/core/profiles/standard/config/plugin.core.block.bartik.navigation.yml new file mode 100755 index 0000000..a20b790 --- /dev/null +++ b/core/profiles/standard/config/plugin.core.block.bartik.navigation.yml @@ -0,0 +1,18 @@ +id: 'system_menu_block:menu-main' +status: '1' +cache: '-1' +visibility: + path: + visibility: '0' + pages: '' + role: + roles: { } + node_type: + types: + article: '0' + page: '0' + visibility__active_tab: edit-visibility-path +subject: '' +module: system +region: sidebar_first +weight: '0' diff --git a/core/profiles/standard/config/plugin.core.block.bartik.powered.yml b/core/profiles/standard/config/plugin.core.block.bartik.powered.yml new file mode 100755 index 0000000..3ef20d7 --- /dev/null +++ b/core/profiles/standard/config/plugin.core.block.bartik.powered.yml @@ -0,0 +1,18 @@ +id: system_powered_by_block +status: '1' +cache: '-1' +visibility: + path: + visibility: '0' + pages: '' + role: + roles: { } + node_type: + types: + article: '0' + page: '0' + visibility__active_tab: edit-visibility-path +subject: '' +module: system +region: footer +weight: '0' diff --git a/core/profiles/standard/config/plugin.core.block.bartik.search.yml b/core/profiles/standard/config/plugin.core.block.bartik.search.yml new file mode 100755 index 0000000..52a5788 --- /dev/null +++ b/core/profiles/standard/config/plugin.core.block.bartik.search.yml @@ -0,0 +1,18 @@ +id: search_form_block +status: '1' +cache: '-1' +visibility: + path: + visibility: '0' + pages: '' + role: + roles: { } + node_type: + types: + article: '0' + page: '0' + visibility__active_tab: edit-visibility-path +subject: '' +module: search +region: sidebar_first +weight: '0' diff --git a/core/profiles/standard/config/plugin.core.block.seven.content.yml b/core/profiles/standard/config/plugin.core.block.seven.content.yml new file mode 100755 index 0000000..51b155f --- /dev/null +++ b/core/profiles/standard/config/plugin.core.block.seven.content.yml @@ -0,0 +1,18 @@ +id: system_main_block +status: '1' +cache: '-1' +visibility: + path: + visibility: '0' + pages: '' + role: + roles: { } + node_type: + types: + article: '0' + page: '0' + visibility__active_tab: edit-visibility-path +subject: '' +module: system +region: content +weight: '-3' diff --git a/core/profiles/standard/config/plugin.core.block.seven.help.yml b/core/profiles/standard/config/plugin.core.block.seven.help.yml new file mode 100755 index 0000000..a5c4467 --- /dev/null +++ b/core/profiles/standard/config/plugin.core.block.seven.help.yml @@ -0,0 +1,18 @@ +id: system_help_block +status: '1' +cache: '-1' +visibility: + path: + visibility: '0' + pages: '' + role: + roles: { } + node_type: + types: + article: '0' + page: '0' + visibility__active_tab: edit-visibility-path +subject: '' +module: system +region: help +weight: '0' diff --git a/core/profiles/standard/config/plugin.core.block.seven.login.yml b/core/profiles/standard/config/plugin.core.block.seven.login.yml new file mode 100755 index 0000000..dbbcfac --- /dev/null +++ b/core/profiles/standard/config/plugin.core.block.seven.login.yml @@ -0,0 +1,19 @@ +region: '-1' +id: user_login_block +whois_new_count: '5' +status: '1' +cache: '-1' +visibility: + path: + visibility: '0' + pages: '' + role: + roles: { } + node_type: + types: + article: '0' + page: '0' + visibility__active_tab: edit-visibility-path +subject: '' +module: user +weight: '-3' diff --git a/core/profiles/standard/config/plugin.core.block.seven.navigation.yml b/core/profiles/standard/config/plugin.core.block.seven.navigation.yml new file mode 100755 index 0000000..879191e --- /dev/null +++ b/core/profiles/standard/config/plugin.core.block.seven.navigation.yml @@ -0,0 +1,18 @@ +region: '-1' +id: 'system_menu_block:menu-main' +status: '1' +cache: '-1' +visibility: + path: + visibility: '0' + pages: '' + role: + roles: { } + node_type: + types: + article: '0' + page: '0' + visibility__active_tab: edit-visibility-path +subject: '' +module: system +weight: '-2' diff --git a/core/profiles/standard/config/plugin.core.block.seven.powered.yml b/core/profiles/standard/config/plugin.core.block.seven.powered.yml new file mode 100755 index 0000000..b9aac19 --- /dev/null +++ b/core/profiles/standard/config/plugin.core.block.seven.powered.yml @@ -0,0 +1,18 @@ +region: '-1' +id: system_powered_by_block +status: '1' +cache: '-1' +visibility: + path: + visibility: '0' + pages: '' + role: + roles: { } + node_type: + types: + article: '0' + page: '0' + visibility__active_tab: edit-visibility-path +subject: '' +module: system +weight: '0' diff --git a/core/profiles/standard/config/plugin.core.block.seven.search.yml b/core/profiles/standard/config/plugin.core.block.seven.search.yml new file mode 100755 index 0000000..e3cf4c3 --- /dev/null +++ b/core/profiles/standard/config/plugin.core.block.seven.search.yml @@ -0,0 +1,18 @@ +region: '-1' +id: search_form_block +status: '1' +cache: '-1' +visibility: + path: + visibility: '0' + pages: '' + role: + roles: { } + node_type: + types: + article: '0' + page: '0' + visibility__active_tab: edit-visibility-path +subject: '' +module: search +weight: '-1'