You are here

scrollreveal.install in Scroll Reveal 7.2

Same filename and directory in other branches
  1. 7 scrollreveal.install

scrollreveal.install Installation and update functions for the ScrollReveal Module

File

scrollreveal.install
View source
<?php

/**
 * @file scrollreveal.install
 * Installation and update functions for the ScrollReveal
 * Module
 */

/**
 * Default settings storage.
 */
function _scrollreveal_defaults() {
  $theme = variable_get('theme_default', NULL);
  return array(
    'config' => array(
      'enter' => 'bottom',
      'move' => 24,
      'over' => 0.66,
      'after' => 0,
      'easing' => 'ease',
      'reset' => 'false',
      'viewportFactor' => 0.33,
    ),
    'pages' => array(
      'visibility' => 0,
      'pages' => 'admin/*',
    ),
    'theme' => array(
      'visibility' => 1,
      'themes' => array(
        $theme => $theme,
      ),
    ),
  );
}

/**
 * Implementation of hook_install().
 * This will create our system variable defaults.
 * The benefit is that we do not need to pass defaults
 * to variable_get(), which allows centralization of defaults.
 */
function scrollreveal_install() {
  variable_set('scrollreveal_settings', _scrollreveal_defaults());
}

/**
 * Implementation of hook_uninstall().
 * Only clears our variables, so a fresh installation can repopulate them.
 */
function scrollreveal_uninstall() {

  // Settings.
  variable_del('scrollreveal_settings');
}

/**
 * Implementation of hook_update().
 */

/**
 * Adds visibility options().
 */
function scrollreveal_update_7001() {
  $theme = variable_get('theme_default', NULL);
  $settings = variable_get('scrollreveal_settings');
  $update = FALSE;
  if (!isset($settings['theme']['visibility'])) {
    $settings['theme'] = array(
      'visibility' => 1,
      'themes' => array(
        $theme => $theme,
      ),
    );
    $update = TRUE;
  }
  if (!isset($settings['theme']['visibility'])) {
    $settings['pages'] = array(
      'visibility' => 0,
      'pages' => 'admin/*',
    );
    $update = TRUE;
  }
  if ($update) {
    variable_set('scrollreveal_settings', $settings);
  }
}

/**
 * Adds default options().
 */
function scrollreveal_update_7002() {
  $settings = variable_get('scrollreveal_settings');
  $update = FALSE;
  if (!isset($settings['config'])) {
    $settings['config'] = array(
      'enter' => 'bottom',
      'move' => 24,
      'over' => 0.66,
      'after' => 0,
      'easing' => 'ease',
      'reset' => 'false',
      'viewportFactor' => 0.33,
    );
    $update = TRUE;
  }
  if ($update) {
    variable_set('scrollreveal_settings', $settings);
  }
}

Functions

Namesort descending Description
scrollreveal_install Implementation of hook_install(). This will create our system variable defaults. The benefit is that we do not need to pass defaults to variable_get(), which allows centralization of defaults.
scrollreveal_uninstall Implementation of hook_uninstall(). Only clears our variables, so a fresh installation can repopulate them.
scrollreveal_update_7001 Adds visibility options().
scrollreveal_update_7002 Adds default options().
_scrollreveal_defaults Default settings storage.