diff options
Diffstat (limited to 'modules/block')
-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 |
4 files changed, 43 insertions, 5 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; |