Index: CHANGELOG.txt =================================================================== RCS file: /cvs/drupal/drupal/CHANGELOG.txt,v retrieving revision 1.308 diff -u -p -r1.308 CHANGELOG.txt --- CHANGELOG.txt 12 May 2009 13:43:44 -0000 1.308 +++ CHANGELOG.txt 13 May 2009 09:24:37 -0000 @@ -113,6 +113,8 @@ Drupal 7.0, xxxx-xx-xx (development vers * Site mission is replaced with the highlighted content block region and separate RSS feed description settings. * The footer message setting was removed in favor of custom blocks. + * Made the main page content a block which can be moved and ordered + with other blocks in the same region. - Upgraded the core JavaScript library to jQuery version 1.3.2. - Upgraded the jQuery Forms library to 2.21. Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.898 diff -u -p -r1.898 common.inc --- includes/common.inc 12 May 2009 08:37:44 -0000 1.898 +++ includes/common.inc 13 May 2009 09:24:38 -0000 @@ -3232,8 +3232,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; } @@ -3244,7 +3243,6 @@ function drupal_get_page($content = NULL * A string or array representing the content of a page. The array consists of * the following keys: * - #type: Value is always 'page'. This pushes the theming through page.tpl.php (required). - * - content: A renderable array as built by the menu callback (required). * - #show_blocks: A marker which suppresses left/right regions if FALSE (optional). * - #show_messages: Suppress drupal_get_message() items. Used by Batch API (optional). * @@ -3252,8 +3250,10 @@ function drupal_get_page($content = NULL * @see drupal_get_page() */ function drupal_render_page($page) { - // Allow menu callbacks to return strings, or bare content arrays. - if (is_string($page) || empty($page['content'])) { + // Allow menu callbacks to return strings or arbitrary arrays to render. + // If the array returned is not of #type page directly, we need to fill + // in the page with defaults. + if (is_string($page) || (is_array($page) && (!isset($page['#type']) || ($page['#type'] != 'page')))) { $page = drupal_get_page($page); } // Modules alter the $page as needed. Blocks are populated into regions like Index: modules/block/block.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/block/block.admin.inc,v retrieving revision 1.37 diff -u -p -r1.37 block.admin.inc --- modules/block/block.admin.inc 7 May 2009 15:29:08 -0000 1.37 +++ modules/block/block.admin.inc 13 May 2009 09:24:38 -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_set_value($form[$key]['region'], 'content', $form_state); + } + } +} + +/** * Process main blocks administration form submissions. */ function block_admin_display_form_submit($form, &$form_state) { Index: modules/block/block.install =================================================================== RCS file: /cvs/drupal/drupal/modules/block/block.install,v retrieving revision 1.22 diff -u -p -r1.22 block.install --- modules/block/block.install 6 May 2009 10:39:42 -0000 1.22 +++ modules/block/block.install 13 May 2009 09:24:38 -0000 @@ -178,6 +178,14 @@ function block_schema() { */ function block_install() { drupal_install_schema('block'); + + // Block should go first so that other modules can alter its output during hook_page_alter(). + db_update('system') + ->fields(array( + 'weight' => -5, + )) + ->condition('name', 'block') + ->execute(); } /** @@ -186,3 +194,12 @@ function block_install() { function block_uninstall() { drupal_uninstall_schema('block'); } + +/** + * Set system.weight for easy use during hook_page_alter(). + */ +function block_update_7000() { + $ret = array(); + $ret[] = update_sql("UPDATE {system} SET weight = -5 WHERE name = 'block'"); + return $ret; +} Index: modules/block/block.module =================================================================== RCS file: /cvs/drupal/drupal/modules/block/block.module,v retrieving revision 1.330 diff -u -p -r1.330 block.module --- modules/block/block.module 7 May 2009 15:29:08 -0000 1.330 +++ modules/block/block.module 13 May 2009 09:24:38 -0000 @@ -242,7 +242,7 @@ function block_page_alter($page) { // Load all region content assigned via blocks. foreach (array_keys($regions) as $region) { // Prevent left and right regions from rendering blocks when 'show_blocks' == FALSE. - if ($page['#show_blocks'] || ($region != 'left' && $region != 'right')) { + if (!empty($page['#show_blocks']) || ($region != 'left' && $region != 'right')) { // Assign blocks to region. if ($blocks = block_get_blocks_by_region($region)) { $page[$region]['blocks'] = $blocks; @@ -760,6 +760,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/system/system.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.admin.inc,v retrieving revision 1.143 diff -u -p -r1.143 system.admin.inc --- modules/system/system.admin.inc 12 May 2009 13:43:44 -0000 1.143 +++ modules/system/system.admin.inc 13 May 2009 09:24:38 -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.323 diff -u -p -r1.323 system.install --- modules/system/system.install 12 May 2009 13:43:45 -0000 1.323 +++ modules/system/system.install 13 May 2009 09:24:39 -0000 @@ -3316,7 +3316,7 @@ function system_update_7020() { } /** - * Add help block to the help region, migrate custom variables to blocks. + * Add new blocks to new regions, migrate custom variables to blocks. */ function system_update_7021() { $ret = array(); @@ -3328,6 +3328,8 @@ function system_update_7021() { $themes_with_blocks[] = $theme->name; // Add new system generated help block. $ret[] = update_sql("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('system', 'help', '" . $theme->name . "', 1, 0, 'help', '', 1)"); + // Add new system generated main page content block. + $ret[] = update_sql("INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES ('system', 'main', '" . $theme->name . "', 1, 0, 'content', '', -1)"); } // Migrate contact form information. Index: modules/system/system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.module,v retrieving revision 1.692 diff -u -p -r1.692 system.module --- modules/system/system.module 12 May 2009 08:37:45 -0000 1.692 +++ modules/system/system.module 13 May 2009 09:24:39 -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', @@ -957,6 +962,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'; $block['subject'] = NULL; @@ -979,6 +988,25 @@ 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)) { + //var_dump($content); + //var_dump(debug_backtrace()); + $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.41 diff -u -p -r1.41 default.profile --- profiles/default/default.profile 30 Apr 2009 21:44:20 -0000 1.41 +++ profiles/default/default.profile 13 May 2009 09:24:39 -0000 @@ -91,9 +91,19 @@ function default_profile_task_list() { */ function default_profile_tasks(&$task, $url) { - // Enable 5 standard blocks. + // Enable some standard blocks. $values = array( array( + 'module' => 'system', + 'delta' => 'main', + 'theme' => 'garland', + 'status' => 1, + 'weight' => 0, + 'region' => 'content', + 'pages' => '', + 'cache' => -1, + ), + array( 'module' => 'user', 'delta' => 'login', 'theme' => 'garland', Index: profiles/expert/expert.profile =================================================================== RCS file: /cvs/drupal/drupal/profiles/expert/expert.profile,v retrieving revision 1.7 diff -u -p -r1.7 expert.profile --- profiles/expert/expert.profile 30 Apr 2009 21:44:20 -0000 1.7 +++ profiles/expert/expert.profile 13 May 2009 09:24:39 -0000 @@ -42,9 +42,20 @@ function expert_profile_task_list() { * Perform any final installation tasks for this profile. */ function expert_profile_tasks(&$task, $url) { - // Enable 4 standard blocks. + + // Enable some standard blocks. $values = array( array( + 'module' => 'system', + 'delta' => 'main', + 'theme' => 'garland', + 'status' => 1, + 'weight' => 0, + 'region' => 'content', + 'pages' => '', + 'cache' => -1, + ), + array( 'module' => 'user', 'delta' => 'login', 'theme' => 'garland',