|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* This file contains all install related hooks.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements hook_install().
|
|
|
|
*/
|
|
|
|
function islandora_basic_image_install() {
|
|
|
|
$t = get_t();
|
|
|
|
|
|
|
|
// Create basic_image bundle.
|
|
|
|
$basic_image_content_type = array(
|
|
|
|
'type' => ISLANDORA_BASIC_IMAGE_BUNDLE,
|
|
|
|
'name' => $t('Basic Image'),
|
|
|
|
'base' => 'node_content',
|
|
|
|
'description' => $t('An image object in Fedora'),
|
|
|
|
'custom' => 1,
|
|
|
|
'modified' => 1,
|
|
|
|
'locked' => 0,
|
|
|
|
'disabled' => 0,
|
|
|
|
);
|
|
|
|
|
|
|
|
$basic_image_content_type = node_type_set_defaults($basic_image_content_type);
|
|
|
|
|
|
|
|
$status = node_type_save($basic_image_content_type);
|
|
|
|
|
|
|
|
$t_args = array('%name' => $basic_image_content_type->name);
|
|
|
|
|
|
|
|
if ($status == SAVED_UPDATED) {
|
|
|
|
drupal_set_message($t('Updated %name content type.', $t_args));
|
|
|
|
}
|
|
|
|
elseif ($status == SAVED_NEW) {
|
|
|
|
drupal_set_message($t('Created %name content type.', $t_args));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create medium size field.
|
|
|
|
$medium_size_field = array(
|
|
|
|
'field_name' => ISLANDORA_BASIC_IMAGE_MEDIUM_SIZE,
|
|
|
|
'type' => 'image',
|
|
|
|
);
|
|
|
|
field_create_field($medium_size_field);
|
|
|
|
|
|
|
|
// Add fields instances to bundle.
|
|
|
|
if (field_info_field(ISLANDORA_BASIC_IMAGE_MEDIUM_SIZE)) {
|
|
|
|
$medium_size_field_instance = array(
|
|
|
|
'field_name' => ISLANDORA_BASIC_IMAGE_MEDIUM_SIZE,
|
|
|
|
'entity_type' => 'node',
|
|
|
|
'bundle' => ISLANDORA_BASIC_IMAGE_BUNDLE,
|
|
|
|
'label' => $t("Medium Size"),
|
|
|
|
'description' => $t("A display copy of the image."),
|
|
|
|
'required' => FALSE,
|
|
|
|
);
|
|
|
|
field_create_instance($medium_size_instance);
|
|
|
|
drupal_set_message($t('Field %name was created successfully', array('%name' => ISLANDORA_BASIC_IMAGE_MEDIUM_SIZE)));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (field_info_field(ISLANDORA_TN_FIELD)) {
|
|
|
|
$tn_field_instance = array(
|
|
|
|
'field_name' => ISLANDORA_TN_FIELD,
|
|
|
|
'entity_type' => 'node',
|
|
|
|
'bundle' => ISLANDORA_BASIC_IMAGE_BUNDLE,
|
|
|
|
'label' => $t("Thumbnail"),
|
|
|
|
'description' => $t("A thumbnail for the Fedora resource"),
|
|
|
|
'required' => FALSE,
|
|
|
|
);
|
|
|
|
field_create_instance($tn_field_instance);
|
|
|
|
drupal_set_message($t('Field %name was created successfully', array('%name' => ISLANDORA_TN_FIELD)));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (field_info_field(ISLANDORA_MODS_FIELD)) {
|
|
|
|
$mods_field_instance = array(
|
|
|
|
'field_name' => ISLANDORA_MODS_FIELD,
|
|
|
|
'entity_type' => 'node',
|
|
|
|
'bundle' => ISLANDORA_BASIC_IMAGE_BUNDLE,
|
|
|
|
'label' => $t("MODS"),
|
|
|
|
'description' => $t("A MODS record for the Fedora resource"),
|
|
|
|
'required' => FALSE,
|
|
|
|
);
|
|
|
|
field_create_instance($mods_field_instance);
|
|
|
|
drupal_set_message($t('Field %name was created successfully', array('%name' => ISLANDORA_MODS_FIELD)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements hook_uninstall().
|
|
|
|
*/
|
|
|
|
function islandora_basic_image_uninstall() {
|
|
|
|
field_delete_instance(field_info_instance('node_content', ISLANDORA_BASIC_IMAGE_MEDIUM_SIZE, ISLANDORA_BASIC_IMAGE_BUNDLE));
|
|
|
|
field_delete_instance(field_info_instance('node_content', ISLANDORA_TN_FIELD, ISLANDORA_BASIC_IMAGE_BUNDLE));
|
|
|
|
field_delete_instance(field_info_instance('node_content', ISLANDORA_MODS_FIELD, ISLANDORA_BASIC_IMAGE_BUNDLE));
|
|
|
|
node_type_delete(ISLANDORA_BASIC_IMAGE_BUNDLE);
|
|
|
|
}
|