You are here

function theme_workbench_moderation_admin_states_form in Workbench Moderation 7.3

Same name and namespace in other branches
  1. 7 workbench_moderation.admin.inc \theme_workbench_moderation_admin_states_form()

Transforms the states administration form into a reorderable table.

File

./workbench_moderation.admin.inc, line 98
Administrative functions for Workbench Moderation.

Code

function theme_workbench_moderation_admin_states_form($variables) {
  $form = $variables['form'];
  drupal_add_tabledrag('workbench-moderation-states', 'order', 'sibling', 'workbench-moderation-state-weight');
  $header = array(
    t('Name'),
    t('Machine name'),
    t('Description'),
    array(
      'data' => t('Delete'),
      'class' => array(
        'checkbox',
      ),
    ),
    t('Weight'),
  );
  $rows = array();
  foreach (element_children($form['states']) as $key) {
    $element =& $form['states'][$key];
    $row = array(
      'data' => array(),
      'class' => array(
        'draggable',
      ),
    );
    $row['data']['label'] = drupal_render($element['label']);
    $row['data']['name'] = drupal_render($element['name']) . drupal_render($element['machine_name']);
    $row['data']['description'] = drupal_render($element['description']);
    $row['data']['delete'] = drupal_render($element['delete']);
    $element['weight']['#attributes']['class'] = array(
      'workbench-moderation-state-weight',
    );
    $row['data']['weight'] = drupal_render($element['weight']);
    $rows[] = $row;
  }
  $output = theme('table', array(
    'header' => $header,
    'rows' => $rows,
    'attributes' => array(
      'id' => 'workbench-moderation-states',
    ),
  ));
  $output .= drupal_render_children($form);
  return $output;
}