-
Notifications
You must be signed in to change notification settings - Fork 0
/
ffmpeg_wrapper.install
66 lines (58 loc) · 2.28 KB
/
ffmpeg_wrapper.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
<?php
/**
* @FILE Install file for ffmpeg_wrapper
*
*/
function ffmpeg_wrapper_install() {
// see if we can find ffmpeg
if ($path = exec('export PATH=$PATH:/sw/bin:/bin:/usr/bin:/usr/local/bin; which ffmpeg')) {
variable_set('ffmpeg_wrapper_path', $path);
drupal_set_message(t('The FFmpeg binary was found. You are ready to start transcoding files.'));
}
else {
drupal_set_message(t('The FFmpeg binary was not found. You will need to set the path by hand !here.',
array('!here' => l(t('here'), 'admin/settings/ffmpeg_wrapper'))
));
}
}
/**
* Implementation of hook_requirements().
*
* TODO: We could probably check the swfobject file's version here too, similar
* to how the jQuery_update 5.x module checks version of jQuery.
*/
function ffmpeg_wrapper_requirements($phase) {
$requirements = array();
$t = get_t();
// Do not link to the settings page when module is installed from install.php
// as part of an installation profile.
$args = array('!url' => function_exists('db_result') ? l($t('Please update your settings'), 'admin/settings/ffmpeg_wrapper') : $t('Please configure FFmpeg Wrapper after installation.'));
if (! variable_get('ffmpeg_wrapper_path', false)) {
$error_message = $t('The path to FFmpeg is not set correctly or missing. !url', $args);
}
else if (! file_exists(variable_get('ffmpeg_wrapper_path', false))) {
$error_message = $t('The path that you have set to FFmpeg does not appear to be correct. !url', $args);
}
if ($error_message) {
// we need to explicitly set the message when installing the module,
// because drupal_check_module() in install.inc doesn't print out
// warning messages, and we prefer to tell the user what's wrong.
if ($phase == 'install') {
drupal_set_message($error_message, 'warning');
}
$requirements['ffmpeg_wrapper'] = array(
'title' => $t('FFmpeg Wrapper'),
'description' => $error_message,
'severity' => $phase == 'install' ? REQUIREMENT_WARNING : REQUIREMENT_ERROR,
'value' => $t('Copy swfobject.js'),
);
}
elseif ($phase == 'runtime') {
$requirements['ffmpeg_wrapper'] = array(
'title' => $t('FFmpeg Wrapper'),
'severity' => REQUIREMENT_OK,
'value' => $t('Installed correctly'),
);
}
return $requirements;
}