function print_mail_link in Printer, email and PDF versions 5.4
Same name and namespace in other branches
- 5.3 print_mail/print_mail.module \print_mail_link()
- 6 print_mail/print_mail.module \print_mail_link()
- 5.x print_mail/print_mail.module \print_mail_link()
Implementation of hook_link().
File
- print_mail/
print_mail.module, line 150
Code
function print_mail_link($type, $node = NULL, $teaser = FALSE) {
$print_mail_link_pos = variable_get('print_mail_link_pos', array(
PRINT_MAIL_LINK_POS_DEFAULT => PRINT_MAIL_LINK_POS_DEFAULT,
));
$print_mail_link_use_alias = variable_get('print_mail_link_use_alias', PRINT_MAIL_LINK_USE_ALIAS_DEFAULT);
$allowed_type = print_mail_link_allowed(array(
'type' => $type,
'node' => $node,
'teaser' => $teaser,
));
if ($allowed_type && !empty($print_mail_link_pos['link'])) {
drupal_add_css(drupal_get_path('module', 'print') . '/css/printlinks.css');
$links = array();
$format = theme('print_mail_format_link');
// Show book link
if ($allowed_type === PRINT_ALLOW_BOOK_LINK) {
$links['book_mail'] = array(
'href' => PRINTMAIL_PATH . '/book/export/html/' . $node->nid,
'title' => $format['text'],
'attributes' => $format['attributes'],
'html' => $format['html'],
);
return $links;
}
elseif ($allowed_type === PRINT_ALLOW_NORMAL_LINK) {
$query_arr = $_GET;
if ($type == 'comment') {
$query_arr['comment'] = $node->cid;
}
$query = print_query_string_encode($query_arr, array(
'q',
));
if (empty($query)) {
$query = NULL;
}
if ($print_mail_link_use_alias) {
$path = drupal_get_path_alias('node/' . $node->nid);
}
else {
$path = $node->nid;
}
$links['print_mail'] = array(
'href' => PRINTMAIL_PATH . '/' . $path,
'title' => $format['text'],
'attributes' => $format['attributes'],
'html' => $format['html'],
'query' => $query,
);
return $links;
}
}
else {
return;
}
}