You are here

image_hotspots.install in Image Hotspots 7.2

File

image_hotspots.install
View source
<?php

/**
 * Implements hook_schema().
 */
function image_hotspots_schema() {
  $schema['image_hotspot'] = array(
    'description' => 'Stores data for image hotspots.',
    'fields' => array(
      'hid' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Primary Key: Unique hotspot ID.',
      ),
      'fid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Primary Key: File ID that contains hotspots.',
      ),
      'language' => array(
        'type' => 'varchar',
        'length' => 12,
        'not null' => TRUE,
        'default' => '',
        'description' => "Language code, e.g. 'de' or 'en-US'.",
      ),
      'coordinates' => array(
        'type' => 'text',
        'not null' => TRUE,
        'description' => 'The hotspots data (JSON).',
      ),
    ),
    'primary key' => array(
      'hid',
      'fid',
    ),
  );
  return $schema;
}

/**
 * Adds the language column to the image_hotspot table.
 */
function image_hotspots_update_7000() {

  // A serial field must be defined as a key, so make a temporary index on
  // 'hid' so we can safely drop the primary key.
  db_add_index('image_hotspot', 'hid', array(
    'hid',
  ));

  // Drop the primary key before adding a new field.
  db_drop_primary_key('image_hotspot');

  // Add a new field.
  $spec = array(
    'type' => 'varchar',
    'length' => 12,
    'not null' => TRUE,
    'default' => '',
    'description' => "Language code, e.g. 'de' or 'en-US'.",
  );
  db_add_field('image_hotspot', 'language', $spec);

  // Add primary key.
  db_add_primary_key('image_hotspot', array(
    'hid',
    'fid',
    'language',
  ));

  // Drop temporary added index.
  db_drop_index('image_hotspot', 'hid');
}

/**
 * Implements hook_install().
 */
function image_hotspots_install() {
  $default_opacity = '0.3';
  $default_colors = array(
    '6666FF',
    '66CCCC',
    'FF3366',
    'FF3300',
    'FFFF66',
    '33FF66',
    '99FF66',
    'FFCC99',
    '9966FF',
    '33CCFF',
  );
  $default_hotspots = array();
  foreach ($default_colors as $color) {
    $default_hotspots[] = array(
      'background-color' => $color,
      'opacity' => $default_opacity,
    );
  }
  variable_set('image_hotspots_settings', $default_hotspots);
}

/**
 * Implements hook_uninstall().
 */
function image_hotspots_uninstall() {
  variable_del('image_hotspot_fields');
  variable_del('image_hotspots_settings');
}

Functions

Namesort descending Description
image_hotspots_install Implements hook_install().
image_hotspots_schema Implements hook_schema().
image_hotspots_uninstall Implements hook_uninstall().
image_hotspots_update_7000 Adds the language column to the image_hotspot table.