Browse Source

ISLANDORA-743 Before the hook was not firing at the right time.

pull/164/head
William Panting 12 years ago
parent
commit
f863d9f2a4
  1. 262
      fedora_repository.module
  2. 16
      fedora_repository.solutionpacks.inc

262
fedora_repository.module

@ -27,7 +27,7 @@ function fedora_repository_menu() {
* *
* @param type $path * @param type $path
* @param type $arg * @param type $arg
* @return type * @return type
*/ */
function fedora_repository_help($path, $arg) { function fedora_repository_help($path, $arg) {
switch ($path) { switch ($path) {
@ -42,7 +42,7 @@ function fedora_repository_help($path, $arg) {
* fedora repository purge object * fedora repository purge object
* @param type $pid * @param type $pid
* @param type $name * @param type $name
* @return type * @return type
*/ */
function fedora_repository_purge_object($pid = NULL, $name = NULL) { function fedora_repository_purge_object($pid = NULL, $name = NULL) {
if (!user_access('purge objects and datastreams')) { if (!user_access('purge objects and datastreams')) {
@ -67,7 +67,7 @@ function fedora_repository_purge_object($pid = NULL, $name = NULL) {
* @param type $collection_pid * @param type $collection_pid
* @param type $collection_label * @param type $collection_label
* @param type $content_model * @param type $content_model
* @return type * @return type
*/ */
function fedora_repository_ingest_object($collection_pid=NULL, $collection_label = NULL, $content_model = NULL) { function fedora_repository_ingest_object($collection_pid=NULL, $collection_label = NULL, $content_model = NULL) {
module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
@ -106,7 +106,7 @@ function fedora_repository_ingest_object($collection_pid=NULL, $collection_label
* @global type $base_url * @global type $base_url
* @global type $user * @global type $user
* @param array $form * @param array $form
* @param array $form_state * @param array $form_state
*/ */
function fedora_repository_ingest_form_submit(array $form, array &$form_state) { function fedora_repository_ingest_form_submit(array $form, array &$form_state) {
//only validate the form if the submit button was pressed (other buttons may be used for AHAH //only validate the form if the submit button was pressed (other buttons may be used for AHAH
@ -163,7 +163,7 @@ function fedora_repository_ingest_form_submit(array $form, array &$form_state) {
* fedora repository ingest form validate * fedora repository ingest form validate
* @param type $form * @param type $form
* @param type $form_state * @param type $form_state
* @return type * @return type
*/ */
function fedora_repository_ingest_form_validate($form, &$form_state) { function fedora_repository_ingest_form_validate($form, &$form_state) {
//only validate the form if the submit button was pressed (other buttons may be used for AHAH //only validate the form if the submit button was pressed (other buttons may be used for AHAH
@ -220,7 +220,7 @@ function fedora_repository_ingest_form_validate($form, &$form_state) {
if (!empty($file)) { if (!empty($file)) {
if (!in_array($dformat, $allowedMimeTypes)) { if (!in_array($dformat, $allowedMimeTypes)) {
form_set_error($ifl, form_set_error($ifl,
t('The uploaded file\'s mimetype (@mime) is not associated with this Content Model. The allowed types are: @allowed', array( t('The uploaded file\'s mimetype (@mime) is not associated with this Content Model. The allowed types are: @allowed', array(
'@mime' => $dformat, '@mime' => $dformat,
'@allowed' => implode(', ', $allowedMimeTypes), '@allowed' => implode(', ', $allowedMimeTypes),
@ -249,7 +249,7 @@ function fedora_repository_ingest_form_validate($form, &$form_state) {
* @param type $collection_pid * @param type $collection_pid
* @param type $collection_label * @param type $collection_label
* @param type $content_model * @param type $content_model
* @return type * @return type
*/ */
function fedora_repository_ingest_form(&$form_state, $collection_pid, $collection_label = NULL, $content_model = NULL) { function fedora_repository_ingest_form(&$form_state, $collection_pid, $collection_label = NULL, $content_model = NULL) {
module_load_include('inc', 'fedora_repository', 'formClass'); module_load_include('inc', 'fedora_repository', 'formClass');
@ -270,7 +270,7 @@ function fedora_repository_ingest_form(&$form_state, $collection_pid, $collectio
* @param type $form_state * @param type $form_state
* @param type $pid * @param type $pid
* @param type $referrer * @param type $referrer
* @return type * @return type
*/ */
function fedora_repository_purge_object_form(&$form_state, $pid, $referrer = NULL) { function fedora_repository_purge_object_form(&$form_state, $pid, $referrer = NULL) {
global $base_url; global $base_url;
@ -319,7 +319,7 @@ function fedora_repository_purge_object_form(&$form_state, $pid, $referrer = NUL
* add stream * add stream
* @param type $collection_pid * @param type $collection_pid
* @param type $collectionName * @param type $collectionName
* @return type * @return type
*/ */
function add_stream($collection_pid=NULL, $collectionName=NULL) { function add_stream($collection_pid=NULL, $collectionName=NULL) {
module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
@ -345,7 +345,7 @@ function add_stream($collection_pid=NULL, $collectionName=NULL) {
* @global type $base_url * @global type $base_url
* @param type $form * @param type $form
* @param type $form_state * @param type $form_state
* @return type * @return type
*/ */
function add_stream_form_submit($form, &$form_state) { function add_stream_form_submit($form, &$form_state) {
global $base_url; global $base_url;
@ -353,7 +353,7 @@ function add_stream_form_submit($form, &$form_state) {
$form_state['rebuild'] = TRUE; $form_state['rebuild'] = TRUE;
return; return;
} }
module_load_include('inc', 'fedora_repository', 'ObjectHelper'); module_load_include('inc', 'fedora_repository', 'ObjectHelper');
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$pathToModule = drupal_get_path('module', 'fedora_repository'); $pathToModule = drupal_get_path('module', 'fedora_repository');
@ -384,7 +384,7 @@ function add_stream_form_submit($form, &$form_state) {
* add stream form * add stream form
* @param type $form_state * @param type $form_state
* @param type $pid * @param type $pid
* @return type * @return type
*/ */
function add_stream_form(&$form_state, $pid) { function add_stream_form(&$form_state, $pid) {
module_load_include('inc', 'fedora_repository', 'formClass'); module_load_include('inc', 'fedora_repository', 'formClass');
@ -396,7 +396,7 @@ function add_stream_form(&$form_state, $pid) {
* add stream form validate * add stream form validate
* @param type $form * @param type $form
* @param type $form_state * @param type $form_state
* @return type * @return type
*/ */
function add_stream_form_validate($form, &$form_state) { function add_stream_form_validate($form, &$form_state) {
module_load_include('inc', 'fedora_repository', 'MimeClass'); module_load_include('inc', 'fedora_repository', 'MimeClass');
@ -427,14 +427,14 @@ function add_stream_form_validate($form, &$form_state) {
// 'file_validate_image_resolution' => array('85x85'), // 'file_validate_image_resolution' => array('85x85'),
// 'file_validate_size' => array(30 * 1024), // 'file_validate_size' => array(30 * 1024),
); );
$controlGroup = $form_state['storage']['control_group'] = $form_state['values']['control_group']; $controlGroup = $form_state['storage']['control_group'] = $form_state['values']['control_group'];
if ((($controlGroup && in_array($controlGroup, array('X', 'M'))) || !$controlGroup) && (($fileObject = file_save_upload('add-stream-file-location', $validators)))) { if ((($controlGroup && in_array($controlGroup, array('X', 'M'))) || !$controlGroup) && (($fileObject = file_save_upload('add-stream-file-location', $validators)))) {
// Move the uploaded file to Drupal's files directory. // Move the uploaded file to Drupal's files directory.
$file_path = $fileObject->filepath; $file_path = $fileObject->filepath;
file_move($file_path, 0, FILE_EXISTS_RENAME); file_move($file_path, 0, FILE_EXISTS_RENAME);
$form_state['values']['add-stream-file-location'] = $file_path; $form_state['values']['add-stream-file-location'] = $file_path;
$form_state['storage']['stream_url'] = file_create_url($file_path); $form_state['storage']['stream_url'] = file_create_url($file_path);
} }
elseif ($controlGroup && in_array($controlGroup, array('M', 'R', 'E')) && ($ref = $form_state['values']['ds_reference'])) { elseif ($controlGroup && in_array($controlGroup, array('M', 'R', 'E')) && ($ref = $form_state['values']['ds_reference'])) {
@ -443,10 +443,10 @@ function add_stream_form_validate($form, &$form_state) {
else { else {
form_set_error('', t('No file given when "X" or "M", or no reference given when "M", "R" or "E".')); form_set_error('', t('No file given when "X" or "M", or no reference given when "M", "R" or "E".'));
} }
$mimeClass = new MimeClass(); $mimeClass = new MimeClass();
$mimetype = $form_state['storage']['ds_mimetype'] = $mimeClass->getType($form_state['storage']['stream_url']); $mimetype = $form_state['storage']['ds_mimetype'] = $mimeClass->getType($form_state['storage']['stream_url']);
if (!$controlGroup) { if (!$controlGroup) {
if ($mimetype == 'text/xml') { if ($mimetype == 'text/xml') {
$form_state['storage']['control_group'] = 'X'; $form_state['storage']['control_group'] = 'X';
@ -455,7 +455,7 @@ function add_stream_form_validate($form, &$form_state) {
$form_state['storage']['control_group'] = 'M'; $form_state['storage']['control_group'] = 'M';
} }
} }
// TODO: Add error checking here. // TODO: Add error checking here.
$form_state['rebuild'] = FALSE; $form_state['rebuild'] = FALSE;
} }
@ -466,7 +466,7 @@ function add_stream_form_validate($form, &$form_state) {
* @param type $pid * @param type $pid
* @param type $dsId * @param type $dsId
* @param type $name * @param type $name
* @return type * @return type
*/ */
function fedora_repository_purge_stream($pid = NULL, $dsId = NULL, $name = NULL) { function fedora_repository_purge_stream($pid = NULL, $dsId = NULL, $name = NULL) {
module_load_include('inc', 'fedora_repository', 'ObjectHelper'); module_load_include('inc', 'fedora_repository', 'ObjectHelper');
@ -508,7 +508,7 @@ function fedora_repository_purge_object_form_validate($form, &$form_state) {
* fedora repository purge object form submit * fedora repository purge object form submit
* @param type $form * @param type $form
* @param type $form_state * @param type $form_state
* @return type * @return type
*/ */
function fedora_repository_purge_object_form_submit($form, &$form_state) { function fedora_repository_purge_object_form_submit($form, &$form_state) {
module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); module_load_include('inc', 'fedora_repository', 'ConnectionHelper');
@ -557,7 +557,7 @@ function fedora_repository_purge_object_form_submit($form, &$form_state) {
* @param type $form_state * @param type $form_state
* @param type $pid * @param type $pid
* @param type $dsId * @param type $dsId
* @return type * @return type
*/ */
function fedora_repository_purge_stream_form(&$form_state, $pid, $dsId) { function fedora_repository_purge_stream_form(&$form_state, $pid, $dsId) {
$form['pid'] = array( $form['pid'] = array(
@ -580,7 +580,7 @@ function fedora_repository_purge_stream_form(&$form_state, $pid, $dsId) {
* fedora repository purge stream form submit * fedora repository purge stream form submit
* @global type $base_url * @global type $base_url
* @param type $form * @param type $form
* @param array $form_state * @param array $form_state
*/ */
function fedora_repository_purge_stream_form_submit($form, &$form_state) { function fedora_repository_purge_stream_form_submit($form, &$form_state) {
global $base_url; global $base_url;
@ -605,7 +605,7 @@ function fedora_repository_download_datastream_form(&$form_state, $pid, $dsid, $
'#value' => t('Download'), '#value' => t('Download'),
), ),
); );
if (user_access(ObjectHelper::$EDIT_FEDORA_METADATA)) { if (user_access(ObjectHelper::$EDIT_FEDORA_METADATA)) {
$item = new Fedora_Item($pid); $item = new Fedora_Item($pid);
$versions = $item->get_datastream_history($dsid); $versions = $item->get_datastream_history($dsid);
@ -618,7 +618,7 @@ function fedora_repository_download_datastream_form(&$form_state, $pid, $dsid, $
else { else {
$version_array[] = $versions->createDate; $version_array[] = $versions->createDate;
} }
if (count($version_array) > 1) { if (count($version_array) > 1) {
$form['#attributes'] = array( $form['#attributes'] = array(
'onsubmit' => 'this.action="' . $form['#action'] . '/" + this.version.value;' 'onsubmit' => 'this.action="' . $form['#action'] . '/" + this.version.value;'
@ -629,7 +629,7 @@ function fedora_repository_download_datastream_form(&$form_state, $pid, $dsid, $
); );
} }
} }
return $form; return $form;
} }
@ -639,7 +639,7 @@ function fedora_repository_download_datastream_form(&$form_state, $pid, $dsid, $
* @param type $dsId * @param type $dsId
* @param type $dsLabel * @param type $dsLabel
* @param type $collectionName * @param type $collectionName
* @return type * @return type
*/ */
function fedora_repository_replace_stream($pid, $dsId, $dsLabel = '', $collectionName = NULL) { function fedora_repository_replace_stream($pid, $dsId, $dsLabel = '', $collectionName = NULL) {
if ($pid == NULL || $dsId == NULL) { if ($pid == NULL || $dsId == NULL) {
@ -657,7 +657,7 @@ function fedora_repository_replace_stream($pid, $dsId, $dsLabel = '', $collectio
* @param type $pid * @param type $pid
* @param type $dsId * @param type $dsId
* @param type $dsLabel * @param type $dsLabel
* @return type * @return type
*/ */
function fedora_repository_replace_stream_form(&$form_state, $pid, $dsId, $dsLabel) { function fedora_repository_replace_stream_form(&$form_state, $pid, $dsId, $dsLabel) {
module_load_include('inc', 'fedora_repository', 'formClass'); module_load_include('inc', 'fedora_repository', 'formClass');
@ -669,7 +669,7 @@ function fedora_repository_replace_stream_form(&$form_state, $pid, $dsId, $dsLab
* fedora repository replace stream form validate * fedora repository replace stream form validate
* @param type $form * @param type $form
* @param type $form_state * @param type $form_state
* @return type * @return type
*/ */
function fedora_repository_replace_stream_form_validate($form, &$form_state) { function fedora_repository_replace_stream_form_validate($form, &$form_state) {
// If a file was uploaded, process it. // If a file was uploaded, process it.
@ -683,7 +683,7 @@ function fedora_repository_replace_stream_form_validate($form, &$form_state) {
form_set_error('file', 'Error uploading file.'); form_set_error('file', 'Error uploading file.');
return; return;
} }
/* ----------------------------------------------------------------- /* -----------------------------------------------------------------
* TODO: need a better way to get mimetypes * TODO: need a better way to get mimetypes
*/ */
@ -691,7 +691,7 @@ function fedora_repository_replace_stream_form_validate($form, &$form_state) {
module_load_include('inc', 'fedora_repository', 'MimeClass'); module_load_include('inc', 'fedora_repository', 'MimeClass');
$mime = new MimeClass(); $mime = new MimeClass();
$mimetype = $form_state['storage']['mime_type'] = $mime->getType($file->filepath); $mimetype = $form_state['storage']['mime_type'] = $mime->getType($file->filepath);
if ($mimetype == 'text/xml' && !DOMDocument::load($file->filepath)) { if ($mimetype == 'text/xml' && !DOMDocument::load($file->filepath)) {
form_set_error('file', 'Invalid XML format. (XML could not be parsed)'); form_set_error('file', 'Invalid XML format. (XML could not be parsed)');
return; return;
@ -709,7 +709,7 @@ function fedora_repository_replace_stream_form_validate($form, &$form_state) {
* fedora repository replace stream form submit * fedora repository replace stream form submit
* @global type $base_url * @global type $base_url
* @param type $form * @param type $form
* @param array $form_state * @param array $form_state
*/ */
function fedora_repository_replace_stream_form_submit($form, &$form_state) { function fedora_repository_replace_stream_form_submit($form, &$form_state) {
$file = $form_state['values']['file']; $file = $form_state['values']['file'];
@ -717,11 +717,11 @@ function fedora_repository_replace_stream_form_submit($form, &$form_state) {
$pid = $form_state['values']['pid']; $pid = $form_state['values']['pid'];
$dsid = $form_state['values']['dsId']; $dsid = $form_state['values']['dsId'];
$dsLabel = $form_state['values']['dsLabel']; $dsLabel = $form_state['values']['dsLabel'];
$streamUrl = ($file !== NULL) ? $streamUrl = ($file !== NULL) ?
file_create_url($file->filepath): file_create_url($file->filepath):
url($form_state['values']['reference'], array('absolute' => TRUE)); url($form_state['values']['reference'], array('absolute' => TRUE));
// Remove the original file extension from the label and add the new one // Remove the original file extension from the label and add the new one
// use strrpos to get the last dot // use strrpos to get the last dot
if (($indexOfDot = strrpos($dsLabel, '.')) !== FALSE) { if (($indexOfDot = strrpos($dsLabel, '.')) !== FALSE) {
@ -744,7 +744,7 @@ function fedora_repository_replace_stream_form_submit($form, &$form_state) {
* @global type $user * @global type $user
* @param type $pid * @param type $pid
* @param type $dsId * @param type $dsId
* @return type * @return type
*/ */
function fedora_repository_edit_qdc_page($pid = NULL, $dsId = NULL) { function fedora_repository_edit_qdc_page($pid = NULL, $dsId = NULL) {
module_load_include('inc', 'fedora_repository', 'ObjectHelper'); module_load_include('inc', 'fedora_repository', 'ObjectHelper');
@ -763,12 +763,12 @@ function fedora_repository_edit_qdc_page($pid = NULL, $dsId = NULL) {
} }
/** /**
* fedora repository edit qdc form * fedora repository edit qdc form
* @global type $user * @global type $user
* @param type $form_state * @param type $form_state
* @param type $pid * @param type $pid
* @param type $dsId * @param type $dsId
* @return type * @return type
*/ */
function fedora_repository_edit_qdc_form(&$form_state, $pid, $dsId = NULL) { function fedora_repository_edit_qdc_form(&$form_state, $pid, $dsId = NULL) {
module_load_include('inc', 'fedora_repository', 'ContentModel'); module_load_include('inc', 'fedora_repository', 'ContentModel');
@ -786,7 +786,7 @@ function fedora_repository_edit_qdc_form(&$form_state, $pid, $dsId = NULL) {
module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); module_load_include('inc', 'fedora_repository', 'ConnectionHelper');
$soapHelper = new ConnectionHelper(); $soapHelper = new ConnectionHelper();
$client = $soapHelper->getSoapClient(variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl')); $client = $soapHelper->getSoapClient(variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl'));
// Check if there is a custom edit metadata function defined in the content model. // Check if there is a custom edit metadata function defined in the content model.
$output = ''; $output = '';
if (($cm = ContentModel::loadFromObject($pid)) !== FALSE) { if (($cm = ContentModel::loadFromObject($pid)) !== FALSE) {
@ -799,14 +799,14 @@ function fedora_repository_edit_qdc_form(&$form_state, $pid, $dsId = NULL) {
//currently we only edit the dc metadata. If you defined a custom form with a custom handler you are sol for now. //currently we only edit the dc metadata. If you defined a custom form with a custom handler you are sol for now.
$output = $metaDataForm->createMetaDataForm($pid, $dsId, $client, $form_state); $output = $metaDataForm->createMetaDataForm($pid, $dsId, $client, $form_state);
} }
return $output; return $output;
} }
/** /**
* fedora repository edit qdc form validate * fedora repository edit qdc form validate
* @param type $form * @param type $form
* @param boolean $form_state * @param boolean $form_state
*/ */
function fedora_repository_edit_qdc_form_validate($form, &$form_state) { function fedora_repository_edit_qdc_form_validate($form, &$form_state) {
if ($form_state['storage']['xml']) { if ($form_state['storage']['xml']) {
@ -886,7 +886,7 @@ function fedora_repository_perm() {
* @param type $op * @param type $op
* @param type $node * @param type $node
* @param type $account * @param type $account
* @return type * @return type
*/ */
function fedora_repository_access($op, $node = NULL, $account = NULL) { function fedora_repository_access($op, $node = NULL, $account = NULL) {
module_load_include('inc', 'fedora_repository', 'ObjectHelper'); module_load_include('inc', 'fedora_repository', 'ObjectHelper');
@ -935,7 +935,7 @@ function makeObject($pid, $dsID) {
/** /**
* Implementation of hook_islandora_tabs(). * Implementation of hook_islandora_tabs().
* *
* @param $content_models array * @param $content_models array
* An array of ContentModel objects to which the current Fedora Object * An array of ContentModel objects to which the current Fedora Object
* subscribes. * subscribes.
@ -949,10 +949,10 @@ function makeObject($pid, $dsID) {
*/ */
function fedora_repository_islandora_tabs($content_models, $pid, $page_number) { function fedora_repository_islandora_tabs($content_models, $pid, $page_number) {
$cmodels_tabs = array(); $cmodels_tabs = array();
foreach ($content_models as $content_model) { foreach ($content_models as $content_model) {
$content_model_fieldset = $content_model->displayExtraFieldset($pid, $page_number); $content_model_fieldset = $content_model->displayExtraFieldset($pid, $page_number);
// Each content model may return either a tabpage array or plain HTML. If // Each content model may return either a tabpage array or plain HTML. If
// it is HTML, stick it in a tabpage. // it is HTML, stick it in a tabpage.
if (is_array($content_model_fieldset)) { if (is_array($content_model_fieldset)) {
@ -966,24 +966,24 @@ function fedora_repository_islandora_tabs($content_models, $pid, $page_number) {
); );
} }
} }
//can disable showing the object details tab in admin UI //can disable showing the object details tab in admin UI
if (variable_get('fedora_repository_show_object_details_tab', TRUE)) { if (variable_get('fedora_repository_show_object_details_tab', TRUE)) {
// Add a 'manage object' tab for all objects, where detailed list of content is shown. // Add a 'manage object' tab for all objects, where detailed list of content is shown.
// XXX: Perhaps this should be extracted into its own object? // XXX: Perhaps this should be extracted into its own object?
module_load_include('inc', 'fedora_repository', 'plugins/FedoraObjectDetailedContent'); module_load_include('inc', 'fedora_repository', 'plugins/FedoraObjectDetailedContent');
$obj = new FedoraObjectDetailedContent($pid); $obj = new FedoraObjectDetailedContent($pid);
$object_details = $obj->showFieldSets(); $object_details = $obj->showFieldSets();
$cmodels_tabs = array_merge($cmodels_tabs, $object_details); $cmodels_tabs = array_merge($cmodels_tabs, $object_details);
} }
return $cmodels_tabs; return $cmodels_tabs;
} }
/** /**
* Implementation of hook_islandora_tabs_alter(). * Implementation of hook_islandora_tabs_alter().
* *
* @param &$tabs array * @param &$tabs array
* The array of tabs/tabset to alter. * The array of tabs/tabset to alter.
* @param $params array * @param $params array
@ -1006,7 +1006,7 @@ function fedora_repository_islandora_tabs_alter(&$tabs, $params) {
/** /**
* Menu callback for "fedora/repository". * Menu callback for "fedora/repository".
* *
* If user is allow, and we are given a PID and a sensical DSID, return the * If user is allow, and we are given a PID and a sensical DSID, return the
* datastream via the makeObject() function; otherwise, call out to the PIDs' * datastream via the makeObject() function; otherwise, call out to the PIDs'
* ContentModels and all Drupal modules for Islandora tabs. * ContentModels and all Drupal modules for Islandora tabs.
@ -1088,29 +1088,29 @@ function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NU
$breadcrumbs = array(); $breadcrumbs = array();
$objectHelper->getBreadcrumbs($pid, $breadcrumbs); $objectHelper->getBreadcrumbs($pid, $breadcrumbs);
drupal_set_breadcrumb(array_reverse($breadcrumbs)); drupal_set_breadcrumb(array_reverse($breadcrumbs));
drupal_set_title(truncate_utf8($item->objectProfile->objLabel, 56, TRUE, TRUE)); drupal_set_title(truncate_utf8($item->objectProfile->objLabel, 56, TRUE, TRUE));
$content_models = $objectHelper->get_content_models_list($pid); $content_models = $objectHelper->get_content_models_list($pid);
//Get the tabs from all modules... //Get the tabs from all modules...
$hook_tabs = module_invoke_all('islandora_tabs', $content_models, $pid, $page_number); $hook_tabs = module_invoke_all('islandora_tabs', $content_models, $pid, $page_number);
$cmodels_tabs = array( $cmodels_tabs = array(
'#type' => 'tabset', '#type' => 'tabset',
); );
$cmodels_tabs += $hook_tabs; $cmodels_tabs += $hook_tabs;
//Assemble parameters, to pass during alter //Assemble parameters, to pass during alter
$params = array( $params = array(
'content_models' => $content_models, 'content_models' => $content_models,
'pid' => $pid, 'pid' => $pid,
'page' => $page_number, 'page' => $page_number,
); );
//Allow returned tabs to be altered, before return. //Allow returned tabs to be altered, before return.
drupal_alter('islandora_tabs', $cmodels_tabs, $params); drupal_alter('islandora_tabs', $cmodels_tabs, $params);
return tabs_render($cmodels_tabs); return tabs_render($cmodels_tabs);
} }
@ -1118,7 +1118,7 @@ function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NU
* fedora repository urlencode string * fedora repository urlencode string
* FIXME: URL-encoding is not the same as HTML/XML encoding... * FIXME: URL-encoding is not the same as HTML/XML encoding...
* @param type $str * @param type $str
* @return type * @return type
*/ */
function fedora_repository_urlencode_string($str) { function fedora_repository_urlencode_string($str) {
return htmlentities($str); return htmlentities($str);
@ -1133,7 +1133,7 @@ function fedora_repository_urlencode_string($str) {
* @param type $dsId * @param type $dsId
* @param type $label * @param type $label
* @param type $version * @param type $version
* @return type * @return type
*/ */
function fedora_object_as_attachment($pid, $dsId, $label=NULL, $version=NULL) { function fedora_object_as_attachment($pid, $dsId, $label=NULL, $version=NULL) {
module_load_include('inc', 'fedora_repository', 'ObjectHelper'); module_load_include('inc', 'fedora_repository', 'ObjectHelper');
@ -1156,7 +1156,7 @@ function fedora_object_as_attachment($pid, $dsId, $label=NULL, $version=NULL) {
* @param type $dsId * @param type $dsId
* @param type $collection * @param type $collection
* @param type $pageNumber * @param type $pageNumber
* @return type * @return type
*/ */
function repository_page($pid = NULL, $dsId = NULL, $collection = NULL, $pageNumber = NULL) { function repository_page($pid = NULL, $dsId = NULL, $collection = NULL, $pageNumber = NULL) {
//do security check at fedora_repository_get_items function as it has to be called there in case //do security check at fedora_repository_get_items function as it has to be called there in case
@ -1170,7 +1170,7 @@ function repository_page($pid = NULL, $dsId = NULL, $collection = NULL, $pageNum
* @param type $pid * @param type $pid
* @param type $servicePid * @param type $servicePid
* @param type $serviceMethod * @param type $serviceMethod
* @return type * @return type
*/ */
function repository_service($pid = NULL, $servicePid = NULL, $serviceMethod = NULL) { function repository_service($pid = NULL, $servicePid = NULL, $serviceMethod = NULL) {
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
@ -1216,7 +1216,7 @@ function repository_service($pid = NULL, $servicePid = NULL, $serviceMethod = NU
* *
* @param type $op * @param type $op
* @param type $keys * @param type $keys
* @return array * @return array
*/ */
function fedora_repository_search($op = 'search', $keys = NULL) { function fedora_repository_search($op = 'search', $keys = NULL) {
module_load_include('inc', 'fedora_repository', 'ObjectHelper'); module_load_include('inc', 'fedora_repository', 'ObjectHelper');
@ -1299,7 +1299,7 @@ function fedora_repository_search($op = 'search', $keys = NULL) {
* Display the search results * Display the search results
* *
* @param type $resultData * @param type $resultData
* @return array * @return array
*/ */
function fedora_repository_search_page($resultData) { function fedora_repository_search_page($resultData) {
$path = drupal_get_path('module', 'fedora_repository'); $path = drupal_get_path('module', 'fedora_repository');
@ -1377,7 +1377,7 @@ function fedora_repository_search_page($resultData) {
* *
* @param type $form * @param type $form
* @param type $form_state * @param type $form_state
* @param type $form_id * @param type $form_id
*/ */
function fedora_repository_form_alter(&$form, &$form_state, $form_id) { function fedora_repository_form_alter(&$form, &$form_state, $form_id) {
// Advanced node search form // Advanced node search form
@ -1433,7 +1433,7 @@ function fedora_repository_form_alter(&$form, &$form_state, $form_id) {
* Implementation of hook_search_validate() * Implementation of hook_search_validate()
* *
* @param type $form * @param type $form
* @param type $form_state * @param type $form_state
*/ */
function fedora_repository_search_validate($form, &$form_state) { function fedora_repository_search_validate($form, &$form_state) {
// Initialise using any existing basic search keywords. // Initialise using any existing basic search keywords.
@ -1453,7 +1453,7 @@ function fedora_repository_search_validate($form, &$form_state) {
/** /**
* fedora repository theme * fedora repository theme
* @return type * @return type
*/ */
function fedora_repository_theme() { function fedora_repository_theme() {
return array( return array(
@ -1481,7 +1481,7 @@ function fedora_repository_theme() {
* @param type $field * @param type $field
* @param type $startTerm * @param type $startTerm
* @param type $displayName * @param type $displayName
* @return type * @return type
*/ */
function fedora_repository_list_terms($field, $startTerm = NULL, $displayName = NULL) { function fedora_repository_list_terms($field, $startTerm = NULL, $displayName = NULL) {
module_load_include('inc', 'fedora_repository', 'SearchClass'); module_load_include('inc', 'fedora_repository', 'SearchClass');
@ -1491,7 +1491,7 @@ function fedora_repository_list_terms($field, $startTerm = NULL, $displayName =
/** /**
* fedora repository mnpl advanced search form * fedora repository mnpl advanced search form
* @return type * @return type
*/ */
function fedora_repository_mnpl_advanced_search_form() { function fedora_repository_mnpl_advanced_search_form() {
module_load_include('inc', 'fedora_repository', 'SearchClass'); module_load_include('inc', 'fedora_repository', 'SearchClass');
@ -1500,9 +1500,9 @@ function fedora_repository_mnpl_advanced_search_form() {
} }
/** /**
* theme fedora repository mnpl advanced search form * theme fedora repository mnpl advanced search form
* @param type $form * @param type $form
* @return type * @return type
*/ */
function theme_fedora_repository_mnpl_advanced_search_form($form) { function theme_fedora_repository_mnpl_advanced_search_form($form) {
module_load_include('inc', 'fedora_repository', 'SearchClass'); module_load_include('inc', 'fedora_repository', 'SearchClass');
@ -1514,7 +1514,7 @@ function theme_fedora_repository_mnpl_advanced_search_form($form) {
* fedora repository mnpl advanced search * fedora repository mnpl advanced search
* @param type $query * @param type $query
* @param type $startPage * @param type $startPage
* @return type * @return type
*/ */
function fedora_repository_mnpl_advanced_search($query, $startPage = 1) { function fedora_repository_mnpl_advanced_search($query, $startPage = 1) {
module_load_include('inc', 'fedora_repository', 'SearchClass'); module_load_include('inc', 'fedora_repository', 'SearchClass');
@ -1526,7 +1526,7 @@ function fedora_repository_mnpl_advanced_search($query, $startPage = 1) {
/** /**
* fedora repository mnpl_advanced search form submit * fedora repository mnpl_advanced search form submit
* @param type $form * @param type $form
* @param type $form_state * @param type $form_state
*/ */
function fedora_repository_mnpl_advanced_search_form_submit($form, &$form_state) { function fedora_repository_mnpl_advanced_search_form_submit($form, &$form_state) {
$type_id = $form_state['values']['type']; $type_id = $form_state['values']['type'];
@ -1548,7 +1548,7 @@ function fedora_repository_mnpl_advanced_search_form_submit($form, &$form_state)
/** /**
* fedora repository install demo page * fedora repository install demo page
* @return type * @return type
*/ */
function fedora_repository_install_demos_page() { function fedora_repository_install_demos_page() {
$output = drupal_get_form('fedora_repository_demo_objects_form'); $output = drupal_get_form('fedora_repository_demo_objects_form');
@ -1557,7 +1557,7 @@ function fedora_repository_install_demos_page() {
/** /**
* fedora repository demo objects form * fedora repository demo objects form
* @return string * @return string
*/ */
function fedora_repository_demo_objects_form() { function fedora_repository_demo_objects_form() {
module_load_include('inc', 'fedora_repository', 'ObjectHelper'); module_load_include('inc', 'fedora_repository', 'ObjectHelper');
@ -1590,7 +1590,7 @@ function fedora_repository_demo_objects_form() {
try { try {
$demo_objects[$available_demo] = new Fedora_Item($available_demo); $demo_objects[$available_demo] = new Fedora_Item($available_demo);
} catch (exception $e) { } catch (exception $e) {
} }
if (empty($demo_objects[$available_demo]->objectProfile)) { if (empty($demo_objects[$available_demo]->objectProfile)) {
@ -1650,7 +1650,7 @@ function fedora_repository_demo_objects_form() {
* fedora repository demo objects form submit * fedora repository demo objects form submit
* @global type $base_url * @global type $base_url
* @param type $form * @param type $form
* @param type $form_state * @param type $form_state
*/ */
function fedora_repository_demo_objects_form_submit($form, &$form_state) { function fedora_repository_demo_objects_form_submit($form, &$form_state) {
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
@ -1727,7 +1727,7 @@ function fedora_repository_demo_objects_form_submit($form, &$form_state) {
$tn = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/Crystal_Clear_mimetype_pdf.png', 'TN', 'Thumbnail.png', 'image/png', 'M'); $tn = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/Crystal_Clear_mimetype_pdf.png', 'TN', 'Thumbnail.png', 'image/png', 'M');
drupal_set_message(t("Successfully installed <a href=\"@base_url/fedora/repository/islandora:demos\">islandora:demos</a>.", array('@base_url' => check_plain($base_url))), 'message'); drupal_set_message(t("Successfully installed <a href=\"@base_url/fedora/repository/islandora:demos\">islandora:demos</a>.", array('@base_url' => check_plain($base_url))), 'message');
} catch (exception $e) { } catch (exception $e) {
} }
} }
@ -1742,14 +1742,14 @@ function fedora_repository_demo_objects_form_submit($form, &$form_state) {
try { try {
$cmstream = $cm->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/content_models/STANDARD JPG.xml', 'ISLANDORACM', 'Content Model.xml', 'application/xml', 'X'); $cmstream = $cm->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/content_models/STANDARD JPG.xml', 'ISLANDORACM', 'Content Model.xml', 'application/xml', 'X');
} catch (exception $e) { } catch (exception $e) {
} }
$dual_res_image_collection_cmodel = new Fedora_Item('demo:DualResImageCollection'); $dual_res_image_collection_cmodel = new Fedora_Item('demo:DualResImageCollection');
try { try {
$cmstream = $dual_res_image_collection_cmodel->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/content_models/COLLECTIONCM.xml', 'ISLANDORACM', 'Islandora Content Model.xml', 'application/xml', 'X'); $cmstream = $dual_res_image_collection_cmodel->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/content_models/COLLECTIONCM.xml', 'ISLANDORACM', 'Islandora Content Model.xml', 'application/xml', 'X');
drupal_set_message(t("Successfully installed <a href=\"@base_url/fedora/repository/demo:SmileyStuff\">demo:SmileyStuff</a> collection view.", array('@base_url' => check_plain($base_url))), 'message'); drupal_set_message(t("Successfully installed <a href=\"@base_url/fedora/repository/demo:SmileyStuff\">demo:SmileyStuff</a> collection view.", array('@base_url' => check_plain($base_url))), 'message');
} catch (exception $e) { } catch (exception $e) {
} }
} }
@ -1780,7 +1780,7 @@ function fedora_repository_demo_objects_form_submit($form, &$form_state) {
/** /**
* fedora repository required fedora objects * fedora repository required fedora objects
* @return type * @return type
*/ */
function fedora_repository_required_fedora_objects() { function fedora_repository_required_fedora_objects() {
// array( 'path-to-foxml-file', 'pid', 'dsid', 'path-to-datastream-file', int dsversion, boolean required) // array( 'path-to-foxml-file', 'pid', 'dsid', 'path-to-datastream-file', int dsversion, boolean required)
@ -1834,7 +1834,7 @@ function fedora_repository_elements() {
/** /**
* fedora repository expand time * fedora repository expand time
* @param type $element * @param type $element
* @return string * @return string
*/ */
function fedora_repository_expand_time($element) { function fedora_repository_expand_time($element) {
// Default to current time, check default_value but set value so that if // Default to current time, check default_value but set value so that if
@ -1877,7 +1877,7 @@ function fedora_repository_expand_time($element) {
/** /**
* fedora repository time * fedora repository time
* @param type $element * @param type $element
* @return type * @return type
*/ */
function fedora_repository_time($element) { function fedora_repository_time($element) {
$output = '<div class="container-inline">' . $element['#children'] . '</div>'; $output = '<div class="container-inline">' . $element['#children'] . '</div>';
@ -1887,7 +1887,7 @@ function fedora_repository_time($element) {
/** /**
* theme fedora repository time * theme fedora repository time
* @param type $element * @param type $element
* @return type * @return type
*/ */
function theme_fedora_repository_time($element) { function theme_fedora_repository_time($element) {
$output = '<div class="container-inline">' . $element['#children'] . '</div>'; $output = '<div class="container-inline">' . $element['#children'] . '</div>';
@ -1898,7 +1898,7 @@ function theme_fedora_repository_time($element) {
/** /**
* fedora repository remove item from basket * fedora repository remove item from basket
* @param type $pid * @param type $pid
*/ */
function fedora_repository_remove_item_from_basket($pid) { function fedora_repository_remove_item_from_basket($pid) {
@ -1923,7 +1923,7 @@ function fedora_repository_remove_item_from_basket($pid) {
/** /**
* fedora repository basket * fedora repository basket
* @return type * @return type
*/ */
function fedora_repository_basket() { function fedora_repository_basket() {
$pids = _fedora_repository_get_basket_pids(); $pids = _fedora_repository_get_basket_pids();
@ -1984,7 +1984,7 @@ function fedora_repository_basket_form($form_state, $pids) {
/** /**
* theme fedora repository basket form * theme fedora repository basket form
* @param type $form * @param type $form
* @return string * @return string
*/ */
function theme_fedora_repository_basket_form($form) { function theme_fedora_repository_basket_form($form) {
$header = array( $header = array(
@ -2019,7 +2019,7 @@ function theme_fedora_repository_basket_form($form) {
/** /**
* fedora repository basket form validate * fedora repository basket form validate
* @param type $form * @param type $form
* @param type $form_state * @param type $form_state
*/ */
function fedora_repository_basket_form_validate($form, &$form_state) { function fedora_repository_basket_form_validate($form, &$form_state) {
@ -2030,7 +2030,7 @@ function fedora_repository_basket_form_validate($form, &$form_state) {
* @global type $user * @global type $user
* @param type $form * @param type $form
* @param type $form_state * @param type $form_state
* @return type * @return type
*/ */
function fedora_repository_basket_form_submit($form, &$form_state) { function fedora_repository_basket_form_submit($form, &$form_state) {
if ($form_state['values']['op'] == $form_state['values']['remove_submit']) { if ($form_state['values']['op'] == $form_state['values']['remove_submit']) {
@ -2099,9 +2099,9 @@ function fedora_repository_basket_form_submit($form, &$form_state) {
} }
/** /**
* Get all pids saved to the basket. * Get all pids saved to the basket.
* *
* @return type * @return type
*/ */
function _fedora_repository_get_basket_pids() { function _fedora_repository_get_basket_pids() {
@ -2141,7 +2141,7 @@ function _fedora_repository_empty_basket() {
* fedora repository add to basket * fedora repository add to basket
* @param type $pid * @param type $pid
* @param type $warn * @param type $warn
* @param type $searchResultsFlag * @param type $searchResultsFlag
*/ */
function fedora_repository_add_to_basket($pid, $warn = TRUE, $searchResultsFlag = FALSE) { function fedora_repository_add_to_basket($pid, $warn = TRUE, $searchResultsFlag = FALSE) {
if ($warn && _is_added_to_basket($pid)) { if ($warn && _is_added_to_basket($pid)) {
@ -2164,7 +2164,7 @@ function fedora_repository_add_to_basket($pid, $warn = TRUE, $searchResultsFlag
/** /**
* fedora repository remove from basket * fedora repository remove from basket
* @param type $pid * @param type $pid
* @return type * @return type
*/ */
function fedora_repository_remove_from_basket($pid) { function fedora_repository_remove_from_basket($pid) {
if (isset($_SESSION['basket']['unprocessed'][$pid])) { if (isset($_SESSION['basket']['unprocessed'][$pid])) {
@ -2181,7 +2181,7 @@ function fedora_repository_remove_from_basket($pid) {
* theme add to basket link * theme add to basket link
* @param type $pid * @param type $pid
* @param type $type * @param type $type
* @return type * @return type
*/ */
function theme_add_to_basket_link($pid, $type = 'object') { function theme_add_to_basket_link($pid, $type = 'object') {
$object = t($type); $object = t($type);
@ -2208,7 +2208,7 @@ function theme_add_to_basket_link($pid, $type = 'object') {
* is added to basket * is added to basket
* @param type $pid * @param type $pid
* @param type $account * @param type $account
* @return type * @return type
*/ */
function _is_added_to_basket($pid, $account = NULL) { function _is_added_to_basket($pid, $account = NULL) {
return isset($_SESSION['basket']['unprocessed'][$pid]) || isset($_SESSION['basket']['processed'][$pid]); return isset($_SESSION['basket']['unprocessed'][$pid]) || isset($_SESSION['basket']['processed'][$pid]);
@ -2218,7 +2218,7 @@ function _is_added_to_basket($pid, $account = NULL) {
/** /**
* fedora repository display schema * fedora repository display schema
* @param type $file * @param type $file
* @return type * @return type
*/ */
function fedora_repository_display_schema($file) { function fedora_repository_display_schema($file) {
$path = drupal_get_path('module', 'fedora_repository'); $path = drupal_get_path('module', 'fedora_repository');
@ -2233,12 +2233,14 @@ function fedora_repository_display_schema($file) {
/** /**
* fedora repository batch reingest object * fedora repository batch reingest object
* @param type $object *
* @param array $object
* An array defining an object to ingest.
* @param type $context * @param type $context
* @return type * @return type
*/ */
function fedora_repository_batch_reingest_object($object, &$context) { function fedora_repository_batch_reingest_object($object, &$context) {
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
@ -2247,29 +2249,28 @@ function fedora_repository_batch_reingest_object($object, &$context) {
if (!valid_pid($pid)) { if (!valid_pid($pid)) {
return NULL; return NULL;
} }
// Does the object exist? If so, purge it. // Does the object exist? If so, purge it.
//dd("About to test existence of PID: $pid");
$item = new Fedora_Item($pid); $item = new Fedora_Item($pid);
if ($item->exists()) { if ($item->exists()) {
//dd(' Found');
$item->purge(t('Remove during re-install batch job')); $item->purge(t('Remove during re-install batch job'));
//dd(' Purged');
} }
// Need to have this a couple places...
// (After trying from FOXML and later for individual DSs)
$new_item = NULL;
// Seems like this might be getting messed up due to scope?.
$datastreams = array();
$new_item = NULL; //Need to have this a couple places... (After trying from FOXML and later for individual DSs) // Ingest the object from the source file.
$datastreams = array(); //Seems like this might be getting messed up due to scope?
// Ingest the object from the source file.
if (!empty($object['foxml_file'])) { if (!empty($object['foxml_file'])) {
$foxml_file = $object['foxml_file']; $foxml_file = $object['foxml_file'];
$new_item = Fedora_Item::ingest_from_FOXML_file($foxml_file); $new_item = Fedora_Item::ingest_from_FOXML_file($foxml_file);
if ($new_item->exists()) { if ($new_item->exists()) {
// Batch operation was successful; can still add additional DSs, though // Batch operation was successful; can still add additional DSs, though.
$context['message'][] = t('%pid installed.', array('%pid' => $new_item->pid)); $context['message'][] = t('%pid installed.', array('%pid' => $new_item->pid));
} }
} }
if (!empty($object['dsid']) && !empty($object['datastream_file'])) { if (!empty($object['dsid']) && !empty($object['datastream_file'])) {
$datastreams[] = array( $datastreams[] = array(
'dsid' => $object['dsid'], 'dsid' => $object['dsid'],
@ -2282,9 +2283,7 @@ function fedora_repository_batch_reingest_object($object, &$context) {
$label = !empty($object['label']) ? $object['label'] : ''; $label = !empty($object['label']) ? $object['label'] : '';
if (!isset($new_item)) { if (!isset($new_item)) {
//dd(' Not found, creating');
$new_item = Fedora_Item::ingest_new_item($pid, 'A', $label); $new_item = Fedora_Item::ingest_new_item($pid, 'A', $label);
//dd(' Created');
} }
elseif (!empty($label)) { elseif (!empty($label)) {
$new_item->modify_object($label); $new_item->modify_object($label);
@ -2292,17 +2291,12 @@ function fedora_repository_batch_reingest_object($object, &$context) {
if (isset($new_item)) { if (isset($new_item)) {
if (!empty($object['cmodel'])) { if (!empty($object['cmodel'])) {
//dd(' relating to cmodel');
$new_item->add_relationship('hasModel', $object['cmodel'], FEDORA_MODEL_URI); $new_item->add_relationship('hasModel', $object['cmodel'], FEDORA_MODEL_URI);
//dd(' related to cmodel');
} }
if (!empty($object['parent'])) { if (!empty($object['parent'])) {
//dd(' adding parent');
$new_item->add_relationship('isMemberOfCollection', $object['parent']); $new_item->add_relationship('isMemberOfCollection', $object['parent']);
//dd(' parent added');
} }
foreach ((array)$datastreams as $ds) { foreach ((array) $datastreams as $ds) {
//dd("trying to add ds: {$ds['dsid']}");
if ($ds['dsid'] == 'DC') { if ($ds['dsid'] == 'DC') {
$new_item->modify_datastream_by_value(file_get_contents($ds['datastream_file']), $ds['dsid'], $ds['label'], 'text/xml'); $new_item->modify_datastream_by_value(file_get_contents($ds['datastream_file']), $ds['dsid'], $ds['label'], 'text/xml');
} }
@ -2315,14 +2309,28 @@ function fedora_repository_batch_reingest_object($object, &$context) {
} }
/** /**
* Content model, collection view and collection policy datastreams may now optionally define a version * This function will send the postprocess solution pack hook.
* It is referenced by the solution pack form's batch finished entry.
*
*/
function fedora_repository_solutionpack_send_postprocess($success, $results, $operations) {
// Hook to let solution pack objects be modified.
// Not using module_invoke so solution packs can be expanded by other modules.
if($success) {
module_invoke_all('postprocess_solution_pack', $_SESSION['solution_pack_module_name']);
}
}
/**
* Content model, collection view and collection policy datastreams may
* now optionally define a version
* number in their top-level XML element as an attribute, as in: * number in their top-level XML element as an attribute, as in:
* <content_model name="Collection" version="2" ... * <content_model name="Collection" version="2" ...
* *
* @param Fedora_Item $item * @param Fedora_Item $item
* @param string $dsid * @param string $dsid
* @param string $datastream_file * @param string $datastream_file
* @return int, or NULL if no version attribute was found. * @return int, or NULL if no version attribute was found.
*/ */
function fedora_repository_get_islandora_datastream_version($item = NULL, $dsid = NULL, $datastream_file = NULL) { function fedora_repository_get_islandora_datastream_version($item = NULL, $dsid = NULL, $datastream_file = NULL) {
$return = NULL; $return = NULL;
@ -2332,18 +2340,18 @@ function fedora_repository_get_islandora_datastream_version($item = NULL, $dsid
elseif (!empty($datastream_file)) { elseif (!empty($datastream_file)) {
$doc = simplexml_load_file($datastream_file); $doc = simplexml_load_file($datastream_file);
} }
if (!empty($doc) && $version = (int)$doc->attributes()->version) { if (!empty($doc) && $version = (int)$doc->attributes()->version) {
$return = $version; $return = $version;
} }
return $return; return $return;
} }
/** /**
* theme fedora repository solution pack list * theme fedora repository solution pack list
* @param type $solution_packs * @param type $solution_packs
* @return string * @return string
*/ */
function theme_fedora_repository_solution_packs_list($solution_packs) { function theme_fedora_repository_solution_packs_list($solution_packs) {
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
@ -2359,7 +2367,7 @@ function theme_fedora_repository_solution_packs_list($solution_packs) {
/** /**
* Implementation of hook_forms() * Implementation of hook_forms()
* @param string $form_id * @param string $form_id
* @return array * @return array
*/ */
function fedora_repository_forms($form_id) { function fedora_repository_forms($form_id) {
$forms = array(); $forms = array();
@ -2396,12 +2404,12 @@ function fedora_repository_imagecache_default_presets() {
/** /**
* Actually render an image, given an arbitrary path and preset. * Actually render an image, given an arbitrary path and preset.
* *
* Note: If imagecache_external is not available, the full-sized image will be * Note: If imagecache_external is not available, the full-sized image will be
* produced... Might want to look into restricting the display size by adding * produced... Might want to look into restricting the display size by adding
* the width and height attributes to the theme('image') call, based on the * the width and height attributes to the theme('image') call, based on the
* selected preset? (get the presets and figure out the size from its actions?) * selected preset? (get the presets and figure out the size from its actions?)
* *
* @param $tn_path string * @param $tn_path string
* @param $imagecache_preset string * @param $imagecache_preset string
* @return * @return
@ -2425,10 +2433,10 @@ function _fedora_repository_render_image($tn_path, $imagecache_preset = 'fedora_
/** /**
* Render an image, given a PID, DSID and preset. * Render an image, given a PID, DSID and preset.
* *
* Produces a Drupal path for the image, passes to * Produces a Drupal path for the image, passes to
* _fedora_repository_render_image(), and returns the result. * _fedora_repository_render_image(), and returns the result.
* *
* @see _fedora_repository_render_image() * @see _fedora_repository_render_image()
* @param $pid string * @param $pid string
* A string containing a Fedora PID. * A string containing a Fedora PID.
@ -2447,7 +2455,7 @@ function fedora_repository_render_image($pid, $dsid, $imagecache_preset = 'fedor
/** /**
* Convenience function used in XSLT callback... * Convenience function used in XSLT callback...
* *
* @param $string string * @param $string string
* A string containing some markup to convert to a domnode. * A string containing some markup to convert to a domnode.
*/ */

16
fedora_repository.solutionpacks.inc

@ -57,7 +57,9 @@ function fedora_repository_solution_packs_page() {
* Check for installed objects and add a 'Update' or 'Install' button if * Check for installed objects and add a 'Update' or 'Install' button if
* some objects are missing. * some objects are missing.
* *
* @param array $solution_pack * @param array &$form_state
* @param array $solution_pack_module
* @param array $solution_pack_name
*/ */
function fedora_repository_solution_pack_form(&$form_state, $solution_pack_module, $solution_pack_name, $objects = array()) { function fedora_repository_solution_pack_form(&$form_state, $solution_pack_module, $solution_pack_name, $objects = array()) {
@ -201,15 +203,18 @@ function fedora_repository_solution_pack_form_submit($form, &$form_state) {
$batch['operations'][] = array('fedora_repository_batch_reingest_object', array($object)); $batch['operations'][] = array('fedora_repository_batch_reingest_object', array($object));
} }
batch_set($batch); // Used in postprocess hook.
$_SESSION['solution_pack_module_name'] = $module_name;
// Tell the batch to call the function to send out a postprocess hook.
$batch['finished'] = 'fedora_repository_solutionpack_send_postprocess';
// Hook to let solution pack objects be modified. batch_set($batch);
// Not using module_invoke so solution packs can be expanded by other modules.
module_invoke_all('postprocess_solution_pack', $module_name);
} }
/** /**
* Writes a form entry into the database.
* *
* @param unknown_type $form_name * @param unknown_type $form_name
* @param unknown_type $form_xml * @param unknown_type $form_xml
@ -226,6 +231,7 @@ function solution_pack_add_form($form_name, $form_xml) {
} }
/** /**
* Writes a form association to the database
* *
* @param unknown_type $content_model * @param unknown_type $content_model
* @param unknown_type $form_name * @param unknown_type $form_name

Loading…
Cancel
Save