function theme_library_items_field in Library 7
Same name and namespace in other branches
- 5.2 library.theme.inc \theme_library_items_field()
- 6.2 library.theme.inc \theme_library_items_field()
- 6 library.theme.inc \theme_library_items_field()
Theme the items section on library entries.
1 theme call to theme_library_items_field()
- library_form_alter in ./
library.module - Implements hook_form_alter().
File
- ./
library.theme.inc, line 98 - Theming for the library module
Code
function theme_library_items_field($form) {
$barcodes = variable_get('library_item_barcodes', LIBRARY_NO_BARCODES) == LIBRARY_BARCODES;
$rows = array();
if ($barcodes) {
$header[] = t('Barcode');
}
else {
$header[] = t('Copy');
}
$header[] = t('Reference Only');
$header[] = t('Notes');
$header[] = t('Delete');
foreach (element_children($form['form']['library_items']) as $key) {
// No need to print the field title every time.
unset($form['form']['library_items'][$key]['barcode']['#title'], $form['form']['library_items'][$key]['in_circulation']['#title'], $form['form']['library_items'][$key]['notes']['#title'], $form['form']['library_items'][$key]['delete']['#title']);
// Build the table row.
if ($barcodes) {
$row['data'][] = array(
'data' => drupal_render($form['form']['library_items'][$key]['barcode']),
'class' => 'library-barcode',
);
}
else {
$row['data'][] = array(
'data' => $key + 1,
'class' => 'library-copy',
);
}
$row['data'][] = array(
'data' => drupal_render($form['form']['library_items'][$key]['in_circulation']),
'class' => 'library_circulation',
);
$row['data'][] = array(
'data' => drupal_render($form['form']['library_items'][$key]['notes']),
'class' => 'library_notes',
);
if ($key > 0) {
$row['data'][] = array(
'data' => drupal_render($form['form']['library_items'][$key]['delete']),
'class' => 'library-delete',
);
}
else {
$row['data'][] = array();
}
// Add additional attributes to the row, such as a class for this row.
if (isset($form['form']['library_items'][$key]['#attributes'])) {
$row = array_merge($row, $form['form']['library_items'][$key]['#attributes']);
}
$rows[] = $row;
$row = array();
}
$output = theme('table', array(
'header' => $header,
'rows' => $rows,
));
$output .= drupal_render_children($form['form']);
return $output;
}