#90395 by joshk, mj2308, and kkaefer. Fix book outline saving.
parent
a0deec8c45
commit
3a5d412efb
|
@ -180,13 +180,6 @@ function book_block($op = 'list', $delta = 0) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Implementation of hook_load().
|
|
||||||
*/
|
|
||||||
function book_load($node) {
|
|
||||||
return db_fetch_object(db_query('SELECT * FROM {book} WHERE vid = %d', $node->vid));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of hook_insert().
|
* Implementation of hook_insert().
|
||||||
*/
|
*/
|
||||||
|
@ -194,25 +187,6 @@ function book_insert($node) {
|
||||||
db_query("INSERT INTO {book} (nid, vid, parent, weight) VALUES (%d, %d, %d, %d)", $node->nid, $node->vid, $node->parent, $node->weight);
|
db_query("INSERT INTO {book} (nid, vid, parent, weight) VALUES (%d, %d, %d, %d)", $node->nid, $node->vid, $node->parent, $node->weight);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Implementation of hook_update().
|
|
||||||
*/
|
|
||||||
function book_update($node) {
|
|
||||||
if ($node->revision) {
|
|
||||||
db_query("INSERT INTO {book} (nid, vid, parent, weight) VALUES (%d, %d, %d, %d)", $node->nid, $node->vid, $node->parent, $node->weight);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
db_query("UPDATE {book} SET parent = %d, weight = %d WHERE vid = %d", $node->parent, $node->weight, $node->vid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implementation of hook_delete().
|
|
||||||
*/
|
|
||||||
function book_delete(&$node) {
|
|
||||||
db_query('DELETE FROM {book} WHERE nid = %d', $node->nid);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of hook_submit().
|
* Implementation of hook_submit().
|
||||||
*/
|
*/
|
||||||
|
@ -292,17 +266,16 @@ function book_form(&$node) {
|
||||||
*/
|
*/
|
||||||
function book_outline($nid) {
|
function book_outline($nid) {
|
||||||
$node = node_load($nid);
|
$node = node_load($nid);
|
||||||
$page = book_load($node);
|
|
||||||
|
|
||||||
$form['parent'] = array('#type' => 'select',
|
$form['parent'] = array('#type' => 'select',
|
||||||
'#title' => t('Parent'),
|
'#title' => t('Parent'),
|
||||||
'#default_value' => $page->parent,
|
'#default_value' => $node->parent,
|
||||||
'#options' => book_toc($node->nid),
|
'#options' => book_toc($node->nid),
|
||||||
'#description' => t('The parent page in the book.'),
|
'#description' => t('The parent page in the book.'),
|
||||||
);
|
);
|
||||||
$form['weight'] = array('#type' => 'weight',
|
$form['weight'] = array('#type' => 'weight',
|
||||||
'#title' => t('Weight'),
|
'#title' => t('Weight'),
|
||||||
'#default_value' => $page->weight,
|
'#default_value' => $node->weight,
|
||||||
'#delta' => 15,
|
'#delta' => 15,
|
||||||
'#description' => t('Pages at a given level are ordered first by weight and then by title.'),
|
'#description' => t('Pages at a given level are ordered first by weight and then by title.'),
|
||||||
);
|
);
|
||||||
|
@ -312,7 +285,7 @@ function book_outline($nid) {
|
||||||
);
|
);
|
||||||
|
|
||||||
$form['nid'] = array('#type' => 'value', '#value' => $nid);
|
$form['nid'] = array('#type' => 'value', '#value' => $nid);
|
||||||
if ($page->nid) {
|
if ($node->parent) {
|
||||||
$form['update'] = array('#type' => 'submit',
|
$form['update'] = array('#type' => 'submit',
|
||||||
'#value' => t('Update book outline'),
|
'#value' => t('Update book outline'),
|
||||||
);
|
);
|
||||||
|
@ -462,14 +435,12 @@ function book_content($node, $teaser = FALSE) {
|
||||||
*/
|
*/
|
||||||
function book_nodeapi(&$node, $op, $teaser, $page) {
|
function book_nodeapi(&$node, $op, $teaser, $page) {
|
||||||
switch ($op) {
|
switch ($op) {
|
||||||
|
case 'load':
|
||||||
|
return db_fetch_array(db_query('SELECT parent, weight FROM {book} WHERE vid = %d', $node->vid));
|
||||||
|
break;
|
||||||
case 'view':
|
case 'view':
|
||||||
if (!$teaser) {
|
if (!$teaser) {
|
||||||
$book = db_fetch_array(db_query('SELECT * FROM {book} WHERE vid = %d', $node->vid));
|
if (isset($node->parent)) {
|
||||||
if ($book) {
|
|
||||||
foreach ($book as $key => $value) {
|
|
||||||
$node->$key = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
$path = book_location($node);
|
$path = book_location($node);
|
||||||
// Construct the breadcrumb:
|
// Construct the breadcrumb:
|
||||||
$node->breadcrumb = array(); // Overwrite the trail with a book trail.
|
$node->breadcrumb = array(); // Overwrite the trail with a book trail.
|
||||||
|
@ -489,6 +460,16 @@ function book_nodeapi(&$node, $op, $teaser, $page) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'update':
|
||||||
|
if (isset($node->parent)) {
|
||||||
|
if ($node->revision) {
|
||||||
|
db_query("INSERT INTO {book} (nid, vid, parent, weight) VALUES (%d, %d, %d, %d)", $node->nid, $node->vid, $node->parent, $node->weight);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
db_query("UPDATE {book} SET parent = %d, weight = %d WHERE vid = %d", $node->parent, $node->weight, $node->vid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'delete revision':
|
case 'delete revision':
|
||||||
db_query('DELETE FROM {book} WHERE vid = %d', $node->vid);
|
db_query('DELETE FROM {book} WHERE vid = %d', $node->vid);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue