? reorder-displays_5.patch
? views-exposed_form-block-fix_0.patch
? views_plugin_argument_default_fixed.inc
? modules/697354-comment-row_plugin.patch
Index: views_ui.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views/views_ui.module,v
retrieving revision 1.109.6.4
diff -u -p -r1.109.6.4 views_ui.module
--- views_ui.module	28 Jan 2010 17:16:40 -0000	1.109.6.4
+++ views_ui.module	29 Jan 2010 00:03:15 -0000
@@ -120,6 +120,7 @@ function views_ui_menu() {
     'details' => 'views_ui_edit_details',
     'add-display' => 'views_ui_add_display',
     'preview' => 'views_ui_preview',
+    'reorder-displays' => 'views_ui_reorder_view',
   );
 
   foreach ($ajax_callbacks as $menu => $menu_callback) {
@@ -212,6 +213,11 @@ function views_ui_theme() {
     'views_tab' => array(
       'variables' => array('body' => NULL),
     ),
+    'views_ui_reorder_displays_form' => array(
+      'render element' => 'form',
+      'file' => 'includes/admin.inc',
+    ),
+
 
     // On behalf of a plugin
     'views_ui_style_plugin_table' => array(
Index: css/views-admin.css
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views/css/views-admin.css,v
retrieving revision 1.14.4.3
diff -u -p -r1.14.4.3 views-admin.css
--- css/views-admin.css	28 Jan 2010 17:16:40 -0000	1.14.4.3
+++ css/views-admin.css	29 Jan 2010 00:03:16 -0000
@@ -554,6 +554,14 @@ div.changed div.view-changed {
   padding: .5em;
 }
 
+form#views-ui-reorder-displays-button {
+  margin-bottom: 0em;
+  border-bottom: 1px solid #ccc;
+}
+form#views-ui-reorder-displays-button input.form-submit{
+  margin-bottom: 2em;
+}
+
 form#views-add-display-form {
   margin-bottom: 0em;
   border-bottom: 1px solid #ccc;
Index: includes/admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views/includes/admin.inc,v
retrieving revision 1.161.4.15
diff -u -p -r1.161.4.15 admin.inc
--- includes/admin.inc	28 Jan 2010 23:25:33 -0000	1.161.4.15
+++ includes/admin.inc	29 Jan 2010 00:03:17 -0000
@@ -1025,7 +1025,8 @@ function template_preprocess_views_ui_ed
 
   $display_button = drupal_render(drupal_build_form('views_ui_add_display_form', $form_state));
   $analyze_button = drupal_render(drupal_get_form('views_ui_analyze_view_button', $view));
-  $tabs->add_extra($display_button . $analyze_button);
+  $reorder_button = drupal_render(drupal_get_form('views_ui_reorder_displays_button', $view));
+  $tabs->add_extra($display_button . $reorder_button . $analyze_button);
 
   $vars['tabs'] = $tabs->render();
 
@@ -1869,6 +1870,228 @@ function views_ui_analyze_view_form_subm
 }
 
 /**
+ * Page callback to display analysis information on a view.
+ */
+function views_ui_reorder_view($js, $view) {
+  views_include('ajax');
+  $form_state = array(
+    'view' => &$view,
+    'ajax' => $js,
+  );
+
+  $output = views_ajax_form_wrapper('views_ui_reorder_displays_form', $form_state);
+
+  if ($js) {
+    if(empty($output)) {
+      // I don't want preprocess to modify the views -> no references
+      $vars = array('view' => $view);
+      template_preprocess_views_ui_edit_view($vars);
+      $output = new stdClass();
+      $output->replace['.views-tabset'] = $vars['tabs'];
+      // Not the right place to have html i know !
+      $output->replace['.views-quick-links'] = '<div class="views-quick-links">'. $vars['quick_links'] .'</div>';
+      // Doesn't work yet, maybe we should reload the page dunno
+      //return views_ui_regenerate_tabs($view);
+    }
+    return views_ajax_render($output);
+  }
+
+  return $output;
+}
+
+/**
+ * Form constructor callback to reorder displays on a view
+ */
+function views_ui_reorder_displays_form(&$form, &$form_state) {
+  $view = &$form_state['view'];
+
+  $form['view'] = array('#type' => 'value', '#value' => $view);
+
+  $form['#tree'] = TRUE;
+
+  $last_display = end($view->display);
+
+  foreach ($view->display as $display) {
+    $form[$display->id] = array(
+      'title'  => array('#markup' => $display->display_title),
+      'weight' => array(
+        '#type' => 'weight',
+        '#value' => $display->position,
+        '#delta' => $last_display->position,
+      ),
+      '#tree' => TRUE,
+      '#display' => $display,
+      'removed' => array(
+        '#type' => 'checkbox',
+        '#id' => 'display-removed-' . $display->id,
+        '#attributes' => array('class' => array('views-remove-checkbox')),
+        '#default_value' => isset($display->deleted),
+      ),
+    );
+
+    if (isset($display->deleted) && $display->deleted) {
+      $form[$display->id]['deleted'] = array('#type' => 'value', '#value' => TRUE);
+    }
+    if ($display->id === 'default') {
+      unset($form[$display->id]['weight']);
+      unset($form[$display->id]['removed']);
+    }
+
+  }
+
+  $form['#title'] = t('Displays Reorder');
+  $form['#section'] = 'reorder';
+
+  // Add javascript settings that will be added via $.extend for tabledragging
+  $form['#js']['tableDrag']['reorder-displays']['weight'][0] = array(
+    'target' => 'weight',
+    'source' => NULL,
+    'relationship' => 'sibling',
+    'action' => 'order',
+    'hidden' => TRUE,
+    'limit' => 0,
+  );
+
+  
+  $form['#action'] = url('admin/structure/views/nojs/reorder-display/'. $view->name);
+
+  views_ui_standard_form_buttons($form, $form_state, 'views_ui_reorder_displays_form');
+
+  return $form;
+}
+
+
+/**
+ * Display position sorting function
+ */
+function _views_position_sort($display1, $display2) {
+  if ($display1->position != $display2->position) {
+    return $display1->position < $display2->position ? -1 : 1;
+  }
+
+  return 0;
+}
+
+/**
+ * Submit handler for rearranging display form
+ */
+function views_ui_reorder_displays_form_submit($form, &$form_state) {
+  foreach($form_state['input'] as $display => $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[$display] = $info['weight'];
+    }
+  }
+
+  // Sort the order array
+  asort($order);
+
+  // Fixing up positions
+  $position = 2;
+
+  foreach(array_keys($order) as $display) {
+    $order[$display] = $position++;
+  }
+
+  // Setting up position and removing deleted displays
+  $displays = $form_state['view']->display;
+  foreach($displays as $display_id => $display) {
+    // Don't touch the default !!!
+    if ($display_id === 'default') {
+      continue;
+    }
+    if (isset($order[$display_id])) {
+      $form_state['view']->display[$display_id]->position = $order[$display_id];
+    }
+    else {
+      $form_state['view']->display[$display_id]->deleted = TRUE;
+    }
+  }
+
+  // Sorting back the display array as the position is not enough
+  uasort($form_state['view']->display, '_views_position_sort');
+
+  // Store in cache
+  views_ui_cache_set($form_state['view']);
+  $form_state['redirect'] = array('admin/structure/views/edit/' . $form_state['view']->name, NULL, 'views-tab-default');
+}
+
+/**
+ * Turn the reorder form into a proper table
+ */
+function theme_views_ui_reorder_displays_form($vars) {
+  $form = $vars['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'] = array('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' => array('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' => $class, 'id' => 'display-row-' . $key, 'style' => $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', 
+    array('header' => $header,
+    'rows' => $rows,
+    'attributes' => array('id' => 'reorder-displays'),
+  ));
+  $output .= drupal_render_children($form);
+
+  return $output;
+}
+
+/**
+ * This form doesn't particularly do much; it's really just providing a link
+ * but a button seems like it would be nicer here.
+ *
+ * It has no submit or anything, as we will never actually submit this form
+ * where the form is placed.
+ */
+function views_ui_reorder_displays_button(&$form, &$form_state, $view) {
+  $form['#action'] = url("admin/structure/views/nojs/reorder-displays/$view->name");
+  $form['#attributes'] = array('class' => array('views-ajax-form'));
+  $form['submit'] = array(
+    '#type' => 'submit',
+    '#value' => t('Reorder'),
+  );
+
+  return $form;
+}
+
+/**
  * Page callback to edit details of a view.
  */
 function views_ui_edit_details($js, $view) {
Index: js/base.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views/js/base.js,v
retrieving revision 1.11.4.1
diff -u -p -r1.11.4.1 base.js
--- js/base.js	2 Nov 2009 22:01:26 -0000	1.11.4.1
+++ js/base.js	29 Jan 2010 00:03:17 -0000
@@ -13,18 +13,30 @@ Drupal.Views = {};
  */
 Drupal.behaviors.viewsTabs = {
   attach: function (context) {
-  if ($.viewsUi && $.viewsUi.tabs) {
-    $('#views-tabset').once('views-processed').viewsTabs({
-      selectedClass: 'active'
-    });
-  }
+    if ($.viewsUi && $.viewsUi.tabs) {
+      $('#views-tabset').once('views-processed').viewsTabs({
+        selectedClass: 'active'
+      });
+    }
 
-  $('a.views-remove-link').once('views-processed').click(function() {
+    $('a.views-remove-link').once('views-processed').click(function() {
       var id = $(this).attr('id').replace('views-remove-link-', '');
       $('#views-row-' + id).hide();
       $('#views-removed-' + id).attr('checked', true);
       return false;
-    });
+   });
+  /**
+    * Here is to handle display deletion 
+    * (checking in the hidden checkbox and hiding out the row) 
+    */
+  $('a.display-remove-link')
+    .addClass('display-processed')
+    .click(function() {
+      var id = $(this).attr('id').replace('display-remove-link-', '');
+      $('#display-row-' + id).hide();
+      $('#display-removed-' + id).attr('checked', true);
+      return false;
+  });
   }
 };
 
@@ -123,4 +135,4 @@ Drupal.Views.getPath = function (href) {
   return href;
 };
 
-})(jQuery);
\ No newline at end of file
+})(jQuery);
