You are here

function book_export in Drupal 5

Same name and namespace in other branches
  1. 4 modules/book.module \book_export()
  2. 6 modules/book/book.pages.inc \book_export()
  3. 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/book.module
Implementation of hook_menu().

File

modules/book/book.module, line 639
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();
  }
}