function theme_book_helper_admin_table in Book helper 7
Same name and namespace in other branches
- 6 book_helper.admin.inc \theme_book_helper_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()
1 theme call to theme_book_helper_admin_table()
- _book_helper_admin_table in ./
book_helper.admin.inc - Build the table portion of the form for the book administration page.
File
- ./
book_helper.admin.inc, line 365 - Administration page for the 'Book helper' module.
Code
function theme_book_helper_admin_table($variables) {
$form = $variables['form'];
// New code: Adds js to sync link title and node title.
drupal_add_js(drupal_get_path('module', 'book_helper') . '/book_helper.js');
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');
/* Over-ridden code: Do not delete.
$header = array(t('Title'), t('Weight'), t('Parent'), array('data' => t('Operations'), 'colspan' => '3'));
*/
// Updated code: Adds hidden to header.
$header = array(
'',
t('Page title'),
t('Menu title'),
array(
'data' => t('Sync'),
'class' => 'checkbox',
),
t('Weight'),
t('Parent'),
array(
'data' => t('Enabled'),
'class' => 'checkbox',
),
array(
'data' => t('Operations'),
'colspan' => '4',
),
);
$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(
// first column is the page title
theme('indentation', array(
'size' => $form[$key]['depth']['#value'] - 2,
)),
// New code: Add menu title and sync checkbox.
drupal_render($form[$key]['title']),
drupal_render($form[$key]['link_title']),
array(
'data' => drupal_render($form[$key]['link_title_sync']),
'class' => 'checkbox',
),
drupal_render($form[$key]['weight']),
drupal_render($form[$key]['plid']) . drupal_render($form[$key]['mlid']),
// New code: Add hidden checkbox to table.
array(
'data' => drupal_render($form[$key]['hidden']),
'class' => 'checkbox',
),
l(t('view'), $href),
$access ? l(t('edit'), 'node/' . $nid . '/edit', array(
'query' => $destination,
)) : ' ',
$access ? l(t('remove from book'), 'node/' . $nid . '/outline/remove', array(
'query' => $destination,
)) : ' ',
$access ? l(t('delete node'), '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';
if (empty($form[$key]['hidden']['#value'])) {
$row['class'][] = 'hidden';
}
$rows[] = $row;
}
return theme('table', array(
'header' => $header,
'rows' => $rows,
'attributes' => array(
'id' => 'book-outline',
),
));
}