You are here

function media_gallery_update_7000 in Media Gallery 7.2

Same name and namespace in other branches
  1. 7 media_gallery.install \media_gallery_update_7000()

Set the default value of media_gallery_expose_block to zero In order to have the expose block checkbox appear above the column and row number dropdowns it was necessary to update those field instances with their initial values, essentially refreshing them.

File

./media_gallery.install, line 975
Install file for media_gallery. Includes field and instance definitions.

Code

function media_gallery_update_7000() {
  $t = get_t();

  // Add a check to make sure the instance exists if we want to update it.
  $instance = field_info_instance('node', 'media_gallery_expose_block', 'media_gallery');
  if ($instance) {
    $instance['default_value'] = array(
      array(
        'value' => 0,
      ),
    );
    field_update_instance($instance);
  }

  // Update the media_display field so that it shows the label
  foreach (array(
    'video',
    'image',
  ) as $bundle) {
    field_update_instance(array(
      'field_name' => 'media_description',
      'bundle' => $bundle,
      'entity_type' => 'media',
      'display' => array(
        'default' => array(
          'type' => 'text_default',
          'label' => 'above',
        ),
        'media_gallery_thumbnail' => array(
          'type' => 'text_default',
          'label' => 'above',
        ),
        'media_gallery_lightbox' => array(
          'type' => 'text_default',
          'label' => 'above',
        ),
        'media_gallery_detail' => array(
          'type' => 'text_default',
          'label' => 'above',
        ),
      ),
    ));
  }

  // Remove the media_gallery_gallery_info field
  field_delete_field('media_gallery_gallery_info');
  field_delete_field('media_gallery_image_info');

  // Ensure that the new field exists
  $extra_field = array(
    'field_name' => 'media_gallery_lightbox_extras',
    'cardinality' => 1,
    'locked' => TRUE,
    'type' => 'list_boolean',
    'settings' => array(
      'allowed_values_function' => '_media_gallery_get_lightbox_extras_values',
    ),
  );
  _media_gallery_ensure_field($extra_field);
  $new_instance = array(
    'field_name' => 'media_gallery_lightbox_extras',
    'label' => 'Lightbox title and description',
    'description' => $t('Show title and description'),
    'default_value' => array(
      array(
        'value' => 0,
      ),
    ),
    'entity_type' => 'node',
    'bundle' => 'media_gallery',
    'widget' => array(
      'type' => 'options_onoff',
    ),
    'display' => array(
      'default' => array(
        'type' => 'hidden',
        'label' => 'hidden',
      ),
      'full' => array(
        'type' => 'hidden',
        'label' => 'hidden',
      ),
      'teaser' => array(
        'type' => 'hidden',
        'label' => 'hidden',
      ),
      'media_gallery_block' => array(
        'type' => 'hidden',
        'label' => 'hidden',
      ),
    ),
  );
  _media_gallery_ensure_instance($new_instance);
}