function print_insert_link in Printer, email and PDF versions 5.3
Same name and namespace in other branches
- 5.4 print.module \print_insert_link()
- 5.2 print.module \print_insert_link()
- 6 print.module \print_insert_link()
- 7.2 print.module \print_insert_link()
- 7 print.module \print_insert_link()
- 5.x print.module \print_insert_link()
Auxiliary function to display a formatted Printer-friendly 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_insert_link()
- print_help in ./
print.module - Implementation of hook_help().
- print_nodeapi in ./
print.module - Implementation of hook_nodeapi().
File
- ./
print.module, line 398 - Displays Printer-friendly versions of Drupal pages.
Code
function print_insert_link($path = NULL, $node = NULL) {
if ($node !== NULL) {
$nid = $node->nid;
$path = 'node/' . $nid;
$allowed_type = print_link_allowed(array(
'node' => $node,
));
}
else {
if ($path === NULL) {
$nid = preg_replace('!^node/!', '', $_GET['q']);
$path = $_GET['q'];
}
else {
$nid = NULL;
}
$allowed_type = print_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_html_link_use_alias', PRINT_HTML_LINK_USE_ALIAS_DEFAULT)) {
$path = drupal_get_path_alias($path);
}
else {
$path = $nid;
}
}
$path = PRINT_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_format_link');
return '<span class="print">' . l($format['text'], $path, $format['attributes'], $query, NULL, TRUE, $format['html']) . '</span>';
}
else {
return FALSE;
}
}