You are here

function jw_player_requirements in JW Player 7.2

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

Implements hook_requirements().

File

./jw_player.install, line 72
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();
  $requirements['jw_player'] = array(
    'title' => $t('JW Player'),
    'severity' => REQUIREMENT_OK,
  );

  // Player could be cloud-hosted so no reason to check in other phases.
  if ($phase === 'runtime') {
    if ($account_token = variable_get('jw_player_cloud_player_default', FALSE)) {

      // Cloud-hosted is a priority over self-hosted.
      $requirements['jw_player']['value'] = t('Cloud-Hosted');
    }
    else {
      $info = libraries_detect('jwplayer');
      if ($info['installed']) {
        $value = t('Self-Hosted') . " (v{$info['version']})";
        if (!($key = jw_player_get_key())) {
          $requirements['jw_player']['severity'] = REQUIREMENT_ERROR;
          $requirements['jw_player']['description'] = t('Please configure your Self-Hosted Player License Key from the <a href="@url">JW Player settings page</a>.', array(
            '@url' => url('admin/config/media/jw_player/settings'),
          ));
        }
      }
      else {
        $value = t('Not found');
        $requirements['jw_player']['description'] = t('Please consult README.txt for installation instructions.');
        $requirements['jw_player']['severity'] = REQUIREMENT_ERROR;
      }
      $requirements['jw_player']['value'] = $value;
    }
  }
  return $requirements;
}