| 1 |
<?php
|
| 2 |
// $Id:
|
| 3 |
|
| 4 |
/**
|
| 5 |
* Menu callback: Library Actions
|
| 6 |
* Theme Form to create a new action
|
| 7 |
*
|
| 8 |
* @see library_admin_action()
|
| 9 |
* @see library_admin_action_validate()
|
| 10 |
* @see library_admin_action_submit()
|
| 11 |
*/
|
| 12 |
function theme_library_admin_new_action($form) {
|
| 13 |
$header = array(t('Name'), t('Item Status'), t('Edit'));
|
| 14 |
foreach (library_actions() as $aid => $action) {
|
| 15 |
switch ($action['status_change']) {
|
| 16 |
case LIBRARY_ACTION_TYPE_UNAVAILABLE:
|
| 17 |
$status_text = 'Unavailable';
|
| 18 |
break;
|
| 19 |
case LIBRARY_ACTION_TYPE_AVAILABLE:
|
| 20 |
$status_text = 'Available';
|
| 21 |
break;
|
| 22 |
default:
|
| 23 |
$status_text = 'No Change';
|
| 24 |
}
|
| 25 |
$rows[] = array($action['name'], $status_text, l(t('edit action'), 'admin/settings/library/actions/edit/'. $aid));
|
| 26 |
}
|
| 27 |
$rows[] = array(drupal_render($form['name']), drupal_render($form['status_change']), drupal_render($form['submit']));
|
| 28 |
|
| 29 |
$output = drupal_render($form);
|
| 30 |
$output .= theme('table', $header, $rows);
|
| 31 |
|
| 32 |
return $output;
|
| 33 |
}
|
| 34 |
|
| 35 |
function theme_library_items($node) {
|
| 36 |
$barcodes = (variable_get('library_item_barcodes', LIBRARY_NO_BARCODES) == LIBRARY_BARCODES);
|
| 37 |
$display_status = (variable_get(library_status_display, 0) == 1);
|
| 38 |
|
| 39 |
$items = $node->items;
|
| 40 |
$header = array(t('Copy'));
|
| 41 |
if ($barcodes) {
|
| 42 |
$header[] = t('Barcode');
|
| 43 |
}
|
| 44 |
if ($display_status) {
|
| 45 |
$header[] = t('Status');
|
| 46 |
}
|
| 47 |
$header[] = t('Notes');
|
| 48 |
$header[] = t('Actions');
|
| 49 |
$rows = array();
|
| 50 |
if ($items) {
|
| 51 |
foreach ($items as $key => $item) {
|
| 52 |
$temp_array = array(($key + 1));
|
| 53 |
if ($barcodes) {
|
| 54 |
$temp_array[] = $item['barcode'];
|
| 55 |
}
|
| 56 |
if ($display_status) {
|
| 57 |
$temp_array[] = library_get_status_text($item);
|
| 58 |
}
|
| 59 |
$temp_array[] = $item['notes'];
|
| 60 |
$temp_array[] = implode(" | ", library_get_action_links($item)) .' ';
|
| 61 |
$rows[] = $temp_array;
|
| 62 |
}
|
| 63 |
}
|
| 64 |
return theme('table', $header, $rows);
|
| 65 |
}
|
| 66 |
|
| 67 |
|
| 68 |
/**
|
| 69 |
* Theme the items section on library entries.
|
| 70 |
*
|
| 71 |
* @ingroup themeable
|
| 72 |
*/
|
| 73 |
function theme_library_items_field($form) {
|
| 74 |
// Change the button title to reflect the behavior when using JavaScript.
|
| 75 |
drupal_add_js('if (Drupal.jsEnabled) { $(document).ready(function() { $("#edit-library-more").val("'. t('Add an Item') .'"); }); }', 'inline');
|
| 76 |
|
| 77 |
$barcodes = variable_get('library_item_barcodes', LIBRARY_NO_BARCODES) == LIBRARY_BARCODES;
|
| 78 |
|
| 79 |
$rows = array();
|
| 80 |
|
| 81 |
if ($barcodes) {
|
| 82 |
$headers[] = t('Barcode');
|
| 83 |
}
|
| 84 |
else {
|
| 85 |
$headers[] = t('Copy');
|
| 86 |
}
|
| 87 |
$headers[] = t('Reference Only');
|
| 88 |
$headers[] = t('Notes');
|
| 89 |
$headers[] = t('');
|
| 90 |
$headers[] = t('Delete');
|
| 91 |
|
| 92 |
foreach (element_children($form) as $key) {
|
| 93 |
// No need to print the field title every time.
|
| 94 |
unset($form[$key]['barcode']['#title'], $form[$key]['in_circulation']['#title'], $form[$key]['notes']['#title'], $form[$key]['delete']['#title']);
|
| 95 |
|
| 96 |
// Build the table row.
|
| 97 |
|
| 98 |
if ($barcodes) {
|
| 99 |
$row['data'][] = array('data' => drupal_render($form[$key]['barcode']), 'class' => 'library-barcode');
|
| 100 |
}
|
| 101 |
else {
|
| 102 |
$row['data'][] = array('data' => ($key + 1), 'class' => 'library-copy');
|
| 103 |
}
|
| 104 |
|
| 105 |
$row['data'][] = array('data' => drupal_render($form[$key]['in_circulation']), 'class' => 'library_circulation');
|
| 106 |
$row['data'][] = array('data' => drupal_render($form[$key]['notes']), 'class' => 'library_notes');
|
| 107 |
$row['data'][] = array('data' => drupal_render($form[$key]['id']), 'class' => 'library-id');
|
| 108 |
|
| 109 |
if ($key > 0) {
|
| 110 |
$row['data'][] = array('data' => drupal_render($form[$key]['delete']), 'class' => 'library-delete');
|
| 111 |
}
|
| 112 |
else {
|
| 113 |
$row['data'][] = array();
|
| 114 |
}
|
| 115 |
|
| 116 |
// Add additional attributes to the row, such as a class for this row.
|
| 117 |
if (isset($form[$key]['#attributes'])) {
|
| 118 |
$row = array_merge($row, $form[$key]['#attributes']);
|
| 119 |
}
|
| 120 |
$rows[] = $row;
|
| 121 |
$row = array();
|
| 122 |
}
|
| 123 |
|
| 124 |
$output = theme('table', $headers, $rows);
|
| 125 |
$output .= drupal_render($form);
|
| 126 |
return $output;
|
| 127 |
}
|