function print_mail_insert_link in Printer, email and PDF versions 5.3
Same name and namespace in other branches
- 5.4 print_mail/print_mail.module \print_mail_insert_link()
- 6 print_mail/print_mail.module \print_mail_insert_link()
- 7.2 print_mail/print_mail.module \print_mail_insert_link()
- 7 print_mail/print_mail.module \print_mail_insert_link()
- 5.x print_mail/print_mail.module \print_mail_insert_link()
Auxiliary function to display a formatted send by e-mail link
Function made available so that developers may call this function from their defined pages/blocks.
Parameters
$path: path of the original page (optional). If not specified, the current URL is used
$node: an optional node object, to be used in defining the path, if used, the path argument is irrelevant
Return value
string with the HTML link to the printer-friendly page
2 calls to print_mail_insert_link()
- print_mail_help in print_mail/
print_mail.module - Implementation of hook_help().
- print_mail_nodeapi in print_mail/
print_mail.module - Implementation of hook_nodeapi().
File
- print_mail/
print_mail.module, line 207
Code
function print_mail_insert_link($path = NULL, $node = NULL) {
if ($node !== NULL) {
$nid = $node->nid;
$path = 'node/' . $nid;
$allowed_type = print_mail_link_allowed(array(
'node' => $node,
));
}
else {
if ($path === NULL) {
$nid = preg_replace('!^node/!', '', $_GET['q']);
$path = $_GET['q'];
}
else {
$nid = NULL;
}
$allowed_type = print_mail_link_allowed(array(
'path' => $path,
));
}
if ($allowed_type) {
if ($nid !== NULL) {
if ($allowed_type === PRINT_ALLOW_BOOK_LINK) {
$path = 'book/export/html/' . $nid;
}
else {
if (variable_get('print_mail_link_use_alias', PRINT_MAIL_LINK_USE_ALIAS_DEFAULT)) {
$path = drupal_get_path_alias($path);
}
else {
$path = $nid;
}
}
$path = PRINTMAIL_PATH . '/' . $path;
$query = print_query_string_encode($_GET, array(
'q',
));
if (empty($query)) {
$query = NULL;
}
}
else {
$query = NULL;
}
drupal_add_css(drupal_get_path('module', 'print') . '/css/printlinks.css');
$format = theme('print_mail_format_link');
return '<span class="print_mail">' . l($format['text'], $path, $format['attributes'], $query, NULL, TRUE, $format['html']) . '</span>';
}
else {
return FALSE;
}
}