Commit 0597c9e4 authored by Dries's avatar Dries

- Patch #560746 by dropcube: rename hook_block_list() to hook_block_info() for...

- Patch #560746 by dropcube: rename hook_block_list() to hook_block_info() for consistency in the API.
parent fb0275fa
...@@ -319,9 +319,9 @@ function aggregator_cron() { ...@@ -319,9 +319,9 @@ function aggregator_cron() {
} }
/** /**
* Implement hook_block_list(). * Implement hook_block_info().
*/ */
function aggregator_block_list() { function aggregator_block_info() {
$block = array(); $block = array();
$result = db_query('SELECT cid, title FROM {aggregator_category} ORDER BY title'); $result = db_query('SELECT cid, title FROM {aggregator_category} ORDER BY title');
foreach ($result as $category) { foreach ($result as $category) {
......
...@@ -249,7 +249,7 @@ function block_admin_configure(&$form_state, $module = NULL, $delta = 0) { ...@@ -249,7 +249,7 @@ function block_admin_configure(&$form_state, $module = NULL, $delta = 0) {
} }
// Get the block subject for the page title. // Get the block subject for the page title.
$info = module_invoke($module, 'block_list'); $info = module_invoke($module, 'block_info');
if (isset($info[$delta])) { if (isset($info[$delta])) {
drupal_set_title(t("'%name' block", array('%name' => $info[$delta]['info'])), PASS_THROUGH); drupal_set_title(t("'%name' block", array('%name' => $info[$delta]['info'])), PASS_THROUGH);
} }
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
*/ */
/** /**
* List of all blocks defined by the module. * Define all blocks provided by the module.
* *
* Any module can export a block (or blocks) to be displayed by defining * Any module can export a block (or blocks) to be displayed by defining
* the _block hook. This hook is called by theme.inc to display a block, * the _block hook. This hook is called by theme.inc to display a block,
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
* *
* For a detailed usage example, see block_example.module. * For a detailed usage example, see block_example.module.
*/ */
function hook_block_list() { function hook_block_info() {
$blocks['exciting'] = array( $blocks['exciting'] = array(
'info' => t('An exciting block provided by Mymodule.'), 'info' => t('An exciting block provided by Mymodule.'),
'weight' => 0, 'weight' => 0,
...@@ -76,7 +76,7 @@ function hook_block_list() { ...@@ -76,7 +76,7 @@ function hook_block_list() {
* Which block to return. This is a descriptive string used to identify * Which block to return. This is a descriptive string used to identify
* blocks within each module and also within the theme system. * blocks within each module and also within the theme system.
* The $delta for each block is defined within the array that your module * The $delta for each block is defined within the array that your module
* returns when the hook_block_list() implementation is called. * returns when the hook_block_info() implementation is called.
* @return * @return
* Optionally return the configuration form. * Optionally return the configuration form.
* *
...@@ -101,7 +101,7 @@ function hook_block_configure($delta = '') { ...@@ -101,7 +101,7 @@ function hook_block_configure($delta = '') {
* Which block to save the settings for. This is a descriptive string used * Which block to save the settings for. This is a descriptive string used
* to identify blocks within each module and also within the theme system. * to identify blocks within each module and also within the theme system.
* The $delta for each block is defined within the array that your module * The $delta for each block is defined within the array that your module
* returns when the hook_block_list() implementation is called. * returns when the hook_block_info() implementation is called.
* @param $edit * @param $edit
* The submitted form data from the configuration form. * The submitted form data from the configuration form.
* *
...@@ -120,7 +120,7 @@ function hook_block_save($delta = '', $edit = array()) { ...@@ -120,7 +120,7 @@ function hook_block_save($delta = '', $edit = array()) {
* Which block to return. This is a descriptive string used to identify * Which block to return. This is a descriptive string used to identify
* blocks within each module and also within the theme system. * blocks within each module and also within the theme system.
* The $delta for each block is defined within the array that your module * The $delta for each block is defined within the array that your module
* returns when the hook_block_list() implementation is called. * returns when the hook_block_info() implementation is called.
* @return * @return
* An array which must define a 'subject' element and a 'content' element * An array which must define a 'subject' element and a 'content' element
* defining the block indexed by $delta. * defining the block indexed by $delta.
...@@ -166,7 +166,7 @@ function hook_block_view($delta = '') { ...@@ -166,7 +166,7 @@ function hook_block_view($delta = '') {
* This example shows how to achieve language specific visibility setting for * This example shows how to achieve language specific visibility setting for
* blocks. * blocks.
*/ */
function hook_block_list_alter(&$blocks) { function hook_block_info_alter(&$blocks) {
global $language, $theme_key; global $language, $theme_key;
$result = db_query('SELECT module, delta, language FROM {my_table}'); $result = db_query('SELECT module, delta, language FROM {my_table}');
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* Constants defining cache granularity for blocks. * Constants defining cache granularity for blocks.
* *
* Modules specify the caching patterns for their blocks using binary * Modules specify the caching patterns for their blocks using binary
* combinations of these constants in their hook_block_list(): * combinations of these constants in their hook_block_info():
* $block[delta]['cache'] = BLOCK_CACHE_PER_ROLE | BLOCK_CACHE_PER_PAGE; * $block[delta]['cache'] = BLOCK_CACHE_PER_ROLE | BLOCK_CACHE_PER_PAGE;
* BLOCK_CACHE_PER_ROLE is used as a default when no caching pattern is * BLOCK_CACHE_PER_ROLE is used as a default when no caching pattern is
* specified. * specified.
...@@ -187,9 +187,9 @@ function _block_themes_access($theme) { ...@@ -187,9 +187,9 @@ function _block_themes_access($theme) {
} }
/** /**
* Implement hook_block_list(). * Implement hook_block_info().
*/ */
function block_block_list() { function block_block_info() {
$blocks = array(); $blocks = array();
$result = db_query('SELECT bid, info FROM {block_custom} ORDER BY info'); $result = db_query('SELECT bid, info FROM {block_custom} ORDER BY info');
...@@ -312,8 +312,8 @@ function _block_rehash() { ...@@ -312,8 +312,8 @@ function _block_rehash() {
// Valid region names for the theme. // Valid region names for the theme.
$regions = system_region_list($theme_key); $regions = system_region_list($theme_key);
foreach (module_implements('block_list') as $module) { foreach (module_implements('block_info') as $module) {
$module_blocks = module_invoke($module, 'block_list'); $module_blocks = module_invoke($module, 'block_info');
if ($module_blocks) { if ($module_blocks) {
foreach ($module_blocks as $delta => $block) { foreach ($module_blocks as $delta => $block) {
if (empty($old_blocks[$module][$delta])) { if (empty($old_blocks[$module][$delta])) {
...@@ -437,7 +437,7 @@ function block_user_form(&$edit, $account, $category) { ...@@ -437,7 +437,7 @@ function block_user_form(&$edit, $account, $category) {
'#tree' => TRUE '#tree' => TRUE
); );
foreach ($result as $block) { foreach ($result as $block) {
$data = module_invoke($block->module, 'block_list'); $data = module_invoke($block->module, 'block_info');
if ($data[$block->delta]['info']) { if ($data[$block->delta]['info']) {
$return = TRUE; $return = TRUE;
$form['block'][$block->module][$block->delta] = array( $form['block'][$block->module][$block->delta] = array(
...@@ -576,24 +576,24 @@ function _block_load_blocks() { ...@@ -576,24 +576,24 @@ function _block_load_blocks() {
->addTag('block_load') ->addTag('block_load')
->execute(); ->execute();
$block_list = $result->fetchAllAssoc('bid'); $block_info = $result->fetchAllAssoc('bid');
// Allow modules to modify the block list. // Allow modules to modify the block list.
drupal_alter('block_list', $block_list); drupal_alter('block_info', $block_info);
$blocks = array(); $blocks = array();
foreach ($block_list as $block) { foreach ($block_info as $block) {
$blocks[$block->region]["{$block->module}_{$block->delta}"] = $block; $blocks[$block->region]["{$block->module}_{$block->delta}"] = $block;
} }
return $blocks; return $blocks;
} }
/** /**
* Implement hook_block_list_alter(). * Implement hook_block_info_alter().
* *
* Check the page, user role, content type and user specific visibilty settings. * Check the page, user role, content type and user specific visibilty settings.
* Remove the block if the visibility conditions are not met. * Remove the block if the visibility conditions are not met.
*/ */
function block_block_list_alter(&$blocks) { function block_block_info_alter(&$blocks) {
global $user, $theme_key; global $user, $theme_key;
// Build an array of roles for each block. // Build an array of roles for each block.
......
...@@ -150,9 +150,9 @@ function _blog_post_exists($account) { ...@@ -150,9 +150,9 @@ function _blog_post_exists($account) {
} }
/** /**
* Implement hook_block_list(). * Implement hook_block_info().
*/ */
function blog_block_list() { function blog_block_info() {
$block['recent']['info'] = t('Recent blog posts'); $block['recent']['info'] = t('Recent blog posts');
return $block; return $block;
} }
......
...@@ -207,9 +207,9 @@ function book_field_build_modes($obj_type) { ...@@ -207,9 +207,9 @@ function book_field_build_modes($obj_type) {
} }
/** /**
* Implement hook_block_list(). * Implement hook_block_info().
*/ */
function book_block_list() { function book_block_info() {
$block = array(); $block = array();
$block['navigation']['info'] = t('Book navigation'); $block['navigation']['info'] = t('Book navigation');
$block['navigation']['cache'] = BLOCK_CACHE_PER_PAGE | BLOCK_CACHE_PER_ROLE; $block['navigation']['cache'] = BLOCK_CACHE_PER_PAGE | BLOCK_CACHE_PER_ROLE;
......
...@@ -278,9 +278,9 @@ function comment_permission() { ...@@ -278,9 +278,9 @@ function comment_permission() {
} }
/** /**
* Implement hook_block_list(). * Implement hook_block_info().
*/ */
function comment_block_list() { function comment_block_info() {
$blocks['recent']['info'] = t('Recent comments'); $blocks['recent']['info'] = t('Recent comments');
return $blocks; return $blocks;
......
...@@ -476,9 +476,9 @@ function forum_form_alter(&$form, $form_state, $form_id) { ...@@ -476,9 +476,9 @@ function forum_form_alter(&$form, $form_state, $form_id) {
} }
/** /**
* Implement hook_block_list(). * Implement hook_block_info().
*/ */
function forum_block_list() { function forum_block_info() {
$blocks['active']['info'] = t('Active forum topics'); $blocks['active']['info'] = t('Active forum topics');
$blocks['new']['info'] = t('New forum topics'); $blocks['new']['info'] = t('New forum topics');
return $blocks; return $blocks;
......
...@@ -629,9 +629,9 @@ function locale_css_alter(&$css) { ...@@ -629,9 +629,9 @@ function locale_css_alter(&$css) {
// Language switcher block // Language switcher block
/** /**
* Implement hook_block_list(). * Implement hook_block_info().
*/ */
function locale_block_list() { function locale_block_info() {
$block['language-switcher']['info'] = t('Language switcher'); $block['language-switcher']['info'] = t('Language switcher');
// Not worth caching. // Not worth caching.
$block['language-switcher']['cache'] = BLOCK_NO_CACHE; $block['language-switcher']['cache'] = BLOCK_NO_CACHE;
......
...@@ -274,9 +274,9 @@ function menu_reset_item($item) { ...@@ -274,9 +274,9 @@ function menu_reset_item($item) {
} }
/** /**
* Implement hook_block_list(). * Implement hook_block_info().
*/ */
function menu_block_list() { function menu_block_info() {
$menus = menu_get_menus(FALSE); $menus = menu_get_menus(FALSE);
$blocks = array(); $blocks = array();
......
...@@ -1761,9 +1761,9 @@ function node_revision_list($node) { ...@@ -1761,9 +1761,9 @@ function node_revision_list($node) {
} }
/** /**
* Implement hook_block_list(). * Implement hook_block_info().
*/ */
function node_block_list() { function node_block_info() {
$blocks['syndicate']['info'] = t('Syndicate'); $blocks['syndicate']['info'] = t('Syndicate');
// Not worth caching. // Not worth caching.
$blocks['syndicate']['cache'] = BLOCK_NO_CACHE; $blocks['syndicate']['cache'] = BLOCK_NO_CACHE;
......
...@@ -117,9 +117,9 @@ function _poll_menu_access($node, $perm, $inspect_allowvotes) { ...@@ -117,9 +117,9 @@ function _poll_menu_access($node, $perm, $inspect_allowvotes) {
} }
/** /**
* Implement hook_block_list(). * Implement hook_block_info().
*/ */
function poll_block_list() { function poll_block_info() {
if (user_access('access content')) { if (user_access('access content')) {
$blocks['recent']['info'] = t('Most recent poll'); $blocks['recent']['info'] = t('Most recent poll');
return $blocks; return $blocks;
......
...@@ -133,9 +133,9 @@ function profile_menu() { ...@@ -133,9 +133,9 @@ function profile_menu() {
} }
/** /**
* Implement hook_block_list(). * Implement hook_block_info().
*/ */
function profile_block_list() { function profile_block_info() {
$blocks['author-information']['info'] = t('Author information'); $blocks['author-information']['info'] = t('Author information');
$blocks['author-information']['cache'] = BLOCK_CACHE_PER_PAGE | BLOCK_CACHE_PER_ROLE; $blocks['author-information']['cache'] = BLOCK_CACHE_PER_PAGE | BLOCK_CACHE_PER_ROLE;
return $blocks; return $blocks;
......
...@@ -161,9 +161,9 @@ function search_permission() { ...@@ -161,9 +161,9 @@ function search_permission() {
} }
/** /**
* Implement hook_block_list(). * Implement hook_block_info().
*/ */
function search_block_list() { function search_block_info() {
$blocks['form']['info'] = t('Search form'); $blocks['form']['info'] = t('Search form');
// Not worth caching. // Not worth caching.
$blocks['form']['cache'] = BLOCK_NO_CACHE; $blocks['form']['cache'] = BLOCK_NO_CACHE;
......
...@@ -294,9 +294,9 @@ function statistics_get($nid) { ...@@ -294,9 +294,9 @@ function statistics_get($nid) {
} }
/** /**
* Implement hook_block_list(). * Implement hook_block_info().
*/ */
function statistics_block_list() { function statistics_block_info() {
if (variable_get('statistics_count_content_views', 0)) { if (variable_get('statistics_count_content_views', 0)) {
$blocks['popular']['info'] = t('Popular content'); $blocks['popular']['info'] = t('Popular content');
// Too dynamic to cache. // Too dynamic to cache.
......
...@@ -1560,9 +1560,9 @@ function system_user_timezone(&$edit, &$form) { ...@@ -1560,9 +1560,9 @@ function system_user_timezone(&$edit, &$form) {
} }
/** /**
* Implement hook_block_list(). * Implement hook_block_info().
*/ */
function system_block_list() { function system_block_info() {
$blocks['main'] = array( $blocks['main'] = array(
'info' => t('Main page content'), 'info' => t('Main page content'),
// Cached elsewhere. // Cached elsewhere.
......
...@@ -984,9 +984,9 @@ function user_login_block() { ...@@ -984,9 +984,9 @@ function user_login_block() {
} }
/** /**
* Implement hook_block_list(). * Implement hook_block_info().
*/ */
function user_block_list() { function user_block_info() {
global $user; global $user;
$blocks['login']['info'] = t('User login'); $blocks['login']['info'] = t('User login');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment