| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
/** |
| 5 |
* @FILE Install file for ffmpeg_wrapper |
| 6 |
* |
| 7 |
*/ |
| 8 |
|
| 9 |
function ffmpeg_wrapper_install() { |
| 10 |
// see if we can find ffmpeg |
| 11 |
if ($path = exec('export PATH=$PATH:/sw/bin:/bin:/usr/bin:/usr/local/bin; which ffmpeg')) { |
| 12 |
variable_set('ffmpeg_wrapper_path', $path); |
| 13 |
drupal_set_message(t('The FFmpeg binary was found. You are ready to start transcoding files.')); |
| 14 |
} |
| 15 |
else { |
| 16 |
drupal_set_message(t('The FFmpeg binary was not found. You will need to set the path by hand !here.', |
| 17 |
array('!here' => l(t('here'), 'admin/settings/ffmpeg_wrapper')) |
| 18 |
)); |
| 19 |
} |
| 20 |
} |
| 21 |
|
| 22 |
|
| 23 |
/** |
| 24 |
* Implementation of hook_requirements(). |
| 25 |
* |
| 26 |
* TODO: We could probably check the swfobject file's version here too, similar |
| 27 |
* to how the jQuery_update 5.x module checks version of jQuery. |
| 28 |
*/ |
| 29 |
function ffmpeg_wrapper_requirements($phase) { |
| 30 |
$requirements = array(); |
| 31 |
$t = get_t(); |
| 32 |
|
| 33 |
// Do not link to the settings page when module is installed from install.php |
| 34 |
// as part of an installation profile. |
| 35 |
$args = array('!url' => function_exists('db_result') ? l($t('Please update your settings'), 'admin/settings/ffmpeg_wrapper') : $t('Please configure FFmpeg Wrapper after installation.')); |
| 36 |
if (! variable_get('ffmpeg_wrapper_path', false)) { |
| 37 |
$error_message = $t('The path to FFmpeg is not set correctly or missing. !url', $args); |
| 38 |
} |
| 39 |
else if (! file_exists(variable_get('ffmpeg_wrapper_path', false))) { |
| 40 |
$error_message = $t('The path that you have set to FFmpeg does not appear to be correct. !url', $args); |
| 41 |
} |
| 42 |
|
| 43 |
if ($error_message) { |
| 44 |
// we need to explicitly set the message when installing the module, |
| 45 |
// because drupal_check_module() in install.inc doesn't print out |
| 46 |
// warning messages, and we prefer to tell the user what's wrong. |
| 47 |
if ($phase == 'install') { |
| 48 |
drupal_set_message($error_message, 'warning'); |
| 49 |
} |
| 50 |
$requirements['ffmpeg_wrapper'] = array( |
| 51 |
'title' => $t('FFmpeg Wrapper'), |
| 52 |
'description' => $error_message, |
| 53 |
'severity' => $phase == 'install' ? REQUIREMENT_WARNING : REQUIREMENT_ERROR, |
| 54 |
'value' => $t('Copy swfobject.js'), |
| 55 |
); |
| 56 |
} |
| 57 |
elseif ($phase == 'runtime') { |
| 58 |
$requirements['ffmpeg_wrapper'] = array( |
| 59 |
'title' => $t('FFmpeg Wrapper'), |
| 60 |
'severity' => REQUIREMENT_OK, |
| 61 |
'value' => $t('Installed correctly'), |
| 62 |
); |
| 63 |
} |
| 64 |
|
| 65 |
return $requirements; |
| 66 |
} |