Browse Source

Islandora MODS module.

7.x-2.x
Daniel Lamb 10 years ago
parent
commit
fbf8ee87ca
  1. 58
      islandora/include/fields.inc
  2. 6
      islandora/islandora.install
  3. 5
      islandora/islandora.module
  4. 13
      islandora_basic_image/islandora_basic_image.install
  5. 2
      islandora_dc/include/fields.inc
  6. 9
      islandora_dc/islandora_dc.module
  7. 36
      islandora_mods/include/fields.inc
  8. 5
      islandora_mods/islandora_mods.info
  9. 19
      islandora_mods/islandora_mods.install
  10. 21
      islandora_mods/islandora_mods.module

58
islandora/include/fields.inc

@ -0,0 +1,58 @@
<?php
/**
* @file
* Utility functions for working Islandora core fields.
*/
/**
* Adds all the core Islandora fields to a bundle.
*
* @param string $bundle_name
* The name of the bundle to give the fields.
*/
function islandora_add_fields_to_bundle($bundle_name) {
// If this gets called from an install hook, we can't guarantee the t's
// existance.
$t = get_t();
// Big list of field names/labels/descriptions.
$field_data = array(
ISLANDORA_TN_FIELD => array(
'label' => 'Thumbnail',
'description' => 'Thumbnail image',
),
ISLANDORA_FEDORA_HAS_PARENT_FIELD => array(
'label' => 'fedora:hasParent',
'description' => 'Parent resource in Fedora 4',
),
ISLANDORA_PCDM_HAS_MEMBER_FIELD => array(
'label' => 'pcdm:hasMember',
'description' => 'Child resources in Fedora 4',
),
);
// Iterate over fields and add each to the specified bundle.
foreach ($field_data as $field_name => $data) {
$field_label = $data['label'];
$field_description = $data['description'];
if (field_info_field($field_name)) {
$field_instance = array(
'field_name' => $field_name,
'entity_type' => 'node',
'bundle' => $bundle_name,
'label' => $t("%label", array("%description" => $field_label)),
'description' => $t("%description", array("%description" => $field_description)),
'required' => FALSE,
);
field_create_instance($field_instance);
$message = $t('Field %name was added to %bundle successfully',
array(
'%name' => $field_name,
'%bundle' => $bundle_name,
));
drupal_set_message($message);
}
}
}

6
islandora/islandora.install

@ -17,12 +17,6 @@ function islandora_install() {
); );
field_create_field($tn_field); field_create_field($tn_field);
$mods_field = array(
'field_name' => ISLANDORA_MODS_FIELD,
'type' => 'xml_field_xml',
);
field_create_field($mods_field);
$fedora_path_field = array( $fedora_path_field = array(
'field_name' => ISLANDORA_FEDORA_PATH_FIELD, 'field_name' => ISLANDORA_FEDORA_PATH_FIELD,
'type' => 'text', 'type' => 'text',

5
islandora/islandora.module

@ -9,9 +9,8 @@ define('ISLANDORA_NAMESPACE', 'http://islandora.ca/ontology/v2/');
define('ISLANDORA_FEDORA_NAMESPACE', 'http://fedora.info/definitions/v4/repository#'); define('ISLANDORA_FEDORA_NAMESPACE', 'http://fedora.info/definitions/v4/repository#');
define('ISLANDORA_PCDM_NAMESPACE', 'http://pcdm.org/models#'); define('ISLANDORA_PCDM_NAMESPACE', 'http://pcdm.org/models#');
define('ISLANDORA_TN_FIELD', 'field_tn'); define('ISLANDORA_TN_FIELD', 'field_tn');
define('ISLANDORA_MODS_FIELD', 'field_mods'); define('ISLANDORA_FEDORA_HAS_PARENT_FIELD', 'field_fedora_has_parent');
define('ISLANDORA_FEDORA_HAS_PARENT', 'field_fedora_has_parent'); define('ISLANDORA_PCDM_HAS_MEMBER_FIELD', 'field_pcdm_has_member');
define('ISLANDORA_PCDM_HAS_MEMBER', 'field_pcdm_has_member');
/** /**
* Implements hook_ctools_plugin_api(). * Implements hook_ctools_plugin_api().

13
islandora_basic_image/islandora_basic_image.install

@ -47,17 +47,4 @@ function islandora_basic_image_install() {
field_create_instance($tn_field_instance); field_create_instance($tn_field_instance);
drupal_set_message($t('Field %name was created successfully', array('%name' => ISLANDORA_TN_FIELD))); 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_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)));
}
} }

2
islandora_dc/include/fields.inc

@ -99,7 +99,7 @@ function islandora_dc_add_fields_to_bundle($bundle_name) {
$message = $t('Field %name was added to %bundle successfully', $message = $t('Field %name was added to %bundle successfully',
array( array(
'%name' => $field_name, '%name' => $field_name,
'%bundle' => $bundle, '%bundle' => $bundle_name,
)); ));
drupal_set_message($message); drupal_set_message($message);
} }

9
islandora_dc/islandora_dc.module

@ -22,3 +22,12 @@ define('ISLANDORA_DC_SOURCE_FIELD', 'field_dc_source');
define('ISLANDORA_DC_SUBJECT_FIELD', 'field_dc_subject'); define('ISLANDORA_DC_SUBJECT_FIELD', 'field_dc_subject');
define('ISLANDORA_DC_TITLE_FIELD', 'field_dc_title'); define('ISLANDORA_DC_TITLE_FIELD', 'field_dc_title');
define('ISLANDORA_DC_TYPE_FIELD', 'field_dc_type'); define('ISLANDORA_DC_TYPE_FIELD', 'field_dc_type');
/**
* Implements hook_rdf_namespaces().
*/
function islandora_dc_rdf_namespaces() {
return array(
ISLANDORA_DC_NAMESPACE_PREFIX => ISLANDORA_DC_NAMESPACE,
);
}

36
islandora_mods/include/fields.inc

@ -0,0 +1,36 @@
<?php
/**
* @file
* Utility functions for working with MODS fields.
*/
/**
* Adds all the MODS fields to a bundle.
*
* @param string $bundle_name
* The name of the bundle to give the fields.
*/
function islandora_mods_add_fields_to_bundle($bundle_name) {
// If this gets called from an install hook, we can't guarantee the t's
// existance.
$t = get_t();
if (field_info_field(ISLANDORA_MODS_FIELD)) {
$mods_field_instance = array(
'field_name' => ISLANDORA_MODS_FIELD,
'entity_type' => 'node',
'bundle' => $bundle_name,
'label' => $t("MODS XML"),
'description' => $t("A MODS record for the Fedora resource"),
'required' => FALSE,
);
field_create_instance($mods_field_instance);
$message = $t('Field %name was successfully added to %bundle',
array(
'%name' => ISLANDORA_MODS_FIELD,
'%bundle' => $bundle_name,
));
drupal_set_message($message);
}
}

5
islandora_mods/islandora_mods.info

@ -0,0 +1,5 @@
name = Islandora MODS
description = "Fields and utilities for managing MODS metadata in Islandora"
package = Islandora
version = 7.x-dev
core = 7.x

19
islandora_mods/islandora_mods.install

@ -0,0 +1,19 @@
<?php
/**
* @file
* Install hooks for this module.
*/
/**
* Implements hook_install().
*
* Creates shared fields for content types using MODS metadata.
*/
function islandora_dc_install() {
$mods_field = array(
'field_name' => ISLANDORA_MODS_FIELD,
'type' => 'xml_field_xml',
);
field_create_field($mods_field);
}

21
islandora_mods/islandora_mods.module

@ -0,0 +1,21 @@
<?php
/**
* @file
* Islandora module for working with MODS Metadata.
*/
define('ISLANDORA_MODS_NAMESPACE', 'http://www.loc.gov/mods/v3/');
define('ISLANDORA_MODS_NAMESPACE_PREFIX', 'mods');
define('ISLANDORA_MODS_RDF_NAMESPACE', 'http://www.loc.gov/mods/modsrdf/v1#');
define('ISLANDORA_MODS_RDF_NAMESPACE_PREFIX', 'modsrdf');
define('ISLANDORA_MODS_FIELD', 'field_mods');
/**
* Implements hook_rdf_namespaces().
*/
function islandora_mods_rdf_namespaces() {
return array(
ISLANDORA_MODS_RDF_NAMESPACE_PREFIX => ISLANDORA_MODS_RDF_NAMESPACE,
);
}
Loading…
Cancel
Save