You are here

function theme_views_fieldsets_rearrange_form in Views fieldsets 7.2

Same name and namespace in other branches
  1. 7 views_fieldsets.module \theme_views_fieldsets_rearrange_form()

Theme function for views_fieldsets_rearrange_form.

File

./views_fieldsets.module, line 602
Hooks, helpers and theming for the Views Fieldsets module.

Code

function theme_views_fieldsets_rearrange_form($variables) {
  $form = $variables['form'];
  $display_handler = $form['#display_handler'];
  $rows = array();
  foreach (element_children($form['fields']) as $id) {
    if (isset($form['fields'][$id]['name'])) {
      $field_name = $form['fields'][$id]['field_name']['#value'];
      $depth = $form['fields'][$id]['depth']['#default_value'];
      $indentation = $depth > 0 ? theme('indentation', array(
        'size' => $depth,
      )) : '';
      $row = array();
      $row[] = $indentation . drupal_render($form['fields'][$id]['name']) . drupal_render($form['fields'][$id]['hierarchy']) . drupal_render($form['fields'][$id]['depth']) . drupal_render($form['fields'][$id]['field_name']);
      $form['fields'][$id]['weight']['#attributes']['class'] = array(
        'weight',
      );
      $row[] = drupal_render($form['fields'][$id]['weight']);
      $row[] = drupal_render($form['fields'][$id]['removed']) . l('<span>' . t('Remove') . '</span>', 'javascript:void()', array(
        'attributes' => array(
          'id' => 'views-remove-link-' . $id,
          'class' => array(
            'views-hidden',
            'views-button-remove',
            'views-remove-link',
          ),
          'alt' => t('Remove this item'),
          'title' => t('Remove this item'),
        ),
        'html' => TRUE,
      ));
      $classes = array(
        'draggable',
      );
      if (!views_fieldsets_field_is_fieldset($field_name, $display_handler)) {
        $classes[] = 'tabledrag-leaf';
      }
      $rows[] = array(
        'data' => $row,
        'class' => $classes,
        'id' => 'views-row-' . $id,
      );
    }
  }
  if (empty($rows)) {
    $rows[] = array(
      array(
        'data' => t('No fields available.'),
        'colspan' => '2',
      ),
    );
  }
  $header = array(
    '',
    t('Weight'),
    t('Remove'),
  );
  $output = drupal_render($form['override']);
  $output .= '<div class="scroll">';
  $output .= theme('table', array(
    'header' => $header,
    'rows' => $rows,
    'attributes' => array(
      'id' => 'arrange',
    ),
  ));
  $output .= '</div>';
  $output .= drupal_render_children($form);
  drupal_add_tabledrag('arrange', 'match', 'parent', 'hierarchy', 'hierarchy', 'field-name', FALSE);
  drupal_add_tabledrag('arrange', 'depth', 'group', 'depth', NULL, NULL, FALSE);
  drupal_add_tabledrag('arrange', 'order', 'sibling', 'weight');
  return $output;
}