function book_export in Drupal 4
Same name and namespace in other branches
- 5 modules/book/book.module \book_export()
- 6 modules/book/book.pages.inc \book_export()
- 7 modules/book/book.pages.inc \book_export()
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().
Parameters
type:
- a string encoding the type of output requested. The following types are currently supported in book module html: HTML (printer friendly output) Other types are supported in contributed modules.
nid:
- an integer representing the node id (nid) of the node to export
1 string reference to 'book_export'
- book_menu in modules/
book.module - Implementation of hook_menu().
File
- modules/
book.module, line 663 - Allows users to collaboratively author a book.
Code
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();
}
}