You are here

royalslider.install in RoyalSlider Integration 7

Installation hooks for RoyalSlider.

File

royalslider.install
View source
<?php

/**
 * @file
 * Installation hooks for RoyalSlider.
 */

/**
 * Implements hook_requirements().
 *
 * Checks for the RoyalSlider library.
 */
function royalslider_requirements($phase) {
  $requirements = array();

  // Check for RoyalSlider library.
  if ($phase == 'runtime') {
    $path = libraries_get_path('royalslider');
    if (!$path || !file_exists("{$path}/jquery.royalslider.min.js")) {
      $requirements['royalslider_library'] = array(
        'description' => t('The <a href="@url">RoyalSlider library</a> should be installed at [libraries-path]/royalslider.', array(
          '@url' => 'http://dimsemenov.com/plugins/royal-slider/',
        )),
        'severity' => REQUIREMENT_ERROR,
        'value' => t('Not installed.'),
        'title' => t('RoyalSlider library'),
      );
    }

    // Also check for minimum required jQuery version.
    $jquery_version = variable_get('jquery_update_jquery_version', '1.5');
    if (!version_compare($jquery_version, '1.7', '>=')) {
      $requirements['royalslider_jquery_version'] = array(
        'description' => t('Incorrect jQuery version detected. RoyalSlider requires jQuery 1.7 or higher. Please change your <a href="!settings">jQuery Update settings</a>.', array(
          '!settings' => url('admin/config/development/jquery_update'),
        )),
        'severity' => REQUIREMENT_ERROR,
        'value' => t('Not installed. Please enable jQuery 1.7 or higher.'),
        'title' => t('RoyalSlider jQuery version'),
      );
    }
  }
  return $requirements;
}

/**
 * Implements hook_schema().
 */
function royalslider_schema() {
  $schema = array();
  $schema['royalslider_optionset'] = array(
    'description' => 'Store RoyalSlider Option Sets.',
    'export' => array(
      'key' => 'name',
      'identifier' => 'preset',
      'default hook' => 'royalslider_default_presets',
      'api' => array(
        'owner' => 'royalslider',
        'api' => 'royalslider_default_preset',
        'minimum_version' => 1,
        'current_version' => 1,
      ),
    ),
    'fields' => array(
      'name' => array(
        'description' => 'The machine-readable option set name.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'title' => array(
        'description' => 'The human-readable title for this option set.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'skin' => array(
        'description' => 'The RoyalSlider skin.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => 'default',
      ),
      'imagestyle_fullscreen' => array(
        'description' => 'The image style for full screen images.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'imagestyle_normal' => array(
        'description' => 'The image style for normal images.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => 'large',
      ),
      'imagestyle_thumbnail' => array(
        'description' => 'The image style for thumbnail images.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => 'thumbnail',
      ),
      'options' => array(
        'description' => 'The options array.',
        'type' => 'blob',
        'size' => 'big',
        'serialize' => TRUE,
      ),
    ),
    'primary key' => array(
      'name',
    ),
  );
  return $schema;
}

Functions