-
Notifications
You must be signed in to change notification settings - Fork 2
/
islandora_default_thumbs.install
55 lines (47 loc) · 1.69 KB
/
islandora_default_thumbs.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
<?php
/**
* @file
* Install file, remove files and module variables.
*/
/**
* Implements hook_uninstall().
*/
function islandora_default_thumbs_uninstall() {
module_load_include('inc', 'islandora_basic_collection', 'includes/utilities');
module_load_include('inc', 'islandora', 'includes/utilities');
module_load_include('inc', 'islandora_default_thumbs', 'includes/utilities');
// Define our master variables array.
$variables = array(
'islandora_default_thumbs_replacements',
'islandora_default_thumbs_missing_thumbnail',
'islandora_default_thumbs_default_tn_datastream',
'islandora_default_thumbs_force_thumb_config',
'islandora_default_thumbs_file_fids',
);
// Retrieve current configuration.
$current_config = islandora_default_thumbs_configuration();
// Delete the default thumb.
if ($current_config['missing_obj_thumb'] != 0 && $current_config['missing_obj_thumb'] != NULL) {
$file = file_load($current_config['missing_obj_thumb']);
file_delete($file, TRUE);
}
// Delete compare thumbs.
foreach ($current_config['compare_thumbs'] as $fid => $hash) {
if ($fid != 0 && $fid != NULL) {
$file = file_load($fid);
file_delete($file, TRUE);
}
}
// Delete thumb replacements.
$content_models = islandora_get_content_models();
foreach ($content_models as $pid => $content_model) {
$default = str_replace(":", "__", $content_model['pid']);
$fid = $current_config['thumb_replacements'][$content_model['pid']]['thumb_override'][$default];
if ($fid != 0 && $fid != NULL) {
$file = file_load($fid);
file_delete($file, TRUE);
}
}
// Finally, clean up remaining variables.
array_walk($variables, 'variable_del');
}