node.admin.inc in Signup 7
Same filename and directory in other branches
Theme functions for the signup node administration page (node/N/signups).
File
theme/node.admin.incView source
<?php
/**
* @file
* Theme functions for the signup node administration page (node/N/signups).
*/
/**
* Theme function for the signup administrative tab (node/N/signups).
*
* This is responsible for rendering the signup summary form (allows
* admins to open/close signups, set a signup limit, and see the total
* number of signups), the table of signup details (generated by
* signup_node_admin_page()), and if the node is signup-enabled, the
* form to signup other users.
*
* @param array $variables
* An array of variables including:
* - 'node': The node object for the signup-enabled node this is a tab on.
* - 'signup_node_admin_summary_form': The rendered HTML for the signup node
* summary form (to set the signup limit, open/close signups, see the total
* number of signups, etc).
* - 'signup_node_admin_details_form': The rendered HTML for the signup node
* details form (to view all the users who have signed up, their full
* signup details, and checkboxes to cancel multiple signups at once.
*/
function theme_signup_node_admin_page($variables) {
$node = $variables['node'];
$signup_node_admin_summary_form = $variables['signup_node_admin_summary_form'];
$signup_node_admin_details_form = $variables['signup_node_admin_details_form'];
$output = '';
// Administrative summary table to control signups for this node.
$output .= $signup_node_admin_summary_form;
// Details for each user who signed up.
$output .= $signup_node_admin_details_form;
return $output;
}
/**
* Renders the HTML for the per-node signup summary administrative form.
*/
function theme_signup_node_admin_summary_form($variables) {
$form = $variables['form'];
$output = '';
$output .= '<div class="container-inline">' . drupal_render($form['status']);
if (!empty($form['submit']) && $form['status']['#type'] == 'select') {
$output .= ' ' . drupal_render($form['submit']);
}
$output .= '</div>';
foreach (element_children($form) as $key) {
if (!in_array($key, array(
'status',
'submit',
'nid',
'form_build_id',
'form_token',
'form_id',
))) {
$prefix = '<div class="container-inline">';
$suffix = '</div>';
if (empty($form[$key]['#prefix'])) {
$form[$key]['#prefix'] = $prefix;
}
else {
$form[$key]['#prefix'] .= $prefix;
}
if (empty($form[$key]['#suffix'])) {
$form[$key]['#suffix'] = $suffix;
}
else {
$form[$key]['#suffix'] .= $suffix;
}
}
}
$output .= drupal_render_children($form);
$fieldset = array(
'#title' => t('Signup summary'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#attributes' => array(),
'#children' => '',
'#value' => $output,
);
return theme('fieldset', array(
'element' => $fieldset,
));
}
/**
* @todo Please document this function.
* @see http://drupal.org/node/1354
*/
function theme_signup_node_admin_details_form($variables) {
$form = $variables['form'];
$fieldset = array(
'#title' => t('Signup details'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#attributes' => array(),
'#children' => '',
);
if (!empty($form['users']['#options'])) {
$header = $form['#header'];
$rows = array();
foreach ($form['users']['#options'] as $key => $value) {
$rows[] = array(
'cancel_checkbox' => drupal_render($form['users'][$key]),
'username' => drupal_render($form['username'][$key]),
'signup_date' => drupal_render($form['signup_date'][$key]),
'signup_form_data' => drupal_render($form['signup_form_data'][$key]),
'attended' => drupal_render($form['attended'][$key]),
);
}
$fieldset['#value'] = '<div class="container-inline">';
$fieldset['#value'] .= drupal_render($form['operation']);
$fieldset['#value'] .= drupal_render($form['submit']);
$fieldset['#value'] .= '</div>';
$fieldset['#value'] .= theme('table', array(
'header' => $header,
'rows' => $rows,
));
}
else {
$fieldset['#value'] = '<span>' . drupal_render($form['no_users']) . '</span>';
}
return theme('fieldset', array(
'element' => $fieldset,
)) . drupal_render_children($form);
}
/**
* Renders custom signup user data into a human-readable format.
*
* WARNING: This theme function is recursive (it calls itself for
* nested data), so if you override it, be sure not to change the part
* where it does "call_user_func(__FUNCTION__)".
*
* @param array $variables
* An array of variables including:
* - 'data': Array of custom user signup data.
*
* @return string
* User data directly formatted in divs.
*
* @see theme_signup_user_form()
*/
function theme_signup_custom_data($variables) {
$data = $variables['data'];
$output = '';
// All of the possible array key values should already be translated as
// string literals in theme_signup_user_form() via the #title attributes, so
// passing a variable to t() is actually safe here. However, to avoid
// warnings when extracting strings, "hide" the call to t() by using a
// variable to hold the function name.
$tr = 't';
// Loop through each first level element.
foreach ($data as $key => $value) {
$output .= '<div id="' . signup_id_safe($key) . '">';
if (is_array($value)) {
// Element is nested, render it recursively.
// Instead of the overhead of theme(), just call ourself directly.
$output .= call_user_func(__FUNCTION__, $value);
}
else {
$output .= $tr($key) . ': ' . check_plain($value);
}
$output .= "</div>\n";
}
return $output;
}
/**
* @todo Please document this function.
* @see http://drupal.org/node/1354
*/
function theme_signup_attended_text($variables) {
$attended = $variables['attended'];
if ($attended === NULL) {
return '';
}
if ($attended == 0) {
return t('Did not attend');
}
else {
return t('Attended');
}
}
Functions
Name![]() |
Description |
---|---|
theme_signup_attended_text | @todo Please document this function. |
theme_signup_custom_data | Renders custom signup user data into a human-readable format. |
theme_signup_node_admin_details_form | @todo Please document this function. |
theme_signup_node_admin_page | Theme function for the signup administrative tab (node/N/signups). |
theme_signup_node_admin_summary_form | Renders the HTML for the per-node signup summary administrative form. |