[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/ctools/plugins/contexts/ -> token.inc (source)

   1  <?php
   2  // $Id: token.inc,v 1.1.2.2 2010/02/23 21:00:59 merlinofchaos Exp $
   3  
   4  /**
   5   * @file
   6   *  Provide a global context to allow for token support.
   7   */
   8  
   9  if (module_exists('token')) {
  10    $plugin = array(
  11      'title' => t('Token'),
  12      'description' => t('A context that contains token replacements from token.module.'),
  13      'context' => 'ctools_context_create_token',  // func to create context
  14      'context name' => 'token',
  15      'keyword' => 'token',
  16      'convert list' => 'ctools_context_token_convert_list',
  17      'convert' => 'ctools_context_token_convert',
  18    );
  19  }
  20  
  21  /**
  22   * Create a context from manual configuration.
  23   */
  24  function ctools_context_create_token($empty, $data = NULL, $conf = FALSE) {
  25    $context = new ctools_context('token');
  26    $context->plugin = 'token';
  27  
  28    return $context;
  29  }
  30  
  31  /**
  32   * Implementation of hook_ctools_context_convert_list().
  33   */
  34  function ctools_context_token_convert_list() {
  35    // Pass everything through to token_get_list().
  36    return reset(token_get_list(array('global')));
  37  }
  38  
  39  /**
  40   * Implementation of hook_ctools_context_converter_alter().
  41   */
  42  function ctools_context_token_convert($context, $token) {
  43    $values = token_get_values();
  44    $key = array_search($token, $values->tokens);
  45    if ($key !== FALSE) {
  46      return $values->values[$key];
  47    }
  48  }


Generated: Thu Mar 24 11:18:33 2011 Cross-referenced by PHPXref 0.7