function views_ui_rearrange_form_submit

Same name in other branches
  1. 6.x-3.x includes/admin.inc \views_ui_rearrange_form_submit()

Submit handler for rearranging form.

File

includes/admin.inc, line 3764

Code

function views_ui_rearrange_form_submit($form, &$form_state) {
    $types = views_object_types();
    $display =& $form_state['view']->display[$form_state['display_id']];
    $old_fields = $display->handler
        ->get_option($types[$form_state['type']]['plural']);
    $new_fields = $order = array();
    // Make an array with the weights.
    foreach ($form_state['values'] as $field => $info) {
        // Add each value that is a field with a weight to our list, but only if
        // it has had its 'removed' checkbox checked.
        if (is_array($info) && isset($info['weight']) && empty($info['removed'])) {
            $order[$field] = $info['weight'];
        }
    }
    // Sort the array.
    asort($order);
    // Create a new list of fields in the new order.
    foreach (array_keys($order) as $field) {
        $new_fields[$field] = $old_fields[$field];
    }
    $display->handler
        ->set_option($types[$form_state['type']]['plural'], $new_fields);
    // Store in cache.
    views_ui_cache_set($form_state['view']);
}