Daniel Lamb
10 years ago
10 changed files with 151 additions and 23 deletions
@ -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); |
||||
} |
||||
} |
||||
} |
@ -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); |
||||
} |
||||
} |
@ -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 |
@ -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); |
||||
} |
@ -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…
Reference in new issue