You are here

function jw_player_requirements in JW Player 7

Same name and namespace in other branches
  1. 8 jw_player.install \jw_player_requirements()
  2. 7.2 jw_player.install \jw_player_requirements()

Implements hook_requirements().

File

./jw_player.install, line 59
Install, update and uninstall functions for the JW Player module.

Code

function jw_player_requirements($phase) {
  $requirements = array();

  // Ensure translations don't break at install time
  $t = get_t();
  drupal_load('module', 'libraries');
  $directory = libraries_get_path('jwplayer');

  // Check the exisence of the JW Player Library
  if ($phase == 'runtime') {
    $errors = array();
    foreach (array(
      'player.swf',
      'jwplayer.js',
    ) as $file) {
      if (!file_exists($directory . '/' . $file)) {
        $errors[] = $t('The file %file is not present in the directory %directory', array(
          '%file' => $file,
          '%directory' => $directory,
        ));
      }
    }
    $requirements['jw_player'] = array(
      'title' => $t('JW Player'),
      'value' => !empty($errors) ? theme('item_list', array(
        'items' => $errors,
      )) . $t('Please consult INSTALL.txt for installation instructions.') : $t('Installed correctly'),
      'severity' => !empty($errors) ? REQUIREMENT_ERROR : REQUIREMENT_OK,
    );
  }
  return $requirements;
}