Issue #1049892 by ogi: add missing > in ->setFontSubsetting
[project/print.git] / print.install
1 <?php
2
3 /**
4 * @file
5 * Install file of the print module
6 *
7 * @ingroup print
8 */
9
10 /**
11 * Implementation of hook_install().
12 */
13 function print_install() {
14 drupal_install_schema('print');
15
16 // Module weight
17 update_sql("UPDATE {system} SET weight = 0 WHERE name = 'print'");
18
19 $t = get_t();
20 drupal_set_message($t('Printer-friendly Page settings are available under !link',
21 array( '!link' => l($t('Administer > Site configuration > Printer-friendly Pages'), 'admin/settings/print' ) )
22 ));
23 }
24
25 /**
26 * Implementation of hook_uninstall().
27 */
28 function print_uninstall() {
29 drupal_uninstall_schema('print');
30
31 variable_del('print_settings');
32 variable_del('print_sourceurl_settings');
33 variable_del('print_html_settings');
34 variable_del('print_robot_settings');
35 variable_del('print_logo_url');
36 variable_del('print_logo_options');
37 variable_del('print_css');
38 variable_del('print_urls');
39 variable_del('print_urls_anchors');
40 variable_del('print_comments');
41 variable_del('print_newwindow');
42 variable_del('print_sourceurl_enabled');
43 variable_del('print_sourceurl_date');
44 variable_del('print_sourceurl_forcenode');
45 variable_del('print_html_show_link');
46 variable_del('print_html_link_pos');
47 variable_del('print_html_link_teaser');
48 variable_del('print_html_node_link_visibility');
49 variable_del('print_html_node_link_pages');
50 variable_del('print_html_link_class');
51 variable_del('print_html_sys_link_visibility');
52 variable_del('print_html_sys_link_pages');
53 variable_del('print_html_book_link');
54 variable_del('print_html_new_window');
55 variable_del('print_html_sendtoprinter');
56 variable_del('print_html_windowclose');
57 variable_del('print_robots_noindex');
58 variable_del('print_robots_nofollow');
59 variable_del('print_robots_noarchive');
60 variable_del('print_footer_options');
61 variable_del('print_footer_user');
62 variable_del('print_html_link_text');
63 variable_del('print_html_link_use_alias');
64 variable_del('print_text_links');
65 variable_del('print_text_published');
66 variable_del('print_text_retrieved');
67 variable_del('print_text_source_url');
68 $settings = db_query("SELECT name FROM {variable} WHERE name LIKE 'print\_display\_%'");
69 while ($variable = db_fetch_object($settings)) {
70 variable_del($variable->name);
71 }
72 }
73
74 /**
75 * Implementation of hook_schema().
76 */
77 function print_schema() {
78 $schema['print_node_conf'] = array(
79 'fields' => array(
80 'nid' => array(
81 'type' => 'int',
82 'unsigned' => TRUE,
83 'not null' => TRUE,
84 ),
85 'link' => array(
86 'type' => 'int',
87 'unsigned' => TRUE,
88 'not null' => TRUE,
89 'default' => 1,
90 'size' => 'tiny',
91 ),
92 'comments' => array(
93 'type' => 'int',
94 'unsigned' => TRUE,
95 'not null' => TRUE,
96 'default' => 1,
97 'size' => 'tiny',
98 ),
99 'url_list' => array(
100 'type' => 'int',
101 'unsigned' => TRUE,
102 'not null' => TRUE,
103 'default' => 1,
104 'size' => 'tiny',
105 ),
106 ),
107 'primary key' => array('nid'),
108 );
109
110 $schema['print_page_counter'] = array(
111 'fields' => array(
112 'path' => array(
113 'type' => 'varchar',
114 'length' => 128,
115 'not null' => TRUE,
116 ),
117 'totalcount' => array(
118 'type' => 'int',
119 'unsigned' => TRUE,
120 'not null' => TRUE,
121 'default' => 0,
122 'size' => 'big',
123 ),
124 'timestamp' => array(
125 'type' => 'int',
126 'unsigned' => TRUE,
127 'not null' => TRUE,
128 'default' => 0,
129 ),
130 ),
131 'primary key' => array('path'),
132 );
133
134 return $schema;
135 }
136
137
138 /**
139 * Update to version 6.x-1.0
140 */
141 function print_update_6000() {
142 global $conf;
143 $ret = array();
144
145 $lastversion = drupal_get_installed_schema_version('print');
146 if (($lastversion >= 5300) && ($lastversion < 6000)) {
147 return $ret;
148 }
149
150 if (isset($conf['print_settings'])) {
151 $print_settings = variable_get('print_settings', '');
152 variable_set('print_logo_options', ($print_settings['logo_url'] ? 2 : 1));
153 variable_set('print_logo_url', $print_settings['logo_url']);
154 variable_set('print_css', $print_settings['css']);
155 variable_set('print_urls', $print_settings['urls']);
156 variable_set('print_comments', $print_settings['comments']);
157 variable_set('print_newwindow', $print_settings['newwindow']);
158 variable_del('print_settings');
159 }
160 if (isset($conf['print_sourceurl_settings'])) {
161 $print_sourceurl_settings = variable_get('print_sourceurl_settings', '');
162 variable_set('print_sourceurl_enabled', $print_sourceurl_settings['enabled']);
163 variable_set('print_sourceurl_date', $print_sourceurl_settings['date']);
164 variable_set('print_sourceurl_forcenode', $print_sourceurl_settings['forcenode']);
165 variable_del('print_sourceurl_settings');
166 }
167 if (isset($conf['print_html_settings'])) {
168 $print_html_settings = variable_get('print_html_settings', '');
169 variable_set('print_html_link_pos', array('link' => ($print_html_settings['show_link'] ? 'link' : 0) ));
170 variable_set('print_html_show_link', max(1, $print_html_settings['show_link']));
171 variable_set('print_html_node_link_visibility', $print_html_settings['node_link_visibility']);
172 variable_set('print_html_node_link_pages', $print_html_settings['node_link_pages']);
173 variable_set('print_html_link_class', $print_html_settings['link_class']);
174 variable_set('print_html_sys_link_visibility', $print_html_settings['sys_link_visibility']);
175 variable_set('print_html_sys_link_pages', $print_html_settings['sys_link_pages']);
176 variable_set('print_html_book_link', $print_html_settings['book_link']);
177 variable_set('print_html_new_window', $print_html_settings['new_window']);
178 variable_set('print_html_sendtoprinter', $print_html_settings['sendtoprinter']);
179 variable_del('print_html_settings');
180 }
181 if (isset($conf['print_robot_settings'])) {
182 $print_robot_settings = variable_get('print_robot_settings', '');
183 variable_set('print_robots_noindex', $print_robot_settings['noindex']);
184 variable_set('print_robots_nofollow', $print_robot_settings['nofollow']);
185 variable_set('print_robots_noarchive', $print_robot_settings['noarchive']);
186 variable_del('print_robot_settings');
187 }
188 return $ret;
189 }
190
191 /**
192 * Update to version 6.x-1.0
193 */
194 function print_update_6001() {
195 $ret = array();
196 $lastversion = drupal_get_installed_schema_version('print');
197 if (($lastversion >= 5301) && ($lastversion < 6000)) {
198 return $ret;
199 }
200
201 menu_rebuild();
202 return $ret;
203 }
204
205 /**
206 * Update to version 6.x-1.1
207 */
208 function print_update_6002() {
209 $ret = array();
210 $lastversion = drupal_get_installed_schema_version('print');
211 if (($lastversion >= 5302) && ($lastversion < 6000)) {
212 return $ret;
213 }
214
215 $schema['print_node_conf'] = array(
216 'fields' => array(
217 'nid' => array(
218 'type' => 'int',
219 'unsigned' => TRUE,
220 'not null' => TRUE,
221 ),
222 'link' => array(
223 'type' => 'int',
224 'unsigned' => TRUE,
225 'not null' => TRUE,
226 'default' => '1',
227 'size' => 'tiny',
228 ),
229 'comments' => array(
230 'type' => 'int',
231 'unsigned' => TRUE,
232 'not null' => TRUE,
233 'default' => '1',
234 'size' => 'tiny',
235 ),
236 'url_list' => array(
237 'type' => 'int',
238 'unsigned' => TRUE,
239 'not null' => TRUE,
240 'default' => '1',
241 'size' => 'tiny',
242 ),
243 ),
244 'primary key' => array('nid'),
245 );
246
247 $schema['print_page_counter'] = array(
248 'fields' => array(
249 'path' => array(
250 'type' => 'varchar',
251 'length' => 128,
252 'not null' => TRUE,
253 ),
254 'totalcount' => array(
255 'type' => 'int',
256 'unsigned' => TRUE,
257 'not null' => TRUE,
258 'default' => 0,
259 'size' => 'big',
260 ),
261 'timestamp' => array(
262 'type' => 'int',
263 'unsigned' => TRUE,
264 'not null' => TRUE,
265 'default' => 0,
266 ),
267 ),
268 'primary key' => array('path'),
269 );
270
271 db_create_table($ret, 'print_node_conf', $schema['print_node_conf']);
272 db_create_table($ret, 'print_page_counter', $schema['print_page_counter']);
273 return $ret;
274 }
275
276 /**
277 * Update to version 6.x-1.2
278 */
279 function print_update_6003() {
280 $ret = array();
281
282 $lastversion = drupal_get_installed_schema_version('print');
283 if (($lastversion >= 5303) && ($lastversion < 6000)) {
284 return $ret;
285 }
286
287 // Delete custom text strings set to the default
288 $vars = array(
289 'print_html_link_text' => 'Printer-friendly version',
290 'print_text_published' => 'Published on %site_name',
291 'print_text_by' => 'By %author',
292 'print_text_created' => 'Created %date',
293 'print_text_source_url' => 'Source URL',
294 'print_text_retrieved' => 'retrieved on %date',
295 'print_text_links' => 'Links',
296 );
297
298 $t = get_t();
299
300 foreach ($vars as $name => $default) {
301 if (variable_get($name, '') == $t($default)) {
302 variable_del($name);
303 }
304 }
305
306 menu_rebuild();
307 return $ret;
308 }
309
310 /**
311 * Update to version 6.x-1.11
312 */
313 function print_update_6004() {
314 $ret = array();
315 // BLOCK_CACHE_PER_PAGE -> 4
316 $ret[] = update_sql("UPDATE {blocks} SET cache = 4 WHERE module = 'print' AND delta = '0'");
317 // BLOCK_CACHE_GLOBAL -> 8
318 $ret[] = update_sql("UPDATE {blocks} SET cache = 8 WHERE module = 'print' AND delta = '1'");
319 return $ret;
320 }
321
322 /**
323 * Update to version 6.x-1.11
324 */
325 function print_update_6005() {
326 $ret = array();
327 // Module weight
328 $ret[] = update_sql("UPDATE {system} SET weight = 0 WHERE name = 'print'");
329 return $ret;
330 }
331
332 /**
333 * Update to version 6.x-1.11
334 */
335 function print_update_6006() {
336 global $base_root, $base_path;
337
338 $ret = array();
339 $t = get_t();
340
341 $print_css = variable_get('print_css', '');
342 $pattern = "!(?:${base_root})?${base_path}(.*)!is";
343 if (preg_match($pattern, strtr($print_css, array('%b' => base_path())), $matches)) {
344 variable_set('print_css', $matches[1]);
345 }
346 elseif (!empty($print_css)) {
347 drupal_set_message($t('Please review your custom stylesheet path in the <a href="!url">print module settings</a>, as the path must now be relative to the base path of the site.', array('!url' => url('admin/settings/print/common'))));
348 }
349
350 return $ret;
351 }
352
353 /**
354 * Update to version 6.x-1.11
355 */
356 function print_update_6007() {
357 $ret = array();
358
359 foreach (node_get_types() as $key => $value) {
360 $print_display = variable_get('print_display_'. $value->type, 1);
361 $print_display_comment = variable_get('print_display_comment_'. $value->type, 0);
362 $print_display_urllist = variable_get('print_display_urllist_'. $value->type, 1);
363
364 if (!$print_display || $print_display_comment || !$print_display_urllist) {
365 $result = db_query("SELECT n.nid, link, comments, url_list from {node} AS n LEFT JOIN {print_node_conf} AS pnc ON n.nid = pnc.nid WHERE type = '%s'", $value->type);
366 while ($conf = db_fetch_object($result)) {
367 if (($conf->link != NULL) && ($conf->comments != NULL) && ($conf->url_list != NULL)) {
368 $conf->link = !$print_display ? 0 : $conf->link;
369 $conf->comments = $print_display_comment ? 1 : $conf->comments;
370 $conf->url_list = !$print_display_urllist ? 0 : $conf->url_list;
371 $ret[] = update_sql("UPDATE {print_node_conf} SET link = $conf->link, comments = $conf->comments, url_list = $conf->url_list WHERE nid = $conf->nid");
372 }
373 else {
374 $ret[] = update_sql("INSERT INTO {print_node_conf} (nid, link, comments, url_list) VALUES ($conf->nid, $print_display, $print_display_comment, $print_display_urllist)");
375 }
376 }
377 }
378 }
379 return $ret;
380 }
381
382 /**
383 * Update to version 6.x-1.13
384 */
385 function print_update_6008() {
386 variable_del('print_text_by');
387 variable_del('print_text_created');
388 }