You are here

function theme_privatemsg_admin_settings_display_fields in Privatemsg 6.2

Same name and namespace in other branches
  1. 7.2 privatemsg.theme.inc \theme_privatemsg_admin_settings_display_fields()

Output the admin settings display fields and weight settings as a drag and drop sortable table.

Related topics

1 theme call to theme_privatemsg_admin_settings_display_fields()
privatemsg_admin_settings in ./privatemsg.admin.inc
@file Administration menu callbacks for Privatemsg.

File

./privatemsg.theme.inc, line 199
Theme functions for privatemsg.

Code

function theme_privatemsg_admin_settings_display_fields($element = array()) {
  $header = array(
    array(
      'data' => t('Field'),
      'class' => 'field',
    ),
    array(
      'data' => t('Enable'),
      'class' => 'enable',
    ),
    array(
      'data' => t('Weight'),
      'class' => 'weight',
    ),
  );
  $rows = array();
  foreach (element_children($element['privatemsg_display_fields']) as $child) {
    $row = array();

    // Title.
    $row[] = array(
      'data' => $element['privatemsg_display_fields'][$child]['#title'],
      'class' => 'field',
    );
    unset($element['privatemsg_display_fields'][$child]['#title']);

    // Enable checkbox.
    $row[] = array(
      'data' => drupal_render($element['privatemsg_display_fields'][$child]),
      'class' => 'enable',
    );

    // Weight selector.
    unset($element['privatemsg_display_fields_weights'][$child]['#title']);
    $element['privatemsg_display_fields_weights'][$child]['#attributes']['class'] = 'privatemsg-display-fields-weight';
    $row[] = array(
      'data' => drupal_render($element['privatemsg_display_fields_weights'][$child]),
      'class' => 'weight',
    );
    $rows[] = array(
      'data' => $row,
      'class' => 'draggable',
    );
  }
  if (!empty($rows)) {
    drupal_add_tabledrag('privatemsg-list-display-fields', 'order', 'sibling', 'privatemsg-display-fields-weight');
    return theme('table', $header, $rows, array(
      'id' => 'privatemsg-list-display-fields',
    )) . drupal_render($element);
  }
  else {
    return drupal_render($element);
  }
}