Projet

Général

Profil

Paste
Télécharger (3,93 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / colorbox / colorbox.install @ b433176d

1
<?php
2

    
3
/**
4
 * @file
5
 * Install, update and uninstall functions for the colorbox module.
6
 */
7

    
8
/**
9
 * Implements hook_enable().
10
 */
11
function colorbox_enable() {
12
  drupal_set_message(t('Thanks for installing Colorbox'));
13
  drupal_set_message(t('You may configure Colorbox by visiting <a href="@url_settings">@url_settings</a>', array(
14
    '@url_settings' => url('admin/config/media/colorbox'),
15
  )));
16
}
17

    
18
/**
19
 * Implements hook_requirements().
20
 */
21
function colorbox_requirements($phase) {
22
  $requirements = array();
23

    
24
  if ($phase == 'runtime') {
25
    $t = get_t();
26
    $library = libraries_detect('colorbox');
27
    $error_type = isset($library['error']) ? drupal_ucfirst($library['error']) : '';
28
    $error_message = isset($library['error message']) ? $library['error message'] : '';
29

    
30
    if (empty($library['installed'])) {
31
      $requirements['colorbox_plugin'] = array(
32
        'title' => $t('Colorbox plugin'),
33
        'value' => $t('@e: At least @a', array('@e' => $error_type, '@a' => COLORBOX_MIN_PLUGIN_VERSION)),
34
        'severity' => REQUIREMENT_ERROR,
35
        'description' => $t('!error You need to download the !colorbox, extract the archive and place the colorbox directory in the %path directory on your server.', array(
36
          '!error' => $error_message,
37
          '!colorbox' => l($t('Colorbox plugin'),
38
          $library['download url']),
39
          '%path' => 'sites/all/libraries',
40
        )),
41
      );
42
    }
43
    elseif (version_compare($library['version'], COLORBOX_MIN_PLUGIN_VERSION, '>=')) {
44
      $requirements['colorbox_plugin'] = array(
45
        'title' => $t('Colorbox plugin'),
46
        'severity' => REQUIREMENT_OK,
47
        'value' => $library['version'],
48
      );
49
    }
50
    else {
51
      $requirements['colorbox_plugin'] = array(
52
        'title' => $t('Colorbox plugin'),
53
        'value' => $t('At least @a', array('@a' => COLORBOX_MIN_PLUGIN_VERSION)),
54
        'severity' => REQUIREMENT_ERROR,
55
        'description' => $t('You need to download a later version of the !colorbox and replace the old version located in the %path directory on your server.', array(
56
          '!colorbox' => l($t('Colorbox plugin'),
57
          $library['download url']),
58
          '%path' => $library['library path'],
59
        )),
60
      );
61
    }
62
  }
63

    
64
  return $requirements;
65
}
66

    
67
/**
68
 * Implements hook_uninstall().
69
 */
70
function colorbox_uninstall() {
71
  db_delete('variable')->condition('name', db_like('colorbox_') . '%', 'LIKE')->execute();
72
}
73

    
74
/**
75
 * Delete the unused colorbox_login_form variable.
76
 */
77
function colorbox_update_7001() {
78
  $ret = array();
79
  variable_del('colorbox_login_form');
80

    
81
  return $ret;
82
}
83

    
84
/**
85
 * Implements hook_update_N().
86
 *
87
 * Delete the unused colorbox_title_trim and colorbox_title_trim_length
88
 * variables.
89
 */
90
function colorbox_update_7002() {
91
  $ret = array();
92
  $colorbox_title_trim = variable_get('colorbox_title_trim', NULL);
93
  $colorbox_title_trim_length = variable_get('colorbox_title_trim_length', NULL);
94
  if (!empty($colorbox_title_trim)) {
95
    variable_set('colorbox_caption_trim', $colorbox_title_trim);
96
  }
97
  if (!empty($colorbox_title_trim_length)) {
98
    variable_set('colorbox_caption_trim_length', $colorbox_title_trim_length);
99
  }
100
  variable_del('colorbox_title_trim');
101
  variable_del('colorbox_title_trim_length');
102

    
103
  return $ret;
104
}
105

    
106
/**
107
 * Delete the unused colorbox_login and colorbox_login_links variables.
108
 */
109
function colorbox_update_7200() {
110
  $ret = array();
111
  variable_del('colorbox_login');
112
  variable_del('colorbox_login_links');
113

    
114
  return $ret;
115
}
116

    
117
/**
118
 * Delete the unused colorbox_auto_image_nodes variable.
119
 */
120
function colorbox_update_7201() {
121
  $ret = array();
122
  variable_del('colorbox_auto_image_nodes');
123

    
124
  return $ret;
125
}
126

    
127
/**
128
 * Update the colorbox_compression_type variable.
129
 */
130
function colorbox_update_7202() {
131
  $ret = array();
132
  if (variable_get('colorbox_compression_type', 'minified') == 'none') {
133
    variable_set('colorbox_compression_type', 'source');
134
  }
135
  else {
136
    variable_set('colorbox_compression_type', 'minified');
137
  }
138

    
139
  return $ret;
140
}