--- token_contrib.info +++ token_contrib.info @@ -0,0 +1,5 @@ +; $Id$ +name = Token contrib +description = Provides additional tokens for some contributed modules. +dependencies[] = token +core = 6.x --- token_contrib.module +++ token_contrib.module @@ -0,0 +1,35 @@ +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; +}