diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/block/block.admin.inc | 2 | ||||
-rw-r--r-- | modules/block/block.install | 23 | ||||
-rw-r--r-- | modules/block/block.js | 16 | ||||
-rw-r--r-- | modules/block/block.module | 7 | ||||
-rw-r--r-- | modules/blog/blog.pages.inc | 4 | ||||
-rw-r--r-- | modules/node/node.module | 4 | ||||
-rw-r--r-- | modules/simpletest/tests/common.test | 18 | ||||
-rw-r--r-- | modules/system/system.admin.inc | 7 | ||||
-rw-r--r-- | modules/system/system.install | 4 | ||||
-rw-r--r-- | modules/system/system.module | 9 | ||||
-rw-r--r-- | modules/taxonomy/taxonomy.pages.inc | 2 | ||||
-rw-r--r-- | modules/user/user.pages.inc | 2 |
12 files changed, 75 insertions, 23 deletions
diff --git a/modules/block/block.admin.inc b/modules/block/block.admin.inc index 80d1321ba..358211f3c 100644 --- a/modules/block/block.admin.inc +++ b/modules/block/block.admin.inc @@ -85,6 +85,8 @@ function block_admin_display_form(&$form_state, $blocks, $theme = NULL) { ); } } + // Do not allow disabling the main system content block. + unset($form['system_main']['region']['#options'][BLOCK_REGION_NONE]); $form['submit'] = array( '#type' => 'submit', diff --git a/modules/block/block.install b/modules/block/block.install index cc2dd690d..0b4544ed0 100644 --- a/modules/block/block.install +++ b/modules/block/block.install @@ -178,6 +178,16 @@ 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(). Almost everything on the page is a block, + // so before block module runs, there will not be much to alter. + db_update('system') + ->fields(array( + 'weight' => -5, + )) + ->condition('name', 'block') + ->execute(); } /** @@ -186,3 +196,16 @@ function block_install() { function block_uninstall() { drupal_uninstall_schema('block'); } + +/** + * Set system.weight to a low value for block module. + * + * Block should go first so that other modules can alter its output + * during hook_page_alter(). Almost everything on the page is a block, + * so before block module runs, there will not be much to alter. + */ +function block_update_7000() { + $ret = array(); + $ret[] = update_sql("UPDATE {system} SET weight = -5 WHERE name = 'block'"); + return $ret; +} diff --git a/modules/block/block.js b/modules/block/block.js index 3fd6a5aba..b722d30df 100644 --- a/modules/block/block.js +++ b/modules/block/block.js @@ -25,10 +25,18 @@ Drupal.behaviors.blockDrag = { // Add a handler so when a row is dropped, update fields dropped into new regions. tableDrag.onDrop = function () { dragObject = this; - if ($(dragObject.rowObject.element).prev('tr').is('.region-message')) { - var regionRow = $(dragObject.rowObject.element).prev('tr').get(0); - var regionName = regionRow.className.replace(/([^ ]+[ ]+)*region-([^ ]+)-message([ ]+[^ ]+)*/, '$2'); - var regionField = $('select.block-region-select', dragObject.rowObject.element); + var regionRow = $(dragObject.rowObject.element).prev('tr').get(0); + var regionName = regionRow.className.replace(/([^ ]+[ ]+)*region-([^ ]+)-message([ ]+[^ ]+)*/, '$2'); + var regionField = $('select.block-region-select', dragObject.rowObject.element); + // Check whether the newly picked region is available for this block. + if ($('option[value=' + regionName + ']', regionField).length == 0) { + // If not, alert the user and keep the block in its old region setting. + alert(Drupal.t('The block cannot be placed in this region.')); + // Simulate that there was a selected element change, so the row is put + // back to from where the user tried to drag it. + regionField.change(); + } + else if ($(dragObject.rowObject.element).prev('tr').is('.region-message')) { var weightField = $('select.block-weight', dragObject.rowObject.element); var oldRegionName = weightField[0].className.replace(/([^ ]+[ ]+)*block-weight-([^ ]+)([ ]+[^ ]+)*/, '$2'); diff --git a/modules/block/block.module b/modules/block/block.module index aeb4bddc1..83146e9ab 100644 --- a/modules/block/block.module +++ b/modules/block/block.module @@ -241,7 +241,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(&$variables) { $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; diff --git a/modules/blog/blog.pages.inc b/modules/blog/blog.pages.inc index b6b0346f5..ace4f8ece 100644 --- a/modules/blog/blog.pages.inc +++ b/modules/blog/blog.pages.inc @@ -60,7 +60,7 @@ function blog_page_user($account) { } drupal_add_feed(url('blog/' . $account->uid . '/feed'), t('RSS - !title', array('!title' => $title))); - return drupal_get_page($build); + return $build; } /** @@ -104,7 +104,7 @@ function blog_page_last() { } drupal_add_feed(url('blog/feed'), t('RSS - blogs')); - return drupal_get_page($build); + return $build; } /** diff --git a/modules/node/node.module b/modules/node/node.module index 1b61ed2fb..0eb5c3f31 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -1325,7 +1325,7 @@ function node_show($node, $message = FALSE) { node_tag_new($node->nid); // For markup consistency with other pages, use node_build_multiple() rather than node_build(). - return drupal_get_page(node_build_multiple(array($node), FALSE)); + return node_build_multiple(array($node), FALSE); } /** @@ -2088,7 +2088,7 @@ function node_page_default() { ); } drupal_set_title(''); - return drupal_get_page($build); + return $build; } /** diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test index 3fcaa454d..20e75ed6f 100644 --- a/modules/simpletest/tests/common.test +++ b/modules/simpletest/tests/common.test @@ -362,12 +362,12 @@ class DrupalHTTPRequestTestCase extends DrupalWebTestCase { } /** - * Testing drupal_set_content and drupal_get_content. + * Testing drupal_add_region_content and drupal_get_region_content. */ class DrupalSetContentTestCase extends DrupalWebTestCase { public static function getInfo() { return array( - 'name' => t('Drupal set/get content'), + 'name' => t('Drupal set/get regions'), 'description' => t('Performs tests on setting and retrieiving content from theme regions.'), 'group' => t('System') ); @@ -386,22 +386,22 @@ class DrupalSetContentTestCase extends DrupalWebTestCase { // Set some random content for each region available. foreach ($block_regions as $region) { $first_chunk = $this->randomName(32); - drupal_set_content($region, $first_chunk); + drupal_add_region_content($region, $first_chunk); $second_chunk = $this->randomName(32); - drupal_set_content($region, $second_chunk); - // Store the expected result for a drupal_get_content call for this region. + drupal_add_region_content($region, $second_chunk); + // Store the expected result for a drupal_get_region_content call for this region. $values[$region] = $first_chunk . $delimiter . $second_chunk; } - // Ensure drupal_get_content returns expected results when fetching all regions. - $content = drupal_get_content(NULL, $delimiter); + // Ensure drupal_get_region_content returns expected results when fetching all regions. + $content = drupal_get_region_content(NULL, $delimiter); foreach ($content as $region => $region_content) { $this->assertEqual($region_content, $values[$region], t('@region region text verified when fetching all regions', array('@region' => $region))); } - // Ensure drupal_get_content returns expected results when fetching a single region. + // Ensure drupal_get_region_content returns expected results when fetching a single region. foreach ($block_regions as $region) { - $region_content = drupal_get_content($region, $delimiter); + $region_content = drupal_get_region_content($region, $delimiter); $this->assertEqual($region_content, $values[$region], t('@region region text verified when fetching single region.', array('@region' => $region))); } } diff --git a/modules/system/system.admin.inc b/modules/system/system.admin.inc index e352a60dc..a9f040f96 100644 --- a/modules/system/system.admin.inc +++ b/modules/system/system.admin.inc @@ -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) { @@ -1882,7 +1884,8 @@ function system_batch_page() { elseif (isset($output)) { // Force a page without blocks or messages to // display a list of collected messages later. - $page = drupal_get_page($output); + drupal_set_page_content($output); + $page = element_info('page'); $page['#show_blocks'] = FALSE; $page['#show_messages'] = FALSE; return $page; diff --git a/modules/system/system.install b/modules/system/system.install index 9b8ab44d3..d0246fbc8 100644 --- a/modules/system/system.install +++ b/modules/system/system.install @@ -3347,7 +3347,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(); @@ -3359,6 +3359,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. diff --git a/modules/system/system.module b/modules/system/system.module index 3f7c8521b..017c43473 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -878,6 +878,11 @@ function system_user_timezone(&$edit, &$form) { * 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', @@ -946,6 +951,10 @@ function system_block_save($delta = '', $edit = NULL) { function system_block_view($delta = '') { $block = array(); switch ($delta) { + case 'main': + $block['subject'] = NULL; + $block['content'] = drupal_set_page_content(); + 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; diff --git a/modules/taxonomy/taxonomy.pages.inc b/modules/taxonomy/taxonomy.pages.inc index 65c81cbb1..2454c5195 100644 --- a/modules/taxonomy/taxonomy.pages.inc +++ b/modules/taxonomy/taxonomy.pages.inc @@ -79,7 +79,7 @@ function taxonomy_term_page($terms, $depth = 0, $op = 'page') { ); } - return drupal_get_page($build); + return $build; case 'feed': $channel['link'] = url('taxonomy/term/' . $str_tids . '/' . $depth, array('absolute' => TRUE)); diff --git a/modules/user/user.pages.inc b/modules/user/user.pages.inc index 36a40bee1..804f152e6 100644 --- a/modules/user/user.pages.inc +++ b/modules/user/user.pages.inc @@ -176,7 +176,7 @@ function user_view($account) { '#account' => $account, ); - return drupal_get_page($build); + return $build; } /** |