You are here

views_slideshow_cycle.install in Views Slideshow 7.3

Same filename and directory in other branches
  1. 6.3 contrib/views_slideshow_cycle/views_slideshow_cycle.install

Install/requirements functions for Views Slideshow: Cycle.

File

contrib/views_slideshow_cycle/views_slideshow_cycle.install
View source
<?php

/**
 * @file
 * Install/requirements functions for Views Slideshow: Cycle.
 */

/**
 * Implements hook_requirements().
 */
function views_slideshow_cycle_requirements($phase) {
  $requirements = array();

  // If installing via Drush skip requirement checking here.
  if (php_sapi_name() == 'cli') {
    return $requirements;
  }

  // Ensure translations do not break at install time.
  $t = get_t();
  if ($phase == 'install' || $phase == 'runtime') {
    if (!drupal_get_path('module', 'libraries')) {
      $requirements['views_slideshow_cycle'] = array(
        'title' => t('Libraries module missing'),
        'severity' => REQUIREMENT_ERROR,
        'value' => t('Libraries module required for Views Slideshow Cycle'),
        'description' => $t('Views Slideshow Cycle module requires the <a href="@url">Libraries module</a> to be installed.', array(
          '@url' => 'http://drupal.org/project/libraries',
        )),
      );
    }
    else {
      if ($phase == 'install') {
        $views_slideshow = drupal_get_path('module', 'views_slideshow_cycle');
        require_once $views_slideshow . '/views_slideshow_cycle.module';
      }

      // Libraries module may not be installed,
      // even if it is listed as dependency in .info file.
      // For example, during installation from an installation profile
      // Libraries will *not* be installed when hook_requirements get called.
      if (!function_exists('libraries_get_path')) {
        include_once drupal_get_path('module', 'libraries') . '/libraries.module';
      }
      if (!($cycle_path = _views_slideshow_cycle_library_path())) {
        $requirements['views_slideshow_jquery_cycle'] = array(
          'title' => t('jQuery Cycle Library'),
          'severity' => REQUIREMENT_ERROR,
          'value' => t('Library required for Views Slideshow Cycle'),
          'description' => t('You need to install the jQuery cycle plugin. Create a directory in sites/all/libraries called jquery.cycle, and then copy jquery.cycle.all.js into it. You can find the plugin at !url.', array(
            '!url' => l(t('GitHub'), 'https://raw.githubusercontent.com/malsup/cycle/3.0.3/jquery.cycle.all.js', array(
              'attributes' => array(
                'target' => '_blank',
              ),
            )),
          )),
        );
      }
      else {
        $requirements['views_slideshow_jquery_cycle'] = array(
          'title' => t('jQuery Cycle Library'),
          'value' => t('Installed'),
          'severity' => REQUIREMENT_OK,
        );
      }
    }
  }
  return $requirements;
}

Functions