function theme_views_ui_rearrange_form

Turn the rearrange form into a proper table.

File

includes/admin.inc, line 3621

Code

function theme_views_ui_rearrange_form($variables) {
    $form = $variables['form'];
    $rows = array();
    foreach (element_children($form['fields']) as $id) {
        if (isset($form['fields'][$id]['name'])) {
            $row = array();
            $row[] = drupal_render($form['fields'][$id]['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,
            ));
            $rows[] = array(
                'data' => $row,
                'class' => array(
                    'draggable',
                ),
                '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', 'order', 'sibling', 'weight');
    return $output;
}