print_block_view
- drupal
Drupal 7 print_block_view($delta = '')
Implements hook_block_view().
File
- sites/
all/ modules/ print/ print.module, line 265 - Displays Printer-friendly versions of Drupal pages.
Code
function print_block_view($delta = '') {
switch ($delta) {
case 'print-links':
$nid = preg_replace('!^node/!', '', $_GET['q']);
if (ctype_digit($nid)) {
$node = node_load($nid);
if (!node_access('view', $node)) {
// If the user doesn't have access to the node, don't show any links
$block['content'] == '';
return;
}
}
else {
$node = NULL;
}
$block['content'] = '';
foreach (array(
'html' => 'print',
'mail' => 'print_mail',
'pdf' => 'print_pdf',
) as $format => $module) {
$link_pos = variable_get('print_' . $format . '_link_pos', array(PRINT_HTML_LINK_POS_DEFAULT => PRINT_HTML_LINK_POS_DEFAULT));
if (!(empty($link_pos['block']))) {
$func = $module . '_insert_link';
if (function_exists($func)) {
$links = $func(NULL, $node);
if (!empty($links)) {
$block['content'] .= $links;
}
}
}
}
break;
case 'print-top':
$block['subject'] = t('Most printed');
$result = db_query_range("SELECT path FROM {print_page_counter} LEFT JOIN {node} ON path = CONCAT('node/', node.nid) WHERE status <> 0 OR status IS NULL ORDER BY totalcount DESC", 0, 3)
->fetchAll();
if (count($result)) {
$block['content'] = '<div class="item-list"><ul>';
foreach ($result as $obj) {
$block['content'] .= '<li>' . l(_print_get_title($obj->path), $obj->path) . '</li>';
}
$block['content'] .= '</ul></div>';
}
break;
}
return $block;
}

