diff --git a/core/modules/block/block.admin.css b/core/modules/block/block.admin.css index 831ad44..8a13d10 100644 --- a/core/modules/block/block.admin.css +++ b/core/modules/block/block.admin.css @@ -2,16 +2,16 @@ font-weight: bold; } #blocks tr.region-message { - font-weight: normal; color: #999; + font-weight: normal; } #blocks tr.region-populated { display: none; } .block-region { background-color: #ff6; - margin-top: 4px; margin-bottom: 4px; + margin-top: 4px; padding: 3px; } a.block-demo-backlink, @@ -22,8 +22,8 @@ a.block-demo-backlink:visited { color: #000; font-family: "Lucida Grande", Verdana, sans-serif; font-size: small; - line-height: 20px; left: 20px; /*LTR*/ + line-height: 20px; padding: 5px 10px; position: fixed; z-index: 499; diff --git a/core/modules/block/block.admin.inc b/core/modules/block/block.admin.inc index 848298f..4ee109d 100644 --- a/core/modules/block/block.admin.inc +++ b/core/modules/block/block.admin.inc @@ -18,7 +18,7 @@ function block_admin_demo($theme = NULL) { /** * Page callback: Shows the block administration page. * - * @param $theme + * @param string $theme * The theme to display the administration page for. If not provided, defaults * to the currently used theme. * @@ -43,10 +43,10 @@ function block_admin_display($theme = NULL) { /** * Prepares a list of blocks for display on the blocks administration page. * - * @param $theme + * @param string $theme * The machine-readable name of the theme whose blocks should be returned. * - * @return + * @return array * An array of blocks, as returned by _block_rehash(), sorted by region in * preparation for display on the blocks administration page. * @@ -63,17 +63,17 @@ function block_admin_display_prepare_blocks($theme) { /** * Form constructor for the main block administration form. * - * @param $blocks + * @param array $blocks * An array of blocks, as returned by block_admin_display_prepare_blocks(). - * @param $theme + * @param string $theme * A string representing the name of the theme to edit blocks for. - * @param $block_regions + * @param array $block_regions * (optional) An array of regions in which the blocks will be allowed to be * placed. Defaults to all visible regions for the theme whose blocks are * being configured. In all cases, a dummy region for disabled blocks will * also be displayed. * - * @return + * @return array * An array representing the form definition. * * @ingroup forms @@ -93,8 +93,22 @@ function block_admin_display_form($form, &$form_state, $blocks, $theme, $block_r $block_regions_with_disabled = $block_regions + array(BLOCK_REGION_NONE => BLOCK_REGION_NONE); foreach ($block_regions_with_disabled as $region => $title) { - $form['#attached']['drupal_add_tabledrag'][] = array('blocks', 'match', 'sibling', 'block-region-select', 'block-region-' . $region, NULL, FALSE); - $form['#attached']['drupal_add_tabledrag'][] = array('blocks', 'order', 'sibling', 'block-weight', 'block-weight-' . $region); + $form['#attached']['drupal_add_tabledrag'][] = array( + 'blocks', + 'match', + 'sibling', + 'block-region-select', + 'block-region-' . $region, + NULL, + FALSE, + ); + $form['#attached']['drupal_add_tabledrag'][] = array( + 'blocks', + 'order', + 'sibling', + 'block-weight', + 'block-weight-' . $region, + ); } // Weights range from -delta to +delta, so delta should be at least half @@ -156,7 +170,7 @@ function block_admin_display_form($form, &$form_state, $blocks, $theme, $block_r '#type' => 'link', '#title' => t('delete'), '#href' => 'admin/structure/block/manage/' . $block['module'] . '/' . $block['delta'] . '/delete', - ); + ); } } // Do not allow disabling the main system content block when it is present. @@ -255,9 +269,9 @@ function _block_compare($a, $b) { * * Also used by block_add_block_form() for adding a new custom block. * - * @param $module + * @param string $module * Name of the module that implements the block to be configured. - * @param $delta + * @param string $delta * Unique ID of the block within the context of $module. * * @see block_menu() @@ -310,7 +324,7 @@ function block_admin_configure($form, &$form_state, $module, $delta) { $theme_default = variable_get('theme_default', 'stark'); $admin_theme = variable_get('admin_theme'); foreach (list_themes() as $key => $theme) { - // Only display enabled themes + // Only display enabled themes. if ($theme->status) { $region = db_query("SELECT region FROM {block} WHERE module = :module AND delta = :delta AND theme = :theme", array( ':module' => $block->module, @@ -376,7 +390,14 @@ function block_admin_configure($form, &$form_state, $module, $delta) { 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' => '')); + $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)')); @@ -565,7 +586,11 @@ function block_admin_configure_submit($form, &$form_state) { // Store regions per theme for this block. foreach ($form_state['values']['regions'] as $theme => $region) { db_merge('block') - ->key(array('theme' => $theme, 'delta' => $form_state['values']['delta'], 'module' => $form_state['values']['module'])) + ->key(array( + 'theme' => $theme, + 'delta' => $form_state['values']['delta'], + 'module' => $form_state['values']['module'], + )) ->fields(array( 'region' => ($region == BLOCK_REGION_NONE ? '' : $region), 'pages' => trim($form_state['values']['pages']), @@ -582,7 +607,7 @@ function block_admin_configure_submit($form, &$form_state) { ->condition('delta', $form_state['values']['delta']) ->execute(); $query = db_insert('block_language')->fields(array( - 'type', 'langcode', 'module', 'delta' + 'type', 'langcode', 'module', 'delta', )); foreach (array_filter($form_state['values']['langcodes']) as $langcode) { $query->values(array( @@ -653,7 +678,18 @@ function block_add_block_form_submit($form, &$form_state) { // Store block delta to allow other modules to work with new block. $form_state['values']['delta'] = $delta; - $query = db_insert('block')->fields(array('visibility', 'pages', 'custom', 'title', 'module', 'theme', 'status', 'weight', 'delta', 'cache')); + $query = db_insert('block')->fields(array( + 'visibility', + 'pages', + 'custom', + 'title', + 'module', + 'theme', + 'status', + 'weight', + 'delta', + 'cache', + )); foreach (list_themes() as $key => $theme) { if ($theme->status) { $query->values(array( @@ -685,7 +721,11 @@ function block_add_block_form_submit($form, &$form_state) { // Store regions per theme for this block. foreach ($form_state['values']['regions'] as $theme => $region) { db_merge('block') - ->key(array('theme' => $theme, 'delta' => $delta, 'module' => $form_state['values']['module'])) + ->key(array( + 'theme' => $theme, + 'delta' => $delta, + 'module' => $form_state['values']['module'], + )) ->fields(array( 'region' => ($region == BLOCK_REGION_NONE ? '' : $region), 'pages' => trim($form_state['values']['pages']), @@ -698,7 +738,7 @@ function block_add_block_form_submit($form, &$form_state) { // for the existing languages. if (module_exists('language') && isset($form_state['values']['langcodes'])) { $query = db_insert('block_language')->fields(array( - 'type', 'langcode', 'module', 'delta' + 'type', 'langcode', 'module', 'delta', )); foreach (array_filter($form_state['values']['langcodes']) as $langcode) { $query->values(array( @@ -719,10 +759,10 @@ function block_add_block_form_submit($form, &$form_state) { /** * Form constructor for the custom block deletion form. * - * @param $module + * @param string $module * The name of the module that implements the block to be deleted. This should * always equal 'block' since it only allows custom blocks to be deleted. - * @param $delta + * @param string $delta * The unique ID of the block within the context of $module. * * @see block_menu() diff --git a/core/modules/block/block.api.php b/core/modules/block/block.api.php index 858a21b..4b95872 100644 --- a/core/modules/block/block.api.php +++ b/core/modules/block/block.api.php @@ -35,7 +35,7 @@ * to create several similar blocks that you identify within your module code * with numeric IDs). The maximum length for delta values is 32 bytes. * - * @return + * @return array * An associative array whose keys define the delta for each block and whose * values contain the block descriptions. Each block description is itself an * associative array, with the following key-value pairs: @@ -107,7 +107,7 @@ function hook_block_info() { // This example comes from node.module. $blocks['syndicate'] = array( 'info' => t('Syndicate'), - 'cache' => DRUPAL_NO_CACHE + 'cache' => DRUPAL_NO_CACHE, ); $blocks['recent'] = array( @@ -121,14 +121,14 @@ function hook_block_info() { /** * Change block definition before saving to the database. * - * @param $blocks + * @param array $blocks * A multidimensional array of blocks keyed by the defining module and delta; * the values are blocks returned by hook_block_info(). This hook is fired * after the blocks are collected from hook_block_info() and the database, * right before saving back to the database. - * @param $theme + * @param string $theme * The theme these blocks belong to. - * @param $code_blocks + * @param array $code_blocks * The blocks as defined in hook_block_info() before being overwritten by the * database data. * @@ -142,11 +142,11 @@ function hook_block_info_alter(&$blocks, $theme, $code_blocks) { /** * Define a configuration form for a block. * - * @param $delta + * @param string $delta * Which block is being configured. This is a unique identifier for the block * within the module, defined in hook_block_info(). * - * @return + * @return array * A configuration form, if one is needed for your block beyond the standard * elements that the block module provides (block title, visibility, etc.). * @@ -163,7 +163,7 @@ function hook_block_configure($delta = '') { '#type' => 'select', '#title' => t('Number of recent content items to display'), '#default_value' => variable_get('node_recent_block_count', 10), - '#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)), + '#options' => drupal_map_assoc(range(2, 20)), ); } return $form; @@ -175,10 +175,10 @@ function hook_block_configure($delta = '') { * This hook allows you to save the block-specific configuration settings * defined within your hook_block_configure(). * - * @param $delta + * @param string $delta * Which block is being configured. This is a unique identifier for the block * within the module, defined in hook_block_info(). - * @param $edit + * @param array $edit * The submitted form data from the configuration form. * * For a detailed usage example, see block_example.module. @@ -196,11 +196,11 @@ function hook_block_save($delta = '', $edit = array()) { /** * Return a rendered or renderable view of a block. * - * @param $delta + * @param string $delta * Which block to render. This is a unique identifier for the block * within the module, defined in hook_block_info(). * - * @return + * @return array * An array containing the following elements: * - subject: The default localized title of the block. If the block does not * have a default title, this should be set to NULL. @@ -235,7 +235,8 @@ function hook_block_view($delta = '') { '#theme' => 'node_recent_block', '#nodes' => $nodes, ); - } else { + } + else { $block['content'] = t('No content available.'); } } @@ -253,14 +254,14 @@ function hook_block_view($delta = '') { * blocks, you can also use hook_block_view_MODULE_DELTA_alter() to alter a * specific block. * - * @param $data + * @param array $data * An array of data, as returned from the hook_block_view() implementation of * the module that defined the block: * - subject: The default localized title of the block. * - content: Either a string or a renderable array representing the content * of the block. You should check that the content is an array before trying * to modify parts of the renderable structure. - * @param $block + * @param object $block * The block object, as loaded from the database, having the main properties: * - module: The name of the module that defined the block. * - delta: The unique identifier for the block within that module, as defined @@ -285,16 +286,20 @@ function hook_block_view_alter(&$data, $block) { * Perform alterations to a specific block. * * Modules can implement hook_block_view_MODULE_DELTA_alter() to modify a - * specific block, rather than implementing hook_block_view_alter(). + * specific block, rather than implementing hook_block_view_alter(). For + * example, if MODULE_DELTA were replaced with "mymodule_somedelta" in the + * function definition (i.e. hook_block_view_mymodule_somedelta_alter()), the + * code would only run on the "somedelta" block provided by the "mymodule" + * module. * - * @param $data + * @param array $data * An array of data, as returned from the hook_block_view() implementation of * the module that defined the block: * - subject: The localized title of the block. * - content: Either a string or a renderable array representing the content * of the block. You should check that the content is an array before trying * to modify parts of the renderable structure. - * @param $block + * @param object $block * The block object, as loaded from the database, having the main properties: * - module: The name of the module that defined the block. * - delta: The unique identifier for the block within that module, as defined @@ -304,10 +309,6 @@ function hook_block_view_alter(&$data, $block) { * @see hook_block_view() */ function hook_block_view_MODULE_DELTA_alter(&$data, $block) { - // This code will only run for a specific block. For example, if MODULE_DELTA - // in the function definition above is set to "mymodule_somedelta", the code - // will only run on the "somedelta" block provided by the "mymodule" module. - // Change the title of the "somedelta" block provided by the "mymodule" // module. $data['subject'] = t('New title of the block'); @@ -324,16 +325,16 @@ function hook_block_view_MODULE_DELTA_alter(&$data, $block) { * You can also set $block->content here, which will override the content of the * block and prevent hook_block_view() from running. * - * @param $blocks + * This example shows how to achieve language specific visibility setting for + * blocks. + * + * @param array $blocks * An array of $blocks, keyed by the block ID. */ function hook_block_list_alter(&$blocks) { global $theme_key; $language_interface = language(LANGUAGE_TYPE_INTERFACE); - // This example shows how to achieve language specific visibility setting for - // blocks. - $result = db_query('SELECT module, delta, language FROM {my_table}'); $block_languages = array(); foreach ($result as $record) { diff --git a/core/modules/block/block.js b/core/modules/block/block.js index 96ce310..8178889 100644 --- a/core/modules/block/block.js +++ b/core/modules/block/block.js @@ -66,7 +66,8 @@ Drupal.behaviors.blockDrag = { } var table = $('#blocks'); - var tableDrag = Drupal.tableDrag.blocks; // Get the blocks tableDrag object. + // Get the blocks tableDrag object. + var tableDrag = Drupal.tableDrag.blocks; // Add a handler for when a row is swapped, update empty regions. tableDrag.row.prototype.onSwap = function (swappedRow) { diff --git a/core/modules/block/block.module b/core/modules/block/block.module index 0626c08..409a3d2 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -385,7 +385,13 @@ function _block_get_renderable_region($list = array()) { // to perform contextual actions on the help block, and the links needlessly // draw attention on it. if ($key != 'system_main' && $key != 'system_help') { - $build[$key]['#contextual_links']['block'] = array('admin/structure/block/manage', array($block->module, $block->delta)); + $build[$key]['#contextual_links']['block'] = array( + 'admin/structure/block/manage', + array( + $block->module, + $block->delta, + ), + ); } } $build['#sorted'] = TRUE; @@ -679,7 +685,8 @@ function block_theme_initialize($theme) { $regions = system_region_list($theme, REGIONS_VISIBLE); $result = db_query("SELECT * FROM {block} WHERE theme = :theme", array(':theme' => $default_theme), array('fetch' => PDO::FETCH_ASSOC)); foreach ($result as $block) { - // If the region isn't supported by the theme, assign the block to the theme's default region. + // If the region isn't supported by the theme, assign the block to the + // theme's default region. if ($block['status'] && !isset($regions[$block['region']])) { $block['region'] = system_default_region($theme); } @@ -855,8 +862,8 @@ function block_block_list_alter(&$blocks) { $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. + // When set to 1 (BLOCK_VISIBILITY_LISTED), it is displayed only on + // those pages listed in $block->pages. $page_match = !($block->visibility xor $page_match); } elseif (module_exists('php')) { diff --git a/core/modules/block/tests/block_test.module b/core/modules/block/tests/block_test.module index 5e06d5c..6176c90 100644 --- a/core/modules/block/tests/block_test.module +++ b/core/modules/block/tests/block_test.module @@ -2,7 +2,7 @@ /** * @file - * Provide test blocks. + * Provide test blocks. */ /** diff --git a/core/modules/block/tests/themes/block_test_theme/page.tpl.php b/core/modules/block/tests/themes/block_test_theme/page.tpl.php index ba72882..6a3fabf 100644 --- a/core/modules/block/tests/themes/block_test_theme/page.tpl.php +++ b/core/modules/block/tests/themes/block_test_theme/page.tpl.php @@ -44,8 +44,32 @@