Révision a60304ed
Ajouté par Assos Assos il y a plus de 7 ans
drupal7/sites/all/modules/flexslider/flexslider.install | ||
---|---|---|
83 | 83 |
|
84 | 84 |
// Check to see if the flexslider library is available |
85 | 85 |
if ($phase == 'runtime') { |
86 |
$requirements['flexslider'] = array( |
|
87 |
'title' => $t('FlexSlider'), |
|
88 |
// @todo have the version automatically detected |
|
89 |
'description' => $t('Version 2.0 installed'), |
|
90 |
'severity' => REQUIREMENT_OK, |
|
91 |
); |
|
92 |
_flexslider_requirements_library_installed($requirements); |
|
86 |
$library = libraries_detect('flexslider'); |
|
87 |
|
|
88 |
if ($library['installed']) { |
|
89 |
$version = explode('.', $library['version']); |
|
90 |
|
|
91 |
if ($version[0] == FLEXSLIDER_COMPATIBLE_MAJOR_VERSION) { |
|
92 |
$requirements['flexslider'] = array( |
|
93 |
'value' => $library['version'], |
|
94 |
'severity' => REQUIREMENT_OK, |
|
95 |
); |
|
96 |
} |
|
97 |
else { |
|
98 |
$requirements['flexslider'] = array( |
|
99 |
'value' => $library['version'], |
|
100 |
'description' => $t('Incompatible version detected. The FlexSlider library version must be from the %version.x branch.', array('%version' => FLEXSLIDER_COMPATIBLE_MAJOR_VERSION)), |
|
101 |
'severity' => REQUIREMENT_WARNING, |
|
102 |
); |
|
103 |
} |
|
104 |
} |
|
105 |
else { |
|
106 |
$requirements['flexslider'] = array( |
|
107 |
'value' => $t('FlexSlider library not found.'), |
|
108 |
'description' => $t('The FlexSlider library could not be detected. Please consult the README.md for installation instructions.'), |
|
109 |
'severity' => REQUIREMENT_ERROR, |
|
110 |
); |
|
111 |
} |
|
112 |
|
|
113 |
$requirements['flexslider']['title'] = $t('FlexSlider'); |
|
93 | 114 |
} |
115 |
|
|
94 | 116 |
return $requirements; |
95 | 117 |
} |
96 | 118 |
|
... | ... | |
130 | 152 |
*/ |
131 | 153 |
function flexslider_update_7200(&$sandbox) { |
132 | 154 |
$t = get_t(); |
133 |
|
|
155 |
|
|
156 |
module_load_include('module', 'flexslider', 'flexslider'); |
|
134 | 157 |
$optionsets = flexslider_optionset_load_all(); |
135 | 158 |
|
136 | 159 |
foreach ($optionsets as $optionset) { |
... | ... | |
186 | 209 |
} |
187 | 210 |
|
188 | 211 |
/** |
189 |
* Check if the library is available
|
|
212 |
* Implements hook_update_N().
|
|
190 | 213 |
* |
191 |
* @param array $requirements |
|
192 |
* Requirements definition |
|
214 |
* Remove the flexslider_version variable. |
|
193 | 215 |
*/ |
194 |
function _flexslider_requirements_library_installed(&$requirements) { |
|
195 |
$t = get_t(); |
|
196 |
|
|
197 |
$path = libraries_get_path('flexslider'); |
|
198 |
$installed = file_exists($path . '/jquery.flexslider-min.js') && file_exists($path . '/jquery.flexslider.js'); |
|
199 |
|
|
200 |
// Check the results of the test |
|
201 |
if (!$installed) { |
|
202 |
$requirements['flexslider']['description'] = $t('FlexSlider library not found. Please consult the README.txt for installation instructions.'); |
|
203 |
$requirements['flexslider']['severity'] = REQUIREMENT_ERROR; |
|
204 |
$requirements['flexslider']['value'] = $t('FlexSlider library not found.'); |
|
205 |
return; |
|
206 |
} |
|
207 |
|
|
208 |
$js = file_exists($path . '/jquery.flexslider-min.js') ? fopen($path . '/jquery.flexslider-min.js', 'r') : fopen($path . '/jquery.flexslider.js', 'r'); |
|
209 |
$header = fread($js, 64); |
|
210 |
$matches = array(); |
|
211 |
if (preg_match("/ v([0-9]+)\.([0-9]+)/", $header, $matches)) { |
|
212 |
if (!($matches[1] == 2 and $matches[2] >= 0)) { |
|
213 |
$requirements['flexslider']['description'] = $t('FlexSlider must be version 2.0 or higher, but lower than version 3.0. Please consult the README.txt for installation instructions.'); |
|
214 |
$requirements['flexslider']['severity'] = REQUIREMENT_WARNING; |
|
215 |
$requirements['flexslider']['value'] = $t('Incorrect version detected.'); |
|
216 |
return; |
|
217 |
} |
|
218 |
else { |
|
219 |
$version = $matches[1] . "." . $matches[2]; |
|
220 |
variable_set('flexslider_version', $version); |
|
221 |
$requirements['flexslider']['description'] = $t('Version %version installed', array( '%version' => $version)); |
|
222 |
$requirements['flexslider']['value'] = $t('FlexSlider library installed.'); |
|
223 |
return; |
|
224 |
} |
|
225 |
} |
|
226 |
else { |
|
227 |
$requirements['flexslider']['description'] = $t('FlexSlider version could not be determined. Please consult the README.txt for installation instructions.'); |
|
228 |
$requirements['flexslider']['severity'] = REQUIREMENT_WARNING; |
|
229 |
$requirements['flexslider']['value'] = $t('Unable to detect version.'); |
|
230 |
} |
|
216 |
function flexslider_update_7203(&$sandbox) { |
|
217 |
variable_del('flexslider_version'); |
|
231 | 218 |
} |
232 | 219 |
|
233 | 220 |
// @todo add hook_update_N function to migrate old option set data to new values |
Formats disponibles : Unified diff
Weekly update of contrib modules