Index: token.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/token/token.module,v retrieving revision 1.7.4.26 diff -u -r1.7.4.26 token.module --- token.module 12 Jun 2010 14:59:00 -0000 1.7.4.26 +++ token.module 16 Jun 2010 22:18:25 -0000 @@ -129,7 +129,7 @@ if (!$run) { $run = TRUE; $modules_enabled = array_keys(module_list()); - $modules = array('node', 'user', 'taxonomy', 'comment'); + $modules = array('node', 'user', 'taxonomy', 'comment', 'views'); $modules = array_intersect($modules, $modules_enabled); foreach ($modules as $module) { module_load_include('inc', 'token', "token_$module"); --- token_views.inc +++ token_views.inc @@ -0,0 +1,77 @@ +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; +} +?>