You are here

function uc_catalog_update_7000 in Ubercart 7.3

Sets up a default term image for the Catalog.

File

uc_catalog/uc_catalog.install, line 63
Install, update and uninstall functions for the uc_catalog module.

Code

function uc_catalog_update_7000() {
  if (!module_exists('image')) {
    module_enable(array(
      'file',
      'image',
    ), FALSE);
  }

  // Copied from uc_catalog_add_image_field(), since the module won't be
  // enabled during an upgrade.
  $field = field_info_field('uc_catalog_image');
  if (!$field) {
    $field = array(
      'field_name' => 'uc_catalog_image',
      'type' => 'image',
    );
    field_create_field($field);
  }
  $instance = field_info_instance('taxonomy_term', 'uc_catalog_image', 'catalog');

  // Only add the instance if it doesn't exist. Don't overwrite any changes.
  if (!$instance) {
    $label = t('Image');
    $instance = array(
      'field_name' => 'uc_catalog_image',
      'entity_type' => 'taxonomy_term',
      'bundle' => 'catalog',
      'label' => $label,
      'widget' => array(
        'type' => 'image_image',
      ),
      'display' => array(
        'full' => array(
          'label' => 'hidden',
          'type' => 'image',
          'settings' => array(
            'image_link' => 'content',
            'image_style' => 'uc_category',
          ),
        ),
      ),
    );
    field_create_instance($instance);
  }
}