| Versions | |
|---|---|
| 4.7 – 5 | book_export($type = 'html', $nid = 0) |
| 6 – 7 | book_export($type, $nid) |
Menu callback; Generates various representation of a book page with all descendants and prints the requested representation to output.
The function delegates the generation of output to helper functions. The function name is derived by prepending 'book_export_' to the given output type. So, e.g., a type of 'html' results in a call to the function book_export_html().
type
nid
modules/
<?php
function book_export($type = 'html', $nid = 0) {
$type = drupal_strtolower($type);
$node_result = db_query(db_rewrite_sql('SELECT n.nid, n.title, b.parent FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE n.nid = %d'), $nid);
if (db_num_rows($node_result) > 0) {
$node = db_fetch_object($node_result);
}
$depth = count(book_location($node)) + 1;
$export_function = 'book_export_' . $type;
if (function_exists($export_function)) {
print call_user_func($export_function, $nid, $depth);
}
else {
drupal_set_message(t('Unknown export format.'));
drupal_not_found();
}
}
?>