You are here

asset_audio.install in Asset 7

Install, update, and uninstall functions for the Asset audio module.

File

modules/asset_audio/asset_audio.install
View source
<?php

/**
 * @file
 * Install, update, and uninstall functions for the Asset audio module.
 */

/**
 * Implements hook_install().
 */
function asset_audio_install() {
  field_info_cache_clear();
  $fields = array();

  // Exported field: 'asset-audio-field_asset_audio'.
  $fields['asset-audio-field_asset_audio'] = array(
    'field_config' => array(
      'active' => '1',
      'cardinality' => '1',
      'deleted' => '0',
      'entity_types' => array(),
      'field_name' => 'field_asset_audio',
      'foreign keys' => array(
        'fid' => array(
          'columns' => array(
            'fid' => 'fid',
          ),
          'table' => 'file_managed',
        ),
      ),
      'indexes' => array(
        'fid' => array(
          0 => 'fid',
        ),
      ),
      'locked' => '0',
      'module' => 'file',
      'settings' => array(
        'display_default' => 0,
        'display_field' => 0,
        'uri_scheme' => 'public',
      ),
      'translatable' => '0',
      'type' => 'file',
    ),
    'field_instance' => array(
      'bundle' => 'audio',
      'deleted' => '0',
      'description' => '',
      'display' => array(
        'default' => array(
          'label' => 'above',
          'module' => 'jplayer',
          'settings' => array(
            'autoplay' => '0',
            'backgroundColor' => '000000',
            'mode' => 'single',
            'muted' => '0',
            'preload' => 'metadata',
            'repeat' => 'none',
            'solution' => 'html, flash',
            'volume' => '80',
          ),
          'type' => 'jplayer_player',
          'weight' => '0',
        ),
        'full' => array(
          'label' => 'hidden',
          'module' => 'jplayer',
          'settings' => array(
            'autoplay' => 0,
            'backgroundColor' => '000000',
            'mode' => 'playlist',
            'muted' => FALSE,
            'preload' => 'metadata',
            'repeat' => 'none',
            'solution' => 'html, flash',
            'volume' => 80,
          ),
          'type' => 'jplayer_player',
          'weight' => '0',
        ),
      ),
      'entity_type' => 'asset',
      'field_name' => 'field_asset_audio',
      'label' => 'Audio',
      'required' => 1,
      'settings' => array(
        'description_field' => 1,
        'file_directory' => 'asset/audio',
        'file_extensions' => 'mp3 ogg mp4',
        'max_filesize' => '',
        'user_register_form' => FALSE,
      ),
      'widget' => array(
        'active' => 1,
        'module' => 'file',
        'settings' => array(
          'progress_indicator' => 'throbber',
        ),
        'type' => 'file_generic',
        'weight' => '1',
      ),
    ),
  );

  // Translatables.
  // Included for use with string extractors like potx.
  $t = get_t();
  $t('Audio');
  foreach ($fields as $field) {

    // Create or update field.
    $field_config = $field['field_config'];
    if ($existing_field = field_info_field($field_config['field_name'])) {
      field_update_field($field_config);
    }
    else {
      field_create_field($field_config);
    }

    // Create or update field instance.
    $field_instance = $field['field_instance'];
    $existing_instance = field_info_instance($field_instance['entity_type'], $field_instance['field_name'], $field_instance['bundle']);
    if ($existing_instance) {
      field_update_instance($field_instance);
    }
    else {
      field_create_instance($field_instance);
    }
    variable_set('menu_rebuild_needed', TRUE);
  }
  $bundle_settings = array(
    'view_modes' => array(
      'full' => array(
        'custom_settings' => TRUE,
      ),
      'small' => array(
        'custom_settings' => FALSE,
      ),
      'tooltip' => array(
        'custom_settings' => FALSE,
      ),
    ),
    'extra_fields' => array(
      'form' => array(
        'title' => array(
          'weight' => '0',
        ),
      ),
      'display' => array(),
    ),
  );
  field_bundle_settings('asset', 'audio', $bundle_settings);
  assets_set_wysiwyg_modes('audio', array(
    'full' => 'full',
  ));
}

/**
 * Implements hook_uninstall().
 */
function asset_audio_uninstall() {
  field_delete_field('field_asset_audio');
}

Functions