You are here

function sharerich_requirements in Sharerich 7.2

Same name and namespace in other branches
  1. 7.3 sharerich.install \sharerich_requirements()

Implements hook_requirements().

File

./sharerich.install, line 80
Install hooks for Sharerich project.

Code

function sharerich_requirements($phase) {
  $requirements = array();
  $t = get_t();
  if ($phase == 'runtime') {
    module_load_include('module', 'libraries', 'libraries');

    // require.js library.
    $library = libraries_detect('rrssb');
    $requirements['sharerich_rrssb'] = array(
      'title' => $t('@name library', array(
        '@name' => $library['title'],
      )),
      'value' => $t('Unknown'),
    );
    $requirements['sharerich_rrssb']['severity'] = REQUIREMENT_OK;
    if (!$library['installed']) {
      $requirements['sharerich_rrssb']['value'] = ucfirst($library['error']);
      $requirements['sharerich_rrssb']['description'] = $library['error message'];
      $options = array(
        '!url' => $library['download url'],
        '@name' => $library['name'],
        '%path' => 'libraries/' . $library['machine name'],
      );
      $requirements['sharerich_rrssb']['description'] .= ' ' . $t('Download the library from the <a href="!url">download page</a> and make sure it is installed in the %path folder.', $options);
      $requirements['sharerich_rrssb']['severity'] = REQUIREMENT_ERROR;
    }
    else {
      $requirements['sharerich_rrssb']['value'] = $t('@version', array(
        '@version' => $library['version'],
      ));
    }
  }
  return $requirements;
}