Update dompdf download URL
[project/print.git] / print.install
1 <?php
2 // $Id$
3
4 /**
5 * @file
6 * Install file of the print module
7 */
8
9 /**
10 * Implementation of hook_install().
11 */
12 function print_install() {
13 switch ($GLOBALS['db_type']) {
14 case 'mysql':
15 case 'mysqli':
16 db_query("CREATE TABLE {print_node_conf} (
17 nid int(10) unsigned NOT NULL,
18 link tinyint(3) unsigned NOT NULL default '1',
19 comments tinyint(3) unsigned NOT NULL default '1',
20 url_list tinyint(3) unsigned NOT NULL default '1',
21 PRIMARY KEY (nid)
22 ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
23 db_query("CREATE TABLE {print_page_counter} (
24 path varchar(128) NOT NULL,
25 totalcount bigint(20) unsigned NOT NULL default '0',
26 timestamp int(10) unsigned NOT NULL default '0',
27 PRIMARY KEY (path)
28 ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
29 break;
30 case 'pgsql':
31 db_query("CREATE TABLE {print_node_conf} (
32 nid int_unsigned NOT NULL,
33 link smallint NOT NULL default '1',
34 comments smallint_unsigned NOT NULL default '1',
35 url_list smallint_unsigned NOT NULL default '1',
36 PRIMARY KEY (nid)
37 )");
38 db_query("CREATE TABLE {print_page_counter} (
39 path varchar(128) NOT NULL,
40 totalcount bigint NOT NULL default '0',
41 timestamp int_unsigned NOT NULL default '0',
42 PRIMARY KEY (path)
43 )");
44 break;
45 }
46
47 $t = get_t();
48 drupal_set_message($t('Printer-friendly Page settings are available under !link',
49 array( '!link' => l($t('Administer > Site configuration > Printer-friendly Pages'), 'admin/settings/print' ) )
50 ));
51 }
52
53 /**
54 * Implementation of hook_uninstall().
55 */
56 function print_uninstall() {
57 db_query('DROP TABLE {print_node_conf}');
58 db_query('DROP TABLE {print_page_counter}');
59
60 variable_del('print_settings');
61 variable_del('print_display_comment');
62 variable_del('print_sourceurl_settings');
63 variable_del('print_robot_settings');
64 variable_del('print_logo_url');
65 variable_del('print_logo_options');
66 variable_del('print_css');
67 variable_del('print_urls');
68 variable_del('print_comments');
69 variable_del('print_newwindow');
70 variable_del('print_sourceurl_enabled');
71 variable_del('print_sourceurl_date');
72 variable_del('print_sourceurl_forcenode');
73 variable_del('print_html_show_link');
74 variable_del('print_html_link_pos');
75 variable_del('print_html_node_link_visibility');
76 variable_del('print_html_node_link_pages');
77 variable_del('print_html_link_class');
78 variable_del('print_html_sys_link_visibility');
79 variable_del('print_html_sys_link_pages');
80 variable_del('print_html_book_link');
81 variable_del('print_html_new_window');
82 variable_del('print_html_sendtoprinter');
83 variable_del('print_robots_noindex');
84 variable_del('print_robots_nofollow');
85 variable_del('print_robots_noarchive');
86 variable_del('print_footer_options');
87 variable_del('print_footer_user');
88 variable_del('print_html_link_text');
89 variable_del('print_html_link_use_alias');
90 variable_del('print_text_by');
91 variable_del('print_text_created');
92 variable_del('print_text_links');
93 variable_del('print_text_published');
94 variable_del('print_text_retrieved');
95 variable_del('print_text_source_url');
96 $settings = db_query("SELECT name FROM {variable} WHERE name LIKE 'print\_display\_%'");
97 while ($variable = db_fetch_object($settings)) {
98 variable_del($variable->name);
99 }
100 }
101
102 /**
103 * Update to version 5.x-3.6
104 */
105 function print_update_5300() {
106 global $conf;
107
108 $ret = array();
109 if (isset($conf['print_settings'])) {
110 $print_settings = variable_get('print_settings', '');
111 $print_settings['node_link_visibility'] = 0;
112 $print_settings['node_link_pages'] = '';
113 $print_settings['link_class'] = 'print-page';
114 $print_settings['sys_link_visibility'] = ($print_settings['show_sys_link']) ? 0 : 1;
115 $print_settings['sys_link_pages'] = '';
116 $oldwindow = $print_settings['newwindow'];
117 $print_settings['newwindow'] = 1;
118 $print_settings['new_window'] = 0;
119 switch ($oldwindow) {
120 case 1: // Use HTML target
121 $print_settings['newwindow'] = 0;
122 // no break on purpose
123 case 2: // Use Javascript
124 $print_settings['new_window'] = 1;
125 break;
126 case 3: // Use Greybox Redux
127 $print_settings['link_class'] .= ' '. variable_get('greybox_class_text', 'greybox');
128 break;
129 case 4: // Use Thickbox
130 $print_settings['link_class'] .= ' thickbox';
131 break;
132 }
133 unset($print_settings['show_sys_link']);
134 variable_set('print_settings', $print_settings);
135 }
136 if (isset($conf['print_robot_settings'])) {
137 $robots_settings = variable_get('print_robot_settings', '');
138 unset($robots_settings['nocache']);
139 variable_set('print_robot_settings', $robots_settings);
140 }
141 return $ret;
142 }
143
144 /**
145 * Update to version 5.x-3.7
146 */
147 function print_update_5301() {
148 global $conf;
149
150 $ret = array();
151 if (isset($conf['print_settings'])) {
152 $print_settings = variable_get('print_settings', '');
153 variable_set('print_logo_options', ($print_settings['logo_url'] ? 2 : 1));
154 variable_set('print_logo_url', $print_settings['logo_url']);
155 variable_set('print_css', $print_settings['css']);
156 variable_set('print_urls', $print_settings['urls']);
157 variable_set('print_comments', $print_settings['comments']);
158 variable_set('print_newwindow', $print_settings['newwindow']);
159 variable_set('print_html_link_pos', array('link' => ($print_settings['show_link'] ? 'link' : 0) ));
160 variable_set('print_html_show_link', max(1, $print_settings['show_link']));
161 variable_set('print_html_node_link_visibility', $print_settings['node_link_visibility']);
162 variable_set('print_html_node_link_pages', $print_settings['node_link_pages']);
163 variable_set('print_html_link_class', $print_settings['link_class']);
164 variable_set('print_html_sys_link_visibility', $print_settings['sys_link_visibility']);
165 variable_set('print_html_sys_link_pages', $print_settings['sys_link_pages']);
166 variable_set('print_html_book_link', $print_settings['book_link']);
167 variable_set('print_html_new_window', $print_settings['new_window']);
168 variable_set('print_html_sendtoprinter', $print_settings['sendtoprinter']);
169 variable_del('print_settings');
170 }
171 if (isset($conf['print_sourceurl_settings'])) {
172 $print_sourceurl_settings = variable_get('print_sourceurl_settings', '');
173 variable_set('print_sourceurl_enabled', $print_sourceurl_settings['enabled']);
174 variable_set('print_sourceurl_date', $print_sourceurl_settings['date']);
175 variable_set('print_sourceurl_forcenode', $print_sourceurl_settings['forcenode']);
176 variable_del('print_sourceurl_settings');
177 }
178 if (isset($conf['print_robot_settings'])) {
179 $print_robot_settings = variable_get('print_robot_settings', '');
180 variable_set('print_robots_noindex', $print_robot_settings['noindex']);
181 variable_set('print_robots_nofollow', $print_robot_settings['nofollow']);
182 variable_set('print_robots_noarchive', $print_robot_settings['noarchive']);
183 variable_del('print_robot_settings');
184 }
185 return $ret;
186 }
187
188 /**
189 * Update to version 5.x-4.1
190 */
191 function print_update_5302() {
192 $ret = array();
193 switch ($GLOBALS['db_type']) {
194 case 'mysql':
195 case 'mysqli':
196 db_query("CREATE TABLE {print_node_conf} (
197 nid int(10) unsigned NOT NULL,
198 link tinyint(3) unsigned NOT NULL default '1',
199 comments tinyint(3) unsigned NOT NULL default '1',
200 url_list tinyint(3) unsigned NOT NULL default '1',
201 PRIMARY KEY (nid)
202 ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
203 db_query("CREATE TABLE {print_page_counter} (
204 path varchar(128) NOT NULL,
205 totalcount bigint(20) unsigned NOT NULL default '0',
206 timestamp int(10) unsigned NOT NULL default '0',
207 PRIMARY KEY (path)
208 ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
209 break;
210 case 'pgsql':
211 db_query("CREATE TABLE {print_node_conf} (
212 nid int_unsigned NOT NULL,
213 link smallint NOT NULL default '1',
214 comments smallint_unsigned NOT NULL default '1',
215 url_list smallint_unsigned NOT NULL default '1',
216 PRIMARY KEY (nid)
217 )");
218 db_query("CREATE TABLE {print_page_counter} (
219 path varchar(128) NOT NULL,
220 totalcount bigint NOT NULL default '0',
221 timestamp int_unsigned NOT NULL default '0',
222 PRIMARY KEY (path)
223 )");
224 break;
225 }
226 return $ret;
227 }
228
229 /**
230 * Update to version 5.x-4.2
231 */
232 function print_update_5303() {
233 // Delete custom text strings set to the default
234 $ret = array();
235 $vars = array(
236 'print_html_link_text' => 'Printer-friendly version',
237 'print_text_published' => 'Published on %site_name',
238 'print_text_by' => 'By %author',
239 'print_text_created' => 'Created %date',
240 'print_text_source_url' => 'Source URL',
241 'print_text_retrieved' => 'retrieved on %date',
242 'print_text_links' => 'Links',
243 );
244
245 $t = get_t();
246
247 foreach ($vars as $name => $default) {
248 if (variable_get($name, '') == $t($default)) {
249 variable_del($name);
250 }
251 }
252
253 menu_rebuild();
254 return $ret;
255 }