You are here

jqmulti.install in jQuery Multi 7

Same filename and directory in other branches
  1. 6 jqmulti.install

Install file for the jQuery Multi module.

File

jqmulti.install
View source
<?php

/**
 * @file
 * Install file for the jQuery Multi module.
 */

/**
 * Implements hook_uninstall().
 */
function jqmulti_uninstall() {
  $vars = array(
    'version',
    'libraries',
    'load_always',
    'load_libraries_always',
  );
  foreach ($vars as $var) {
    variable_del('jqmulti_' . $var);
  }
  cache_clear_all('jqmulti_files', 'cache');
}

/**
 * Implements hook_requirements().
 */
function jqmulti_requirements($phase) {
  require_once dirname(__FILE__) . '/jqmulti.module';
  $requirements = array();
  $requirements['jqmulti_jquery'] = array(
    'title' => 'jQuery Multi jQuery library',
  );
  switch ($phase) {
    case 'install':
    case 'runtime':
      if (function_exists('libraries_get_path')) {
        $version = jqmulti_get_version(TRUE);
        if (!$version) {
          $requirements['jqmulti_jquery']['description'] = 'jQuery Multi: Could not locate a jQuery library. Please look at the README for instructions and ensure you have placed the library correctly.';
          $requirements['jqmulti_jquery']['severity'] = REQUIREMENT_ERROR;
        }
        else {
          $requirements['jqmulti_jquery']['value'] = $version;
          $requirements['jqmulti_jquery']['severity'] = REQUIREMENT_OK;
        }
      }
  }
  return $requirements;
}

/**
 * Refresh the files listing.
 */
function jqmulti_update_7101() {
  jqmulti_get_files(TRUE);
}

/**
 * Enable the new 'Always load libraries and files' option, to ensure the module's
 * behavior is not changed.
 */
function jqmulti_update_7102() {

  /*
   * Set the default value for the new option to include libraries assigned to the
   * jqmulti jQuery library on all pages automatically.
   *
   * The logical setting for this on new sites is disabled. However,
   * this is enabled to mimic existing functionality, so existing
   * sites aren't unexpectedly affected.
   */
  variable_set('jqmulti_load_files_always', TRUE);

  // Display a message to the user to alert them to this new setting.
  drupal_set_message(t('The jqmulti module previously always included all its files and libraries on every page. This is now an option you can disable, so you can load JS selectively only on some pages.') . '<br />' . t('This has been enabled for you so that the module functions exactly as it did before.') . '<br />' . t('You may choose to disable this at the <a href="@url">jqmulti admin settings page</a>.', array(
    '@url' => url('admin/config/system/jqmulti'),
  )));
  return;
}

Functions

Namesort descending Description
jqmulti_requirements Implements hook_requirements().
jqmulti_uninstall Implements hook_uninstall().
jqmulti_update_7101 Refresh the files listing.
jqmulti_update_7102 Enable the new 'Always load libraries and files' option, to ensure the module's behavior is not changed.