diff --git a/core/lib/Drupal/Core/Plugin/Mapper/ConfigMapper.php b/core/lib/Drupal/Core/Plugin/Mapper/ConfigMapper.php new file mode 100755 index 0000000..87da30b --- /dev/null +++ b/core/lib/Drupal/Core/Plugin/Mapper/ConfigMapper.php @@ -0,0 +1,27 @@ +manager = $manager; + } + + /** + * Implements MapperInterface::getInstance(). + */ + public function getInstance(array $options) { + $config = config($options['config']); + if ($config) { + $plugin_id = $config->get('id'); + $settings = $config->get(); + $settings['config_id'] = $options['config']; + return $this->manager->createInstance($plugin_id, $settings); + } + // @Todo throw an exception. + } +} \ No newline at end of file diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Derivative/CategoryBlock.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Derivative/CategoryBlock.php new file mode 100755 index 0000000..1a128c9 --- /dev/null +++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Derivative/CategoryBlock.php @@ -0,0 +1,46 @@ +derivatives) && !empty($this->derivatives[$derivative_id])) { + return $this->derivatives[$derivative_id]; + } + $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)); + return $this->derivatives[$derivative_id]; + } + + /** + * Implements DerivativeInterface::getDerivativeDefinitions(). + */ + public function getDerivativeDefinitions(array $base_plugin_definition) { + // TODO. This check is here for simpletest. See + // http://drupal.org/node/1821658 + if (!module_exists('aggregator')) { + return array(); + } + $result = db_query('SELECT cid, title FROM {aggregator_category} ORDER BY title'); + 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)); + } + return $this->derivatives; + } +} diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Derivative/FeedBlock.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Derivative/FeedBlock.php new file mode 100755 index 0000000..23fa03e --- /dev/null +++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Derivative/FeedBlock.php @@ -0,0 +1,46 @@ +derivatives) && !empty($this->derivatives[$derivative_id])) { + return $this->derivatives[$derivative_id]; + } + $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 feed latest items', array('@title' => $result->title)); + return $this->derivatives[$derivative_id]; + } + + /** + * Implements DerivativeInterface::getDerivativeDefinitions(). + */ + public function getDerivativeDefinitions(array $base_plugin_definition) { + // TODO. This check is here for simpletest. See + // http://drupal.org/node/1821658 + if (!module_exists('aggregator')) { + return array(); + } + $result = db_query('SELECT fid, title FROM {aggregator_feed} WHERE block <> 0 ORDER BY fid'); + 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)); + } + return $this->derivatives; + } +} diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/block/block/CategoryBlock.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/block/block/CategoryBlock.php new file mode 100755 index 0000000..c7cd27e --- /dev/null +++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/block/block/CategoryBlock.php @@ -0,0 +1,78 @@ + 10, + ); + } + + /** + * Implements BlockInterface::access(). + */ + public function access() { + return user_access('access news feeds'); + } + + /** + * Implements BlockInterface::configure(). + */ + public function configure($form, &$form_state) { + $form['block_count'] = array( + '#type' => 'select', + '#title' => t('Number of news items in block'), + '#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() { + $id = $this->getPluginId(); + if ($category = db_query('SELECT cid, title, block FROM {aggregator_category} WHERE cid = :cid', array(':cid' => $id))->fetchObject()) { + $result = db_query_range('SELECT i.* FROM {aggregator_category_item} ci LEFT JOIN {aggregator_item} i ON ci.iid = i.iid WHERE ci.cid = :cid ORDER BY i.timestamp DESC, i.iid DESC', 0, $this->configuration['block_count'], array(':cid' => $category->cid)); + $read_more = theme('more_link', array('url' => 'aggregator/categories/' . $category->cid, 'title' => t("View this category's recent news."))); + + $items = array(); + foreach ($result as $item) { + $items[] = theme('aggregator_block_item', array('item' => $item)); + } + + // Only display the block if there are items to show. + if (count($items) > 0) { + return array( + '#children' => theme('item_list', array('items' => $items)) . $read_more, + ); + } + return array(); + } + } +} diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/block/block/FeedBlock.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/block/block/FeedBlock.php new file mode 100755 index 0000000..a2a0742 --- /dev/null +++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/block/block/FeedBlock.php @@ -0,0 +1,77 @@ + 10, + ); + } + + /** + * Implements BlockInterface::access(). + */ + public function access() { + return user_access('access news feeds'); + } + + /** + * Implements BlockInterface::configure(). + */ + public function configure($form, &$form_state) { + $form['block_count'] = array( + '#type' => 'select', + '#title' => t('Number of news items in block'), + '#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() { + // Plugin ids look something like this: aggregator_feed_block:1. + $id = substr($this->getPluginId(), 22); + if ($feed = db_query('SELECT fid, title, block FROM {aggregator_feed} WHERE block <> 0 AND fid = :fid', array(':fid' => $id))->fetchObject()) { + $result = db_query_range("SELECT * FROM {aggregator_item} WHERE fid = :fid ORDER BY timestamp DESC, iid DESC", 0, $this->configuration['block_count'], array(':fid' => $id)); + $read_more = theme('more_link', array('url' => 'aggregator/sources/' . $feed->fid, 'title' => t("View this feed's recent news."))); + + $items = array(); + foreach ($result as $item) { + $items[] = theme('aggregator_block_item', array('item' => $item)); + } + // Only display the block if there are items to show. + if (count($items) > 0) { + return array( + '#children' => theme('item_list', array('items' => $items)) . $read_more, + ); + } + } + } +} diff --git a/core/modules/block/custom_block/custom_block.admin.inc b/core/modules/block/custom_block/custom_block.admin.inc new file mode 100755 index 0000000..e1f015b --- /dev/null +++ b/core/modules/block/custom_block/custom_block.admin.inc @@ -0,0 +1,42 @@ + array( + 'data' => t('Administrative Title'), + 'field' => 'cb.info', + ), + 'operations' => array( + 'data' => t('Operations') + ) + ); + $header = array(t('Administrative Title'), t('Operations')); + $options = array(); + $results = db_select('block_custom', 'cb') + ->fields('cb') + ->execute(); + foreach ($results as $result) { + $options[$result->bid] = array( + array( + l($result->info, 'custom_block/' . $result->bid . '/edit'), + ), + array( + theme('links', array('links' => array(array( + 'title' => t('edit'), + 'href' => 'custom_block/' . $result->bid . '/edit', + 'query' => $destination, + ))) + ), + ), + ); + } + $form['blocks'] = array( + '#type' => 'tableselect', + '#header' => $header, + '#options' => $options, + '#empty' => t('No custom blocks are available.'), + ); + $form['pager'] = array('#markup' => theme('pager')); + return $form; +} \ No newline at end of file diff --git a/core/modules/block/custom_block/custom_block.info b/core/modules/block/custom_block/custom_block.info new file mode 100755 index 0000000..f9e8f05 --- /dev/null +++ b/core/modules/block/custom_block/custom_block.info @@ -0,0 +1,6 @@ +name = Custom Block +description = Allows the ability to create custom blocks through the block interface. +package = Core +version = VERSION +core = 8.x +dependencies[] = block diff --git a/core/modules/block/custom_block/custom_block.install b/core/modules/block/custom_block/custom_block.install new file mode 100755 index 0000000..a12ccee --- /dev/null +++ b/core/modules/block/custom_block/custom_block.install @@ -0,0 +1,41 @@ + 'Stores contents of custom-made blocks.', + 'fields' => array( + 'bid' => array( + 'type' => 'serial', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'description' => "The block's {block}.bid.", + ), + 'body' => array( + 'type' => 'text', + 'not null' => FALSE, + 'size' => 'big', + 'description' => 'Block contents.', + 'translatable' => TRUE, + ), + 'info' => array( + 'type' => 'varchar', + 'length' => 128, + 'not null' => TRUE, + 'default' => '', + 'description' => 'Block description.', + ), + 'format' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + 'description' => 'The {filter_format}.format of the block body.', + ), + ), + 'unique keys' => array( + 'info' => array('info'), + ), + 'primary key' => array('bid'), + ); + return $schema; +} \ No newline at end of file diff --git a/core/modules/block/custom_block/custom_block.module b/core/modules/block/custom_block/custom_block.module new file mode 100755 index 0000000..f7a0d98 --- /dev/null +++ b/core/modules/block/custom_block/custom_block.module @@ -0,0 +1,58 @@ +getDefinitions() as $plugin_id => $plugin) { + // We only need this menu item for the block_plugin_ui derivatives. + if (strpos($plugin_id, 'block_plugin_ui') === 0) { + list(, $theme) = explode(':', $plugin_id); + $items['admin/structure/block/list/' . $plugin_id . '/add/custom_blocks'] = array( + 'title' => 'Add Custom Block', + 'description' => 'Create a block with custom content and settings.', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('block_admin_configure', 'custom_block:custom_block', $theme), + 'access callback' => TRUE, + 'type' => MENU_LOCAL_ACTION, + 'file' => 'block.admin.inc', + 'file path' => drupal_get_path('module', 'block'), + ); + $items['admin/structure/block/list/' . $plugin_id . '/add/custom_blocks_library'] = array( + 'title' => 'Custom Blocks', + 'description' => 'Administrate custom blocks content.', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('custom_block_admin_custom_block'), + 'access callback' => TRUE, + 'type' => MENU_LOCAL_TASK, + 'file' => 'custom_block.admin.inc', + 'file path' => drupal_get_path('module', 'custom_block'), + ); + } + } + return $items; +} + +/** + * Implements hook_theme(). + */ +function custom_block_theme($existing, $type, $theme, $path) { + return array( + 'custom_block_block' => array( + 'variables' => array('body' => NULL, 'format' => NULL), + ), + ); +} + +/** + * Returns HTML for a custom block. + * + * @ingroup themeable + */ +function theme_custom_block_block($variables) { + $body = $variables['body']; + $format = $variables['format']; + + return check_markup($body, $format); +} diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Derivative/CustomBlock.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Derivative/CustomBlock.php new file mode 100755 index 0000000..f8d9d64 --- /dev/null +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Derivative/CustomBlock.php @@ -0,0 +1,53 @@ +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) { + // TODO. This check is here for simpletest. See + // http://drupal.org/node/1821658 + if (!module_exists('custom_block')) { + return array(); + } + $results = db_select('block_custom', 'b') + ->fields('b') + ->execute(); + if ($results) { + foreach ($results as $result) { + $this->derivatives[$result->bid] = $base_plugin_definition; + $this->derivatives[$result->bid]['settings'] = array( + 'info' => $result->info, + 'body' => $result->body, + 'format' => $result->format, + ) + $base_plugin_definition['settings']; + $this->derivatives[$result->bid]['subject'] = $result->info; + unset($this->derivatives[$result->bid]['custom']); + } + } + $this->derivatives['custom_block'] = $base_plugin_definition; + return $this->derivatives; + } +} diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/block/block/CustomBlock.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/block/block/CustomBlock.php new file mode 100755 index 0000000..a00bc93 --- /dev/null +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/block/block/CustomBlock.php @@ -0,0 +1,96 @@ +getDefinition(); + $this->configuration = parent::getConfig(); + $this->configuration['status'] = $definition['settings']['status']; + $this->configuration['info'] = $definition['settings']['info']; + $this->configuration['body'] = $definition['settings']['body']; + $this->configuration['format'] = $definition['settings']['format']; + return $this->configuration; + } + + /** + * Implements BlockInterface::configure(). + */ + public function configure($form, &$form_state) { + $form = parent::configure($form, $form_state); + $form['settings']['info'] = array( + '#type' => 'textfield', + '#title' => t('Block description'), + '#required' => TRUE, + '#default_value' => $this->configuration['info'], + '#description' => t('A brief description of your block. Used on the Blocks administration page.', array('@overview' => url('admin/structure/block'))), + ); + if (!empty($this->configuration['info'])) { + $form['settings']['info']['#disabled'] = TRUE; + } + $form['settings']['body'] = array( + '#type' => 'text_format', + '#title' => t('Block body'), + '#default_value' => $this->configuration['body'], + '#format' => isset($this->configuration['format']) ? $this->configuration['format'] : filter_default_format(), + '#description' => t('The content of the block as shown to the user.'), + '#rows' => 15, + '#required' => TRUE, + ); + if (!empty($this->configuration['body'])) { + $form['settings']['body']['#disabled'] = TRUE; + } + $form['settings']['title']['#description'] = t('The title of the block as shown to the user.'); + return $form; + } + + /** + * Implements BlockInterface::configureSubmit(). + */ + public function configureSubmit($form, &$form_state) { + parent::configureSubmit($form, $form_state); + list(, $bid) = explode(':', $this->getPluginId()); + $block = array( + 'info' => $form_state['values']['info'], + 'body' => $form_state['values']['body']['value'], + 'format' => $form_state['values']['body']['format'], + 'bid' => is_numeric($bid) ? $bid : NULL, + ); + drupal_write_record('block_custom', $block, !is_null($block['bid']) ? array('bid') : array()); + $this->configuration['id'] = 'custom_block:' . $block['bid']; + } + + /** + * Implements BlockInterface::build(); + */ + public function build() { + return array( + '#theme' => 'custom_block_block', + '#body' => $this->configuration['body'], + '#format' => $this->configuration['format'], + ); + } +} diff --git a/core/modules/block/lib/Drupal/block/BlockBase.php b/core/modules/block/lib/Drupal/block/BlockBase.php new file mode 100755 index 0000000..322b550 --- /dev/null +++ b/core/modules/block/lib/Drupal/block/BlockBase.php @@ -0,0 +1,426 @@ +settings(); + $settings += array( + 'status' => TRUE, + 'cache' => DRUPAL_NO_CACHE, + ); + return $settings; + } + + /** + * Implements BlockInterface::settings(). + */ + public function settings() { + return array(); + } + + /** + * Implements BlockInterface::getConfig(). + */ + public function getConfig() { + if (empty($this->configuration)) { + $definition = $this->getDefinition(); + $this->configuration = $this->settingsWrapper(); + } + return $this->configuration; + } + + public function setConfig($key, $value) { + $this->configuration[$key] = $value; + } + + /** + * Implements BlockInterface::access(). + */ + public function access() { + return TRUE; + } + + /** + * Implements BlockInterface::accessWrapper(). + */ + public function accessWrapper() { + if ($this->access()) { + global $user, $theme_key; + // Status handling. + if (empty($this->configuration['status'])) { + return FALSE; + } + + // User Role Handling. + // If a block has no roles associated, it is displayed for every role. + // For blocks with roles associated, if none of the user's roles matches + // the settings from this block, access is denied. + if (!empty($this->configuration['visibility']['role']['roles']) && !array_intersect(array_filter($this->configuration['visibility']['role']['roles']), array_keys($user->roles))) { + // No match. + return FALSE; + } + + // Page path handling. + // Limited visibility blocks must list at least one page. + if (!empty($this->configuration['visibility']['path']['visibility']) && $this->configuration['visibility']['path']['visibility'] == BLOCK_VISIBILITY_LISTED && empty($this->configuration['visibility']['path']['pages'])) { + return FALSE; + } + + // Match path if necessary. + if (!empty($this->configuration['visibility']['path']['pages'])) { + // Convert path to lowercase. This allows comparison of the same path + // with different case. Ex: /Page, /page, /PAGE. + $pages = drupal_strtolower($this->configuration['visibility']['path']['pages']); + if ($this->configuration['visibility']['path']['visibility'] < BLOCK_VISIBILITY_PHP) { + // Compare the lowercase path alias (if any) and internal path. + $path = current_path(); + $path_alias = drupal_strtolower(drupal_get_path_alias($path)); + $page_match = drupal_match_path($path_alias, $pages) || (($path != $path_alias) && drupal_match_path($path, $pages)); + // When $block->visibility has a value of 0 (BLOCK_VISIBILITY_NOTLISTED), + // the block is displayed on all pages except those listed in $block->pages. + // When set to 1 (BLOCK_VISIBILITY_LISTED), it is displayed only on those + // pages listed in $block->pages. + $page_match = !($this->configuration['visibility']['path']['visibility'] xor $page_match); + } + elseif (module_exists('php')) { + $page_match = php_eval($this->configuration['visibility']['path']['pages']); + } + else { + $page_match = FALSE; + } + } + else { + $page_match = TRUE; + } + if (!$page_match) { + return FALSE; + } + + // Language visibility settings. + if (!empty($this->configuration['visibility']['language']['langcodes']) && array_filter($this->configuration['visibility']['language']['langcodes'])) { + if (empty($this->configuration['visibility']['language']['langcodes'][language($this->configuration['visibility']['language']['language_type'])->langcode])) { + return FALSE; + } + } + + // Check other modules for block access rules. + foreach (module_implements('block_access') as $module) { + if (module_invoke($module, 'block_access', $this) === FALSE) { + return FALSE; + } + } + return TRUE; + } + return FALSE; + } + + /** + * Implements BlockInterface::configureWrapper(). + */ + public function configureWrapper($form, &$form_state) { + $definition = $this->getDefinition(); + $config = $this->getConfig(); + $form['id'] = array( + '#type' => 'value', + '#value' => $definition['id'], + ); + $form['module'] = array( + '#type' => 'value', + '#value' => $definition['module'], + ); + + // Get the block subject for the page title. + $subject = isset($config['subject']) ? $config['subject'] : ''; + if ($subject) { + drupal_set_title(t("'%subject' block", array('%subject' => $subject)), PASS_THROUGH); + } + + $form['settings']['machine_name'] = array( + '#type' => 'textfield', + '#title' => t('Block machine name'), + '#maxlength' => 64, + '#description' => t('A unique name to save this block configuration. Must be alpha-numeric and be underscore separated.'), + '#default_value' => isset($config['config_id']) ? $config['config_id'] : '', + '#weight' => -20, + '#required' => TRUE, + ); + if (isset($config['config_id'])) { + $form['settings']['machine_name']['#disabled'] = TRUE; + } + + $form['settings']['title'] = array( + '#type' => 'textfield', + '#title' => t('Block title'), + '#maxlength' => 64, + '#description' => $definition['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($subject) ? $subject : '', + '#weight' => -19, + ); + + // Region settings. + $form['regions'] = array( + '#type' => 'fieldset', + '#title' => t('Region settings'), + '#collapsible' => FALSE, + '#description' => t('Specify in which themes and regions this block is displayed.'), + ); + + $theme_default = variable_get('theme_default', 'stark'); + $admin_theme = variable_get('admin_theme'); + $themes = list_themes(); + $key = $form['theme']['#value']; + $theme = $themes[$key]; + // Only display enabled themes + if ($theme->status) { + // 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']['region'] = array( + '#type' => 'select', + '#title' => $theme_title, + '#default_value' => !empty($config['region']) && $config['region'] != -1 ? $config['region'] : NULL, + '#empty_value' => BLOCK_REGION_NONE, + '#options' => system_region_list($key, REGIONS_VISIBLE), + '#required' => TRUE, + ); + } + + // Visibility settings. + $form['visibility_title'] = array( + '#type' => 'item', + '#title' => t('Visibility settings'), + ); + $form['visibility'] = array( + '#type' => 'vertical_tabs', + '#attached' => array( + 'js' => array(drupal_get_path('module', 'block') . '/block.js'), + ), + '#tree' => TRUE, + ); + + // Per-path visibility. + $form['visibility']['path'] = array( + '#type' => 'fieldset', + '#title' => t('Pages'), + '#collapsible' => TRUE, + '#collapsed' => TRUE, + '#group' => 'visibility', + '#weight' => 0, + ); + + //@TODO remove this access check and inject it in some other way. + // In fact this entire visibility settings section probably needs a + // separate user interface in the near future. + $access = user_access('use PHP for settings'); + if (!empty($config['visibility']['path']['visibility']) && $config['visibility']['path']['visibility'] == BLOCK_VISIBILITY_PHP && !$access) { + $form['visibility']['path']['visibility'] = array( + '#type' => 'value', + '#value' => BLOCK_VISIBILITY_PHP, + ); + $form['visibility']['path']['pages'] = array( + '#type' => 'value', + '#value' => !empty($config['visibility']['path']['pages']) ? $config['visibility']['path']['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' => !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'] = '
'; + $form['openid_login_form']['#suffix'] = '
'; + $form['openid_login_form']['openid_identifier']['#size'] = $form['name']['#size']; + + // TODO: This should not be needed, but currently user_login_form has no links. + if (!isset($form['user_links'])) { + $form['user_links'] = array('#theme' => 'item_list', '#items' => array()); + } // Put an OpenID link as a first element. - $block['content']['user_links']['#items'] = array( + $form['user_links']['#items'] = array( l(t('Log in using OpenID'), 'user/login/openid', array( 'attributes' => array( 'title' => t('Log in using OpenID.'), @@ -152,10 +155,10 @@ function openid_block_view_user_login_alter(&$block) { 'tabindex' => 0, ), )) - ) + $block['content']['user_links']['#items']; + ) + $form['user_links']['#items']; // Move links under the openid form. - $block['content']['user_links']['#weight'] = 10; + $form['user_links']['#weight'] = 10; } /** diff --git a/core/modules/poll/lib/Drupal/poll/Plugin/block/block/PollRecentBlock.php b/core/modules/poll/lib/Drupal/poll/Plugin/block/block/PollRecentBlock.php new file mode 100755 index 0000000..81ec76f --- /dev/null +++ b/core/modules/poll/lib/Drupal/poll/Plugin/block/block/PollRecentBlock.php @@ -0,0 +1,67 @@ + array( + 'administrative' => TRUE, + ), + ); + } + + /** + * Implements BlockInterface::access(). + */ + public function access() { + if (user_access('access content')) { + // Retrieve the latest poll. + $select = db_select('node', 'n'); + $select->join('poll', 'p', 'p.nid = n.nid'); + $select->fields('n', array('nid')) + ->condition('n.status', 1) + ->condition('p.active', 1) + ->orderBy('n.created', 'DESC') + ->range(0, 1) + ->addTag('node_access'); + + $record = $select->execute()->fetchObject(); + if ($record) { + $this->record = $record; + return TRUE; + } + } + return FALSE; + } + + /** + * Implements BlockInterface::build(). + */ + public function build() { + $poll = node_load($this->record->nid); + if ($poll->nid) { + $poll = poll_block_latest_poll_view($poll); + return array( + $poll->content + ); + } + return array(); + } +} \ No newline at end of file diff --git a/core/modules/search/lib/Drupal/search/Plugin/block/block/SearchBlock.php b/core/modules/search/lib/Drupal/search/Plugin/block/block/SearchBlock.php new file mode 100755 index 0000000..008daa2 --- /dev/null +++ b/core/modules/search/lib/Drupal/search/Plugin/block/block/SearchBlock.php @@ -0,0 +1,31 @@ + 0, + 'top_all_num' => 0, + 'top_last_num' => 0 + ); + } + + /** + * Implements BlockInterface::access(). + */ + public function access() { + if (user_access('access content')) { + $daytop = $this->configuration['top_day_num']; + if (!$daytop || !($result = statistics_title_list('daycount', $daytop)) || !($this->day_list = node_title_list($result, t("Today's:")))) { + return FALSE; + } + $alltimetop = $this->configuration['top_all_num']; + if (!$alltimetop || !($result = statistics_title_list('totalcount', $alltimetop)) || !($this->all_time_list = node_title_list($result, t('All time:')))) { + return FALSE; + } + $lasttop = $this->configuration['top_last_num']; + if (!$lasttop || !($result = statistics_title_list('timestamp', $lasttop)) || !($this->last_list = node_title_list($result, t('Last viewed:')))) { + return FALSE; + } + return TRUE; + } + return FALSE; + } + + /** + * Implements BlockInterface::configure(). + */ + public function configure($form, &$form_state) { + // Popular content block settings + $numbers = array('0' => t('Disabled')) + drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 40)); + $form['statistics_block_top_day_num'] = array( + '#type' => 'select', + '#title' => t("Number of day's top views to display"), + '#default_value' => $this->configuration['top_day_num'], + '#options' => $numbers, + '#description' => t('How many content items to display in "day" list.') + ); + $form['statistics_block_top_all_num'] = array( + '#type' => 'select', + '#title' => t('Number of all time views to display'), + '#default_value' => $this->configuration['top_all_num'], + '#options' => $numbers, + '#description' => t('How many content items to display in "all time" list.') + ); + $form['statistics_block_top_last_num'] = array( + '#type' => 'select', + '#title' => t('Number of most recent views to display'), + '#default_value' => $this->configuration['top_last_num'], + '#options' => $numbers, + '#description' => t('How many content items to display in "recently viewed" list.') + ); + return $form; + } + + /** + * Implements BlockInterface::configureSubmit(). + */ + public function configureSubmit($form, &$form_state) { + $this->configuration['top_day_num'] = $form_state['values']['statistics_block_top_day_num']; + $this->configuration['top_all_num'] = $form_state['values']['statistics_block_top_all_num']; + $this->configuration['top_last_num'] = $form_state['values']['statistics_block_top_last_num']; + } + + /** + * Implements BlockInterface::build(). + */ + public function build() { + $content = array(); + + if ($this->day_list) { + $content['top_day'] = $this->day_list; + $content['top_day']['#suffix'] = '
'; + } + + if ($this->all_time_list) { + $content['top_all'] = $this->all_time_list; + $content['top_all']['#suffix'] = '
'; + } + + if ($this->last_list) { + $content['top_last'] = $this->last_list; + $content['top_last']['#suffix'] = '
'; + } + + return $content; + } + +} diff --git a/core/modules/system/lib/Drupal/system/Plugin/Derivative/SystemMenuBlock.php b/core/modules/system/lib/Drupal/system/Plugin/Derivative/SystemMenuBlock.php new file mode 100755 index 0000000..9ab2455 --- /dev/null +++ b/core/modules/system/lib/Drupal/system/Plugin/Derivative/SystemMenuBlock.php @@ -0,0 +1,36 @@ +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 (menu_list_system_menus() as $menu => $name) { + // The block deltas need to be prefixed with 'menu-', since the 'main' + // menu would otherwise clash with the 'main' page content block. + $menu = "menu-$menu"; + $this->derivatives[$menu] = $base_plugin_definition; + $this->derivatives[$menu]['delta'] = $menu; + $this->derivatives[$menu]['subject'] = t('System Menu: @menu', array('@menu' => $name)); + $this->derivatives[$menu]['cache'] = DRUPAL_NO_CACHE; + } + return $this->derivatives; + } +} diff --git a/core/modules/system/lib/Drupal/system/Plugin/PluginUIBase.php b/core/modules/system/lib/Drupal/system/Plugin/PluginUIBase.php new file mode 100755 index 0000000..c8c6ad2 --- /dev/null +++ b/core/modules/system/lib/Drupal/system/Plugin/PluginUIBase.php @@ -0,0 +1,86 @@ +getDefinition(); + $manager = new $plugin_definition['manager'](); + $plugins = $this->excludeDefinitions($manager->getDefinitions()); + $form['#theme'] = 'system_plugin_ui_form'; + $form['instance'] = array( + '#type' => 'value', + '#value' => $this, + ); + $form['right']['block'] = array( + '#type' => 'textfield', + '#title' => t('Search'), + '#autocomplete_path' => 'system/autocomplete/' . $this->getPluginId(), + ); + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Next'), + ); + $rows = array(); + foreach ($plugins as $plugin_id => $config) { + if (empty($facet) || $this->facetCompare($facet, $config)) { + $row = $this->row($plugin, $plugin_definition, $plugin_id, $config); + $rows[] = $row; + } + foreach ($plugin_definition['facets'] as $key => $title) { + $facets[$key][$config[$key]] = $this->facetLink($key, $plugin, $plugin_definition, $plugin_id, $config, $key); + } + $form['right']['all_plugins'] = array( + '#type' => 'markup', + '#markup' => l($plugin_definition['all_plugins'], $this->allPluginsUrl($plugin, $plugin_definition, $plugin_id, $config)), + ); + foreach ($facets as $group => $values) { + $form['right'][$group] = array( + '#type' => 'markup', + '#markup' => theme('links', array('heading' => array('text' => $plugin_definition['facets'][$group], 'level' => 'h3'), 'links' => $values)), + ); + } + $form['left']['plugin_library'] = array( + '#type' => 'markup', + '#markup' => theme('table', array('header' => $this->tableHeader(), 'rows' => $rows)), + ); + } + return $form; + } + + public function formValidate($form, &$form_state) {} + + public function formSubmit($form, &$form_state) {} + + public function excludeDefinitions($definitions) { + return $definitions; + } + + public function access($plugin_id) { + $definition = $this->getDefinition($plugin_id); + return call_user_func_array('user_access', $definition['access_arguments']); + } + + public function row($plugin, $plugin_definition, $plugin_id, $config) { + return array($config['title'], l($plugin_definition['link_title'], $plugin_definition['config_path'] . '/' . $plugin_id)); + } + + public function facetLink($facet, $plugin, $plugin_definition, $plugin_id, $config, $key) { + return array('title' => $config[$key], 'href' => $plugin_definition['path'] . '/' . $plugin . '/' . $facet . ':' . $config[$key]); + } + + public function allPluginsUrl($plugin, $plugin_definition, $plugin_id, $config) { + return $plugin_definition['path'] . '/' . $plugin . '/add'; + } + + public function tableHeader() { + return array(t('Title'), t('Operations')); + } + + public function facetCompare($facet, $config) { + list($facet_type, $option) = explode(':', $facet); + return $option == $config[$facet_type]; + } +} diff --git a/core/modules/system/lib/Drupal/system/Plugin/PluginUIInterface.php b/core/modules/system/lib/Drupal/system/Plugin/PluginUIInterface.php new file mode 100755 index 0000000..e05e90f --- /dev/null +++ b/core/modules/system/lib/Drupal/system/Plugin/PluginUIInterface.php @@ -0,0 +1,16 @@ +discovery = new DerivativeDiscoveryDecorator(new AnnotatedClassDiscovery('system', 'plugin_ui')); + $this->factory = new ReflectionFactory($this); + } + + protected function processDefinition(&$definition, $plugin_id) { + $definition += array( + 'default_task' => TRUE, + 'task_title' => t('View'), + 'task_suffix' => 'view', + ); + } +} \ No newline at end of file diff --git a/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemHelpBlock.php b/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemHelpBlock.php new file mode 100755 index 0000000..7bfb5e2 --- /dev/null +++ b/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemHelpBlock.php @@ -0,0 +1,38 @@ +help = menu_get_active_help(); + return $this->help ? TRUE : FALSE; + } + + /** + * Implements BlockInterface::build(). + */ + public function build() { + if (empty($this->help)) { + $this->help = menu_get_active_help(); + } + return array( + '#children' => $this->help, + ); + } +} diff --git a/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemMainBlock.php b/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemMainBlock.php new file mode 100755 index 0000000..2fe6ce4 --- /dev/null +++ b/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemMainBlock.php @@ -0,0 +1,26 @@ +uid) { + return FALSE; + } + return TRUE; + } + + /** + * Implements BlockInterface::build(). + */ + public function build() { + list($plugin, $derivative) = explode(':', $this->getPluginId()); + return menu_tree($derivative); + } +} diff --git a/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemPoweredByBlock.php b/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemPoweredByBlock.php new file mode 100755 index 0000000..5c6e0b9 --- /dev/null +++ b/core/modules/system/lib/Drupal/system/Plugin/block/block/SystemPoweredByBlock.php @@ -0,0 +1,26 @@ + theme('system_powered_by'), + ); + } +} diff --git a/core/modules/system/lib/Drupal/system/SystemBundle.php b/core/modules/system/lib/Drupal/system/SystemBundle.php new file mode 100755 index 0000000..af2c029 --- /dev/null +++ b/core/modules/system/lib/Drupal/system/SystemBundle.php @@ -0,0 +1,25 @@ +register('plugin.manager.system.plugin_ui', 'Drupal\system\Plugin\Type\PluginUIManager'); + } +} \ No newline at end of file diff --git a/core/modules/system/system.plugin.ui.css b/core/modules/system/system.plugin.ui.css new file mode 100755 index 0000000..207a6ee --- /dev/null +++ b/core/modules/system/system.plugin.ui.css @@ -0,0 +1,29 @@ +#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; +} \ No newline at end of file diff --git a/core/modules/system/templates/system-plugin-ui-form.tpl.php b/core/modules/system/templates/system-plugin-ui-form.tpl.php new file mode 100755 index 0000000..8179076 --- /dev/null +++ b/core/modules/system/templates/system-plugin-ui-form.tpl.php @@ -0,0 +1,32 @@ + +
+
+
+ +
+
+
+
+ +
+
+ +
+ +
diff --git a/core/modules/user/lib/Drupal/user/Plugin/block/block/UserLoginBlock.php b/core/modules/user/lib/Drupal/user/Plugin/block/block/UserLoginBlock.php new file mode 100755 index 0000000..612f26e --- /dev/null +++ b/core/modules/user/lib/Drupal/user/Plugin/block/block/UserLoginBlock.php @@ -0,0 +1,43 @@ + 5, + ); + } + + /** + * Implements BlockInterface::access(). + */ + public function access() { + global $user; + return (!$user->uid && !(arg(0) == 'user' && !is_numeric(arg(1)))); + } + + /** + * Implements BlockInterface::build(). + */ + public function build() { + return array( + drupal_get_form('user_login_form') + ); + } +} diff --git a/core/modules/user/lib/Drupal/user/Plugin/block/block/UserNewBlock.php b/core/modules/user/lib/Drupal/user/Plugin/block/block/UserNewBlock.php new file mode 100755 index 0000000..33da17e --- /dev/null +++ b/core/modules/user/lib/Drupal/user/Plugin/block/block/UserNewBlock.php @@ -0,0 +1,72 @@ + array( + 'administrative' => TRUE + ), + 'whois_new_count' => 5 + ); + } + + /** + * Implements BlockInterface::access(). + */ + public function access() { + return user_access('access content'); + } + + /** + * Implements BlockInterface::configure(). + */ + public function configure($form, &$form_state) { + $form['user_block_whois_new_count'] = array( + '#type' => 'select', + '#title' => t('Number of users to display'), + '#default_value' => $this->configuration['whois_new_count'], + '#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)), + ); + return $form; + } + + /** + * Implements BlockInterface::configureSubmit(). + */ + public function configureSubmit($form, &$form_state) { + $this->configuration['whois_new_count'] = $form_state['values']['user_block_whois_new_count']; + } + + /** + * Implements BlockInterface::build(). + */ + public function build() { + // Retrieve a list of new users who have subsequently accessed the site successfully. + $items = db_query_range('SELECT uid, name FROM {users} WHERE status <> 0 AND access <> 0 ORDER BY created DESC', 0, $this->configuration['whois_new_count'])->fetchAll(); + $build = array( + '#theme' => 'item_list__user__new', + '#items' => array(), + ); + foreach ($items as $account) { + $build['#items'][] = theme('username', array('account' => $account)); + } + return $build; + } +} diff --git a/core/modules/user/lib/Drupal/user/Plugin/block/block/UserOnlineBlock.php b/core/modules/user/lib/Drupal/user/Plugin/block/block/UserOnlineBlock.php new file mode 100755 index 0000000..30fabe7 --- /dev/null +++ b/core/modules/user/lib/Drupal/user/Plugin/block/block/UserOnlineBlock.php @@ -0,0 +1,92 @@ + array( + 'administrative' => TRUE + ), + 'seconds_online' => 900, + 'max_list_count' => 10 + ); + } + + /** + * Implements BlockInterface::access(). + */ + public function access() { + return user_access('access content'); + } + + /** + * Implements BlockInterface::configure(). + */ + public function configure($form, &$form_state) { + $period = drupal_map_assoc(array(30, 60, 120, 180, 300, 600, 900, 1800, 2700, 3600, 5400, 7200, 10800, 21600, 43200, 86400), 'format_interval'); + $form['user_block_seconds_online'] = array( + '#type' => 'select', + '#title' => t('User activity'), + '#default_value' => $this->configuration['seconds_online'], + '#options' => $period, + '#description' => t('A user is considered online for this long after they have last viewed a page.') + ); + $form['user_block_max_list_count'] = array( + '#type' => 'select', + '#title' => t('User list length'), + '#default_value' => $this->configuration['max_list_count'], + '#options' => drupal_map_assoc(array(0, 5, 10, 15, 20, 25, 30, 40, 50, 75, 100)), + '#description' => t('Maximum number of currently online users to display.') + ); + return $form; + } + + /** + * Implements BlockInterface::configureSubmit(). + */ + public function configureSubmit($form, &$form_state) { + $this->configuration['seconds_online'] = $form_state['values']['user_block_seconds_online']; + $this->configuration['max_list_count'] = $form_state['values']['user_block_max_list_count']; + } + + /** + * Implements BlockInterface::build(). + */ + public function build() { + // Count users active within the defined period. + $interval = REQUEST_TIME - $this->configuration['max_list_count']; + + // Perform database queries to gather online user lists. We use s.timestamp + // rather than u.access because it is much faster. + $authenticated_count = db_query("SELECT COUNT(DISTINCT s.uid) FROM {sessions} s WHERE s.timestamp >= :timestamp AND s.uid > 0", array(':timestamp' => $interval))->fetchField(); + + $build = array( + '#theme' => 'user_list', + '#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'