-
Notifications
You must be signed in to change notification settings - Fork 0
/
simpleads_statsprint.module
82 lines (75 loc) · 1.99 KB
/
simpleads_statsprint.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
74
75
76
77
78
79
80
81
82
<?php
/**
* @file
*
* Provide a pdf format for printing the statistics displayed on node Statistics page.
*/
/**
* Implements hook_libraries_info().
*
* @see xautoload.api.php
*/
function simpleads_statsprint_libraries_info() {
return array(
'dompdf' => array(
'name' => 'dompdf/dompdf',
'xautoload' => function($adaptor) {
/** @var \Drupal\xautoload\Adapter\LocalDirectoryAdapter $adapter */
// Scans sites/all/libraries/dompdf/composer.json to look for
// autoloader information.
$adaptor->composerJson('composer.json');
}
),
);
}
/**
* Implements hook_permission().
*/
function simpleads_statsprint_permission() {
return array(
'access simpleads statsprint' => array(
'title' => t('Access the pdf stats page.'),
'description' => t('Allow view of SimpleAds statitics in pdf format.')
),
);
}
/**
* Implements hook_menu().
*/
function simpleads_statsprint_menu() {
return array(
'printadstat/%' => array(
'page callback' => 'simpleads_statsprint_pdf',
'page arguments' => array(1),
'access arguments' => array('access simpleads statsprint'),
'type' => MENU_CALLBACK,
'file' => 'print.ad.stat.inc',
'file path' => drupal_get_path('module', 'simpleads_statsprint'),
),
);
}
/**
* Implements hook_preprocess_page().
*/
function simpleads_statsprint_preprocess_page(&$variables) {
if (arg(2) == 'stats' || arg(2) == 'stat') {
$markup = '<p><a href="' . $variables['base_path'];
$markup .= 'printadstat/' . arg(1);
$markup .= '" target=_blank>Generate PDF</a></p>';
$markup .= $variables['page']['content']['system_main']['main']['#markup'];
$variables['page']['content']['system_main']['main']['#markup'] = $markup;
}
}
/**
* Implemnts hook_theme().
*/
function simpleads_statsprint_theme() {
return array(
'simpleads_statsprint' => array(
'variables' => array(
'data' => array(),
),
'template' => 'simpleads-statsprint',
),
);
}