You are here

photoswipe.install in PhotoSwipe 7

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_enable().
 */
function photoswipe_enable() {

  // Set jquery 1.7 as the jquery_update version.
  if (variable_get('jquery_update_jquery_version', 0) < 1.7) {
    variable_set('jquery_update_jquery_version', '1.7');
  }
}

/**
 * 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();

  // Ensure translations don't break at install time.
  $t = get_t();
  if ($phase == 'runtime') {
    $path = libraries_get_path('photoswipe');
    $version = photoswipe_get_version($path);
    $requirements['photoswipe'] = array(
      'title' => $t('PhotoSwipe'),
      'value' => $version,
      'severity' => REQUIREMENT_OK,
    );
    if (!$path || !file_exists($path . '/code.photoswipe.jquery-' . $version . '.min.js')) {
      $requirements['photoswipe']['value'] = $t('Third party PhotoSwipe software not properly installed');
      $requirements['photoswipe']['description'] = $t('PhotoSwipe was not found in the \'libraries\' folder (e.g. sites/all/libraries).');
      $requirements['photoswipe']['severity'] = REQUIREMENT_ERROR;
    }
  }
  return $requirements;
}

Functions