Browse Source

Reworked what happens in install hooks. Coder.

7.x-2.x
Daniel Lamb 10 years ago
parent
commit
ccabd9dd01
  1. 15
      islandora_basic_image/islandora_basic_image.install
  2. 41
      islandora_collection/include/fields.inc
  3. 6
      islandora_collection/islandora_collection.install

15
islandora_basic_image/islandora_basic_image.install

@ -9,6 +9,8 @@
* Implements hook_install(). * Implements hook_install().
*/ */
function islandora_basic_image_install() { function islandora_basic_image_install() {
module_load_include('inc', 'islandora', 'include/fields.inc');
// Ensure the basic image node type is available. // Ensure the basic image node type is available.
node_types_rebuild(); node_types_rebuild();
@ -35,16 +37,5 @@ function islandora_basic_image_install() {
drupal_set_message($t('Field %name was created successfully', array('%name' => ISLANDORA_BASIC_IMAGE_MEDIUM_SIZE_FIELD))); drupal_set_message($t('Field %name was created successfully', array('%name' => ISLANDORA_BASIC_IMAGE_MEDIUM_SIZE_FIELD)));
} }
if (field_info_field(ISLANDORA_TN_FIELD)) { islandora_add_fields_to_bundle(ISLANDORA_BASIC_IMAGE_CONTENT_TYPE);
$tn_field_instance = array(
'field_name' => ISLANDORA_TN_FIELD,
'entity_type' => 'node',
'bundle' => ISLANDORA_BASIC_IMAGE_CONTENT_TYPE,
'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)));
}
} }

41
islandora_collection/include/fields.inc

@ -1,41 +0,0 @@
<?php
/**
* @file
* Utility functions for attaching default fields to collections.
*/
/**
* Attaches default fields for this module's content type.
*/
function islandora_collection_attach_default_fields() {
$t = get_t();
// Add thumbnail field.
if (field_info_field(ISLANDORA_TN_FIELD)) {
$tn_field_instance = array(
'field_name' => ISLANDORA_TN_FIELD,
'entity_type' => 'node',
'bundle' => ISLANDORA_COLLECTION_CONTENT_TYPE,
'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)));
}
// Add MODS field.
if (field_info_field(ISLANDORA_MODS_FIELD)) {
$mods_field_instance = array(
'field_name' => ISLANDORA_MODS_FIELD,
'entity_type' => 'node',
'bundle' => ISLANDORA_COLLECTION_CONTENT_TYPE,
'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)));
}
}

6
islandora_collection/islandora_collection.install

@ -9,14 +9,14 @@
* Implements hook_install(). * Implements hook_install().
*/ */
function islandora_collection_install() { function islandora_collection_install() {
module_load_include('inc', 'islandora_collection', 'include/fields'); module_load_include('inc', 'islandora', 'include/fields.inc');
module_load_include('inc', 'islandora_collection', 'include/relations'); module_load_include('inc', 'islandora_collection', 'include/relations');
// Ensure the collection node type is available. // Ensure the collection node type is available.
node_types_rebuild(); node_types_rebuild();
// Create the islandora:collection content type. // Add default Islandora fields.
islandora_collection_attach_default_fields(); islandora_add_fields_to_bundle(ISLANDORA_BASIC_IMAGE_CONTENT_TYPE);
// Create the pcdm:hasMember relation. // Create the pcdm:hasMember relation.
islandora_collection_define_relations(); islandora_collection_define_relations();

Loading…
Cancel
Save