You are here

photoswipe.install in PhotoSwipe 7.2

Install, uninstall and update hooks for Photswipe module.

File

photoswipe.install
View source
<?php

/**
 * @file
 * Install, uninstall and update hooks for Photswipe module.
 */

/**
 * Implements hook_uninstall().
 */
function photoswipe_uninstall() {

  // Remove photoswipe variables.
  db_delete('variable')
    ->condition('name', 'photoswipe_%', 'LIKE')
    ->execute();
  cache_clear_all('variables', 'cache_bootstrap');
}

/**
 * Implements hook_requirements().
 */
function photoswipe_requirements($phase) {
  $requirements = array();
  if ($phase == 'runtime') {
    $t = get_t();
    $library = libraries_detect('photoswipe');
    $error_type = isset($library['error']) ? drupal_ucfirst($library['error']) : '';
    $error_message = isset($library['error message']) ? $library['error message'] : '';
    if (empty($library['installed'])) {
      $requirements['photoswipe_plugin'] = array(
        'title' => $t('Photoswipe plugin'),
        'value' => $t('@e: At least @a', array(
          '@e' => $error_type,
          '@a' => PHOTOSWIPE_MIN_PLUGIN_VERSION,
        )),
        'severity' => REQUIREMENT_ERROR,
        'description' => $t('!error You need to download the !photoswipe, extract the archive and place the photoswipe directory in the %path directory on your server.', array(
          '!error' => $error_message,
          '!photoswipe' => l($t('Photoswipe plugin'), $library['download url']),
          '%path' => 'sites/all/libraries',
        )),
      );
    }
    elseif (version_compare($library['version'], PHOTOSWIPE_MIN_PLUGIN_VERSION, '>=')) {
      $requirements['photoswipe_plugin'] = array(
        'title' => $t('Photoswipe plugin'),
        'severity' => REQUIREMENT_OK,
        'value' => $library['version'],
      );
    }
    else {
      $requirements['photoswipe_plugin'] = array(
        'title' => $t('Photoswipe plugin'),
        'value' => $t('At least @a', array(
          '@a' => PHOTOSWIPE_MIN_PLUGIN_VERSION,
        )),
        'severity' => REQUIREMENT_ERROR,
        'description' => $t('You need to download a later version of the !photoswipe and replace the old version located in the %path directory on your server.', array(
          '!photoswipe' => l($t('Photoswipe plugin'), $library['download url']),
          '%path' => $library['library path'],
        )),
      );
    }

    // Check for the minimum required jQuery version.
    $jquery_version = variable_get('jquery_update_jquery_version', '1.10');
    if (!version_compare($jquery_version, '1.7', '>=')) {
      $requirements['photoswipe_plugin'] = array(
        'description' => $t('Incorrect jQuery version detected. Photoswipe requires jQuery 1.7 or higher. Please change your <a href="!settings">jQuery Update settings</a>.', array(
          '!settings' => url('admin/config/development/jquery_update'),
        )),
        'severity' => REQUIREMENT_ERROR,
        'value' => $t('Not installed. Please enable jQuery 1.7 or higher.'),
        'title' => $t('Photoswipe plugin'),
      );
    }
  }
  return $requirements;
}

/**
 * Trigger cache clear.
 *
 * Empty update function to trigger cache clear after changing field formatter
 * settings.
 */
function photoswipe_update_7001() {

  // Do nothing.
}

/**
 * Trigger cache clear.
 *
 * Empty update function to trigger cache clear after changing field formatter
 * settings.
 */
function photoswipe_update_7002() {

  // Do nothing.
}

Functions

Namesort descending Description
photoswipe_requirements Implements hook_requirements().
photoswipe_uninstall Implements hook_uninstall().
photoswipe_update_7001 Trigger cache clear.
photoswipe_update_7002 Trigger cache clear.