Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
234 lines (215 sloc) 8.454 kB
<?php
/**
* @file
* Handles the creation/display of islandora:sp-audioCModel objects.
*/
/**
* Implements hook_menu().
*/
function islandora_audio_menu() {
return array(
'admin/islandora/solution_pack_config/audio' => array(
'title' => 'Audio Solution Pack',
'description' => 'Select player.',
'page callback' => 'drupal_get_form',
'access arguments' => array('administer site configuration'),
'page arguments' => array('islandora_audio_admin'),
'file' => 'includes/admin.form.inc',
'type' => MENU_NORMAL_ITEM,
),
);
}
/**
* Implements hook_islandora_required_objects().
*/
function islandora_audio_islandora_required_objects(IslandoraTuque $connection) {
$module_path = drupal_get_path('module', 'islandora_audio');
// Audio Content Model.
$audio_content_model = $connection->repository->constructObject('islandora:sp-audioCModel');
$audio_content_model->owner = 'fedoraAdmin';
$audio_content_model->label = 'Islandora Audio Content Model';
$audio_content_model->models = 'fedora-system:ContentModel-3.0';
// DS-COMPOSITE-MODEL Datastream.
$datastream = $audio_content_model->constructDatastream('DS-COMPOSITE-MODEL', 'X');
$datastream->label = 'DS-COMPOSITE-MODEL';
$datastream->mimetype = 'application/xml';
$datastream->setContentFromFile("$module_path/xml/islandora_audio_ds_composite_model.xml", FALSE);
$audio_content_model->ingestDatastream($datastream);
// Audio Collection.
$audio_collection = $connection->repository->constructObject('islandora:audio_collection');
$audio_collection->owner = 'fedoraAdmin';
$audio_collection->label = 'Audio Collection';
$audio_collection->models = 'islandora:collectionCModel';
$audio_collection->relationships->add(FEDORA_RELS_EXT_URI, 'isMemberOfCollection', 'islandora:root');
// Collection Policy Datastream.
$datastream = $audio_collection->constructDatastream('COLLECTION_POLICY', 'X');
$datastream->label = 'Collection policy';
$datastream->mimetype = 'application/xml';
$datastream->setContentFromFile("$module_path/xml/islandora_audio_collection_policy.xml", FALSE);
$audio_collection->ingestDatastream($datastream);
// TN Datastream.
$datastream = $audio_collection->constructDatastream('TN', 'M');
$datastream->label = 'Thumbnail';
$datastream->mimetype = 'image/png';
$datastream->setContentFromFile("$module_path/images/folder.png", FALSE);
$audio_collection->ingestDatastream($datastream);
return array(
'islandora_audio' => array(
'title' => 'Islandora audio',
'objects' => array(
$audio_content_model,
$audio_collection,
),
),
);
}
/**
* Implements hook_CMODEL_PID_islandora_view_object().
*/
function islandora_audio_islandora_sp_audioCModel_islandora_view_object($object, $page_number, $page_size) {
$output = theme('islandora_audio', array('islandora_object' => $object));
return array('' => $output);
}
/**
* Implements hook_islandora_xml_form_builder_forms().
*/
function islandora_audio_islandora_xml_form_builder_forms() {
$module_path = drupal_get_path('module', 'islandora_audio');
return array(
'Audio MODS form' => array(
'form_file' => "$module_path/xml/islandora_audio_form_mods.xml",
),
);
}
/**
* Implements hook_islandora_xml_form_builder_form_associations().
*/
function islandora_audio_islandora_xml_form_builder_form_associations() {
return array(
'islandora_audio_mods_form' => array(
'content_model' => 'islandora:sp-audioCModel',
'form_name' => 'Audio MODS form',
'dsid' => 'MODS',
'title_field' => array('titleInfo', 'title'),
'transform' => 'mods_to_dc.xsl',
'template' => FALSE,
),
);
}
/**
* Implements hook_theme().
*/
function islandora_audio_theme($existing, $type, $theme, $path) {
return array(
'islandora_audio' => array(
'template' => 'theme/islandora-audio',
'pattern' => 'islandora_audio__',
'variables' => array('islandora_object' => NULL),
),
);
}
/**
* Implements template_preprocess_hook().
*/
function islandora_audio_preprocess_islandora_audio(array &$variables) {
drupal_add_js('misc/form.js');
drupal_add_js('misc/collapse.js');
$islandora_object = $variables['islandora_object'];
$repository = $islandora_object->repository;
module_load_include('inc', 'islandora', 'includes/datastream');
module_load_include('inc', 'islandora', 'includes/utilities');
module_load_include('inc', 'islandora', 'includes/metadata');
// We should eventually remove the DC object and dc_array code as it only
// exists to not break legacy implementations.
try {
if (isset($islandora_object['DC']) && islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $islandora_object['DC'])) {
$dc = $islandora_object['DC']->content;
$dc_object = DublinCore::importFromXMLString($dc);
}
}
catch (Exception $e) {
drupal_set_message(t('Error retrieving object %s %t', array('%s' => $islandora_object->id, '%t' => $e->getMessage())), 'error', FALSE);
}
$variables['islandora_dublin_core'] = isset($dc_object) ? $dc_object : NULL;
$variables['dc_array'] = isset($dc_object) ? $dc_object->asArray() : array();
$variables['islandora_object_label'] = $islandora_object->label;
$variables['theme_hook_suggestions'][] = 'islandora_audio__' . str_replace(':', '_', $islandora_object->id);
$variables['parent_collections'] = islandora_get_parents_from_rels_ext($islandora_object);
$variables['metadata'] = islandora_retrieve_metadata_markup($islandora_object);
$variables['description'] = islandora_retrieve_description_markup($islandora_object);
// Start getting parameters for the player...
$audio_params = array(
"pid" => $islandora_object->id,
);
// Thumbnail.
if (isset($islandora_object['TN']) && islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $islandora_object['TN'])) {
$tn_url = url("islandora/object/{$islandora_object->id}/datastream/TN/view");
$params = array(
'title' => $islandora_object->label,
'path' => $tn_url,
);
$variables['islandora_thumbnail_img'] = theme('image', $params);
$audio_params += array(
'tn' => $tn_url,
);
}
// Audio player.
if (isset($islandora_object['PROXY_MP3']) && islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $islandora_object['PROXY_MP3'])) {
$audio_url = url("islandora/object/{$islandora_object->id}/datastream/PROXY_MP3", array('absolute' => TRUE));
$audio_params += array(
"url" => $audio_url,
"mime" => 'audio/mpeg',
);
}
module_load_include('inc', 'islandora', 'includes/solution_packs');
$viewer = islandora_get_viewer($audio_params, 'islandora_audio_viewers', $islandora_object);
if ($viewer) {
$variables['islandora_content'] = $viewer;
}
elseif (isset($variables['islandora_thumbnail_img']) && isset($islandora_object['PROXY_MP3']) &&
islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $islandora_object['PROXY_MP3'])) {
$variables['islandora_content'] = l($variables['islandora_thumbnail_img'], $audio_url, array('html' => TRUE));
}
elseif (isset($islandora_object['PROXY_MP3']) && islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $islandora_object['PROXY_MP3'])) {
$variables['islandora_content'] = l($islandora_object->label, $audio_url);
}
}
/**
* Implements hook_islandora_ingest_steps().
*/
function islandora_audio_islandora_sp_audiocmodel_islandora_ingest_steps() {
return array(
'islandora_audio_upload' => array(
'weight' => 10,
'type' => 'form',
'form_id' => 'islandora_audio_audio_upload_form',
'module' => 'islandora_audio',
'file' => 'includes/audio_upload.form.inc',
),
);
}
/**
* Implements hook_CMODEL_PID_islandora_derivative().
*/
function islandora_audio_islandora_sp_audiocmodel_islandora_derivative() {
return array(
array(
'source_dsid' => 'OBJ',
'destination_dsid' => 'PROXY_MP3',
'weight' => '0',
'function' => array(
'islandora_audio_create_mp3',
),
'file' => drupal_get_path('module', 'islandora_audio') . '/includes/derivatives.inc',
),
array(
'source_dsid' => NULL,
'destination_dsid' => 'TN',
'weight' => 1,
'function' => array(
'islandora_audio_create_thumbnail',
),
'file' => drupal_get_path('module', 'islandora_audio') . '/includes/derivatives.inc',
),
);
}
Jump to Line
Something went wrong with that request. Please try again.