function addtocal_token_info_alter in Add to Cal 8.2
Same name and namespace in other branches
- 7 addtocal.tokens.inc \addtocal_token_info_alter()
Implements hook_token_info_alter().
File
- ./
addtocal.module, line 91
Code
function addtocal_token_info_alter(&$data) {
// Addtocal url token type.
$data['types']['addtocal-url'] = [
'name' => 'Add to Cal URL',
'description' => 'Add to Calendar url.',
'needs-data' => 'addtocal-url',
];
// Addtocal url default tokens.
$data['tokens']['addtocal-url']['google'] = [
'name' => t('Google'),
'description' => t('Add to Google Calendar url.'),
];
$data['tokens']['addtocal-url']['yahoo'] = [
'name' => t('Yahoo!'),
'description' => t('Add to Yahoo Calendar url.'),
];
$data['tokens']['addtocal-url']['web-outlook'] = [
'name' => t('Outlook.com'),
'description' => t('Add to Outlook.com Calendar url.'),
];
$data['tokens']['addtocal-url']['ics'] = [
'name' => t('iCal / MS Outlook'),
'description' => t('Add to iCal / MS Outlook url.'),
];
// Alter the field tokens added by token.module.
foreach ($data['tokens'] as $token_name => $token_info) {
$date_type = $token_info['date']['type'] ?? $token_info['start_date']['type'] ?? NULL;
if ($date_type == 'date') {
$data['tokens'][$token_name]['addtocal-url'] = [
'name' => 'Add to Cal URL',
'description' => 'Add to Calendar url.',
'module' => 'addtocal',
'type' => 'addtocal-url',
];
}
}
}