You are here

picture.install in Picture 7

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

Install/schema hooks for the picture module.

File

picture.install
View source
<?php

/**
 * @file
 * Install/schema hooks for the picture module.
 */

/**
 * Implements hook_schema().
 */
function picture_schema() {
  $schema = array();
  $schema['picture_mapping'] = array(
    'description' => 'Responsible images and styles mappings to breakpoints',
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'The internal identifier for this mapping',
        'no export' => TRUE,
      ),
      'machine_name' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'description' => 'The machine name of the mapping',
      ),
      'breakpoint_group' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'description' => 'The group this mapping belongs to',
      ),
      'mapping' => array(
        'type' => 'blob',
        'not null' => TRUE,
        'description' => 'The mappings linked to the breakpoints group',
        'serialize' => TRUE,
      ),
    ),
    'primary key' => array(
      'id',
    ),
    // CTools exportable object definition
    'export' => array(
      'key' => 'machine_name',
      'key name' => 'machine_name',
      'primary key' => 'id',
      'identifier' => 'picture_mapping',
      'admin_title' => 'label',
      'default hook' => 'default_picture_mapping',
      'api' => array(
        'owner' => 'picture',
        'api' => 'default_picture_mapping',
        'minimum_version' => 1,
        'current_version' => 1,
      ),
    ),
  );
  return $schema;
}

/**
 * Implements hook_uninstall().
 */
function picture_uninstall() {
  variable_del('picture_ckeditor_groups');
  variable_del('picture_ckeditor_label');
}

/**
 * Update to the new file display formatter provided by file_entity.module.
 */
function picture_update_7001() {
  module_load_include('admin.inc', 'picture');
  variable_set('picture_updated_to_file_entity_2', _picture_update_to_file_entity_2());
}

/**
 * Update field formatters to the new colorbox settings.
 */
function picture_update_7002() {
  $fields = field_read_fields(array(
    'type' => 'image',
  ));
  foreach ($fields as $field) {
    $instances = field_read_instances(array(
      'field_id' => $field['id'],
    ));
    foreach ($instances as $instance) {
      foreach ($instance['display'] as $view_mode => $view_mode_settings) {
        if ($view_mode_settings['type'] == 'picture') {
          $colorbox_group = $instance['display'][$view_mode]['settings']['colorbox'];
          $instance['display'][$view_mode]['settings']['colorbox_settings'] = array(
            'colorbox_group' => $colorbox_group,
            'colorbox_gallery' => 'none',
            'colorbox_gallery_custom' => '',
            'colorbox_caption' => 'none',
            'colorbox_caption_custom' => '',
            'colorbox_multivalue_index' => NULL,
          );
        }
      }
      field_update_instance($instance);
    }
  }
}

Functions

Namesort descending Description
picture_schema Implements hook_schema().
picture_uninstall Implements hook_uninstall().
picture_update_7001 Update to the new file display formatter provided by file_entity.module.
picture_update_7002 Update field formatters to the new colorbox settings.