book_menu

Versions
4.6 – 5
book_menu($may_cache)
6 – 7
book_menu()

Implementation of hook_menu().

Code

modules/book.module, line 76

<?php
function book_menu($may_cache) {
  $items = array();

  if ($may_cache) {
    $items[] = array(
      'path' => 'node/add/book',
      'title' => t('book page'),
      'access' => user_access('create book pages'));
    $items[] = array(
      'path' => 'admin/node/book',
      'title' => t('books'),
      'callback' => 'book_admin',
      'access' => user_access('administer nodes'),
      'type' => MENU_LOCAL_TASK,
      'weight' => -1);
    $items[] = array(
      'path' => 'admin/node/book/list',
      'title' => t('list'),
      'type' => MENU_DEFAULT_LOCAL_TASK);
    $items[] = array(
      'path' => 'admin/node/book/orphan',
      'title' => t('orphan pages'),
      'callback' => 'book_admin_orphan',
      'type' => MENU_LOCAL_TASK,
      'weight' => 8);
    $items[] = array(
      'path' => 'book',
      'title' => t('books'),
      'callback' => 'book_render',
      'access' => user_access('access content'),
      'type' => MENU_SUGGESTED_ITEM);
    $items[] = array(
      'path' => 'book/export',
      'callback' => 'book_export',
      'access' => user_access('access content'),
      'type' => MENU_CALLBACK);
  }
  else {
    // To avoid SQL overhead, check whether we are on a node page and whether the
    // user is allowed to outline posts in books.
    if (arg(0) == 'node' && is_numeric(arg(1)) && user_access('outline posts in books')) {
      // Only add the outline-tab for non-book pages:
      $result = db_query(db_rewrite_sql("SELECT n.nid FROM {node} n WHERE n.nid = %d AND n.type != 'book'"), arg(1));
      if (db_num_rows($result) > 0) {
        $items[] = array(
          'path' => 'node/'. arg(1) .'/outline',
          'title' => t('outline'),
          'callback' => 'book_outline',
          'callback arguments' => array(arg(1)),
          'access' => user_access('outline posts in books'),
          'type' => MENU_LOCAL_TASK,
          'weight' => 2);
      }
    }
  }

  return $items;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.