Projet

Général

Profil

Paste
Télécharger (5,17 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / print / print.install @ a2baadd1

1
<?php
2

    
3
/**
4
 * @file
5
 * Install, update and uninstall functions for the print module.
6
 *
7
 * @ingroup print
8
 */
9

    
10
/**
11
 * Implements hook_install().
12
 */
13
function print_install() {
14
  $t = get_t();
15
  drupal_set_message($t('Printer-friendly Page settings are available under !link',
16
    array('!link' => l($t('Administration > Configuration > User interface > Printer, email and PDF versions'), 'admin/config/user-interface/print'))
17
  ));
18
}
19

    
20
/**
21
 * Implements hook_enable().
22
 */
23
function print_enable() {
24
  // Module weight
25
  db_update('system')
26
    ->fields(array(
27
      'weight' => 0,
28
    ))
29
    ->condition('type', 'module')
30
    ->condition('name', 'print')
31
    ->execute();
32
}
33

    
34
/**
35
 * Implements hook_uninstall().
36
 */
37
function print_uninstall() {
38
  variable_del('print_settings');
39
  variable_del('print_sourceurl_settings');
40
  variable_del('print_html_settings');
41
  variable_del('print_robot_settings');
42
  variable_del('print_logo_url');
43
  variable_del('print_logo_options');
44
  variable_del('print_css');
45
  variable_del('print_keep_theme_css');
46
  variable_del('print_urls');
47
  variable_del('print_urls_anchors');
48
  variable_del('print_comments');
49
  variable_del('print_newwindow');
50
  variable_del('print_sourceurl_enabled');
51
  variable_del('print_sourceurl_date');
52
  variable_del('print_sourceurl_forcenode');
53
  variable_del('print_html_show_link');
54
  variable_del('print_html_link_pos');
55
  variable_del('print_html_link_teaser');
56
  variable_del('print_html_node_link_visibility');
57
  variable_del('print_html_node_link_pages');
58
  variable_del('print_html_link_class');
59
  variable_del('print_html_sys_link_visibility');
60
  variable_del('print_html_sys_link_pages');
61
  variable_del('print_html_book_link');
62
  variable_del('print_html_new_window');
63
  variable_del('print_html_sendtoprinter');
64
  variable_del('print_html_windowclose');
65
  variable_del('print_display_sys_urllist');
66
  variable_del('print_robots_noindex');
67
  variable_del('print_robots_nofollow');
68
  variable_del('print_robots_noarchive');
69
  variable_del('print_footer_options');
70
  variable_del('print_footer_user');
71
  variable_del('print_html_link_text');
72
  variable_del('print_html_link_use_alias');
73
  variable_del('print_text_links');
74
  variable_del('print_text_published');
75
  variable_del('print_text_retrieved');
76
  variable_del('print_text_source_url');
77
  $settings = db_query("SELECT name FROM {variable} WHERE name LIKE 'print\_display\_%'");
78
  foreach ($settings as $variable) {
79
    variable_del($variable->name);
80
  }
81
}
82

    
83
/**
84
 * Implements hook_schema().
85
 */
86
function print_schema() {
87
  $schema['print_node_conf'] = array(
88
    'description' => 'Printer-friendly version node-specific configuration settings',
89
    'fields' => array(
90
      'nid' => array(
91
        'type' => 'int',
92
        'unsigned' => TRUE,
93
        'not null' => TRUE,
94
        'description' => 'The {node}.nid of the node.',
95
      ),
96
      'link' => array(
97
        'type' => 'int',
98
        'unsigned' => TRUE,
99
        'not null' => TRUE,
100
        'default' => 1,
101
        'size' => 'tiny',
102
        'description' => 'Show link',
103
      ),
104
      'comments' => array(
105
        'type' => 'int',
106
        'unsigned' => TRUE,
107
        'not null' => TRUE,
108
        'default' => 1,
109
        'size' => 'tiny',
110
        'description' => 'Show link in individual comments',
111
      ),
112
      'url_list' => array(
113
        'type' => 'int',
114
        'unsigned' => TRUE,
115
        'not null' => TRUE,
116
        'default' => 1,
117
        'size' => 'tiny',
118
        'description' => 'Show Printer-friendly URLs list',
119
      ),
120
    ),
121
    'primary key' => array('nid'),
122
  );
123

    
124
  $schema['print_page_counter'] = array(
125
    'description' => 'Printer-friendly version access counter',
126
    'fields' => array(
127
      'path' => array(
128
        'type' => 'varchar',
129
        'length' => 255,
130
        'not null' => TRUE,
131
        'description' => 'Page path',
132
      ),
133
      'totalcount' => array(
134
        'type' => 'int',
135
        'unsigned' => TRUE,
136
        'not null' => TRUE,
137
        'default' => 0,
138
        'size' => 'big',
139
        'description' => 'Number of page accesses',
140
      ),
141
      'timestamp' => array(
142
        'type' => 'int',
143
        'unsigned' => TRUE,
144
        'not null' => TRUE,
145
        'default' => 0,
146
        'description' => 'Last access',
147
      ),
148
    ),
149
    'primary key' => array('path'),
150
  );
151

    
152
  return $schema;
153
}
154

    
155
/**
156
 * Remove hardcoded numeric deltas from all blocks
157
 */
158
function print_update_7000(&$sandbox) {
159
  $renamed_deltas = array(
160
    'print' => array(
161
      '0' => 'print-links',
162
      '1' => 'print-top',
163
    ),
164
  );
165

    
166
  update_fix_d7_block_deltas($sandbox, $renamed_deltas, array());
167
}
168

    
169
/**
170
 * Enable block and help area links
171
 */
172
function print_update_7101(&$sandbox) {
173
  $link_pos = variable_get('print_html_link_pos', drupal_json_decode('{ "link": "link", "block": "block", "help": "help" }'));
174
  $link_pos['block'] = 'block';
175
  $link_pos['help'] = 'help';
176
  variable_set('print_html_link_pos', $link_pos);
177
}
178

    
179
/**
180
 * Increase size of the path field in the print_page_counter table
181
 */
182
function print_update_7103(&$sandbox) {
183
  db_drop_primary_key('print_page_counter');
184
  db_change_field('print_page_counter', 'path', 'path',
185
    array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'description' => 'Page path'),
186
    array('primary key' => array('path')));
187
}