function ctools_context_token_convert

Token conversion function: look up the token and return it's value.

Parameters

$context: Unused.

string $token: The name of the token.

Return value

array|null The token value, or NULL if not found.

See also

ctools_context_convert_context()

1 string reference to 'ctools_context_token_convert'
token.inc in plugins/contexts/token.inc

File

plugins/contexts/token.inc, line 76

Code

function ctools_context_token_convert($context, $token) {
    $tokens = token_info();
    list($type, $token) = explode(':', $token, 2);
    $parts = explode(':', $token, 2);
    $real_type = isset($tokens['types'][$type]['type']) ? $tokens['types'][$type]['type'] : $type;
    if (isset($tokens['tokens'][$real_type][$parts[0]])) {
        $values = token_generate($type, array(
            $token => $token,
        ));
        if (isset($values[$token])) {
            return $values[$token];
        }
    }
    return NULL;
}