You are here

function theme_privatemsg_admin_settings_display_fields in Privatemsg 7.2

Same name and namespace in other branches
  1. 6.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 160
Theme functions for privatemsg.

Code

function theme_privatemsg_admin_settings_display_fields($variables) {
  $element = $variables['element'];
  $header = array(
    array(
      'data' => t('Field'),
      'class' => array(
        'field',
      ),
    ),
    array(
      'data' => t('Enable'),
      'class' => array(
        'enable',
      ),
    ),
    array(
      'data' => t('Weight'),
      'class' => array(
        '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' => array(
        'field',
      ),
    );
    unset($element['privatemsg_display_fields'][$child]['#title']);

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

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