function print_mail_node_view in Printer, email and PDF versions 7
Implements hook_node_view().
File
- print_mail/
print_mail.module, line 170 - Displays Printer-friendly versions of Drupal pages.
Code
function print_mail_node_view($node, $view_mode) {
$print_mail_link_pos = variable_get('print_mail_link_pos', drupal_json_decode(PRINT_MAIL_LINK_POS_DEFAULT));
$print_mail_link_use_alias = variable_get('print_mail_link_use_alias', PRINT_MAIL_LINK_USE_ALIAS_DEFAULT);
foreach (array(
'node',
'comment',
) as $type) {
$allowed_type = print_mail_link_allowed(array(
'type' => $type,
'node' => $node,
'view_mode' => $view_mode,
));
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'],
);
}
elseif ($allowed_type === PRINT_ALLOW_NORMAL_LINK) {
$path = $print_mail_link_use_alias && ($alias = drupal_lookup_path('alias', 'node/' . $node->nid)) ? $alias : $node->nid;
$links['print_mail'] = array(
'href' => PRINTMAIL_PATH . '/' . $path,
'title' => $format['text'],
'attributes' => $format['attributes'],
'html' => $format['html'],
'query' => print_query_string_encode($_GET, array(
'q',
)),
);
}
$link_content = array(
'#theme' => 'links',
'#links' => $links,
'#attributes' => array(
'class' => array(
'links',
'inline',
),
),
);
if ($type == 'node') {
$node->content['links']['print_mail'] = $link_content;
}
elseif ($type == 'comment' && isset($node->content['comments']['comments'])) {
foreach ($node->content['comments']['comments'] as $cid => $comment) {
if (is_numeric($cid)) {
$link_content['#links']['print_mail']['query']['comment'] = $cid;
$node->content['comments']['comments'][$cid]['links']['print_mail'] = $link_content;
}
}
}
}
}
// Insert content corner links
if (!empty($print_mail_link_pos['corner']) && $view_mode == 'full') {
$node->content['print_links']['#markup'] .= print_mail_insert_link(NULL, $node);
}
}