1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Install, update and uninstall functions for the print_pdf module.
|
6
|
*
|
7
|
* @ingroup print
|
8
|
*/
|
9
|
|
10
|
/**
|
11
|
* Implements hook_enable().
|
12
|
*/
|
13
|
function print_pdf_enable() {
|
14
|
$t = get_t();
|
15
|
|
16
|
// Module weight
|
17
|
db_update('system')
|
18
|
->fields(array(
|
19
|
'weight' => 2,
|
20
|
))
|
21
|
->condition('type', 'module')
|
22
|
->condition('name', 'print_pdf')
|
23
|
->execute();
|
24
|
}
|
25
|
|
26
|
/**
|
27
|
* Implements hook_uninstall().
|
28
|
*/
|
29
|
function print_pdf_uninstall() {
|
30
|
variable_del('print_pdf_settings');
|
31
|
variable_del('print_pdf_show_link');
|
32
|
variable_del('print_pdf_link_pos');
|
33
|
variable_del('print_pdf_link_teaser');
|
34
|
variable_del('print_pdf_node_link_visibility');
|
35
|
variable_del('print_pdf_node_link_pages');
|
36
|
variable_del('print_pdf_link_class');
|
37
|
variable_del('print_pdf_sys_link_visibility');
|
38
|
variable_del('print_pdf_sys_link_pages');
|
39
|
variable_del('print_pdf_book_link');
|
40
|
variable_del('print_pdf_pdf_tool');
|
41
|
variable_del('print_pdf_content_disposition');
|
42
|
variable_del('print_pdf_paper_size');
|
43
|
variable_del('print_pdf_page_orientation');
|
44
|
variable_del('print_pdf_images_via_file');
|
45
|
variable_del('print_pdf_font_family');
|
46
|
variable_del('print_pdf_font_size');
|
47
|
variable_del('print_pdf_link_text');
|
48
|
variable_del('print_pdf_link_use_alias');
|
49
|
variable_del('print_pdf_filename');
|
50
|
variable_del('print_pdf_autoconfig');
|
51
|
variable_del('print_pdf_dompdf_unicode');
|
52
|
variable_del('print_pdf_wkhtmltopdf_options');
|
53
|
variable_del('print_pdf_display_sys_urllist');
|
54
|
$settings = db_query("SELECT name FROM {variable} WHERE name LIKE 'print\_pdf\_display\_%'");
|
55
|
foreach ($settings as $variable) {
|
56
|
variable_del($variable->name);
|
57
|
}
|
58
|
}
|
59
|
|
60
|
/**
|
61
|
* Implements hook_schema().
|
62
|
*/
|
63
|
function print_pdf_schema() {
|
64
|
$schema['print_pdf_node_conf'] = array(
|
65
|
'description' => 'PDF version node-specific configuration settings',
|
66
|
'fields' => array(
|
67
|
'nid' => array(
|
68
|
'type' => 'int',
|
69
|
'unsigned' => TRUE,
|
70
|
'not null' => TRUE,
|
71
|
'description' => 'The {node}.nid of the node.',
|
72
|
),
|
73
|
'link' => array(
|
74
|
'type' => 'int',
|
75
|
'unsigned' => TRUE,
|
76
|
'not null' => TRUE,
|
77
|
'default' => 1,
|
78
|
'size' => 'tiny',
|
79
|
'description' => 'Show link',
|
80
|
),
|
81
|
'comments' => array(
|
82
|
'type' => 'int',
|
83
|
'unsigned' => TRUE,
|
84
|
'not null' => TRUE,
|
85
|
'default' => 1,
|
86
|
'size' => 'tiny',
|
87
|
'description' => 'Show link in individual comments',
|
88
|
),
|
89
|
'url_list' => array(
|
90
|
'type' => 'int',
|
91
|
'unsigned' => TRUE,
|
92
|
'not null' => TRUE,
|
93
|
'default' => 1,
|
94
|
'size' => 'tiny',
|
95
|
'description' => 'Show Printer-friendly URLs list',
|
96
|
),
|
97
|
),
|
98
|
'primary key' => array('nid'),
|
99
|
);
|
100
|
|
101
|
$schema['print_pdf_page_counter'] = array(
|
102
|
'description' => 'PDF version access counter',
|
103
|
'fields' => array(
|
104
|
'path' => array(
|
105
|
'type' => 'varchar',
|
106
|
'length' => 255,
|
107
|
'not null' => TRUE,
|
108
|
'description' => 'Page path',
|
109
|
),
|
110
|
'totalcount' => array(
|
111
|
'type' => 'int',
|
112
|
'unsigned' => TRUE,
|
113
|
'not null' => TRUE,
|
114
|
'default' => 0,
|
115
|
'size' => 'big',
|
116
|
'description' => 'Number of page accesses',
|
117
|
),
|
118
|
'timestamp' => array(
|
119
|
'type' => 'int',
|
120
|
'unsigned' => TRUE,
|
121
|
'not null' => TRUE,
|
122
|
'default' => 0,
|
123
|
'description' => 'Last access',
|
124
|
),
|
125
|
),
|
126
|
'primary key' => array('path'),
|
127
|
);
|
128
|
|
129
|
return $schema;
|
130
|
}
|
131
|
|
132
|
/**
|
133
|
* Remove hardcoded numeric deltas from all blocks
|
134
|
*/
|
135
|
function print_pdf_update_7000(&$sandbox) {
|
136
|
$renamed_deltas = array(
|
137
|
'print_pdf' => array(
|
138
|
'0' => 'print_pdf-top',
|
139
|
),
|
140
|
);
|
141
|
|
142
|
update_fix_d7_block_deltas($sandbox, $renamed_deltas, array());
|
143
|
|
144
|
if (variable_get('print_pdf_filename', '') == '[site-name] - [title] - [mod-yyyy]-[mod-mm]-[mod-dd]') {
|
145
|
variable_set('print_pdf_filename', '[site:name] - [node:title] - [node:changed:custom:Y-m-d]');
|
146
|
}
|
147
|
}
|
148
|
|
149
|
/**
|
150
|
* Enable block and help area links
|
151
|
*/
|
152
|
function print_pdf_update_7101(&$sandbox) {
|
153
|
$link_pos = variable_get('print_pdf_link_pos', drupal_json_decode('{ "link": "link", "block": "block", "help": "help" }'));
|
154
|
$link_pos['block'] = 'block';
|
155
|
$link_pos['help'] = 'help';
|
156
|
variable_set('print_pdf_link_pos', $link_pos);
|
157
|
}
|
158
|
|
159
|
/**
|
160
|
* Increase size of the path field in the print_pdf_page_counter table
|
161
|
*/
|
162
|
function print_pdf_update_7105(&$sandbox) {
|
163
|
db_drop_primary_key('print_pdf_page_counter');
|
164
|
db_change_field('print_pdf_page_counter', 'path', 'path',
|
165
|
array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'description' => 'Page path'),
|
166
|
array('primary key' => array('path')));
|
167
|
}
|