You are here

lightbox2.install in Lightbox2 8

Installation functions for Lightbox2.

File

lightbox2.install
View source
<?php

// $Id: lightbox2.install,v 1.1.4.4.2.49 2010/09/22 17:26:19 snpower Exp $

/**
 * @file
 * Installation functions for Lightbox2.
 */

/**
 * Implementation of hook_install().
 */
function lightbox2_install() {
  \Drupal::moduleHandler()
    ->invoke('content', 'clear_type_cache');
}

/**
 * Implementation of hook_uninstall().
 */
function lightbox2_uninstall() {

  // Delete the variables we created.
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_plus')
    ->save();

  // @FIXME
  // // @FIXME
  // // This looks like another module's variable. You'll need to rewrite this call
  // // to ensure that it uses the correct configuration object.
  // variable_del('lightbox2G2_filter');
  // Remove the general settings.
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_lite')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_use_alt_layout')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_force_show_nav')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_loop_items')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_image_count_str')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_page_count_str')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_video_count_str')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_disable_resize')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_disable_zoom')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_enable_login')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_enable_contact')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_enable_video')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_flv_player_path')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_flv_player_flashvars')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_page_init_action')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_page_list')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_disable_these_urls')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_imagefield_group_node_id')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_imagefield_use_node_title')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_view_image_text')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_image_ncck_group_node_id')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_show_caption')
    ->save();

  // Advanced settings.
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_js_location')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_keys_close')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_keys_previous')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_keys_next')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_keys_zoom')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_keys_play_pause')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_top_position')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_border_size')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_box_color')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_font_color')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_overlay_opacity')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_overlay_color')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_disable_close_click')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_resize_sequence')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_resize_speed')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_fadein_speed')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_slidedown_speed')
    ->save();

  // Remove iframe settings.
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_default_frame_width')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_default_frame_height')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_frame_border')
    ->save();

  // Remove slideshow settings.
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_slideshow_interval')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_slideshow_automatic_start')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_slideshow_automatic_exit')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_slideshow_show_play_pause')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_slideshow_pause_on_next_click')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_slideshow_pause_on_previous_click')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_loop_slides')
    ->save();

  // Remove the automatic image handling settings.
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_image_node')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_display_image_size')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_trigger_image_size')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_disable_nested_galleries')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_flickr')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_gallery2_blocks')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_inline')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_image_assist_custom')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_custom_class_handler')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_custom_trigger_classes')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_node_link_text')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_download_link_text')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_node_link_target')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_show_caption')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_image_group')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_disable_nested_acidfree_galleries')
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_acidfree_video')
    ->save();
}

/**
 * One of the variables was renamed from 'lightbox2_plus' to 'lightbox2_lite'.
 *
 * Should have been created with lightbox2_update_600x() naming convention, but
 * too late now.
 */
function lightbox2_update_1() {
  $ret = array();
  $ret[] = update_sql('UPDATE {variable} SET name="lightbox2_lite"
    WHERE name="lightbox2_plus";');
  return $ret;
}

/**
 * 'lightbox2_image_group' variable has been removed and others need to be
 * updated accordingly.
 *
 * Should have been created with lightbox2_update_600x() naming convention, but
 * too late now.
 */
function lightbox2_update_2() {
  $image_group = \Drupal::config('lightbox2.settings')
    ->get('lightbox2_image_group');
  $image_node = \Drupal::config('lightbox2.settings')
    ->get('lightbox2_image_node');
  $flickr = \Drupal::config('lightbox2.settings')
    ->get('lightbox2_flickr');
  $gallery2 = \Drupal::config('lightbox2.settings')
    ->get('lightbox2_gallery2_blocks');
  $inline = \Drupal::config('lightbox2.settings')
    ->get('lightbox2_inline');
  $image_assist = \Drupal::config('lightbox2.settings')
    ->get('lightbox2_image_assist_custom');
  if ($image_group) {
    if ($image_node) {
      \Drupal::configFactory()
        ->getEditable('lightbox2.settings')
        ->set('lightbox2_image_node', 2)
        ->save();
    }
    if ($flickr) {
      \Drupal::configFactory()
        ->getEditable('lightbox2.settings')
        ->set('lightbox2_flickr', 2)
        ->save();
    }
    if ($gallery2) {
      \Drupal::configFactory()
        ->getEditable('lightbox2.settings')
        ->set('lightbox2_gallery2_blocks', 2)
        ->save();
    }
    if ($inline) {
      \Drupal::configFactory()
        ->getEditable('lightbox2.settings')
        ->set('lightbox2_inline', 2)
        ->save();
    }
    if ($image_assist) {
      \Drupal::configFactory()
        ->getEditable('lightbox2.settings')
        ->set('lightbox2_image_assist_custom', 2)
        ->save();
    }
  }
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_image_group')
    ->save();
  return array();
}

/**
 * 'lightbox2_disable_these_urls' was renamed to 'lightbox2_page_list'.
 * 'lightbox2_page_init_action' was also added which determines whether the
 * lightbox functionality should be enabled or disabled for the page list.
 * 'lightbox2_disable_zoom' has been replaced by 'lightbox2_disable_resize'.
 * 'lightbox2_disable_zoom' still exists but has a different meaning.
 *
 * Should have been created with lightbox2_update_600x() naming convention, but
 * too late now.
 */
function lightbox2_update_3() {
  $disabled_urls = \Drupal::config('lightbox2.settings')
    ->get('lightbox2_disable_these_urls');
  \Drupal::configFactory()
    ->getEditable('lightbox2.settings')
    ->set('lightbox2_page_init_action', 'page_disable')
    ->save();
  \Drupal::configFactory()
    ->getEditable('lightbox2.settings')
    ->set('lightbox2_page_list', $disabled_urls)
    ->save();
  \Drupal::config('lightbox2.settings')
    ->clear('lightbox2_disable_these_urls')
    ->save();
  $disable_zoom = \Drupal::config('lightbox2.settings')
    ->get('lightbox2_disable_zoom');
  \Drupal::configFactory()
    ->getEditable('lightbox2.settings')
    ->set('lightbox2_disable_resize', $disable_zoom)
    ->save();
  \Drupal::configFactory()
    ->getEditable('lightbox2.settings')
    ->set('lightbox2_disable_zoom', FALSE)
    ->save();
  return array();
}
function lightbox2_update_6001() {
  $size = \Drupal::config('lightbox2.settings')
    ->get('lightbox2_display_image_size');
  if ($size == '') {
    \Drupal::configFactory()
      ->getEditable('lightbox2.settings')
      ->set('lightbox2_display_image_size', 'original')
      ->save();
  }
  return array();
}

/**
 * 'lightbox2_slideshow_pause_on_previous_click' was mis-named as
 * 'lightbox2_slideshow_pause_on_prev_click'.
 */
function lightbox2_update_6002() {
  $vars = variable_init();
  if (array_key_exists('lightbox2_slideshow_pause_on_prev_click', $vars)) {
    $value = $vars['lightbox2_slideshow_pause_on_prev_click'];
    \Drupal::configFactory()
      ->getEditable('lightbox2.settings')
      ->set('lightbox2_slideshow_pause_on_previous_click', $value)
      ->save();
    \Drupal::config('lightbox2.settings')
      ->clear('lightbox2_slideshow_pause_on_prev_click')
      ->save();
  }
  return array();
}

/**
 * Menu paths changed.
 */
function lightbox2_update_6003() {
  return array();
}

Functions

Namesort descending Description
lightbox2_install Implementation of hook_install().
lightbox2_uninstall Implementation of hook_uninstall().
lightbox2_update_1 One of the variables was renamed from 'lightbox2_plus' to 'lightbox2_lite'.
lightbox2_update_2 'lightbox2_image_group' variable has been removed and others need to be updated accordingly.
lightbox2_update_3 'lightbox2_disable_these_urls' was renamed to 'lightbox2_page_list'. 'lightbox2_page_init_action' was also added which determines whether the lightbox functionality should be enabled or disabled for the page…
lightbox2_update_6001
lightbox2_update_6002 'lightbox2_slideshow_pause_on_previous_click' was mis-named as 'lightbox2_slideshow_pause_on_prev_click'.
lightbox2_update_6003 Menu paths changed.