You are here

function theme_views_ui_reorder_displays_form in Views (for Drupal 7) 6.3

Same name and namespace in other branches
  1. 8.3 views_ui/theme/theme.inc \theme_views_ui_reorder_displays_form()
  2. 7.3 includes/admin.inc \theme_views_ui_reorder_displays_form()

Turn the reorder form into a proper table

File

includes/admin.inc, line 2232
admin.inc Provides the Views' administrative interface.

Code

function theme_views_ui_reorder_displays_form($form) {
  $rows = array();
  foreach (element_children($form) as $key) {
    if (isset($form[$key]['#display'])) {
      $display =& $form[$key];
      $row = array();
      $row[] = drupal_render($display['title']);
      $form[$key]['weight']['#attributes']['class'] = 'weight';
      $row[] = drupal_render($form[$key]['weight']);
      if (isset($display['removed'])) {
        $row[] = drupal_render($form[$key]['removed']) . l('<span>' . t('Remove') . '</span>', 'javascript:void()', array(
          'attributes' => array(
            'id' => 'display-remove-link-' . $key,
            'class' => 'views-button-remove display-remove-link',
            'alt' => t('Remove this display'),
            'title' => t('Remove this display'),
          ),
          'html' => TRUE,
        ));
      }
      else {
        $row[] = '';
      }
      $class = array();
      $styles = array();
      if (isset($form[$key]['weight']['#type'])) {
        $class[] = 'draggable';
      }
      if (isset($form[$key]['deleted']['#value']) && $form[$key]['deleted']['#value']) {
        $styles[] = 'display: none;';
      }
      $rows[] = array(
        'data' => $row,
        'class' => implode(' ', $class),
        'id' => 'display-row-' . $key,
        'style' => implode(' ', $styles),
      );
    }
  }
  $header = array(
    t('Display'),
    t('Weight'),
    t('Remove'),
  );
  $output = '';
  drupal_add_tabledrag('reorder-displays', 'order', 'sibling', 'weight');
  $output = drupal_render($form['override']);
  $output .= theme('table', $header, $rows, array(
    'id' => 'reorder-displays',
  ));
  $output .= drupal_render($form);
  return $output;
}