You are here

function jquery_update_requirements in jQuery Update 5.2

Same name and namespace in other branches
  1. 5 jquery_update.module \jquery_update_requirements()
  2. 6.2 jquery_update.install \jquery_update_requirements()
  3. 6 jquery_update.install \jquery_update_requirements()
  4. 7.3 jquery_update.install \jquery_update_requirements()
  5. 7 jquery_update.install \jquery_update_requirements()
  6. 7.2 jquery_update.install \jquery_update_requirements()

Implementation of hook_requirements().

File

./jquery_update.install, line 11
Install file for jQuery Update.

Code

function jquery_update_requirements($phase) {
  $requirements = array();
  $t = get_t();
  switch ($phase) {
    case 'install':
    case 'runtime':
      $path = drupal_get_path('module', 'jquery_update') . '/misc/jquery.js';
      if (file_exists($path) && file_exists('misc/jquery.js') && md5_file($path) != md5_file('misc/jquery.js')) {
        $requirements['jquery'] = array(
          'title' => $t('Please copy jQuery'),
          'description' => $t('In order for the jQuery Update module to work correctly, please copy the file at %mod and use it to replace %core.', array(
            '%core' => 'misc/jquery.js',
            '%mod' => $path,
          )),
          'severity' => $phase == 'install' ? REQUIREMENT_WARNING : REQUIREMENT_ERROR,
          'value' => $t('Copy jquery.js'),
        );
      }
      elseif (!file_exists($path)) {
        $requirements['jquery'] = array(
          'title' => $t('jquery.js no longer exists in the jQuery Update directory'),
          'description' => $t('You probably <em>moved</em> rather than <em>copied</em> the jquery.js file from %mod to %core. You should leave a copy of this file in the module directory so that will not lose this file when you upgrade to another revision of Drupal.', array(
            '%core' => 'misc/jquery.js',
            '%mod' => $path,
          )),
          'severity' => $phase == 'install' ? REQUIREMENT_WARNING : REQUIREMENT_ERROR,
          'value' => $t('Copy jquery.js'),
        );
      }
      elseif ($phase == 'runtime') {
        $requirements['jquery'] = array(
          'title' => $t('jQuery Update'),
          'description' => $t('The current installed version of jQuery is !version', array(
            '%core' => 'misc/jquery.js',
            '%mod' => $path,
            '!version' => '<strong><script>document.write($().jquery);</script><noscript>javascript not enabled</noscript></strong>',
          )),
          'severity' => REQUIREMENT_OK,
          'value' => $t('Installed correctly'),
        );
      }
  }
  return $requirements;
}