You are here

views_slideshow_liquid_slider.module in Views Slideshow Liquid Slider 7

Same filename and directory in other branches
  1. 7.2 views_slideshow_liquid_slider.module

File

views_slideshow_liquid_slider.module
View source
<?php

/**
 * @file
 * views_slideshow_liquid_slider.module
 */

/**
 * Implements hook_libraries_info().
 */
function views_slideshow_liquid_slider_libraries_info() {

  //Check for src path... (ver 2.0.1)
  $jsfile = 'js/jquery.liquid-slider.js';
  $library_path = libraries_get_path('liquidslider');
  $jsfile = !file_exists($library_path . '/' . $jsfile) ? 'src/' . $jsfile : $jsfile;
  $libraries['liquidslider'] = array(
    'name' => 'jQuery Liquid Slider',
    'vendor url' => 'http://liquidslider.kevinbatdorf.com/',
    'download url' => 'https://github.com/KevinBatdorf/liquidslider/archive/2.0.12.zip',
    'version arguments' => array(
      // 'pattern' => '@Version ([1-9].[0-9].+)@',
      'pattern' => '@([0-9]\\.[0-9]{1,2}\\.[0-9]{1,2})@',
      'file' => $jsfile,
    ),
    'files' => array(
      'js' => array(
        'js/jquery.easing.1.3.js',
        'js/jquery.touchSwipe.min.js',
        $jsfile,
      ),
    ),
    'variants' => array(
      'minified' => array(
        'files' => array(
          'js' => array(
            'js/jquery.easing.1.3.js',
            'js/jquery.touchSwipe.min.js',
            'js/jquery.liquid-slider.min.js',
          ),
        ),
      ),
    ),
  );
  return $libraries;
}

/**
 * Implements hook_theme().
 */
function views_slideshow_liquid_slider_theme($existing, $type, $theme, $path) {
  return array(
    'views_slideshow_liquid_slider_main_frame' => array(
      'variables' => array(
        'view' => NULL,
        'settings' => array(),
        'rows' => array(),
        'title' => '',
      ),
      'template' => 'theme/views-slideshow-liquidslider-main-frame',
      'file' => 'theme/views_slideshow_liquid_slider.theme.inc',
    ),
  );
}

/**
 * Implements hook_jqmulti_files().
 *
 * Add files to be loaded with jQuery Multi's jQuery library
 * @return
 *   An array of full paths to files that should be loaded with the jqmulti's jQuery library
 *   (paths are relative to Drupal root)
 */
function views_slideshow_liquid_slider_jqmulti_files() {
  $library_path = libraries_get_path('liquidslider');
  $module_path = drupal_get_path('module', 'views_slideshow_liquid_slider');
  return array(
    $library_path . '/js/jquery.liquid-slider.min.js',
    $module_path . '/js/liquidslider.js',
    $library_path . '/js/jquery.easing.1.3.js',
    $library_path . '/js/jquery.touchSwipe.min.js',
  );
}

/* Implements hook_jqmulti_libraries()
 * Add libraries to be loaded with jQuery Multi's jQuery library.
 * @return
 *   An array of library names, where the name corresponds to the name of a directory
 *   in the sites/all/libraries directory. All and only the .js files in this directory will
 *   be automatically loaded by jQuery Multi.
 */
function views_slideshow_liquid_slider_jqmulti_libraries() {
  return array(
    'liquidslider',
  );
}

/**
 * Gets the path to the Liquid Slider library.
 *
 * @return bool
 *   The path to the Liquid Slider library js file, or FALSE if not found.
 */
function _views_slideshow_liquid_slider_library_path() {

  // Add support for Libraries 2.x.
  if (function_exists('libraries_load')) {
    if (($library = libraries_load('liquidslider', 'minified')) && $library['installed']) {
      return TRUE;
    }
    else {
      return FALSE;
    }
  }

  // Legacy code to support Libraries 1.x until Libraries 2.x
  // has a stable release.
  $library_path = libraries_get_path('liquidslider');
  if (!empty($library_path)) {

    // Attempt to use mini, 'minified'fied version of Liquid Slider plugin.
    if (file_exists($liquidslider_path = $library_path . '/js/jquery.liquid-slider.min.js')) {
      return $liquidslider_path;
    }
    elseif (file_exists($liquidslider_path = $library_path . '/src/js/jquery.liquid-slider.js')) {
      return $liquidslider_path;
    }
    elseif (file_exists($liquidslider_path = $library_path . '/js/jquery.liquid-slider.js')) {
      return $liquidslider_path;
    }
  }
  return FALSE;
}

/**
 * Get the install error message.
 */
function _views_slideshow_liquid_slider_get_install_error_message() {
  $library_path = 'sites/all/libraries/';

  //libraries_get_path('liquidslider');

  //$library_url = 'https://github.com/KevinBatdorf/liquidslider/archive/master.zip';
  $library_url = 'https://github.com/KevinBatdorf/liquidslider/archive/2.0.12.zip';
  $library_link = l($library_url, $library_url, array(
    'attributes' => array(
      'target' => '_blank',
    ),
  ));
  $t = get_t();
  $output = $t('The jQuery Liquid Slider plugin needs to be installed.');
  $output .= ' ';
  $output .= $t('Download the jQuery plugin from !link and unzip it into @library_path', array(
    '!link' => $library_link,
    '@library_path' => $library_path,
  ));
  $output .= '<br>';
  $output .= '<b>CAUTION:</b> You must rename the folder name "liquidslider-(version)" to "liquidslider"';
  return $output;
}