You are here

scald_gallery.install in Scald: Gallery 7.2

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

Scald Gallery Installation.

File

scald_gallery.install
View source
<?php

/**
 * @file
 * Scald Gallery Installation.
 */

/**
 * Implements hook_install().
 */
function scald_gallery_install() {
  ScaldAtomController::addType('gallery', 'Gallery', 'Gallery');

  // Associate the gallery atom type to the "library" image style
  // in the library context.
  $context_config = scald_context_config_load('sdl_library_item');
  $context_config->transcoder['gallery']['*'] = 'style-Library';
  scald_context_config_save($context_config);

  // Create fields and instances. Ignore the exceptions when field exists
  // (because it is in a feature etc.).
  try {
    foreach (scald_gallery_installed_fields() as $field) {
      field_create_field($field);
    }
    foreach (scald_gallery_installed_instances() as $instance) {
      field_create_instance($instance);
    }
  } catch (Exception $e) {
  }
}

/**
 * Implements hook_uninstall().
 */
function scald_gallery_uninstall() {
  ScaldAtomController::removeType('gallery');
}

/**
 * List of initially installed fields on gallery bundle.
 */
function scald_gallery_installed_fields() {
  $fields = array(
    'gallery_items' => array(
      'field_name' => 'gallery_items',
      'type' => 'atom_reference',
      'cardinality' => -1,
    ),
  );
  return $fields;
}

/**
 * List of initially installed field instances.
 */
function scald_gallery_installed_instances() {
  $instances = array(
    'gallery_items' => array(
      'field_name' => 'gallery_items',
      'label' => t('Gallery items'),
      'description' => t('Items that make up gallery. An item can be an atom of any type.'),
      'required' => TRUE,
      'widget' => array(
        'weight' => -4,
        'type' => 'atom_reference_textfield',
      ),
    ),
  );
  foreach ($instances as &$instance) {
    $instance['entity_type'] = 'scald_atom';
    $instance['bundle'] = 'gallery';
  }
  return $instances;
}

Functions

Namesort descending Description
scald_gallery_install Implements hook_install().
scald_gallery_installed_fields List of initially installed fields on gallery bundle.
scald_gallery_installed_instances List of initially installed field instances.
scald_gallery_uninstall Implements hook_uninstall().