book_outline
- Versions
- 4.6
book_outline()- 4.7 – 5
book_outline($nid)- 6 – 7
book_outline($node)
Implementation of function book_outline() Handles all book outline operations.
Code
modules/book.module, line 233
<?php
function book_outline() {
$op = $_POST['op'];
$edit = $_POST['edit'];
$node = node_load(array('nid' => arg(1)));
if ($node->nid) {
switch ($op) {
case t('Add to book outline'):
db_query('INSERT INTO {book} (nid, parent, weight) VALUES (%d, %d, %d)', $node->nid, $edit['parent'], $edit['weight']);
drupal_set_message(t('Added the post to the book.'));
drupal_goto("node/$node->nid");
break;
case t('Update book outline'):
db_query('UPDATE {book} SET parent = %d, weight = %d WHERE nid = %d', $edit['parent'], $edit['weight'], $node->nid);
drupal_set_message(t('Updated the book outline.'));
drupal_goto("node/$node->nid");
break;
case t('Remove from book outline'):
db_query('DELETE FROM {book} WHERE nid = %d', $node->nid);
drupal_set_message(t('Removed the post from the book.'));
drupal_goto("node/$node->nid");
break;
default:
$page = db_fetch_object(db_query('SELECT * FROM {book} WHERE nid = %d', $node->nid));
$output = form_select(t('Parent'), 'parent', $page->parent, book_toc($node->nid), t('The parent page in the book.'));
$output .= form_weight(t('Weight'), 'weight', $page->weight, 15, t('Pages at a given level are ordered first by weight and then by title.'));
if ($page->nid) {
$output .= form_submit(t('Update book outline'));
$output .= form_submit(t('Remove from book outline'));
}
else {
$output .= form_submit(t('Add to book outline'));
}
drupal_set_title(check_plain($node->title));
print theme('page', form($output));
}
}
}
?>Login or register to post comments 