Index: jump.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/jump/jump.info,v
retrieving revision 1.1.4.2
diff -u -p -r1.1.4.2 jump.info
--- jump.info	11 Jul 2008 22:41:07 -0000	1.1.4.2
+++ jump.info	24 Oct 2009 03:15:57 -0000
@@ -2,3 +2,5 @@
 name = "Jump"
 description = "Turns a menu into a pick list"
 core = 6.x
+
+dependencies[] = views
Index: jump.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/jump/jump.module,v
retrieving revision 1.1.4.3
diff -u -p -r1.1.4.3 jump.module
--- jump.module	28 Sep 2009 21:50:54 -0000	1.1.4.3
+++ jump.module	24 Oct 2009 03:15:57 -0000
@@ -123,12 +123,20 @@ function jump_quickly($name = 'navigatio
 
   // Give each form on the page a unique id so we can handle multiple
   // jump forms...
-  static $num_jump_forms = 0;
-  $num_jump_forms++;
+  $num_jump_forms = get_num_jump_forms();
 
   return drupal_get_form('jump_quickly_form_'. $num_jump_forms, $options, $active);
 }
 
+/**
+ * A helper function that will keep track of a unique id for multiple jump
+ * forms on a page.
+ */
+function get_num_jump_forms() {
+  static $num_jump_forms = 0;
+  return $num_jump_forms++;
+}
+
 function jump_quickly_form(&$form_state, $options, $active) {
   $default = '';
   if ($active) {
@@ -220,3 +228,13 @@ function jump_get_active_setting($delta)
   $active = variable_get('jump_activepageinmenu_'. $delta, $active_site_default);
   return $active;
 }
+
+/**
+ * Implementation of hook_views_api().
+ */
+function jump_views_api() {
+  return array(
+    'api' => 2,
+  );
+}
+
Index: jump.views.inc
===================================================================
RCS file: jump.views.inc
diff -N jump.views.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ jump.views.inc	24 Oct 2009 03:15:57 -0000
@@ -0,0 +1,27 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Provides views integration.
+ */
+
+/**
+ * Implementation of hook_views_plugins().
+ */
+function jump_views_plugins() {
+  return array(
+    'style' => array(
+      'jump_views' => array(
+        'title' => t('Jump menu'),
+        'theme' => 'jump_views_plugin_style',
+        'help' => t('Displays items as a select list jump menu.'),
+        'handler' => 'jump_views_plugin_style',
+        'uses row plugin' => TRUE,
+        'uses fields' => TRUE,
+        'uses options' => TRUE,
+        'type' => 'normal',
+      ),
+    ),
+  );
+}
Index: jump.views_default.inc
===================================================================
RCS file: jump.views_default.inc
diff -N jump.views_default.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ jump.views_default.inc	24 Oct 2009 03:15:57 -0000
@@ -0,0 +1,108 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Provides the default views for the jump module.
+ */
+
+/**
+ * Implementation of hook_views_default_views().
+ */
+function jump_views_default_views() {
+  $view = new view;
+  $view->name = 'recently_added_nodes_jump_menu';
+  $view->description = 'Recently added nodes in a jump menu.';
+  $view->tag = '';
+  $view->view_php = '';
+  $view->base_table = 'node';
+  $view->is_cacheable = FALSE;
+  $view->api_version = 2;
+  $view->disabled = TRUE; 
+  $handler = $view->new_display('default', 'Defaults', 'default');
+  $handler->override_option('fields', array(
+    'nid' => array(
+      'label' => 'Nid',
+      'alter' => array(
+        'alter_text' => 1,
+        'text' => 'node/[nid]',
+        'make_link' => 0,
+        'path' => '',
+        'link_class' => '',
+        'alt' => '',
+        'prefix' => '',
+        'suffix' => '',
+        'help' => '',
+        'trim' => 0,
+        'max_length' => '',
+        'word_boundary' => 1,
+        'ellipsis' => 1,
+        'strip_tags' => 0,
+        'html' => 0,
+      ),
+      'link_to_node' => 0,
+      'exclude' => 1,
+      'id' => 'nid',
+      'table' => 'node',
+      'field' => 'nid',
+      'relationship' => 'none',
+    ),
+    'title' => array(
+      'label' => '',
+      'alter' => array(
+        'alter_text' => 0,
+        'text' => '',
+        'make_link' => 0,
+        'path' => '',
+        'link_class' => '',
+        'alt' => '',
+        'prefix' => '',
+        'suffix' => '',
+        'help' => '',
+        'trim' => 0,
+        'max_length' => '',
+        'word_boundary' => 1,
+        'ellipsis' => 1,
+        'strip_tags' => 0,
+        'html' => 0,
+      ),
+      'link_to_node' => 0,
+      'exclude' => 0,
+      'id' => 'title',
+      'table' => 'node',
+      'field' => 'title',
+      'relationship' => 'none',
+    ),
+  ));
+  $handler->override_option('sorts', array(
+    'changed' => array(
+      'order' => 'ASC',
+      'granularity' => 'second',
+      'id' => 'changed',
+      'table' => 'node',
+      'field' => 'changed',
+      'relationship' => 'none',
+    ),
+  ));
+  $handler->override_option('access', array(
+    'type' => 'none',
+  ));
+  $handler->override_option('cache', array(
+    'type' => 'none',
+  ));
+  $handler->override_option('style_plugin', 'jump_views');
+  $handler->override_option('style_options', array(
+    'grouping' => '',
+    'keys' => array(
+      'nid' => 'nid',
+      'title' => 0,
+    ),
+    'first_item' => 'Recent nodes',
+  ));
+  $handler = $view->new_display('block', 'Block', 'block_1');
+  $handler->override_option('block_description', '');
+  $handler->override_option('block_caching', -1);
+
+  $views[$view->name] = $view;
+  return $views;
+}
Index: jump_views_plugin_style.inc
===================================================================
RCS file: jump_views_plugin_style.inc
diff -N jump_views_plugin_style.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ jump_views_plugin_style.inc	24 Oct 2009 03:15:58 -0000
@@ -0,0 +1,137 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Defines the jump style plugin.
+ */
+
+class jump_views_plugin_style extends views_plugin_style {
+
+  function render() {
+    // Build an array of field / field_alias pairs.
+    $this->field_map = array();
+    foreach ($this->view->field as $field_name => $object) {
+      $this-> field_map[$object->field_alias] = $field_name;
+    }
+
+    // $keys contains the fields used to build up the path.
+    $keys = array_filter($this->options['keys']);
+
+    // Start building the actual $select options array to pass to our form
+    // callback.
+    $select = array();
+    if (!empty($this->options['first_item'])) {
+      $select[0] = $this->options['first_item'];
+    }
+    foreach ($this->view->result as $row) {
+      $select_key = array();
+      // For each field in the row, we first check if it's to be used
+      // as part of the select key, then run views token replacement
+      // on it. This allows for paths like node/n/revisions/6 to be built
+      // easily.
+      foreach ($row as $field => $value) {
+        if (in_array($this->field_map[$field], $keys)) {
+          $field_object = $this->view->field[$this->field_map[$field]];
+          // Re-implementing some of the code from views_handler_field.inc
+          // since we need to operate on $result, and to avoid using
+          // a row style or templates.
+          if (!empty($field_object->options['alter']['alter_text']) && !empty($field_object->options['alter']['text'])) {
+            $tokens = $this->get_render_tokens($this->field_map[$field], $row);
+            $value = $field_object->render_altered($tokens);
+          }
+          $select_key[] = $value;
+        }
+      }
+      // For the value of the select, just use the output of the row, but strip
+      // all markup first.
+      $select_key = implode('/', $select_key);
+      $select_value = check_plain(strip_tags($this->row_plugin->render($row)));
+      $select[$select_key] = $select_value;
+    }
+
+    $jump_form_name = 'jump_quickly_form_'. get_num_jump_forms();
+    $active = variable_get('jump_activepageinmenu', 1);
+    return drupal_get_form($jump_form_name, $select, $active);
+  }
+
+  function option_definition() {
+    $options = parent::option_definition();
+    $options['keys'] = array('default' => array());
+    $options['first_item'] = array('default' => '');
+    return $options;
+  }
+
+  function options_form(&$form, $form_state) {
+    parent::options_form($form, $form_state);
+    $handlers = $this->display->handler->get_handlers('field');
+    if (empty($handlers)) {
+      $form['error_markup'] = array(
+        '#value' => t('You need at least one field before you can configure your jump menu settings'),
+        '#prefix' => '<div class="error form-item description">',
+        '#suffix' => '</div>',
+      );
+      return;
+    }
+    // Create an array of fields from the data we know.
+    foreach ($handlers as $field => $handler) {
+      if ($label = $handler->label()) {
+        $field_names[$field] = $label;
+      }
+      else {
+        $field_names[$field] = $handler->ui_name();
+      }
+    }
+    $form['keys'] = array(
+      '#type' => 'checkboxes',
+      '#title' => t('Select keys'),
+      '#default_value' => $this->options['keys'],
+      '#description' => t("These fields will be used to build the path for each row, used as the 'key' in the select options, and will be automatically separated by '/'"),
+      '#options' => $field_names,
+    );
+    $form['first_item'] = array(
+      '#type' => 'textfield',
+      '#title' => 'First option',
+      '#default_value' => $this->options['first_option'],
+      '#description' => t('This will be used as the first option of your select list, for example <em>Choose one</em>'),
+    );
+  }
+
+  /**
+   * Get the 'render' tokens to use for advanced rendering.
+   *
+   * This runs through all of the fields and arguments that
+   * are available and gets their values. This will then be
+   * used in one giant str_replace().
+   * Slightly modified from views_handler_field.inc
+   */
+  function get_render_tokens($field_name, $row) {
+    $tokens = array();
+    if (!empty($this->view->build_info['substitutions'])) {
+      $tokens = $this->view->build_info['substitutions'];
+    }
+
+    $count = 0;
+    foreach ($this->view->display_handler->get_handlers('argument') as $arg => $handler) {
+      $token = '%'. ++$count;
+      if (!isset($tokens[$token])) {
+        $tokens[$token] = '';
+      }
+    }
+
+    // Now add replacements for our fields.
+    $options = array();
+    $map = array_flip($this->field_map);
+    foreach ($this->view->display_handler->get_handlers('field') as $field => $handler) {
+      $map = array_flip($this->field_map);
+      if (isset($row->$map[$field])) {
+        $tokens["[$field]"] = $row->$map[$field];
+      }
+      else {
+        $tokens["[$field]"] = '';
+      }
+    }
+
+    return $tokens;
+  }
+}
