function token_insert_get_tokens in Token Insert 6.2
Same name and namespace in other branches
- 7.2 token_insert.inc \token_insert_get_tokens()
@file wysiwyg plugin hook.
3 calls to token_insert_get_tokens()
- token_insert_text_combobox in token_insert_text/
token_insert_text.module - token_insert_wysiwyg_form in token_insert_wysiwyg/
token_insert_wysiwyg.module - _token_insert_ckeditor_tokens_output in token_insert_ckeditor/
token_insert_ckeditor.module - Print out the tokens in a CKEditor-readable format.
File
- ./
token_insert.inc, line 9 - wysiwyg plugin hook.
Code
function token_insert_get_tokens() {
global $user;
$roles['global'] = 'global';
if (variable_get('token_insert_use_tokens_per_role', 0)) {
$roles += $user->roles;
}
$all_tokens = token_get_list();
foreach ($roles as $rid => $role) {
foreach ($all_tokens as $category => $tokens) {
$category_safe = str_replace(' ', '_', $category);
$allowed_options = variable_get('token_insert_' . $rid . '_used_tokens_' . $category_safe, array());
foreach ($tokens as $token => $description) {
if ($allowed_options[$token] === $token) {
$options['token ' . $category . ' ' . $token] = $category . ' : [' . $token . '] : ' . truncate_utf8($description, 60, TRUE, TRUE);
}
else {
$all_options['token ' . $category . ' ' . $token] = $category . ' : [' . $token . '] : ' . truncate_utf8($description, 60, TRUE, TRUE);
}
}
}
}
if (empty($options)) {
$options = $all_options;
}
return $options;
}