You are here

function theme_login_destination_overview_form in Login Destination 7

Returns HTML for a login destination list.

Parameters

array $variables: An associative array containing:

  • form: A render element representing the form.

Return value

string

File

./login_destination.admin.inc, line 108
Admin page callback file for the Login Destination module.

Code

function theme_login_destination_overview_form($variables) {
  $form = $variables['form'];
  drupal_add_tabledrag('login-destination-overview', 'order', 'sibling', 'login-destination-weight');
  $header = array(
    t('Destination'),
    t('Triggers'),
    t('Pages'),
    t('Roles'),
    array(
      'data' => t('Enabled'),
      'class' => array(
        'checkbox',
      ),
    ),
    t('Weight'),
    array(
      'data' => t('Operations'),
      'colspan' => '2',
    ),
  );
  $rows = array();
  foreach (element_children($form) as $ldid) {
    if (!isset($form[$ldid]['enabled'])) {
      continue;
    }
    $element =& $form[$ldid];
    $operations = array();
    foreach (element_children($element['operations']) as $op) {
      $operations[] = array(
        'data' => drupal_render($element['operations'][$op]),
        'class' => array(
          'login-destination-operations',
        ),
      );
    }
    while (count($operations) < 2) {
      $operations[] = '';
    }
    $row = array();
    $row[] = drupal_render($element['destination']);
    $row[] = drupal_render($element['triggers']);
    $row[] = drupal_render($element['pages']);
    $row[] = drupal_render($element['roles']);
    $row[] = array(
      'data' => drupal_render($element['enabled']),
      'class' => array(
        'checkbox',
        'login-destination-enabled',
      ),
    );
    $form[$ldid]['weight']['#attributes']['class'] = array(
      'login-destination-weight',
    );
    $row[] = drupal_render($element['weight']);
    $row = array_merge($row, $operations);
    $row = array_merge(array(
      'data' => $row,
    ), array());
    $row['class'][] = 'draggable';
    $rows[] = $row;
  }
  $output = '';
  if (empty($rows)) {
    $rows[] = array(
      array(
        'data' => $form['#empty_text'],
        'colspan' => '7',
      ),
    );
  }
  $table_arguments = array(
    'header' => $header,
    'rows' => $rows,
    'attributes' => array(
      'id' => 'login-destination-overview',
    ),
  );
  $output .= theme('table', $table_arguments);
  $output .= drupal_render_children($form);
  return $output;
}