forked from easySuite/ding_print_button
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ding_print_button.module
73 lines (62 loc) · 1.85 KB
/
ding_print_button.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
/**
* @file
* Create a button for page printing needs.
*/
/**
* Implements hook_block_info().
*/
function ding_print_button_block_info() {
$blocks = array();
$blocks['print_button'] = array(
'info' => t('Print button'),
);
return $blocks;
}
/**
* Implements hook_block_view().
*/
function ding_print_button_block_view($delta = '') {
$block = array();
switch ($delta) {
case 'print_button':
$module_path = drupal_get_path('module', 'ding_print_button');
drupal_add_js($module_path .'/js/ding_print_button.js', array('scope' => 'footer', 'weight' => 99));
drupal_add_css($module_path .'/css/ding_print_button.css');
// Block markup.
$block['subject'] = t('Print button');
$block['content'] = l(
theme_image(array('path' => $module_path . '/img/icon-print.png', 'attributes' => array())) . t('Print'), '#',
array(
'attributes' => array(
'class' => array(
'print-button',
),
),
'html' => TRUE,
)
);
break;
}
return $block;
}
/**
* Implements hook_preprocess_HOOK().
*/
function ding_print_button_preprocess_25_50_25(&$variables) {
$user_bookmarks = arg(0) == 'user' && arg(2) == 'bookmarks';
$user_pages = arg(0) == 'user' && arg(2) == 'status';
$is_status_page = !!preg_match('/^user\/\d+\/status/', $_GET['q'], $match);
if (!$user_bookmarks && !$user_pages && !$is_status_page) {
return;
}
$block = module_invoke('ding_print_button', 'block_view', 'print_button');
$print_button_markup =
'<div class="panel-pane pane-block pane-print-button">' .
'<div class="pane-content">' .
render($block['content']) .
'</div>' .
'</div>';
$existing_content = $variables['content']['main_content'];
$variables['content']['main_content'] = $print_button_markup . $existing_content;
}