You are here

scald_gallery.install in Scald: Gallery 7

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

Scald Gallery Installation.

File

scald_gallery.install
View source
<?php

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

/**
 * Implements hook_install().
 */
function scald_gallery_install() {
  scald_add_type('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);

  // Associate the gallery atom type to the "galleria" player
  // in the full-page context.
  $context_config = scald_context_config_load('full');
  $context_config->player['gallery']['*'] = 'galleria';
  scald_context_config_save($context_config);

  // Create fields and instances.
  foreach (scald_gallery_installed_fields() as $field) {
    field_create_field($field);
  }
  foreach (scald_gallery_installed_instances() as $instance) {
    field_create_instance($instance);
  }
}

/**
 * Implements hook_uninstall().
 */
function scald_gallery_uninstall() {
  scald_remove_type('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('Images that make up gallery.'),
      'required' => TRUE,
      'widget' => array(
        'weight' => -4,
        'type' => 'atom_reference_textfield',
      ),
      'settings' => array(
        'referencable_types' => array(
          'image' => 'image',
        ),
      ),
    ),
  );
  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().