| 1 |
<?php
|
| 2 |
// $Id: node.admin.inc,v 1.7 2009/01/07 00:55:00 dww Exp $
|
| 3 |
|
| 4 |
|
| 5 |
/**
|
| 6 |
* @file
|
| 7 |
* Theme functions for the signup node administration page (node/N/signups).
|
| 8 |
*/
|
| 9 |
|
| 10 |
/**
|
| 11 |
* Theme function for the signup administrative tab (node/N/signups).
|
| 12 |
*
|
| 13 |
* This is responsible for rendering the signup summary form (allows
|
| 14 |
* admins to open/close signups, set a signup limit, and see the total
|
| 15 |
* number of signups), the table of signup details (generated by
|
| 16 |
* signup_node_admin_page()), and if the node is signup-enabled, the
|
| 17 |
* form to signup other users.
|
| 18 |
*
|
| 19 |
* @param $node
|
| 20 |
* The node object for the signup-enabled node this is a tab on.
|
| 21 |
* @param $signup_node_admin_summary_form
|
| 22 |
* The rendered HTML for the signup node summary form (to set the signup
|
| 23 |
* limit, open/close signups, see the total number of signups, etc).
|
| 24 |
* @param $signup_node_admin_details_form
|
| 25 |
* The rendered HTML for the signup node details form (to view all the users
|
| 26 |
* who have signed up, their full signup details, and checkboxes to cancel
|
| 27 |
* multiple signups at once.
|
| 28 |
*/
|
| 29 |
function theme_signup_node_admin_page($node, $signup_node_admin_summary_form, $signup_node_admin_details_form) {
|
| 30 |
$output = '';
|
| 31 |
|
| 32 |
// Administrative summary table to control signups for this node.
|
| 33 |
$output .= $signup_node_admin_summary_form;
|
| 34 |
|
| 35 |
// Details for each user who signed up.
|
| 36 |
$output .= $signup_node_admin_details_form;
|
| 37 |
|
| 38 |
return $output;
|
| 39 |
}
|
| 40 |
|
| 41 |
/**
|
| 42 |
* Renders the HTML for the per-node signup summary administrative form.
|
| 43 |
*/
|
| 44 |
function theme_signup_node_admin_summary_form($form) {
|
| 45 |
$output = '';
|
| 46 |
$output .= '<div class="container-inline">' . drupal_render($form['status']);
|
| 47 |
if (!empty($form['submit']) && $form['status']['#type'] == 'select') {
|
| 48 |
$output .= ' ' . drupal_render($form['submit']);
|
| 49 |
}
|
| 50 |
$output .= '</div>';
|
| 51 |
foreach (element_children($form) as $key) {
|
| 52 |
if (!in_array($key, array('status', 'submit', 'nid', 'form_build_id', 'form_token', 'form_id'))) {
|
| 53 |
$prefix = '<div class="container-inline">';
|
| 54 |
$suffix = '</div>';
|
| 55 |
if (empty($form[$key]['#prefix'])) {
|
| 56 |
$form[$key]['#prefix'] = $prefix;
|
| 57 |
}
|
| 58 |
else {
|
| 59 |
$form[$key]['#prefix'] .= $prefix;
|
| 60 |
}
|
| 61 |
if (empty($form[$key]['#suffix'])) {
|
| 62 |
$form[$key]['#suffix'] = $suffix;
|
| 63 |
}
|
| 64 |
else {
|
| 65 |
$form[$key]['#suffix'] .= $suffix;
|
| 66 |
}
|
| 67 |
}
|
| 68 |
}
|
| 69 |
$output .= drupal_render($form);
|
| 70 |
$fieldset = array(
|
| 71 |
'#title' => t('Signup summary'),
|
| 72 |
'#collapsible' => TRUE,
|
| 73 |
'#collapsed' => FALSE,
|
| 74 |
'#value' => $output,
|
| 75 |
);
|
| 76 |
return theme('fieldset', $fieldset);
|
| 77 |
}
|
| 78 |
|
| 79 |
function theme_signup_node_admin_details_form($form) {
|
| 80 |
$fieldset = array(
|
| 81 |
'#title' => t('Signup details'),
|
| 82 |
'#collapsible' => TRUE,
|
| 83 |
'#collapsed' => FALSE,
|
| 84 |
);
|
| 85 |
if (!empty($form['users']['#options'])) {
|
| 86 |
$header = $form['#header'];
|
| 87 |
$rows = array();
|
| 88 |
foreach ($form['users']['#options'] as $key => $value) {
|
| 89 |
$rows[] = array(
|
| 90 |
'cancel_checkbox' => drupal_render($form['users'][$key]),
|
| 91 |
'username' => drupal_render($form['username'][$key]),
|
| 92 |
'signup_date' => drupal_render($form['signup_date'][$key]),
|
| 93 |
'signup_form_data' => drupal_render($form['signup_form_data'][$key]),
|
| 94 |
'attended' => drupal_render($form['attended'][$key]),
|
| 95 |
);
|
| 96 |
}
|
| 97 |
$fieldset['#value'] = '<div class="container-inline">';
|
| 98 |
$fieldset['#value'] .= drupal_render($form['operation']);
|
| 99 |
$fieldset['#value'] .= drupal_render($form['submit']);
|
| 100 |
$fieldset['#value'] .= '</div>';
|
| 101 |
$fieldset['#value'] .= theme('table', $header, $rows);
|
| 102 |
}
|
| 103 |
else {
|
| 104 |
$fieldset['#value'] = '<span>'. drupal_render($form['no_users']) .'</span>';
|
| 105 |
}
|
| 106 |
return theme('fieldset', $fieldset) . drupal_render($form);
|
| 107 |
}
|
| 108 |
|
| 109 |
/**
|
| 110 |
* Renders custom signup user data into a human-readable format.
|
| 111 |
*
|
| 112 |
* WARNING: This theme function is recursive (it calls itself for
|
| 113 |
* nested data), so if you override it, be sure not to change the part
|
| 114 |
* where it does "call_user_func(__FUNCTION__)".
|
| 115 |
*
|
| 116 |
* @param $data
|
| 117 |
* Array of custom user signup data.
|
| 118 |
*
|
| 119 |
* @return
|
| 120 |
* User data directly formatted in divs.
|
| 121 |
*
|
| 122 |
* @see theme_signup_user_form()
|
| 123 |
*/
|
| 124 |
function theme_signup_custom_data($data) {
|
| 125 |
$output = '';
|
| 126 |
// All of the possible array key values should already be translated as
|
| 127 |
// string literals in theme_signup_user_form() via the #title attributes, so
|
| 128 |
// passing a variable to t() is actually safe here. However, to avoid
|
| 129 |
// warnings when extracting strings, "hide" the call to t() by using a
|
| 130 |
// variable to hold the function name.
|
| 131 |
$tr = 't';
|
| 132 |
// Loop through each first level element.
|
| 133 |
foreach ($data as $key => $value) {
|
| 134 |
$output .= '<div id="'. signup_id_safe($key) .'">';
|
| 135 |
if (is_array($value)) {
|
| 136 |
// Element is nested, render it recursively.
|
| 137 |
// Instead of the overhead of theme(), just call ourself directly.
|
| 138 |
$output .= call_user_func(__FUNCTION__, $value);
|
| 139 |
}
|
| 140 |
else {
|
| 141 |
$output .= $tr($key) .': '. check_plain($value);
|
| 142 |
}
|
| 143 |
$output .= "</div>\n";
|
| 144 |
}
|
| 145 |
return $output;
|
| 146 |
}
|
| 147 |
|
| 148 |
function theme_signup_attended_text($attended = NULL) {
|
| 149 |
if ($attended === NULL) {
|
| 150 |
return '';
|
| 151 |
}
|
| 152 |
if ($attended == 0) {
|
| 153 |
return t('Did not attend');
|
| 154 |
}
|
| 155 |
else {
|
| 156 |
return t('Attended');
|
| 157 |
}
|
| 158 |
}
|
| 159 |
|