function token_autocomplete_type in Token 7
1 call to token_autocomplete_type()
File
- ./
token.pages.inc, line 318 - User page callbacks for the token module.
Code
function token_autocomplete_type($string = '') {
$token_info = token_info();
$types = $token_info['types'];
$matches = array();
foreach ($types as $type => $info) {
if (!$string || strpos($type, $string) === 0) {
$type_key = "[{$type}:";
$matches[$type_key] = levenshtein($type, $string);
}
}
if ($string) {
asort($matches);
}
else {
ksort($matches);
}
$matches = drupal_map_assoc(array_keys($matches));
drupal_json_output($matches);
}