Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.878 diff -u -p -r1.878 common.inc --- includes/common.inc 22 Apr 2009 09:45:02 -0000 1.878 +++ includes/common.inc 23 Apr 2009 10:16:09 -0000 @@ -3248,8 +3248,7 @@ function drupal_alter($type, &$data) { function drupal_get_page($content = NULL) { // Initialize page array with defaults. @see hook_elements() - 'page' element. $page = element_info('page'); - $page['content'] = is_array($content) ? $content : array('main' => array('#markup' => $content)); - + system_set_content_block($content); return $page; } Index: includes/theme.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/theme.inc,v retrieving revision 1.475 diff -u -p -r1.475 theme.inc --- includes/theme.inc 20 Apr 2009 21:28:13 -0000 1.475 +++ includes/theme.inc 23 Apr 2009 10:16:09 -0000 @@ -2053,6 +2053,11 @@ function template_preprocess_block(&$var $variables['block_zebra'] = ($block_counter[$variables['block']->region] % 2) ? 'odd' : 'even'; $variables['block_id'] = $block_counter[$variables['block']->region]++; + if (is_array($variables['block']->content)) { + // Render the block contents if it is not already rendered. + $variables['block']->content = drupal_render($variables['block']->content); + } + $variables['template_files'][] = 'block-' . $variables['block']->region; $variables['template_files'][] = 'block-' . $variables['block']->module; $variables['template_files'][] = 'block-' . $variables['block']->module . '-' . $variables['block']->delta; Index: modules/block/block.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/block/block.admin.inc,v retrieving revision 1.35 diff -u -p -r1.35 block.admin.inc --- modules/block/block.admin.inc 11 Feb 2009 03:38:46 -0000 1.35 +++ modules/block/block.admin.inc 23 Apr 2009 10:16:09 -0000 @@ -36,6 +36,9 @@ function block_admin_display_form(&$form $block_regions = system_region_list($theme_key) + array(BLOCK_REGION_NONE => '<' . t('none') . '>'); + // Use form submission data to show values if showing the form again. + $blocks = (!empty($form_state['values']) ? $form_state['values'] : $blocks); + // Weights range from -delta to +delta, so delta should be at least half // of the amount of blocks present. This makes sure all blocks in the same // region get an unique weight. @@ -95,6 +98,19 @@ function block_admin_display_form(&$form } /** + * Validate main blocks administration form submissions. + */ +function block_admin_display_form_validate($form, &$form_state) { + foreach ($form_state['values'] as $key => $block) { + if (($block['module'] == 'system') && ($block['delta'] == 'main') && ($block['region'] == BLOCK_REGION_NONE)) { + form_set_error($key, t('Disabling the main page content block makes your system unusable. You should always enable it to display in a region.')); + // Suggest to put it back into the content region. + $form_state['values'][$key]['region'] = 'content'; + } + } +} + +/** * Process main blocks administration form submissions. */ function block_admin_display_form_submit($form, &$form_state) { Index: modules/system/system.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.admin.inc,v retrieving revision 1.136 diff -u -p -r1.136 system.admin.inc --- modules/system/system.admin.inc 21 Apr 2009 09:31:31 -0000 1.136 +++ modules/system/system.admin.inc 23 Apr 2009 10:16:09 -0000 @@ -179,7 +179,9 @@ function system_themes_form() { } else { // Ensure this theme is compatible with this version of core. - if (!isset($theme->info['core']) || $theme->info['core'] != DRUPAL_CORE_COMPATIBILITY) { + // Require the 'content' region to make sure the main page + // content has a common place in all themes. + if (!isset($theme->info['core']) || ($theme->info['core'] != DRUPAL_CORE_COMPATIBILITY) || (!isset($theme->info['regions']['content']))) { $incompatible_core[] = $theme->name; } if (version_compare(phpversion(), $theme->info['php']) < 0) { Index: modules/system/system.install =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.install,v retrieving revision 1.316 diff -u -p -r1.316 system.install --- modules/system/system.install 20 Apr 2009 02:23:16 -0000 1.316 +++ modules/system/system.install 23 Apr 2009 10:16:09 -0000 @@ -3244,6 +3244,25 @@ function system_update_7020() { } /** + * Enable the main content block in all themes. + */ +function system_update_7021() { + $ret = array(); + $themes = list_themes(); + foreach ($themes as $theme) { + if (db_result(db_query("SELECT COUNT(*) FROM {block} WHERE theme = '%s'", $theme->name))) { + // Add new block to all themes which had at least one block, even disabled ones. + // For those, which do not have blocks yet, they were not yet enabled, so we + // should not add this one, because that would prevent + // block_initialize_theme_blocks() to also copy over the other blocks, when the + // theme is enabled later. + db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'system', 'main', $theme->name, 1, 0, 'content', '', -1); + } + } + return $ret; +} + +/** * @} End of "defgroup updates-6.x-to-7.x" * The next series of updates should start at 8000. */ Index: modules/system/system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.module,v retrieving revision 1.682 diff -u -p -r1.682 system.module --- modules/system/system.module 22 Apr 2009 09:45:03 -0000 1.682 +++ modules/system/system.module 23 Apr 2009 10:16:10 -0000 @@ -889,6 +889,11 @@ function system_user_timezone(&$edit, &$ * Implementation of hook_block_list(). */ function system_block_list() { + $blocks['main'] = array( + 'info' => t('Main page content'), + // Cached elsewhere. + 'cache' => BLOCK_NO_CACHE, + ); $blocks['powered-by'] = array( 'info' => t('Powered by Drupal'), 'weight' => '10', @@ -954,6 +959,10 @@ function system_block_save($delta = '', function system_block_view($delta = '') { $block = array(); switch ($delta) { + case 'main': + $block['subject'] = NULL; + $block['content'] = system_set_content_block(); + return $block; case 'powered-by': $image_path = 'misc/' . variable_get('drupal_badge_color', 'powered-blue') . '-' . variable_get('drupal_badge_size', '80x15') . '.png'; // Don't display a title. @@ -973,6 +982,23 @@ function system_block_view($delta = '') } /** + * Memory for the page content so that it can be put into a region as a block. + * + * Given the nature of the Drupal page handling, this will be called once with + * a string or array. We store that and return it later as the block is being + * displayed. + */ +function system_set_content_block($content = NULL) { + $content_block = &drupal_static(__FUNCTION__, NULL); + if (!empty($content)) { + $content_block = (is_array($content) ? $content : array('main' => array('#markup' => $content))); + } + else { + return $content_block; + } +} + +/** * Provide a single block on the administration overview page. * * @param $item Index: profiles/default/default.profile =================================================================== RCS file: /cvs/drupal/drupal/profiles/default/default.profile,v retrieving revision 1.39 diff -u -p -r1.39 default.profile --- profiles/default/default.profile 20 Mar 2009 19:18:11 -0000 1.39 +++ profiles/default/default.profile 23 Apr 2009 10:16:10 -0000 @@ -91,7 +91,8 @@ function default_profile_task_list() { */ function default_profile_tasks(&$task, $url) { - // Enable 4 standard blocks. + // Enable 5 standard blocks. + db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'system', 'main', 'garland', 1, 0, 'content', '', -1); db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'user', 'login', 'garland', 1, 0, 'left', '', -1); db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'system', 'navigation', 'garland', 1, 0, 'left', '', -1); db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'system', 'management', 'garland', 1, 1, 'left', '', -1); Index: profiles/expert/expert.profile =================================================================== RCS file: /cvs/drupal/drupal/profiles/expert/expert.profile,v retrieving revision 1.5 diff -u -p -r1.5 expert.profile --- profiles/expert/expert.profile 20 Mar 2009 19:18:11 -0000 1.5 +++ profiles/expert/expert.profile 23 Apr 2009 10:16:10 -0000 @@ -42,7 +42,8 @@ function expert_profile_task_list() { * Perform any final installation tasks for this profile. */ function expert_profile_tasks(&$task, $url) { - // Enable 3 standard blocks. + // Enable 4 standard blocks. + db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'system', 'main', 'garland', 1, 0, 'content', '', -1); db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'user', 'login', 'garland', 1, 0, 'left', '', -1); db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'system', 'navigation', 'garland', 1, 0, 'left', '', -1); db_query("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'system', 'management', 'garland', 1, 1, 'left', '', -1);