diff --git a/islandora_basic_image/islandora_basic_image.install b/islandora_basic_image/islandora_basic_image.install index 9c2e5730..36dfbe07 100644 --- a/islandora_basic_image/islandora_basic_image.install +++ b/islandora_basic_image/islandora_basic_image.install @@ -11,32 +11,10 @@ function islandora_basic_image_install() { module_load_include('inc', 'islandora_dcterms', 'include/fields'); - $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); + // Ensure the basic image node type is available. + node_types_rebuild(); - $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)); - } + $t = get_t(); // Create medium size field. $medium_size_field = array( @@ -50,7 +28,7 @@ function islandora_basic_image_install() { $medium_size_field_instance = array( 'field_name' => ISLANDORA_BASIC_IMAGE_MEDIUM_SIZE_FIELD, 'entity_type' => 'node', - 'bundle' => ISLANDORA_BASIC_IMAGE_BUNDLE, + 'bundle' => ISLANDORA_BASIC_IMAGE_CONTENT_TYPE, 'label' => $t("Medium Size"), 'description' => $t("A display copy of the image."), 'required' => FALSE, @@ -63,7 +41,7 @@ function islandora_basic_image_install() { $tn_field_instance = array( 'field_name' => ISLANDORA_TN_FIELD, 'entity_type' => 'node', - 'bundle' => ISLANDORA_BASIC_IMAGE_BUNDLE, + 'bundle' => ISLANDORA_BASIC_IMAGE_CONTENT_TYPE, 'label' => $t("Thumbnail"), 'description' => $t("A thumbnail for the Fedora resource"), 'required' => FALSE, @@ -76,7 +54,7 @@ function islandora_basic_image_install() { $mods_field_instance = array( 'field_name' => ISLANDORA_MODS_FIELD, 'entity_type' => 'node', - 'bundle' => ISLANDORA_BASIC_IMAGE_BUNDLE, + 'bundle' => ISLANDORA_BASIC_IMAGE_CONTENT_TYPE, 'label' => $t("MODS"), 'description' => $t("A MODS record for the Fedora resource"), 'required' => FALSE, @@ -85,5 +63,5 @@ function islandora_basic_image_install() { drupal_set_message($t('Field %name was created successfully', array('%name' => ISLANDORA_MODS_FIELD))); } - islandora_dcterms_attach_fields_to_bundle(ISLANDORA_BASIC_IMAGE_BUNDLE); + islandora_dcterms_attach_fields_to_bundle(ISLANDORA_BASIC_IMAGE_CONTENT_TYPE); } diff --git a/islandora_basic_image/islandora_basic_image.module b/islandora_basic_image/islandora_basic_image.module index a7ea8ba3..e8214add 100644 --- a/islandora_basic_image/islandora_basic_image.module +++ b/islandora_basic_image/islandora_basic_image.module @@ -5,16 +5,25 @@ * This is the new Islandora Basic Image module. */ -define('ISLANDORA_BASIC_IMAGE_BUNDLE', 'basic_image'); +define('ISLANDORA_BASIC_IMAGE_CONTENT_TYPE', 'islandora_basic_image'); define('ISLANDORA_BASIC_IMAGE_MEDIUM_SIZE_FIELD', 'field_medium_size'); /** - * Function for using a form. - * - * @param string $node - * The Drupal node. - * @param array $form_state - * The Drupal form state. + * Implements hook_node_info(). + */ +function islandora_basic_image_node_info() { + return array( + ISLANDORA_BASIC_IMAGE_CONTENT_TYPE => array( + 'name' => t("Basic Image"), + 'base' => ISLANDORA_BASIC_IMAGE_CONTENT_TYPE, + 'description' => t("A Drupal node modeling a basic image pcdm:Object"), + 'has_title' => FALSE, + ), + ); +} + +/** + * Implements hook_form(). */ function islandora_basic_image_form($node, array &$form_state) { return node_content_form($node, $form_state); diff --git a/islandora_collection/include/bundles.inc b/islandora_collection/include/fields.inc similarity index 54% rename from islandora_collection/include/bundles.inc rename to islandora_collection/include/fields.inc index adcbcdf1..b09e2d5c 100644 --- a/islandora_collection/include/bundles.inc +++ b/islandora_collection/include/fields.inc @@ -2,48 +2,23 @@ /** * @file - * Utility functions for defining collection bundles. + * Utility functions for attaching default fields to collections. */ /** - * Defines bundles (content types) for this module. + * Attaches default fields for this module's content type. */ -function islandora_collection_define_bundles() { +function islandora_collection_attach_default_fields() { module_load_include('inc', 'islandora_dcterms', 'include/fields'); $t = get_t(); - // Create basic_image bundle. - $collection_content_type = array( - 'type' => ISLANDORA_COLLECTION_BUNDLE, - 'name' => $t('Collection'), - 'base' => 'node_content', - 'description' => $t('A collection in Fedora'), - 'custom' => 1, - 'modified' => 1, - 'locked' => 0, - 'disabled' => 0, - ); - - $collection_content_type = node_type_set_defaults($collection_content_type); - - $status = node_type_save($collection_content_type); - - $t_args = array('%name' => $collection_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)); - } - // 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_BUNDLE, + 'bundle' => ISLANDORA_COLLECTION_CONTENT_TYPE, 'label' => $t("Thumbnail"), 'description' => $t("A thumbnail for the Fedora resource"), 'required' => FALSE, @@ -57,7 +32,7 @@ function islandora_collection_define_bundles() { $mods_field_instance = array( 'field_name' => ISLANDORA_MODS_FIELD, 'entity_type' => 'node', - 'bundle' => ISLANDORA_COLLECTION_BUNDLE, + 'bundle' => ISLANDORA_COLLECTION_CONTENT_TYPE, 'label' => $t("MODS"), 'description' => $t("A MODS record for the Fedora resource"), 'required' => FALSE, @@ -67,5 +42,5 @@ function islandora_collection_define_bundles() { } // Add dcterms fields. - islandora_dcterms_attach_fields_to_bundle(ISLANDORA_COLLECTION_BUNDLE); + islandora_dcterms_attach_fields_to_bundle(ISLANDORA_COLLECTION_CONTENT_TYPE); } diff --git a/islandora_collection/islandora_collection.install b/islandora_collection/islandora_collection.install index 92fd6f95..cc11b709 100644 --- a/islandora_collection/islandora_collection.install +++ b/islandora_collection/islandora_collection.install @@ -9,11 +9,14 @@ * Implements hook_install(). */ function islandora_collection_install() { - module_load_include('inc', 'islandora_collection', 'include/bundles'); + module_load_include('inc', 'islandora_collection', 'include/fields'); module_load_include('inc', 'islandora_collection', 'include/relations'); + // Ensure the collection node type is available. + node_types_rebuild(); + // Create the islandora:collection content type. - islandora_collection_define_bundles(); + islandora_collection_attach_default_fields(); // Create the pcdm:hasMember relation. islandora_collection_define_relations(); diff --git a/islandora_collection/islandora_collection.module b/islandora_collection/islandora_collection.module index 6b95dbf6..4194d61f 100644 --- a/islandora_collection/islandora_collection.module +++ b/islandora_collection/islandora_collection.module @@ -5,7 +5,7 @@ * This is the new Islandora Collection module. */ -define('ISLANDORA_COLLECTION_BUNDLE', 'collection'); +define('ISLANDORA_COLLECTION_CONTENT_TYPE', 'islandora_collection'); /** * Implements hook_views_api(). @@ -17,6 +17,20 @@ function islandora_collection_views_api() { ); } +/** + * Implements hook_node_info(). + */ +function islandora_collection_node_info() { + return array( + ISLANDORA_COLLECTION_CONTENT_TYPE => array( + 'name' => t("Collection"), + 'base' => ISLANDORA_COLLECTION_CONTENT_TYPE, + 'description' => t("A Drupal node modeling an pcdm:Collection."), + 'has_title' => FALSE, + ), + ); +} + /** * Function for using a form. *