You are here

function field_slideshow_requirements in Field Slideshow 8

Same name and namespace in other branches
  1. 8.2 field_slideshow.install \field_slideshow_requirements()
  2. 7.2 field_slideshow.install \field_slideshow_requirements()
  3. 7 field_slideshow.install \field_slideshow_requirements()

Implements hook_schema().

File

./field_slideshow.install, line 13
Install, update and uninstall functions for the Field Slideshow module.

Code

function field_slideshow_requirements($phase) {
  $requirements = array();
  if ($phase == 'runtime') {

    //$path = libraries_get_path('jquery.cycle');
    $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,
        )),
      );
    }
  }
  $carousel_used = FALSE;

  /*foreach (field_info_instances() as $bundles) {
      foreach ($bundles as $instances) {
        foreach ($instances as $field) {
          foreach ($field['display'] as $display) {
            if ($display['type'] == 'slideshow' && $display['settings']['slideshow_pager'] == 'carousel') {
              $carousel_used = TRUE;
              break 4;
            }
          }
        }
      }
    }*/
  if ($carousel_used) {
    $path = '';

    //$path = libraries_get_path('jquery.jcarousel');
    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 = '';

  //$path = libraries_get_path('jquery.imagesloaded');
  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;
}