You are here

function shadowbox_requirements in Shadowbox 6.3

Same name and namespace in other branches
  1. 8 shadowbox.install \shadowbox_requirements()
  2. 5.2 shadowbox.install \shadowbox_requirements()
  3. 5 shadowbox.install \shadowbox_requirements()
  4. 6.4 shadowbox.install \shadowbox_requirements()
  5. 6 shadowbox.install \shadowbox_requirements()
  6. 6.2 shadowbox.install \shadowbox_requirements()
  7. 7.4 shadowbox.install \shadowbox_requirements()
  8. 7.3 shadowbox.install \shadowbox_requirements()

Implementation of hook_requirements().

File

./shadowbox.install, line 25
Shadowbox module install file.

Code

function shadowbox_requirements($phase) {
  $requirements = array();
  $t = get_t();
  $shadowbox_site = 'http://www.shadowbox-js.com/';
  switch ($phase) {
    case 'runtime':
      $shadowbox_path = SHADOWBOX_DEFAULT_PATH;
      $path = variable_get('shadowbox_location', $shadowbox_path);
      if (!file_exists($path)) {
        $requirements['shadowbox'] = array(
          'title' => $t('Shadowbox'),
          'description' => $t('In order for the Shadowbox module to work, the third party Shadowbox distribution should be downloaded and its location set. It is recommended to put the third party plugin in sites/all/libraries/shadowbox but the location can be changed in the !settings. Currently looking for shadowbox in %path', array(
            '!settings' => l('settings', 'admin/settings/shadowbox'),
            '%path' => $path,
          )),
          'severity' => $phase == 'install' ? REQUIREMENT_WARNING : REQUIREMENT_ERROR,
          'value' => $t('Third party !shadowbox software missing', array(
            '!shadowbox' => l('Shadowbox', $shadowbox_site),
          )),
        );
      }
      elseif (!file_exists("{$path}/shadowbox.js") || !file_exists("{$path}/adapters/shadowbox-jquery.js")) {
        $requirements['shadowbox'] = array(
          'title' => $t('Shadowbox'),
          'description' => $t('The <code>%path</code> path exists but it appears that the directory structure underneath is incorrect. Please check that <code>%shadowbox</code> and <code>%jquery</code> exist.', array(
            '%path' => $path,
            '%shadowbox' => "{$path}/shadowbox.js",
            '%jquery' => "{$path}/adapters/shadowbox-jquery.js",
          )),
          'severity' => $phase == 'install' ? REQUIREMENT_WARNING : REQUIREMENT_ERROR,
          'value' => $t('3rd party Shadowbox software not properly installed'),
        );
      }
      elseif ($phase == 'runtime') {
        $requirements['shadowbox'] = array(
          'title' => $t('Shadowbox'),
          'severity' => REQUIREMENT_OK,
          'value' => $t('Installed correctly'),
        );
      }
  }
  return $requirements;
}