forked from Islandora/islandora_solution_pack_large_image
-
Notifications
You must be signed in to change notification settings - Fork 0
/
islandora_large_image.install
123 lines (112 loc) · 4.12 KB
/
islandora_large_image.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php
/**
* @file
* islandora_large_image.install
*/
/**
* Implements hook_requirements().
*/
function islandora_large_image_requirements($phase) {
$requirements = array();
$t = get_t();
if (in_array($phase, array('install', 'runtime'))) {
$has_kakadu = _islandora_large_image_install_has_kakadu();
$has_jp2_imagemagick = _islandora_large_image_install_has_imagemagick_with_jpeg2000_support();
if ($has_kakadu) {
$requirements['islandora_large_image_kakadu'] = array(
'title' => $t("Islandora Solution Pack Large Image: Kakadu Image Compression"),
'value' => $t("Installed"),
'severity' => REQUIREMENT_INFO,
'description' => $t('The kdu_compress executable is accessible.'),
);
}
else {
$requirements['islandora_large_image_kakadu'] = array(
'title' => $t("Islandora Solution Pack Large Image: Kakadu Image Compression"),
'value' => $t("Not found"),
'severity' => REQUIREMENT_INFO,
'description' => $t('The kdu_compress executable was not found. If you wish to use Kakadu Image Compression it must be enabled and configured on the solution pack configuration page.'),
);
}
if ($has_jp2_imagemagick) {
$requirements['islandora_large_image_imagemagick'] = array(
'title' => $t("Islandora Solution Pack Large Image: Imagemagick Image Compression"),
'value' => $t("Installed"),
'severity' => REQUIREMENT_INFO,
'description' => $t('Imagemagick is present and appears to support JPEG2000.'),
);
}
else {
$requirements['islandora_large_image_imagemagick'] = array(
'title' => $t("Islandora Solution Pack Large Image: Imagemagick Image Compression"),
'value' => $t("Not installed"),
'severity' => REQUIREMENT_INFO,
'description' => $t('Imagemagick does not appears to support JPEG2000.'),
);
}
if (!($has_kakadu || $has_jp2_imagemagick)) {
$requirements['islandora_large_image_encoder'] = array(
'title' => $t("Islandora Solution Pack Large Image: JPEG 2000 image encoder"),
'value' => $t("Not installed"),
'severity' => REQUIREMENT_ERROR,
'description' => $t('A JPEG 2000 encoder is not installed/configured.'),
);
}
else {
$requirements['islandora_large_image_encoder'] = array(
'title' => $t("Islandora Solution Pack Large Image: JPEG 2000 image encoder"),
'value' => $t("Installed"),
'severity' => REQUIREMENT_OK,
'description' => $t('A JPEG 2000 encoder is installed.'),
);
}
}
return $requirements;
}
/**
* Helper to test if Kakadu appears to be available.
*/
function _islandora_large_image_install_has_kakadu() {
module_load_include('inc', 'islandora', 'includes/utilities');
$out = array();
$ret = 1;
$kdu_compress = variable_get('islandora_kakadu_url', 'kdu_compress');
$escaped_kdu_compress = escapeshellarg($kdu_compress);
$command = "command -v $escaped_kdu_compress >/dev/null 2>&1";
if (islandora_deployed_on_windows()) {
$command = "$escaped_kdu_compress >NUL 2>&1";
}
exec($command, $out, $ret);
return $ret == 0;
}
/**
* Helper to test that imagemagick appears to have JPEG 2000 support.
*/
function _islandora_large_image_install_has_imagemagick_with_jpeg2000_support() {
require_once __DIR__ . '/includes/utilities.inc';
return islandora_large_image_check_imagemagick_for_jpeg2000();
}
/**
* Implements hook_install().
*
* @see islandora_large_image_islandora_required_objects()
*/
function islandora_large_image_install() {
module_load_include('inc', 'islandora', 'includes/solution_packs');
islandora_install_solution_pack('islandora_large_image');
}
/**
* Implements hook_uninstall().
*/
function islandora_large_image_uninstall() {
module_load_include('inc', 'islandora', 'includes/solution_packs');
islandora_install_solution_pack('islandora_large_image', 'uninstall');
$variables = array(
'islandora_large_image_viewers',
'islandora_use_kakadu',
'islandora_lossless',
'islandora_large_image_uncompress_tiff',
'islandora_kakadu_url',
);
array_walk($variables, 'variable_del');
}