function book_helper_admin_edit in Book helper 6
Same name and namespace in other branches
- 7 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:
- This module attempts to re-use code from the book.module's book.admin.inc while merging it with the 'enabled' checked code from the menu.admin.inc menu_overview_form().
See also
2 string references to 'book_helper_admin_edit'
- book_helper_menu in ./
book_helper.module - Implementation of hook_menu().
- book_helper_menu_alter in ./
book_helper.module - Implementation of hook_menu_alter(). Overrides the books outline page.
File
- ./
book_helper.admin.inc, line 109 - Administration page for the 'Book helper' module.
Code
function book_helper_admin_edit($form_state, $node) {
drupal_set_title(check_plain($node->title));
// Add css
drupal_add_css(drupal_get_path('module', 'book_helper') . '/book_helper.css');
// Build form
$form = array();
$form['#node'] = $node;
_book_helper_admin_table($node, $form);
// Custom code: Allow top-level pages to be removed from books. http://drupal.org/node/283045
if (isset($form['table']['#empty'])) {
unset($form['table']);
// Don't render the empty table with headers
// 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' => "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 heirarchy, please !add_child_page to this book 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;
}