function token_var_token_info in Token Variable 7
Same name and namespace in other branches
- 8 token_var.module \token_var_token_info()
Implements hook_token_info
File
- ./
token_var.module, line 11
Code
function token_var_token_info() {
global $conf;
$info = array();
$token_var_selected_variables = variable_get(TOKENIZE_DRUPAL_VARIABLES_OPTIONS, array());
foreach ($conf as $key => $var) {
if (!is_array($var) && !empty($token_var_selected_variables) && isset($token_var_selected_variables[$key]) && !empty($token_var_selected_variables[$key])) {
$info['tokens']['variables'][$key] = array(
'name' => $key,
'description' => $var,
);
}
elseif (is_array($var) && $key != TOKENIZE_DRUPAL_VARIABLES_OPTIONS) {
foreach ($var as $var_key => $var_val) {
if (!empty($token_var_selected_variables) && isset($token_var_selected_variables[$key . "|" . $var_key]) && !empty($token_var_selected_variables[$key . "|" . $var_key])) {
$info['tokens']['variables_array'][$key . "|" . $var_key] = array(
'name' => $key . "|" . $var_key,
'description' => $var_val,
);
}
}
}
}
if (!empty($info['tokens']['variables_array'])) {
$info['types']['variables_array'] = array(
'name' => t('Variables Array'),
'description' => t('Tokens related to drupal variables (Only variables that contain strings can be used).'),
);
}
if (!empty($info['tokens']['variables'])) {
$info['types']['variables'] = array(
'name' => t('Variables'),
'description' => t('Tokens related to drupal variables (Only variables that contain strings can be used).'),
);
}
return $info;
}