function notifications_nodetype_notifications_templates in Notifications 6.4
Implementation of hook_notifications_templates()
File
- notifications_nodetype/
notifications_nodetype.module, line 102 - Notifications content type extension
Code
function notifications_nodetype_notifications_templates($op, $type = 'all', $language = NULL) {
switch ($op) {
case 'help':
if (strpos($type, 'notifications-content') === 0) {
$help[] = t('The <em>Header</em> and <em>Footer</em> will be taken from Notifications events.');
$help[] = t('The <em>Digest line</em> will be used when composing Short digests on which each event will be just a line.');
return $help;
}
break;
case 'info':
$templates = array();
if ($type == 'all') {
foreach (node_get_types() as $node_type => $type_info) {
foreach (array(
'insert',
'update',
'comment',
'',
) as $action) {
$templates += notifications_nodetype_template($type_info, $action);
}
}
}
elseif (strpos($type, 'notifications-content-') === 0) {
list($module, $content, $node_type, $action) = split('-', $type);
$templates = node_get_types($node_type);
}
return $templates;
case 'parts':
if (strpos($type, 'notifications-content') === 0) {
return array(
'subject' => t('Subject'),
'main' => t('Content'),
'digest' => t('Digest line'),
);
}
/*
* @todo Think about more digesting options
if (strpos($type, 'notifications-digest-content') === 0) {
case 'notifications-digest-node-nid':
case 'notifications-digest-node-type':
$parts['title'] = t('Group title');
$parts['closing'] = t('Group footer');
return $parts;
}
*/
break;
case 'defaults':
if (strpos($type, 'notifications-content-') === 0) {
list($module, $content, $node_type, $action) = split('-', $type);
$type_info = node_get_types($node_type);
$variables = array(
'@name' => $type_info->name,
);
// Common parts for all actions
$text = array(
'main' => array(
'[node-teaser]',
t('Read more [node-url]'),
),
'digest' => array(
'[title]',
'Read more [node-url]',
),
);
switch ($action) {
case 'insert':
$text['subject'] = t('New @name: [title]', $variables, $language->language);
break;
case 'comment':
$text = array(
'subject' => t('Comment for @name: [title]', $variables, $language->language),
'main' => array(
t('Comment by [comment-author-name]: [comment-title]', array(), $language->language),
'[comment-body]',
t('Read more [comment-url]', array(), $language->language),
),
'digest' => array(
t('New Comment on [title] by [comment-author-name] titled [comment-title]', array(), $language->language),
t('Read more [comment-url]', array(), $language->language),
),
);
break;
case 'update':
default:
$text['subject'] = t('Update for @name: [title]', $variables, $language->language);
break;
}
return $text;
}
break;
case 'tokens':
if (strpos($type, 'notifications-content-') === 0) {
list($module, $content, $node_type, $action) = split('-', $type);
$args = explode('-', $type) + array(
2 => '',
3 => '',
);
$tokens = array();
// These are the token groups that will be used for this module's messages
$tokens[] = 'node';
if ($action == 'comment') {
$tokens[] = 'comment';
}
return $tokens;
}
break;
}
}