You are here

colorbox.install in Colorbox 7.2

Same filename and directory in other branches
  1. 8 colorbox.install
  2. 6 colorbox.install
  3. 7 colorbox.install

Install, update and uninstall functions for the colorbox module.

File

colorbox.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the colorbox module.
 */

/**
 * Implements hook_enable().
 */
function colorbox_enable() {
  drupal_set_message(t('Thanks for installing Colorbox'));
  drupal_set_message(t('You may configure Colorbox by visiting <a href="@url_settings">@url_settings</a>', array(
    '@url_settings' => url('admin/config/media/colorbox'),
  )));
}

/**
 * Implements hook_requirements().
 */
function colorbox_requirements($phase) {
  $requirements = array();
  if ($phase == 'runtime') {
    $t = get_t();
    $library = libraries_detect('colorbox');
    $error_type = isset($library['error']) ? drupal_ucfirst($library['error']) : '';
    $error_message = isset($library['error message']) ? $library['error message'] : '';
    if (empty($library['installed'])) {
      $requirements['colorbox_plugin'] = array(
        'title' => $t('Colorbox plugin'),
        'value' => $t('@e: At least @a', array(
          '@e' => $error_type,
          '@a' => COLORBOX_MIN_PLUGIN_VERSION,
        )),
        'severity' => REQUIREMENT_ERROR,
        'description' => $t('!error You need to download the !colorbox, extract the archive and place the colorbox directory in the %path directory on your server.', array(
          '!error' => $error_message,
          '!colorbox' => l($t('Colorbox plugin'), $library['download url']),
          '%path' => 'sites/all/libraries',
        )),
      );
    }
    elseif (version_compare($library['version'], COLORBOX_MIN_PLUGIN_VERSION, '>=')) {
      $requirements['colorbox_plugin'] = array(
        'title' => $t('Colorbox plugin'),
        'severity' => REQUIREMENT_OK,
        'value' => $library['version'],
      );
    }
    else {
      $requirements['colorbox_plugin'] = array(
        'title' => $t('Colorbox plugin'),
        'value' => $t('At least @a', array(
          '@a' => COLORBOX_MIN_PLUGIN_VERSION,
        )),
        'severity' => REQUIREMENT_ERROR,
        'description' => $t('You need to download a later version of the !colorbox and replace the old version located in the %path directory on your server.', array(
          '!colorbox' => l($t('Colorbox plugin'), $library['download url']),
          '%path' => $library['library path'],
        )),
      );
    }
  }
  return $requirements;
}

/**
 * Implements hook_uninstall().
 */
function colorbox_uninstall() {
  db_delete('variable')
    ->condition('name', db_like('colorbox_') . '%', 'LIKE')
    ->execute();
}

/**
 * Delete the unused colorbox_login_form variable.
 */
function colorbox_update_7001() {
  $ret = array();
  variable_del('colorbox_login_form');
  return $ret;
}

/**
 * Implements hook_update_N().
 *
 * Delete the unused colorbox_title_trim and colorbox_title_trim_length
 * variables.
 */
function colorbox_update_7002() {
  $ret = array();
  $colorbox_title_trim = variable_get('colorbox_title_trim', NULL);
  $colorbox_title_trim_length = variable_get('colorbox_title_trim_length', NULL);
  if (!empty($colorbox_title_trim)) {
    variable_set('colorbox_caption_trim', $colorbox_title_trim);
  }
  if (!empty($colorbox_title_trim_length)) {
    variable_set('colorbox_caption_trim_length', $colorbox_title_trim_length);
  }
  variable_del('colorbox_title_trim');
  variable_del('colorbox_title_trim_length');
  return $ret;
}

/**
 * Delete the unused colorbox_login and colorbox_login_links variables.
 */
function colorbox_update_7200() {
  $ret = array();
  variable_del('colorbox_login');
  variable_del('colorbox_login_links');
  return $ret;
}

/**
 * Delete the unused colorbox_auto_image_nodes variable.
 */
function colorbox_update_7201() {
  $ret = array();
  variable_del('colorbox_auto_image_nodes');
  return $ret;
}

/**
 * Update the colorbox_compression_type variable.
 */
function colorbox_update_7202() {
  $ret = array();
  if (variable_get('colorbox_compression_type', 'minified') == 'none') {
    variable_set('colorbox_compression_type', 'source');
  }
  else {
    variable_set('colorbox_compression_type', 'minified');
  }
  return $ret;
}

Functions

Namesort descending Description
colorbox_enable Implements hook_enable().
colorbox_requirements Implements hook_requirements().
colorbox_uninstall Implements hook_uninstall().
colorbox_update_7001 Delete the unused colorbox_login_form variable.
colorbox_update_7002 Implements hook_update_N().
colorbox_update_7200 Delete the unused colorbox_login and colorbox_login_links variables.
colorbox_update_7201 Delete the unused colorbox_auto_image_nodes variable.
colorbox_update_7202 Update the colorbox_compression_type variable.