function theme_book_admin_table in Drupal 7
Same name and namespace in other branches
- 4 modules/book.module \theme_book_admin_table()
- 5 modules/book/book.module \theme_book_admin_table()
- 6 modules/book/book.admin.inc \theme_book_admin_table()
Returns HTML for a book administration form.
Parameters
$variables: An associative array containing:
- form: A render element representing the form.
See also
book_admin_table()
Related topics
1 theme call to theme_book_admin_table()
- _book_admin_table in modules/
book/ book.admin.inc - Builds the table portion of the form for the book administration page.
File
- modules/
book/ book.admin.inc, line 252 - Administration page callbacks for the Book module.
Code
function theme_book_admin_table($variables) {
$form = $variables['form'];
drupal_add_tabledrag('book-outline', 'match', 'parent', 'book-plid', 'book-plid', 'book-mlid', TRUE, MENU_MAX_DEPTH - 2);
drupal_add_tabledrag('book-outline', 'order', 'sibling', 'book-weight');
$header = array(
t('Title'),
t('Weight'),
t('Parent'),
array(
'data' => t('Operations'),
'colspan' => '3',
),
);
$rows = array();
$destination = drupal_get_destination();
$access = user_access('administer nodes');
foreach (element_children($form) as $key) {
$nid = $form[$key]['nid']['#value'];
$href = $form[$key]['href']['#value'];
// Add special classes to be used with tabledrag.js.
$form[$key]['plid']['#attributes']['class'] = array(
'book-plid',
);
$form[$key]['mlid']['#attributes']['class'] = array(
'book-mlid',
);
$form[$key]['weight']['#attributes']['class'] = array(
'book-weight',
);
$data = array(
theme('indentation', array(
'size' => $form[$key]['depth']['#value'] - 2,
)) . drupal_render($form[$key]['title']),
drupal_render($form[$key]['weight']),
drupal_render($form[$key]['plid']) . drupal_render($form[$key]['mlid']),
l(t('view'), $href),
$access ? l(t('edit'), 'node/' . $nid . '/edit', array(
'query' => $destination,
)) : ' ',
$access ? l(t('delete'), 'node/' . $nid . '/delete', array(
'query' => $destination,
)) : ' ',
);
$row = array(
'data' => $data,
);
if (isset($form[$key]['#attributes'])) {
$row = array_merge($row, $form[$key]['#attributes']);
}
$row['class'][] = 'draggable';
$rows[] = $row;
}
return theme('table', array(
'header' => $header,
'rows' => $rows,
'attributes' => array(
'id' => 'book-outline',
),
'empty' => t('No book content available.'),
));
}