function menu_token_menu_token_plugins in Menu Token 7
Implements hook_menu_token_plugins().
File
- ./
menu_token.module, line 42 - Main module file for the Menu Token module.
Code
function menu_token_menu_token_plugins() {
$plugins = array();
$entity_info = entity_get_info();
$entities = variable_get('menu_token_entities', drupal_map_assoc(array(
'node',
'user',
)));
foreach ($entities as $entity => $enabled) {
if ($enabled) {
$token_type = $entity_info[$entity]['token type'];
$plugins["{$token_type}_context"] = array(
'type' => $token_type,
'label' => t('@entity_label from context', array(
'@entity_label' => $entity_info[$entity]['label'],
)),
'description' => t('Picks a @entity_label from the current context.', array(
'@entity_label' => $entity_info[$entity]['label'],
)),
'handler' => array(
'path' => drupal_get_path('module', 'menu_token') . '/plugins',
'file' => 'menu_token_entity_context.inc',
'class' => 'menu_token_entity_context',
),
);
$plugins["{$token_type}_panel_context"] = array(
'type' => $token_type,
'label' => t('@entity_label from panel argument', array(
'@entity_label' => $entity_info[$entity]['label'],
)),
'description' => t('Picks a @entity_label from the panel context.', array(
'@entity_label' => $entity_info[$entity]['label'],
)),
'handler' => array(
'path' => drupal_get_path('module', 'menu_token') . '/plugins',
'file' => 'menu_token_panel_context.inc',
'class' => 'menu_token_panel_context',
),
);
$plugins["{$token_type}_random"] = array(
'type' => $token_type,
'label' => t('Random @entity_label', array(
'@entity_label' => $entity_info[$entity]['label'],
)),
'description' => t('Picks a random @entity_label from the database.', array(
'@entity_label' => $entity_info[$entity]['label'],
)),
'handler' => array(
'path' => drupal_get_path('module', 'menu_token') . '/plugins',
'file' => 'menu_token_entity_random.inc',
'class' => 'menu_token_entity_random',
),
);
$plugins["{$token_type}_user_defined"] = array(
'type' => $token_type,
'label' => t('User-defined @entity_label', array(
'@entity_label' => $entity_info[$entity]['label'],
)),
'description' => t('Uses a user-defined @entity_label.', array(
'@entity_label' => $entity_info[$entity]['label'],
)),
'handler' => array(
'path' => drupal_get_path('module', 'menu_token') . '/plugins',
'file' => 'menu_token_entity_user_defined.inc',
'class' => 'menu_token_entity_user_defined',
),
);
}
}
return $plugins;
}