1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Install, update and uninstall functions for the colorbox module.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* Implements hook_requirements().
|
10 |
|
|
*/
|
11 |
|
|
function colorbox_requirements($phase) {
|
12 |
|
|
$requirements = array();
|
13 |
|
|
|
14 |
|
|
if ($phase == 'runtime') {
|
15 |
|
|
$t = get_t();
|
16 |
|
|
$library = libraries_detect('colorbox');
|
17 |
|
|
$error_type = isset($library['error']) ? drupal_ucfirst($library['error']) : '';
|
18 |
|
|
$error_message = isset($library['error message']) ? $library['error message'] : '';
|
19 |
|
|
|
20 |
|
|
if (empty($library['installed'])) {
|
21 |
|
|
$requirements['colorbox_plugin'] = array(
|
22 |
|
|
'title' => $t('Colorbox plugin'),
|
23 |
|
|
'value' => $t('@e: At least @a', array('@e' => $error_type, '@a' => COLORBOX_MIN_PLUGIN_VERSION)),
|
24 |
|
|
'severity' => REQUIREMENT_ERROR,
|
25 |
|
|
'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('!error' => $error_message, '!colorbox' => l($t('Colorbox plugin'), $library['download url']), '%path' => 'sites/all/libraries')),
|
26 |
|
|
);
|
27 |
|
|
}
|
28 |
|
|
elseif (version_compare($library['version'], COLORBOX_MIN_PLUGIN_VERSION, '>=')) {
|
29 |
|
|
$requirements['colorbox_plugin'] = array(
|
30 |
|
|
'title' => $t('Colorbox plugin'),
|
31 |
|
|
'severity' => REQUIREMENT_OK,
|
32 |
|
|
'value' => $library['version'],
|
33 |
|
|
);
|
34 |
|
|
}
|
35 |
|
|
else {
|
36 |
|
|
$requirements['colorbox_plugin'] = array(
|
37 |
|
|
'title' => $t('Colorbox plugin'),
|
38 |
|
|
'value' => $t('At least @a', array('@a' => COLORBOX_MIN_PLUGIN_VERSION)),
|
39 |
|
|
'severity' => REQUIREMENT_ERROR,
|
40 |
|
|
'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('!colorbox' => l($t('Colorbox plugin'), $library['download url']), '%path' => $library['library path'])),
|
41 |
|
|
);
|
42 |
|
|
}
|
43 |
|
|
}
|
44 |
|
|
|
45 |
|
|
return $requirements;
|
46 |
|
|
}
|
47 |
|
|
|
48 |
|
|
/**
|
49 |
|
|
* Implements hook_uninstall().
|
50 |
|
|
*/
|
51 |
|
|
function colorbox_uninstall() {
|
52 |
|
|
db_delete('variable')->condition('name', db_like('colorbox_') . '%', 'LIKE')->execute();
|
53 |
|
|
}
|
54 |
|
|
|
55 |
|
|
/**
|
56 |
|
|
* Delete the unused colorbox_login_form variable.
|
57 |
|
|
*/
|
58 |
|
|
function colorbox_update_7001() {
|
59 |
|
|
$ret = array();
|
60 |
|
|
variable_del('colorbox_login_form');
|
61 |
|
|
|
62 |
|
|
return $ret;
|
63 |
|
|
}
|
64 |
|
|
|
65 |
|
|
/**
|
66 |
|
|
* Delete the unused colorbox_title_trim and
|
67 |
|
|
* colorbox_title_trim_length variables.
|
68 |
|
|
*/
|
69 |
|
|
function colorbox_update_7002() {
|
70 |
|
|
$ret = array();
|
71 |
|
|
$colorbox_title_trim = variable_get('colorbox_title_trim', NULL);
|
72 |
|
|
$colorbox_title_trim_length = variable_get('colorbox_title_trim_length', NULL);
|
73 |
|
|
if (!empty($colorbox_title_trim)) {
|
74 |
|
|
variable_set('colorbox_caption_trim', $colorbox_title_trim);
|
75 |
|
|
}
|
76 |
|
|
if (!empty($colorbox_title_trim_length)) {
|
77 |
|
|
variable_set('colorbox_caption_trim_length', $colorbox_title_trim_length);
|
78 |
|
|
}
|
79 |
|
|
variable_del('colorbox_title_trim');
|
80 |
|
|
variable_del('colorbox_title_trim_length');
|
81 |
|
|
|
82 |
|
|
return $ret;
|
83 |
|
|
}
|
84 |
|
|
|
85 |
|
|
/**
|
86 |
|
|
* Delete the unused colorbox_login and colorbox_login_links variables.
|
87 |
|
|
*/
|
88 |
|
|
function colorbox_update_7200() {
|
89 |
|
|
$ret = array();
|
90 |
|
|
variable_del('colorbox_login');
|
91 |
|
|
variable_del('colorbox_login_links');
|
92 |
|
|
|
93 |
|
|
return $ret;
|
94 |
|
|
}
|
95 |
|
|
|
96 |
|
|
/**
|
97 |
|
|
* Delete the unused colorbox_auto_image_nodes variable.
|
98 |
|
|
*/
|
99 |
|
|
function colorbox_update_7201() {
|
100 |
|
|
$ret = array();
|
101 |
|
|
variable_del('colorbox_auto_image_nodes');
|
102 |
|
|
|
103 |
|
|
return $ret;
|
104 |
|
|
}
|
105 |
|
|
|
106 |
|
|
/**
|
107 |
|
|
* Update the colorbox_compression_type variable.
|
108 |
|
|
*/
|
109 |
|
|
function colorbox_update_7202() {
|
110 |
|
|
$ret = array();
|
111 |
|
|
if (variable_get('colorbox_compression_type', 'minified') == 'none') {
|
112 |
|
|
variable_set('colorbox_compression_type', 'source');
|
113 |
|
|
}
|
114 |
|
|
else {
|
115 |
|
|
variable_set('colorbox_compression_type', 'minified');
|
116 |
|
|
}
|
117 |
|
|
|
118 |
|
|
return $ret;
|
119 |
|
|
}
|