Index: views.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views/views.module,v
retrieving revision 1.341.2.12
diff -u -r1.341.2.12 views.module
--- views.module	29 Apr 2010 18:26:04 -0000	1.341.2.12
+++ views.module	9 Jun 2010 02:14:27 -0000
@@ -618,6 +618,9 @@
   views_include('handlers');
   views_include('cache');
   views_include('plugins');
+  if (module_exists('token')) {
+    views_include('token');
+  }
   _views_include_handlers();
   $finished = TRUE;
 }
--- includes/token.inc
+++ includes/token.inc
@@ -0,0 +1,77 @@
+<?php
+/**
+ * @file
+ *
+ * Token module support for the Views module.
+ */
+
+/**
+ * Implementation of hook_token_list().
+ */
+function views_token_list($type = 'all') {
+  $tokens = array();
+
+  if ($type == 'global' || $type == 'all') {
+    // List all views.
+    $views = views_get_all_views();
+
+    foreach ($views as $view) {
+      // Skip disabled views.
+      if (!empty($view->disabled)) {
+        continue;
+      }
+
+      foreach ($view->display as $display) {
+        if (isset($display->display_options['path'])) {
+          // Provide path tokens.
+          $tokens['views']['views-'. $view->name .'-'. $display->id .'-display-path'] = t('The path of the "'. $display->id .'" display of the "'. $view->name .'" view.');
+          $tokens['views']['views-'. $view->name .'-'. $display->id .'-display-path-raw'] = t('Unfiltered path of the "'. $display->id .'" display of the "'. $view->name .'" view.  WARNING - raw user input.');
+        }
+
+        if (isset($display->display_options['title'])) {
+          // Provide title tokens.
+          $tokens['views']['views-'. $view->name .'-'. $display->id .'-display-title'] = t('The title of the "'. $display->id .'" display of the "'. $view->name .'" view.');
+          $tokens['views']['views-'. $view->name .'-'. $display->id .'-display-title-raw'] = t('Unfiltered title of the "'. $display->id .'" display of the "'. $view->name .'" view.  WARNING - raw user input.');
+        }
+      }
+    }
+  }
+
+  return $tokens;
+}
+
+/**
+ * Implementation of hook_token_values().
+ */
+function views_token_values($type, $object = NULL) {
+  $values = array();
+
+  if ($type == 'global') {
+    // List all views.
+    $views = views_get_all_views();
+
+    foreach ($views as $view) {
+      // Skip disabled views.
+      if (!empty($view->disabled)) {
+        continue;
+      }
+
+      foreach ($view->display as $display) {
+        if (isset($display->display_options['path'])) {
+          // Provide path tokens.
+          $values['views-'. $view->name .'-'. $display->id .'-display-path'] = decode_entities(check_plain($display->display_options['path']));
+          $values['views-'. $view->name .'-'. $display->id .'-display-path-raw'] = $display->display_options['path'];
+        }
+
+        if (isset($display->display_options['title'])) {
+          // Provide title tokens.
+          $values['views-'. $view->name .'-'. $display->id .'-display-title'] = decode_entities(check_plain($display->display_options['title']));
+          $values['views-'. $view->name .'-'. $display->id .'-display-title-raw'] = $display->display_options['title'];
+        }
+      }
+    }
+  }
+
+  return $values;
+}
+?>


