You are here

function book_helper_admin_edit in Book helper 7

Same name and namespace in other branches
  1. 6 book_helper.admin.inc \book_helper_admin_edit()

Build the form to administrate the hierarchy of a single book.

Hijacks the book.module's 'edit order and titles' page. (admin/content/book/%node) and adds 'enable' checkbox (aka hidden) to the table's form.

Note:

See also

book_admin_edit_submit()

2 string references to 'book_helper_admin_edit'
book_helper_menu in ./book_helper.module
Implements hook_menu().
book_helper_menu_alter in ./book_helper.module
Implements hook_menu_alter().

File

./book_helper.admin.inc, line 121
Administration page for the 'Book helper' module.

Code

function book_helper_admin_edit($form, $form_state, $node) {
  drupal_set_title($node->title);
  $form['#node'] = $node;
  _book_helper_admin_table($node, $form);

  // Add css.
  drupal_add_css(drupal_get_path('module', 'book_helper') . '/book_helper.css');

  // Custom code: Allow top-level pages to be removed from books. http://drupal.org/node/283045
  if (isset($form['table']['#empty'])) {

    // Don't render the empty table with headers.
    unset($form['table']);

    // Display the standard confirmation form.
    $t_args = array(
      '%title' => $node->title,
    );
    $child_type = variable_get('book_child_type', 'book');
    if ((user_access('add content to books') || user_access('administer book outlines')) && node_access('create', $child_type)) {
      $t_args['!add_child_page'] = l(t('add a child page'), 'node/add/' . str_replace('_', '-', $child_type), array(
        'query' => array(
          'parent' => $node->book['mlid'],
        ),
      ));
    }
    else {
      $t_args['!add_child_page'] = t('add a child page');
    }
    drupal_set_message(t('%title contains no child book pages. To create a sort-able book hierarchy, please !add_child_page to this book.', $t_args), 'warning');
    $description = t('%title may be added as a new book again using the Outline tab.', $t_args);
    return confirm_form($form, t('Do you want to revert %title from a book hierarchy?', $t_args), 'node/' . $node->nid, $description, t('Revert'));
  }
  $form['save'] = array(
    '#type' => 'submit',
    '#value' => t('Save book pages'),
  );
  return $form;
}