You are here

field_slideshow.install in Field Slideshow 8.2

Install, update and uninstall functions for the Field Slideshow module.

File

field_slideshow.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the Field Slideshow module.
 */
use Drupal\Core\Url;

/**
 * Implements hook_schema().
 */
function field_slideshow_requirements($phase) {
  $requirements = array();
  if ($phase == 'runtime') {
    $path = '';
    if ($path == '') {
      $path = DRUPAL_ROOT . '/libraries/jquery.cycle';
    }
    if (file_exists($path . '/jquery.cycle.all.min.js') || file_exists($path . '/jquery.cycle.all.js')) {
      $requirements['field_slideshow_cycle_plugin'] = array(
        'title' => t('JQuery Cycle plugin'),
        'severity' => REQUIREMENT_OK,
        'value' => t('Installed'),
      );
    }
    else {
      $url = Url::fromUri('http://jquery.malsup.com/cycle/download.html');
      $requirements['field_slideshow_cycle_plugin'] = array(
        'title' => t('JQuery Cycle plugin'),
        'value' => t('Not found'),
        'severity' => REQUIREMENT_ERROR,
        'description' => t('You need to download the %name and move the downloaded js file(s) into the %path folder of your server.', array(
          '%name' => \Drupal::l(t('JQuery Cycle plugin'), $url),
          '%path' => $path,
        )),
      );
    }
  }

  // @todo Carousel code to be fixed
  $carousel_used = FALSE;
  if ($carousel_used) {
    $path = '';
    if ($path == '') {
      $path = DRUPAL_ROOT . '/libraries/jquery.jcarousel';
    }
    if (file_exists($path . '/lib/jquery.jcarousel.min.js') || file_exists($path . '/lib/jquery.jcarousel.js')) {
      $requirements['field_slideshow_jcarousel_plugin'] = array(
        'title' => t('JCarousel plugin'),
        'severity' => REQUIREMENT_OK,
        'value' => t('Installed'),
      );
    }
    else {
      $url = Url::fromUri('http://sorgalla.com/jcarousel/');
      $requirements['field_slideshow_jcarousel_plugin'] = array(
        'title' => t('JCarousel plugin'),
        'value' => t('Not found'),
        'severity' => REQUIREMENT_ERROR,
        'description' => t('You need to download the %name and move the content of the downloaded folder into the %path folder of your server. When this is done there should be a file sites/all/libraries/jquery.jcarousel/lib/jquery.jcarousel.js, or jquery.jcarousel.min.js', array(
          '%name' => \Drupal::l(t('JCarousel plugin'), $url),
          '%path' => $path,
        )),
      );
    }
  }
  $path = '';
  if ($path == '') {
    $path = DRUPAL_ROOT . '/libraries/jquery.imagesloaded';
  }
  if (file_exists($path . '/jquery.imagesloaded.min.js') || file_exists($path . '/jquery.imagesloaded.js')) {
    $requirements['field_slideshow_imagesloaded_plugin'] = array(
      'title' => t('JQuery ImagesLoaded plugin'),
      'severity' => REQUIREMENT_OK,
      'value' => t('Installed'),
    );
  }
  else {
    $url = Url::fromUri('https://github.com/desandro/imagesloaded/downloads');
    $requirements['field_slideshow_imagesloaded_plugin'] = array(
      'title' => t('JQuery ImagesLoaded plugin'),
      'value' => t('Not found'),
      'severity' => REQUIREMENT_WARNING,
      'description' => t('For best results, you should download the %name and move the downloaded js file(s) into the %path folder of your server.', array(
        '%name' => \Drupal::l(t('JQuery ImagesLoaded plugin'), $url),
        '%path' => $path,
      )),
    );
  }
  return $requirements;
}

Functions

Namesort descending Description
field_slideshow_requirements Implements hook_schema().