You are here

iss.install in Image Style Selector 7.2

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

Install file for the Image Style Selector field.

Creates/drops the database schema on installing/uninstalling the module, through the schema hook function implemention. The database schema contains all necessary information to store the image style selected by the user.

File

iss.install
View source
<?php

/**
 * @file
 * Install file for the Image Style Selector field.
 *
 * Creates/drops the database schema on installing/uninstalling the module,
 * through the schema hook function implemention. The database schema contains
 * all necessary information to store the image style selected by the user.
 */

/**
 * Implements hook_schema().
 */
function iss_schema() {
  $schema['iss_styles'] = array(
    'description' => 'Holds information about image styles changes.',
    'fields' => array(
      'fid' => array(
        'description' => 'The {file_managed}.fid of the image file.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'vid' => array(
        'description' => 'The {file_managed_revisions}.vid (if it exists) of the file.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'source_style' => array(
        'description' => 'The machine name of the source style.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'target_style' => array(
        'description' => 'The machine name of the target style.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
    ),
    'foreign keys' => array(
      'file' => array(
        'table' => 'file_managed',
        'columns' => array(
          'fid' => 'fid',
        ),
      ),
    ),
    'primary key' => array(
      'fid',
      'vid',
      'source_style',
    ),
  );
  return $schema;
}

/**
 * Implements hook_schema_alter().
 */
function iss_schema_alter(&$schema) {
  $schema['image_styles']['fields']['iss_enabled'] = array(
    'description' => 'Boolean telling if image style is ISS enabled.',
    'type' => 'int',
    'not null' => TRUE,
    'default' => 0,
  );
}

/**
 * Implements hook_install().
 */
function iss_install() {
  $schema = array();
  iss_schema_alter($schema);

  // Altering the {image_styles} table.
  db_add_field('image_styles', 'iss_enabled', $schema['image_styles']['fields']['iss_enabled']);
}

/**
 * Implements hook_uninstall().
 */
function iss_uninstall() {

  // Delete the additional columns from the {image_styles} table.
  db_drop_field('image_styles', 'iss_enabled');
}

Functions

Namesort descending Description
iss_install Implements hook_install().
iss_schema Implements hook_schema().
iss_schema_alter Implements hook_schema_alter().
iss_uninstall Implements hook_uninstall().