forked from nigelgbanks/islandora_openseadragon
-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathislandora_openseadragon.install
97 lines (91 loc) · 3.92 KB
/
islandora_openseadragon.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
/**
* @file
* Install hooks for this module.
*/
/**
* Implements hook_requirements().
*/
function islandora_openseadragon_requirements() {
module_load_include('inc', 'islandora_openseadragon', 'includes/utilities');
$requirements = array();
// Ensure translations don't break at install time.
$t = get_t();
if (!function_exists('libraries_get_libraries')) {
module_enable(array('libraries'));
}
if (!in_array('openseadragon', array_keys(libraries_get_libraries()))) {
$readme_link = l($t('README'), drupal_get_path('module', 'islandora_openseadragon') . '/README.txt');
$requirements['openseadragon'] = array(
'title' => $t('OpenSeadragon library'),
'description' => $t('OpenSeadragon library missing; please consult the !readme for installation instructions.', array('!readme' => $readme_link)),
'severity' => REQUIREMENT_ERROR,
);
}
else {
$installed_version = islandora_openseadragon_get_installed_version();
if (version_compare($installed_version, ISLANDORA_OPENSEADRAGON_REQUIRED_VERSION) < 0) {
$readme_link = l($t('README'), drupal_get_path('module', 'islandora_openseadragon') . '/README.txt');
$requirements['openseadragon'] = array(
'title' => $t('OpenSeadragon library'),
'description' => $t('OpenSeadragon library version (%installed_version) does not match required version (%required_version); please consult the !readme for installation instructions.', array(
'%installed_version' => $installed_version,
'%required_version' => ISLANDORA_OPENSEADRAGON_REQUIRED_VERSION,
'!readme' => $readme_link,
)),
'severity' => REQUIREMENT_ERROR,
);
}
}
return $requirements;
}
/**
* Implements hook_uninstall().
*/
function islandora_openseadragon_uninstall() {
$variables = array(
'islandora_openseadragon_settings',
'islandora_openseadragon_tile_size',
'islandora_openseadragon_tile_overlap',
'islandora_openseadragon_fit_to_aspect_ratio',
'islandora_openseadragon_tilesource',
'islandora_openseadragon_djatoka_url',
'islandora_openseadragon_iiif_url',
'islandora_openseadragon_iiif_token_header',
'islandora_openseadragon_iiif_identifier',
);
array_walk($variables, 'variable_del');
}
/**
* Update settings to new format.
*
* Migrates any options from the old version to the new version if they still
* exist.
*/
function islandora_openseadragon_update_7100(array &$sandbox) {
module_load_include('inc', 'islandora_openseadragon', 'includes/admin.form');
module_load_include('inc', 'islandora_openseadragon', 'includes/utilities');
// Get new OpenSeadragon default settings.
$new_settings = islandora_openseadragon_default_options();
// Get the old settings.
$old_settings = variable_get('islandora_openseadragon_settings', array());
if (isset($old_settings['djatokaServerBaseURL'])) {
$message = t('The Drupal variable islandora_openseadragon_settings["djatokaServerBaseURL"] has been moved to islandora_openseadragon_settings["islandora_openseadragon_djatoka_url"].');
trigger_error(check_plain($message), E_USER_DEPRECATED);
$new_settings['islandora_openseadragon_djatoka_url'] = $old_settings['djatokaServerBaseURL'];
unset($old_settings['djatokaServerBaseURL']);
}
// No longer exists.
if (isset($old_settings['wrapOverlays'])) {
$message = t('The Drupal variable islandora_openseadragon_settings["wrapOverlays"] is no longer in use and has been removed.');
trigger_error(check_plain($message), E_USER_DEPRECATED);
unset($old_settings['wrapOverlays']);
}
// The rest of the settings have the same name and will overwrite defaults.
$new_settings = array_replace($new_settings, $old_settings);
_islandora_openseadragon_normalize_settings($new_settings);
// Save updated OpenSeadragon settings.
variable_set('islandora_openseadragon_settings', $new_settings);
$t = get_t();
return $t("Islandora Openseadragon updates complete");
}