summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAngie Byron2011-01-03 07:34:46 (GMT)
committer Angie Byron2011-01-03 07:34:46 (GMT)
commitc5da457f287cdeadc62bcaa3702b1a1bcf29b6ea (patch)
tree9dcfd7845951604b152ce28d3453e3bfd13cffb5
parenta873518489a07e8354361fc3db9e6ad418fb5d2c (diff)
#589440 by Booba, willmoy, JanZ, pwolanin, mlncn: Fixed Reordering fails with more than 31 book pages in a book
-rw-r--r--modules/book/book.admin.inc6
-rw-r--r--modules/book/book.module3
2 files changed, 7 insertions, 2 deletions
diff --git a/modules/book/book.admin.inc b/modules/book/book.admin.inc
index 53f4b40..50ec793 100644
--- a/modules/book/book.admin.inc
+++ b/modules/book/book.admin.inc
@@ -175,6 +175,10 @@ function _book_admin_table($node, &$form) {
* @see book_admin_edit()
*/
function _book_admin_table_tree($tree, &$form) {
+ // The delta must be big enough to give each node a distinct value.
+ $count = count($tree);
+ $delta = ($count < 30) ? 15 : intval($count / 2) + 1;
+
foreach ($tree as $data) {
$form['book-admin-' . $data['link']['nid']] = array(
'#item' => $data['link'],
@@ -190,7 +194,7 @@ function _book_admin_table_tree($tree, &$form) {
'weight' => array(
'#type' => 'weight',
'#default_value' => $data['link']['weight'],
- '#delta' => 15,
+ '#delta' => max($delta, abs($data['link']['weight'])),
'#title' => t('Weight for @title', array('@title' => $data['link']['title'])),
'#title_display' => 'invisible',
),
diff --git a/modules/book/book.module b/modules/book/book.module
index 25f0254..760eb5b 100644
--- a/modules/book/book.module
+++ b/modules/book/book.module
@@ -510,11 +510,12 @@ function _book_add_form_elements(&$form, &$form_state, $node) {
$form['book']['plid'] = _book_parent_select($node->book);
+ // @see _book_admin_table_tree(). The weight may be larger than 15.
$form['book']['weight'] = array(
'#type' => 'weight',
'#title' => t('Weight'),
'#default_value' => $node->book['weight'],
- '#delta' => 15,
+ '#delta' => max(15, abs($node->book['weight'])),
'#weight' => 5,
'#description' => t('Pages at a given level are ordered first by weight and then by title.'),
);