function _book_helper_admin_table_tree in Book helper 6
Same name and namespace in other branches
- 7 book_helper.admin.inc \_book_helper_admin_table_tree()
Recursive helper to build the main table in the book administration page form.
See also
1 call to _book_helper_admin_table_tree()
- _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 281 - Administration page for the 'Book helper' module.
Code
function _book_helper_admin_table_tree($tree, &$form, $bid) {
// Create a cache of all the book's node titles.
static $node_titles;
if (!isset($node_titles)) {
$node_titles = array();
$result = db_query('SELECT n.nid, n.title FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE bid = %d', $bid);
while ($record = db_fetch_array($result)) {
if (function_exists('node_parent_title_remove')) {
$record['title'] = node_parent_title_remove($record['title']);
}
$node_titles[$record['nid']] = $record['title'];
}
}
foreach ($tree as $data) {
$node_title = $node_titles[$data['link']['nid']];
$form['book-admin-' . $data['link']['nid']] = array(
'#item' => $data['link'],
'nid' => array(
'#type' => 'value',
'#value' => $data['link']['nid'],
),
'depth' => array(
'#type' => 'value',
'#value' => $data['link']['depth'],
),
'href' => array(
'#type' => 'value',
'#value' => $data['link']['href'],
),
'title' => array(
'#type' => 'textfield',
'#default_value' => $data['link']['link_title'],
'#maxlength' => 255,
'#size' => 15,
),
// New code: Allows node title to be customized.
'node_title' => array(
'#type' => 'textfield',
'#default_value' => $node_title,
'#maxlength' => 255,
'#size' => 15,
),
'sync' => array(
'#type' => 'checkbox',
'#default_value' => $node_title == $data['link']['link_title'] ? TRUE : FALSE,
),
'weight' => array(
'#type' => 'weight',
'#default_value' => $data['link']['weight'],
'#delta' => 15,
),
'plid' => array(
'#type' => 'textfield',
'#default_value' => $data['link']['plid'],
'#size' => 6,
),
'mlid' => array(
'#type' => 'hidden',
'#default_value' => $data['link']['mlid'],
),
// New code: Add checkbox element for hidden.
'hidden' => array(
'#type' => 'checkbox',
'#default_value' => !$data['link']['hidden'],
),
);
if ($data['below']) {
_book_helper_admin_table_tree($data['below'], $form, $bid);
}
}
return $form;
}