diff -urp plugins/contexts/node.inc --- plugins/contexts/node.inc 2010-05-19 20:43:03.000000000 -0500 +++ plugins/contexts/node.inc 2010-10-16 23:58:59.000000000 -0500 @@ -159,7 +159,7 @@ function ctools_context_node_settings_fo } /** - * Provide a list of ways that this context can be converted to a string. + * Provide a list of ways that this context can be converted into a string. */ function ctools_context_node_convert_list() { $list = array( @@ -170,8 +170,11 @@ function ctools_context_node_convert_lis 'type' => t('Node type'), ); + // Include tokens provided by token.module. if (module_exists('token')) { - $list += reset(token_get_list(array('node'))); + foreach (token_get_list(array('node')) as $tokens) { + $list += $tokens; + } } return $list; @@ -193,9 +196,12 @@ function ctools_context_node_convert($co case 'type': return $context->data->type; } + + // Check if token.module can provide the replacement. if (module_exists('token')) { $values = token_get_values('node', $context->data); - if ($key = array_search($type, $values->tokens)) { + $key = array_search($type, $values->tokens); + if ($key !== FALSE) { return $values->values[$key]; } } diff -urp plugins/contexts/token.inc --- plugins/contexts/token.inc 2010-02-23 15:00:59.000000000 -0600 +++ plugins/contexts/token.inc 2010-10-16 23:57:30.000000000 -0500 @@ -19,7 +19,8 @@ if (module_exists('token')) { } /** - * Create a context from manual configuration. + * It's important to remember that $conf is optional here, because contexts + * are not always created from the UI. */ function ctools_context_create_token($empty, $data = NULL, $conf = FALSE) { $context = new ctools_context('token'); @@ -29,19 +30,22 @@ function ctools_context_create_token($em } /** - * Implementation of hook_ctools_context_convert_list(). + * Provide a list of ways that this context can be converted into a string. */ function ctools_context_token_convert_list() { - // Pass everything through to token_get_list(). - return reset(token_get_list(array('global'))); + $list = array(); + foreach (token_get_list(array('global')) as $tokens) { + $list += $tokens; + } + return $list; } /** - * Implementation of hook_ctools_context_converter_alter(). + * Convert a context into a string. */ -function ctools_context_token_convert($context, $token) { - $values = token_get_values(); - $key = array_search($token, $values->tokens); +function ctools_context_token_convert($context, $type) { + $values = token_get_values('global'); + $key = array_search($type, $values->tokens); if ($key !== FALSE) { return $values->values[$key]; } diff -urp plugins/contexts/user.inc --- plugins/contexts/user.inc 2010-07-16 15:09:48.000000000 -0500 +++ plugins/contexts/user.inc 2010-10-16 23:57:26.000000000 -0500 @@ -141,16 +141,21 @@ function ctools_context_user_settings_fo } /** - * Provide a list of replacements. + * Provide a list of ways that this context can be converted into a string. */ function ctools_context_user_convert_list() { $list = array( 'uid' => t('User ID'), 'name' => t('User name'), ); + + // Include tokens provided by token.module. if (module_exists('token')) { - $list += reset(token_get_list(array('user'))); + foreach (token_get_list(array('user')) as $tokens) { + $list += $tokens; + } } + return $list; } @@ -164,9 +169,12 @@ function ctools_context_user_convert($co case 'name': return $context->data->name; } + + // Check if token.module can provide the replacement. if (module_exists('token')) { $values = token_get_values('user', $context->data); - if ($key = array_search($type, $values->tokens)) { + $key = array_search($type, $values->tokens); + if ($key !== FALSE) { return $values->values[$key]; } }