createAdminForm();
}
function fedora_repository_admin_settings_submit($form, $form_values) {
drupal_set_message("Custom form handler.");
}
/**
* drupal hook
* calls the fedora_repositorys_admin form
*/
function fedora_repository_menu() {
module_load_include('inc', 'fedora_repository', 'formClass');
$adminMenu = new formClass();
return $adminMenu->createMenu();
}
/**
* drupal hook to show help
*/
function fedora_repository_help($path, $arg) {
switch ($path) {
case 'admin/modules#description' :
return t('Grabs a list of items from a collection in Drupal that are presented on the home page.');
case 'node/add#fedora_repository' :
return t('Use this page to grab a list of items from a Fedora collection.');
}
}
function fedora_repository_purge_object($pid = NULL, $name = NULL) {
if (!user_access('purge objects and datastreams')) {
drupal_set_message(t('You do not have access to add a datastream to this object.'), 'error');
return '';
}
if ($pid == NULL) {
drupal_set_message(t('You must specify an object pid to purge an object.'), 'error');
return '';
}
$output = t('Are you sure you wish to purge object %name %pid!
This cannot be undone
',
array(
'%name' => $name,
'%pid' => $pid)
);
$output .= drupal_get_form('fedora_repository_purge_object_form', $pid);
return $output;
}
function fedora_repository_collection_view($pid = NULL, $collection = NULL, $pageNumber = NULL) {
module_load_include('inc', 'fedora_repository', 'ObjectHelper');
global $user;
if (!fedora_repository_access(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) {
drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or access to Fedora denied."), 'error');
return ' ';
}
$objectHelper = new ObjectHelper();
if ($pid == NULL) {
$pid = variable_get('fedora_repository_pid', 'islandora:top');
}
$content = '';
module_load_include('inc', 'fedora_repository', 'CollectionClass');
$collectionClass = new CollectionClass();
$results = $collectionClass->getRelatedItems($pid, NULL);
$content .= $objectHelper->parseContent($results, $pid, $dsId, $collection, $pageNumber);
return $content;
}
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', 'ObjectHelper');
if (!user_access('ingest new fedora objects')) {
drupal_set_message(t('You do not have permission to ingest.'), 'error');
return '';
}
if (!validPid($collection_pid)) {
if (validPid(urldecode($collection_pid))) {
$collection_pid = urldecode($collection_pid);
} else {
drupal_set_message(t("This collection PID $collection_pid is not valid"), 'error');
return ' ';
}
}
if ($collection_pid == NULL) {
drupal_set_message(t('You must specify a collection object pid to ingest an object.'), 'error');
return '';
}
$output = drupal_get_form('fedora_repository_ingest_form', $collection_pid, $collection_label, $content_model);
$breadcrumbs = array();
$objectHelper = new ObjectHelper();
$objectHelper->getBreadcrumbs($collection_pid, $breadcrumbs);
drupal_set_breadcrumb(array_reverse($breadcrumbs));
return $output;
}
function fedora_repository_ingest_form_submit($form, &$form_state) {
//only validate the form if the submit button was pressed (other buttons may be used for AHAH
if ($form_state['clicked_button']['#id'] == 'edit-submit') {
global $base_url;
module_load_include('inc', 'fedora_repository', 'CollectionClass');
module_load_include('inc', 'fedora_repository', 'CollectionPolicy');
module_load_include('inc', 'fedora_repository', 'ContentModel');
$contentModelPid = ContentModel::getPidFromIdentifier($form_state['values']['models']);
$contentModelDsid = ContentModel::getDSIDFromIdentifier($form_state['values']['models']);
$err = TRUE;
$redirect = TRUE;
if (($cp = CollectionPolicy::loadFromCollection($form_state['values']['collection_pid'])) !== FALSE) {
$relationship = $cp->getRelationship();
if (($cm = ContentModel::loadFromModel($contentModelPid, $contentModelDsid)) !== FALSE) {
$pid = $cp->getNextPid($contentModelDsid);
global $user;
$form_state['values']['user_id'] = $user->name;
$form_state['values']['pid'] = $pid;
$form_state['values']['content_model_pid'] = $contentModelPid;
$form_state['values']['relationship'] = $relationship;
$err = (!$cm->execFormHandler($form_state['values']));
$_SESSION['fedora_ingest_files'] = ''; //empty this variable
$attr = $cm->getIngestFormAttributes();
$redirect = $attr['redirect'];
if ($redirect) {
$form_state['storage'] = NULL;
}
}
}
if ($redirect) {
$form_state['redirect'] = ($err) ? ' ' : $base_url . "/fedora/repository/{$form_state['values']['collection_pid']}";
}
}
}
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
if ($form_state['clicked_button']['#id'] == 'edit-submit') {
switch ($form_state['storage']['step']) {
case 1:
$form_state['storage']['step']++;
$form_state['rebuild'] = TRUE;
break;
case 2:
// Get the uploaded file.
$validators = array();
if (!empty($_FILES['files']['name']['ingest-file-location'])) {
$fileObject = file_save_upload('ingest-file-location', $validators);
file_move($fileObject->filepath, 0, 'FILE_EXISTS_RENAME');
$form_state['values']['ingest-file-location'] = $fileObject->filepath;
}
if (file_exists($form_state['values']['ingest-file-location'])) {
module_load_include('inc', 'fedora_repository', 'ContentModel');
module_load_include('inc', 'fedora_repository', 'MimeClass');
$file = $form_state['values']['ingest-file-location'];
$contentModelPid = ContentModel::getPidFromIdentifier($form_state['values']['models']);
$contentModelDsid = ContentModel::getDSIDFromIdentifier($form_state['values']['models']);
if (($cm = ContentModel::loadFromModel($contentModelPid, $contentModelDsid)) !== FALSE) {
$allowedMimeTypes = $cm->getMimetypes();
$mimetype = new MimeClass();
$dformat = $mimetype->getType($file);
if (!empty($file)) {
if (!in_array($dformat, $allowedMimeTypes)) {
form_set_error('ingest-file-location', t('The uploaded file\'s mimetype (' . $dformat . ') is not associated with this Content Model. The allowed types are ' .
implode(' ', $allowedMimeTypes)));
file_delete($file);
return;
} elseif (!$cm->execIngestRules($file, $dformat)) {
drupal_set_message(t('Error following Content Model Rules'), 'error');
foreach (ContentModel::$errors as $err) {
drupal_set_message($err, 'error');
}
}
}
}
}
$form_state['rebuild'] = FALSE;
break;
}
}
}
function fedora_repository_ingest_form(&$form_state, $collection_pid, $collection_label = NULL, $content_model = NULL) {
module_load_include('inc', 'fedora_repository', 'formClass');
//$client = getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl'));
// For the sake of easily maintaining the module in different core versions create our own form_values variable.
if (empty($form_state['storage']['step'])) {
$form_state['storage']['step'] = 1;
}
$ingestForm = new formClass();
$form_state['storage']['content_model'] = $content_model;
$form_state['storage']['collection_pid'] = $collection_pid;
return $ingestForm->createIngestForm($collection_pid, $collection_label, $form_state);
}
function fedora_repository_purge_object_form(&$form_state, $pid, $collectionPid = NULL) {
$form['pid'] = array(
'#type' => 'hidden',
'#value' => "$pid"
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Purge')
);
if ($collectionPid == NULL) {
$collectionPid = $_SESSION['fedora_collection'];
}
// $form['#redirect'] = "fedora/repository/$collectionPid/";
return $form;
}
function add_stream($collection_pid=NULL, $collectionName=NULL) {
module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
if (!validPid($collection_pid)) {
drupal_set_message(t("This PID is not valid!"), 'error');
return ' ';
}
if (!user_access('ingest new fedora objects')) {
drupal_set_message(t('You do not have permission to ingest.'), 'error');
return '';
}
if ($collection_pid == NULL) {
drupal_set_message(t('You must specify an collection object pid to ingest an object.'), 'error');
return '';
}
$output .= drupal_get_form('fedora_repository_add_stream_form', $pid);
return $output;
}
function add_stream_form_submit($form, &$form_state) {
global $base_url;
if (!empty($form_state['submit']) && $form_state['submit'] == 'OK') {
$form_state['rebuild'] = TRUE;
return;
}
module_load_include('inc', 'fedora_repository', 'MimeClass');
module_load_include('inc', 'fedora_repository', 'ObjectHelper');
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$pathToModule = drupal_get_path('module', 'fedora_repository');
$file = $form_state['values']['add-stream-file-location'];
$pid = $form_state['values']['pid'];
$dsid = $form_state['values']['stream_id'];
$dsLabel = $form_state['values']['stream_label'] . substr($file, strrpos($file, '.')); // Add the file extention to the end of the label.;
$streamUrl = $base_url . '/' . drupal_urlencode($file);
/* -----------------------------------------------------------------
* need a better way to get mimetypes
*/
$mimetype = new MimeClass();
$dformat = $mimetype->getType($file);
$controlGroup = "M";
if ($dformat == 'text/xml') {
$controlGroup = 'X';
}
try {
$item = new Fedora_Item($pid);
$item->add_datastream_from_url($streamUrl, $dsid, $dsLabel, $dformat, $controlGroup);
$object_helper = new ObjectHelper();
$object_helper->get_and_do_datastream_rules($pid, $dsid, $file);
file_delete($file);
} catch (exception $e) {
drupal_set_message(t($e->getMessage()), 'error');
return;
}
$form_state['rebuild'] = TRUE;
//$form_state['redirect'] = $base_url."/fedora/repository/$pid";
// drupal_goto("http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
}
function add_stream_form(&$form_state, $pid) {
//module_load_module_load_include('hp', ''Fedora_Repository'', 'config', 'fedora_repository', '');
module_load_include('inc', 'fedora_repository', 'formClass');
//$client = getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl'));
$addDataStreamForm = new formClass();
return $addDataStreamForm->createAddDataStreamForm($pid, $form_state);
}
function add_stream_form_validate($form, &$form_state) {
if ($form_state['clicked_button']['#value'] == 'OK') {
$form_state['rebuild'] = TRUE;
return;
}
$dsid = $form_state['values']['stream_id'];
$dsLabel = $form_state['values']['stream_label'];
if (strlen($dsid) > 64) {
form_set_error('', t('Data stream ID cannot be more than 64 characters.'));
return FALSE;
}
if (!(preg_match("/^[a-zA-Z]/", $dsid))) {
form_set_error('', t('Data stream ID has to start with a letter.'));
return FALSE;
}
if (strlen($dsLabel) > 64) {
form_set_error('', t('Data stream Label cannot be more than 64 characters.'));
return FALSE;
}
if (strpos($dsLabel, '/')) {
form_set_error('', t('Data stream Label cannot contain a "/".'));
return FALSE;
}
$validators = array(
// 'file_validate_is_image' => array(),
// 'file_validate_image_resolution' => array('85x85'),
// 'file_validate_size' => array(30 * 1024),
);
$fileObject = file_save_upload('add-stream-file-location', $validators);
// Move the uploaded file to Drupal's files directory.
file_move($fileObject->filepath, 0, 'FILE_EXISTS_RENAME');
$form_state['values']['add-stream-file-location'] = $fileObject->filepath;
// TODO: Add error checking here.
$form_state['rebuild'] = FALSE;
}
function fedora_repository_purge_stream($pid = NULL, $dsId = NULL, $name = NULL) {
module_load_include('inc', 'fedora_repository', 'ObjectHelper');
global $user;
if ($pid == NULL || $dsId == NULL) {
drupal_set_message(t('You must specify an object pid and DataStream ID to purge a datastream'), 'error');
return ' ';
}
if (!fedora_repository_access(OBJECTHELPER :: $PURGE_FEDORA_OBJECTSANDSTREAMS, $pid, $user)) {
drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or you do not have permission to purge objects."), 'error');
return ' ';
}
$output = t('Are you sure you wish to purge this datastream %name
',
array(
'%name' => $name)
);
$output .= drupal_get_form('fedora_repository_purge_stream_form', $pid, $dsId);
return $output;
}
function fedora_repository_purge_object_form_submit($form, &$form_state) {
module_load_include('inc', 'fedora_repository', 'ConnectionHelper');
//$client = getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl'));
$pid = $form_state['values']['pid'];
$params = array(
"pid" => $pid,
"logMessage" => "Purged",
"force" => ""
);
try {
$soapHelper = new ConnectionHelper();
$client = $soapHelper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl'));
$object = $client->__soapCall('purgeObject', array(
$params
)
);
} catch (exception $e) {
if (preg_match('/org\.fcrepo\.server\.security\.xacml\.pep\.AuthzDeniedException/',$e->getMessage())) {
drupal_set_message(t('Error: Insufficient permissions to purge object.'), 'error');
} else {
drupal_set_message(t($e->getMessage()), 'error');
}
return;
}
if (empty($collectionPid)) {
$collectionPid = $_SESSION['fedora_collection'];
}
$form_state['redirect'] = "fedora/repository/$collectionPid/";
}
function fedora_repository_purge_stream_form(&$form_state, $pid, $dsId) {
$form['pid'] = array(
'#type' => 'hidden',
'#value' => "$pid"
);
$form['dsid'] = array(
'#type' => 'hidden',
'#value' => "$dsId"
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Purge')
);
return $form;
}
function fedora_repository_purge_stream_form_submit($form, &$form_state) {
global $base_url;
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
//$client = getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl'));
$pid = $form_state['values']['pid'];
$item = new Fedora_Item($pid);
$dsid = $form_state['values']['dsid'];
try {
$item->purge_datastream($dsid);
} catch (exception $e) {
drupal_set_message(t($e->getMessage()), 'error');
}
$form_state['redirect'] = $base_url . "/fedora/repository/$pid";
}
function fedora_repository_replace_stream($pid, $dsId, $dsLabel, $collectionName = NULL) {
if ($pid == NULL || $dsId == NULL) {
drupal_set_message(t('You must specify an pid and dsId to replace.'), 'error');
return '';
}
$output .= drupal_get_form('fedora_repository_replace_stream_form', $pid, $dsId, $dsLabel);
return $output;
}
function fedora_repository_replace_stream_form(&$form_state, $pid, $dsId, $dsLabel) {
//module_load_module_load_include('hp', ''Fedora_Repository'', 'config', 'fedora_repository', '');
module_load_include('inc', 'Fedora_Repository', 'formClass');
//$client = getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl'));
$replaceDataStreamForm = new formClass();
return $replaceDataStreamForm->createReplaceDataStreamForm($pid, $dsId, $dsLabel, $form_state);
}
function fedora_repository_replace_stream_form_validate($form, &$form_state) {
// If a file was uploaded, process it.
if (isset($_FILES['files']) && is_uploaded_file($_FILES['files']['tmp_name']['file'])) {
// attempt to save the uploaded file
$file = file_save_upload('file', array(), file_directory_path());
// set error is file was not uploaded
if (!$file) {
form_set_error('file', 'Error uploading file.');
return;
}
$doc = new DOMDocument();
module_load_include('inc', 'Fedora_Repository', 'MimeClass');
$mime = new MimeClass();
if ($mime->getType($file->filepath) == 'text/xml' && !$doc->load($file->filepath)) {
form_set_error('file', 'Invalid XML format.');
return;
}
// set files to form_state, to process when form is submitted
$form_state['values']['file'] = $file;
}
}
function fedora_repository_replace_stream_form_submit($form, &$form_state) {
$file = $form_state['values']['file'];
$pid = $form_state['values']['pid'];
$dsid = $form_state['values']['dsId'];
// Remove the original file extension from the label and add the new one
$dsLabel = substr($form_state['values']['dsLabel'], 0, strrpos($form_state['values']['dsLabel'], '.'));
$dsLabel .= substr($file->filename, strrpos($file->filename, '.')); // Add the file extention to the end of the label.;
module_load_include('inc', 'Fedora_Repository', 'MimeClass');
module_load_include('inc', 'Fedora_Repository', 'ObjectHelper');
module_load_include('inc', 'Fedora_Repository', 'ConnectionHelper');
$streamUrl = file_create_url($file->filepath);
/* -----------------------------------------------------------------
* need a better way to get mimetypes
*/
$mimetype = new MimeClass();
$dformat = $mimetype->getType($file->filepath);
$controlGroup = "M";
$function = 'modifyDatastreamByReference';
$params = array(
'pid' => $pid,
'dsID' => $dsid,
'altIDs' => "",
'dsLabel' => $dsLabel,
'MIMEType' => $dformat,
'formatURI' => "URL",
'dsLocation' => $streamUrl,
'controlGroup' => "$controlGroup",
'dsState' => "A",
'checksumType' => "DISABLED",
'checksum' => "none",
'logMessage' => "datastream replaced",
'force' => FALSE,
);
if ($dformat == 'text/xml') {
$doc = new DOMDocument();
$doc->load($file->filepath);
$controlGroup = 'X';
$function = 'modifyDatastreamByValue';
$params['dsContent'] = $doc->saveXML();
unset($params['dsLocation']);
}
try {
$soapHelper = new ConnectionHelper();
$client = $soapHelper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl'));
if ($client == NULL) {
drupal_set_message(t('Error Getting Soap Client.'), 'error');
return;
}
$object = $client->__soapCall($function, array('parameters' => $params));
// Apply the add datastream rules.
$object_helper = new ObjectHelper();
$object_helper->get_and_do_datastream_rules($pid, $dsid, $file->filepath);
file_delete($file->filepath);
} catch (exception $e) {
drupal_set_message(t($e->getMessage()), 'error');
return;
}
drupal_goto('fedora/repository/' . $pid . '/-/' . $dsId);
}
function fedora_repository_edit_qdc_page($pid = NULL, $dsId = NULL) {
module_load_include('inc', 'fedora_repository', 'ObjectHelper');
global $user;
if ($pid == NULL || $dsId == NULL) {
drupal_set_message(t('You must specify an object pid and a Dublin Core DataStream ID to edit metadata'), 'error');
return ' ';
}
if (!fedora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $pid, $user)) {
drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or you do not have permission to edit meta data for this object."), 'error');
return ' ';
}
$output = drupal_get_form('fedora_repository_edit_qdc_form', $pid, $dsId);
return $output;
}
function fedora_repository_edit_qdc_form(&$form_state, $pid, $dsId = NULL) {
module_load_include('inc', 'fedora_repository', 'ContentModel');
module_load_include('inc', 'fedora_repository', 'ObjectHelper');
if ($pid == NULL) {
drupal_set_message(t('You must specify an object pid!'), 'error');
}
global $user;
if (!fedora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $pid, $user)) {
drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or you do not have permission to edit meta data for this object."), 'error');
return ' ';
}
module_load_include('inc', 'fedora_repository', 'formClass');
module_load_include('inc', 'fedora_repository', 'ConnectionHelper');
$soapHelper = new ConnectionHelper();
$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.
$breadcrumbs = array();
$objectHelper = new ObjectHelper();
$objectHelper->getBreadcrumbs($pid, $breadcrumbs);
drupal_set_breadcrumb(array_reverse($breadcrumbs));
$output = '';
if (($cm = ContentModel::loadFromObject($pid)) !== FALSE) {
$output = $cm->buildEditMetadataForm($pid, $dsId);
}
if (empty($output)) {
// There is no custom function, so just load the standard QDC form.
$metaDataForm = new formClass();
//currently we only edit the dc metadata. If you defined a custom form with a custom handler you are sol for now.
return $metaDataForm->createMetaDataForm($pid, $dsId, $client);
}
return $output;
}
function fedora_repository_edit_qdc_form_validate($form, &$form_state) {
}
/**
* Check if there is a custom edit metadata function defined in the content model. If so,
* call it, if not do the submit action for the standard QDC metadata. Custom forms will
* need to implement their own equivalent to the FormClass->updateMetaData function
*
* @param array $form
* @param array $form_state
* @return
*/
function fedora_repository_edit_qdc_form_submit($form, &$form_state) {
module_load_include('inc', 'fedora_repository', 'ConnectionHelper');
global $base_url;
if (strstr($form_state['clicked_button']['#id'], 'edit-submit')) {
//$client = getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl'));
$soap_helper = new ConnectionHelper();
$client = $soap_helper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl'));
// Check the content model for a custom edit metadata form submit function.
if (isset($form_state['values']['pid'])) {
module_load_include('inc', 'fedora_repository', 'ContentModel');
if (($cm = ContentModel::loadFromObject($form_state['values']['pid'])) !== FALSE) {
return $cm->handleEditMetadataForm($form_state['values']['form_id'], $form_state, $client);
}
}
module_load_include('inc', 'fedora_repository', 'formClass');
$metaDataForm = new formClass();
$return_value = $metaDataForm->updateMetaData($form_state['values']['form_id'], $form_state['values'], $client);
$form_state['redirect'] = $base_url . '/fedora/repository/' . $form_state['values']['pid'];
return $return_value;
}
}
/**
* drupal hook
* creates a new permission than can be assigned to roles
*/
function fedora_repository_perm() {
module_load_include('inc', 'fedora_repository', 'ObjectHelper');
return array(
OBJECTHELPER::$OBJECT_HELPER_VIEW_FEDORA,
OBJECTHELPER::$EDIT_FEDORA_METADATA,
OBJECTHELPER::$PURGE_FEDORA_OBJECTSANDSTREAMS,
OBJECTHELPER::$ADD_FEDORA_STREAMS,
OBJECTHELPER::$INGEST_FEDORA_OBJECTS,
OBJECTHELPER::$EDIT_TAGS_DATASTREAM,
OBJECTHELPER::$VIEW_DETAILED_CONTENT_LIST,
);
}
/**
* drupal hook
* determines if a user has access to what they are asking for
*
*
*/
function fedora_repository_access($op, $node, $account) {
module_load_include('inc', 'fedora_repository', 'ObjectHelper');
$objectHelper = new ObjectHelper();
return $objectHelper->fedora_repository_access($op, $node, $account);
}
/**
* Grabs a stream from fedora sets the mimetype and returns it. $dsID is the
* datastream id.
* @param $pid String
* @param $dsID String
*/
function makeObject($pid, $dsID) {
module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
if (!validPid($pid)) {
drupal_set_message(t("Invalid PID!"), 'error');
return ' ';
}
if (!validDsid($dsID)) {
drupal_set_message(t("Invalid dsID!"), 'error');
return ' ';
}
if ($pid == NULL || $dsID == NULL) {
drupal_set_message(t("No pid or dsid given to create an object with."));
return ' ';
}
global $user;
if (!fedora_repository_access(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) {
drupal_access_denied();
return;
drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace."), 'error');
return ' ';
}
module_load_include('inc', 'fedora_repository', 'ObjectHelper');
$objectHelper = new ObjectHelper();
$objectHelper->makeObject($pid, $dsID);
}
/**
* Sends an ITQL query to the Fedora Resource index (can only communicate with Kowari or mulgara)
* Reads the pid and datastream id as url parameters. Queries the collection object for the query
* if there is no query datastream falls back to the query shipped with the module.
* @return String
*/
function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NULL, $pageNumber = NULL, $limit = NULL) {
module_load_include('inc', 'fedora_repository', 'ObjectHelper');
module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
global $user;
if ($pid &!validPid($pid)) {
drupal_set_message(t("Invalid PID!"), 'error');
return ' ';
}
if ($dsId &!validDsid($dsId)) {
drupal_set_message(t("Invalid dsID!"), 'error');
return ' ';
}
if (!fedora_repository_access(OBJECTHELPER::$OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) {
drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or access to Fedora denied!"), 'error');
return ' ';
}
$objectHelper = new ObjectHelper();
if ($pid == NULL) {
$pid = variable_get('fedora_repository_pid', 'islandora:top');
}
$headers = module_invoke_all('file_download', "/fedora/repository/$pid");
if (in_array(-1, $headers)) {
drupal_access_denied();
exit;
return ' ';
}
if ($dsId != NULL && $dsId != '-') { //if we have a dsID return the stream otherwise query for a collection of objects
//probably should check pid as well here.
return makeObject($pid, $dsId);
}
$content = '
If you install the Fedora demo objects Islandora can display them as a collection.' ); } if (!empty($form['install_demos']['demo_collections']['#options'])) { $form['install_demos']['ingest'] = array( '#type' => 'submit', '#name' => 'install_demos', '#value' => 'Install Selected Demos', ); } $links_to_existing_demos = '
Demo collections already installed in this repository:
' . $links_to_existing_demos, ); return $form; } 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/dublin_core'); module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); global $base_url; if ($form_state['clicked_button']['#name'] == 'install_demos') { if (!empty($form_state['values']['demo_collections']['islandora:collectionCModel'])) { try { $collectioncm = Fedora_Item::ingest_new_item('islandora:collectionCModel', 'A', 'Islandora Collection Content Model'); $collectioncm->add_relationship('hasModel', 'fedora-system:ContentModel-3.0', FEDORA_MODEL_URI); $collectioncm->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/content_models/COLLECTIONCM.xml', 'ISLANDORACM', 'Islandora Content Model.xml', 'application/xml', 'X'); } catch (exception $e) { } try { $strictpdfcm = Fedora_Item::ingest_new_item('islandora:strict_pdf', 'A', 'Strict PDF Content Model'); $strictpdfcm->add_relationship('hasModel', 'fedora-system:ContentModel-3.0', FEDORA_MODEL_URI); $strictpdfcm->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/content_models/STRICT_PDFCM.xml', 'ISLANDORACM', 'Islandora Content Model.xml', 'application/xml', 'X'); } catch (exception $e) { } // Install a collection object that points to all content model objects try { $cmodel_collection_xml = Fedora_Item::create_object_FOXML('islandora:ContentModelCollection'); $cmodel_collection = Fedora_Item::ingest_from_FOXML($cmodel_collection_xml); //$dc = new Dublin_Core(new Fedora_Item('islandora:ContentModelCollection')); $dc = new Dublin_Core($cmodel_collection); $dc->set_element('dc:title', array('Installed Content Model')); $dc->save(); $cmodel_collection->add_datastream_from_string('select $object $title from <#ri> where ($object