Index: panels_views/panels_views.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/panels/panels_views/Attic/panels_views.module,v
retrieving revision 1.1.2.3
diff -u -F^f -r1.1.2.3 panels_views.module
--- panels_views/panels_views.module	1 Jan 2008 00:20:21 -0000	1.1.2.3
+++ panels_views/panels_views.module	8 Jan 2008 23:23:35 -0000
@@ -199,7 +199,7 @@ function panels_views_add_view_form_subm
 }
 
 /**
- * Page callback to add a new view pane from an existing view.
+ * Page callback to add a new panel view from an existing view.
  */
 function panels_views_add_view($view_name) {
   $view = views_get_view($view_name);
@@ -211,7 +211,7 @@ function panels_views_add_view($view_nam
 }
 
 /**
- * Page callback to add a new view pane from an existing view.
+ * Page callback to add a new panel view from an existing view.
  */
 function panels_views_edit_view($view_name) {
   $pv = panels_views_load($view_name);
@@ -225,11 +225,15 @@ function panels_views_edit_view($view_na
 }
 
 /**
- * Form to add or edit add a view pane
+ * Form to add or edit add a panel view.
  */
 function panels_views_edit_view_form($view, $panel_view) {
-  panels_views_pane_arguments($view, $panel_view);
+  // Add Javascript for improved UI.
+  drupal_add_js(panels_get_path('panels_views/panels_views.js'));
 
+  // Update the panel view object to make it map correctly to the view's
+  // arguments.
+  panels_views_pane_arguments($view, $panel_view);
 
   $form['basic'] = array(
     '#type' => 'fieldset',
@@ -295,7 +299,7 @@ function panels_views_edit_view_form($vi
   $form['contexts'] = array(
     '#tree' => TRUE,
   );
-
+  
   views_load_cache();
   $arginfo = _views_get_arguments();
 
@@ -311,19 +315,19 @@ function panels_views_edit_view_form($vi
   foreach ($panel_view->contexts as $id => $info) {
     $name = $arginfo[$view->argument[$id]['type']]['name'];
       $form['contexts'][$id] = array(
-      '#type' => 'fieldset',
+      '#type'  => 'fieldset',
       '#title' => t('Argument: @arg', array('@arg' => $name)),
-      '#tree' => TRUE,
+      '#tree'  => TRUE,
     );
 
     $form['contexts'][$id]['type'] = array(
       '#type' => 'select',
       '#options' => array(
-        'none' => t('No argument'),
+        'none'    => t('No argument'),
         'context' => t('From context'),
-        'panel' => t('From panel argument'),
-        'fixed' => t('Fixed'),
-        'user' => t('Input on pane config'),
+        'panel'   => t('From panel argument'),
+        'fixed'   => t('Fixed'),
+        'user'    => t('Input on pane config'),
       ),
       '#title' => t('Argument source'),
       '#default_value' => $panel_view->contexts[$id]['type'],
@@ -348,6 +352,7 @@ function panels_views_edit_view_form($vi
       '#description' => t('If "Fixed" is selected, what to use as an argument.'),
       '#default_value' => $panel_view->contexts[$id]['fixed'],
     );
+
     $form['contexts'][$id]['label'] = array(
       '#type' => 'textfield',
       '#title' => t('Label'),
@@ -418,7 +423,6 @@ function panels_views_edit_view_form($vi
     '#description' => t('If checked, link the title of the pane to the view.'),
     '#default_value' => $panel_view->link_to_view,
   );
-
   $form['deco']['allow_link_to_view'] = array(
     '#type' => 'checkbox',
     '#title' => t('Allow the pane configuration to modify the link to view setting.'),
@@ -431,7 +435,6 @@ function panels_views_edit_view_form($vi
     '#description' => t('If checked, Panels will provide a "more" link that links to the View URL; this is different from the Views "more" link which will automatically be disabled.'),
     '#default_value' => $panel_view->more_link,
   );
-
   $form['deco']['allow_more_link'] = array(
     '#type' => 'checkbox',
     '#title' => t('Allow the pane configuration to modify the "more" link setting.'),
@@ -453,20 +456,20 @@ function panels_views_edit_view_form($vi
 
   $form['deco']['url_override'] = array(
     '#type' => 'checkbox',
-    '#title' => t('Override the Panel URL with a manually set URL.'),
+    '#title' => t('Override the view URL with a manually set URL.'),
     '#default_value' => $panel_view->url_override,
   );
 
   $form['deco']['url'] = array(
     '#type' => 'textfield',
     '#title' => t('Override view URL'),
-    '#description' => t('If override URL is set, the URL the View thinks it is using; all "more", "exposed filters", "summary" and "feed" type links will use this URL.'),
+    '#description' => t('If override view URL is set, the URL the view thinks it is using; all "more", "exposed filters", "summary" and "feed" type links will use this URL.'),
     '#default_value' => $panel_view->url,
   );
 
   $form['deco']['allow_url_override'] = array(
     '#type' => 'checkbox',
-    '#title' => t('Allow the pane configuration to modify the URL override setting.'),
+    '#title' => t('Allow the pane configuration to modify the view URL override setting.'),
     '#default_value' => $panel_view->allow_url_override,
   );
 
@@ -479,10 +482,11 @@ function panels_views_edit_view_form($vi
 
   $form['deco']['allow_url_from_panel'] = array(
     '#type' => 'checkbox',
-    '#title' => t('Allow the pane configuration to modify the "set view URL to panel URL" setting.'),
+    '#title' => t('Allow the pane configuration to modify the "Set view URL to panel URL" setting.'),
     '#default_value' => $panel_view->allow_url_from_panel,
   );
 
+
   $form['submit'] = array(
     '#type' => 'submit',
     '#value' => t('Save'),
@@ -885,7 +889,7 @@ function panels_views_edit($id, $parents
       );
     }
   }
-  // Provide form gadgets only on the things that th euser can change.
+  // Provide form gadgets only on the things that the user can change.
   if ($pv->allow_type) {
     $form['view_type'] = array(
       '#type' => 'select',
@@ -1203,18 +1207,28 @@ function panels_views_default_view_pane(
 }
 
 /**
- * Adjust a pane for a view's arguments, adding or subtracting
- * as needed to match the current view's argument configuration.
+ * Adjust a panel view object's arguments, adding or subtracting as needed to
+ * match the current view's argument configuration. In simpler terms, this
+ * means that's we're changing the panel view object so that it maps to the
+ * view's arguments correctly.
+ *
+ * Note: $panel_view->contexts is misnamed, and should actually have been
+ * named $panel_view->arguments or so.
+ *
+ * @param $view
+ *   A view object.
+ * @param &$panel_view
+ *   A panel view object.
  */
 function panels_views_pane_arguments($view, &$panel_view) {
   $contexts = array();
   foreach ($view->argument as $id => $arg) {
     if (empty($panel_view->contexts[$id])) {
       $contexts[$id] = array(
-        'type' => 'context',
+        'type'    => 'context',
         'context' => 'any',
-        'panel' => 0,
-        'fixed' => '',
+        'panel'   => 0,
+        'fixed'   => '',
       );
     }
     else {
@@ -1222,8 +1236,8 @@ function panels_views_pane_arguments($vi
     }
   }
 
-  // By copying this back, we automatically erase any arguments that may
-  // no longer exist.
+  // By copying this back, we automatically erase any arguments that may no
+  // longer exist.
   $panel_view->contexts = $contexts;
 }
 
