From 331bf61455c21c15d67b7b9a5929208cbc9af267 Mon Sep 17 00:00:00 2001
From: Dries Buytaert <dries@buytaert.net>
Date: Mon, 24 Nov 2008 06:00:02 +0000
Subject: [PATCH] - Patch #293370 by swentel et al: make block sorting work
 when there are more than 20 blocks.

---
 modules/block/block.admin.inc | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/modules/block/block.admin.inc b/modules/block/block.admin.inc
index 26a8eada17ff..32fa80716dae 100644
--- a/modules/block/block.admin.inc
+++ b/modules/block/block.admin.inc
@@ -38,6 +38,11 @@ function block_admin_display_form(&$form_state, $blocks, $theme = NULL) {
   $throttle = module_exists('throttle');
   $block_regions = system_region_list($theme_key) + array(BLOCK_REGION_NONE => '<'. t('none') .'>');
 
+  // 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.
+  $weight_delta = round(count($blocks) / 2);
+
   // Build form tree
   $form = array(
     '#action' => arg(4) ? url('admin/build/block/list/'. $theme_key) : url('admin/build/block'),
@@ -64,6 +69,7 @@ function block_admin_display_form(&$form_state, $blocks, $theme = NULL) {
     $form[$key]['weight'] = array(
       '#type' => 'weight',
       '#default_value' => $block['weight'],
+      '#delta' => $weight_delta,
     );
     $form[$key]['region'] = array(
       '#type' => 'select',
-- 
GitLab