';
-
- module_load_include('inc', 'fedora_repository', 'CollectionClass');
- $collectionClass = new CollectionClass();
- //if(!isset($pageNumber)){
- // $pageNumber=0;
- //}
- //if(!isset($limit)){
- // $limit=20;
- //}
-
- module_load_include('inc', 'fedora_repository', 'ContentModel');
- module_load_include('inc', 'fedora_repository', 'plugins/fedoraObject');
- $breadcrumbs = array();
- $objectHelper->getBreadcrumbs($pid, $breadcrumbs);
- drupal_set_breadcrumb(array_reverse($breadcrumbs));
-
- $offset = $limit * $page_number;
- //$results = $collectionClass->getRelatedObjects($pid, $limit, $offset, NULL); //updated so we can do paging in query not in xslt
- //$results = $collectionClass->getRelatedItems($pid, NULL);
- $content_models = $objectHelper->get_content_models_list($pid);
- // Each content model may return either a tabset array or plain HTML. If it's HTML, stick it in a tab.
- $cmodels_tabs = array(
- '#type' => 'tabset',
- );
- foreach ($content_models as $content_model) {
- //$content_model_fieldsets = $objectHelper->createExtraFieldsets($pid, $content_model, $pageNumber);
- $content_model_fieldset = $content_model->displayExtraFieldset($pid, $page_number);
- if (is_array($content_model_fieldset)) {
- $cmodels_tabs = array_merge($cmodels_tabs, $content_model_fieldset);
- }
- else {
- $cmodels_tabs[$content_model->pid] = array(
- '#type' => 'tabpage',
- '#title' => $content_model->name,
- '#content' => $content_model_fieldset,
- );
- }
- }
- // Add a 'manage object' tab for all objects, where detailed list of content is shown.
- $obj = new FedoraObject($pid);
- $object_details = $obj->showFieldSets();
- $cmodels_tabs = array_merge($cmodels_tabs, $object_details);
-
-
- //$content .= $objectHelper
- //$content .= $objectHelper->parseContent($results, $pid, $dsId, $collection, $pageNumber);
- //the below is for islandlives we should be able to do this in the xslt though
- //$css=$path.'/stylesheets/container-large.css';
- //drupal_add_css($css);
- return tabs_render($cmodels_tabs);
-}
-
-function fedora_repository_urlencode_string($str) {
- return htmlentities($str);
+function islandora_get_types() {
+ return module_invoke_all('islandora_get_types');
}
/**
- * Uses makeobject to get a stream. Sets the Content Disposition in the header so it suggests a filename
- * and sends it as an attachment. This should prompt for a download of the object.
- *
+ *
+ * @paramstring $datastream_id
+ * @return type
*/
-function fedora_object_as_attachment($pid, $dsId, $label=NULL, $version=NULL) {
- global $user;
- module_load_include('inc', 'fedora_repository', 'ObjectHelper');
-
- if ($pid == NULL || $dsId == NULL) {
- drupal_set_message(t("no pid or dsid given to create an object with!"));
- return ' ';
- }
-
- $objectHelper = new ObjectHelper();
- $objectHelper->makeObject($pid, $dsId, 1, $label, FALSE, $version);
-}
-
-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
- //someone trys to come in a back door.
- return fedora_repository_get_items($pid, $dsId, $collection, $pageNumber);
-}
-
-function repository_service($pid = NULL, $servicePid = NULL, $serviceMethod = NULL) {
- module_load_include('inc', 'fedora_repository', 'api/fedora_item');
- 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');
- drupal_access_denied();
- if (user_access('access administration pages')) {
- drupal_set_message(t("PIDs may be added to allowed namespaces, or all namespace restrictions removed !here", array('!here' => l('here', 'admin/settings/fedora_repository'))), 'error');
- }
- return ' ';
- }
- 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 ' ';
+function islandora_purge_datastream($object_id, $datastream_id) {
+ if (!isset($datastream_id)) {
+ drupal_set_message('Cannot remove datastream, datastream id not set');
+ return;
}
-
-
- $item = new Fedora_Item($pid);
- if ($item !== false) {
- echo $item->get_dissemination($servicePid, $serviceMethod);
+ $object = new Object($object_id);
+ if (!isset($object)) {
+ drupal_set_message('Could not remove object, object not found');
+ return;
}
-
- exit();
-}
-
-//Search Stuff ********************************************************************
-
-/**
- * Implementation of hook_search().
- * sends a search query to fedora fgsearch which is backed by Lucene
- * In our implementation of Fedora we have api-a and api-m locked down
- * to authorized users but at the object level. We can query Lucene and the
- * RI index to get a list of results without authorization but to view any
- * datastreams users must be authorized.
- *
- */
-function fedora_repository_search($op = 'search', $keys = NULL) {
- module_load_include('inc', 'fedora_repository', 'ObjectHelper');
- module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
-
- switch ($op) {
- case 'name':
- if (user_access('view fedora collection')) {
- return t('Digital Repository', array('-9'));
- }
- case 'search':
- if (user_access('view fedora collection')) {
- //demo search string ?operation=gfindObjects&indexName=DemoOnLucene&query=fgs.DS.first.text%3Achristmas&hitPageStart=11&hitPageSize=10
- $resultData = NULL;
- $numberOfHitsPerPage = NULL;
- $index = strpos($keys, '.');
- $test = substr($keys, 0, $index + 1);
- $type = NULL;
- if ($index > 0) {
- $index = strpos($keys, ':');
- $type = substr($keys, 0, $index);
- $keys = substr($keys, $index + 1);
- }
-
- $index = strpos($keys, ':');
- $startPage = substr($keys, 0, $index);
- if ($index > 1) {
- $keys = substr($keys, $index + 1);
- }
-
- if (!$startPage) {
- $startPage = 1;
- }
-
- $xmlDoc = NULL;
-
- $path = drupal_get_path('module', 'fedora_repository');
- $xmlDoc = new DomDocument();
- $xmlDoc->load($path . '/searchTerms.xml');
- $nodeList = $xmlDoc->getElementsByTagName('default');
- if (!$type) {
- //$type = 'dc.description';
- $type = $nodeList->item(0)->nodeValue;
- }
- $nodeList = $xmlDoc->getElementsByTagName('number_of_results');
- $numberOfHitsPerPage = $nodeList->item(0)->nodeValue;
-
- $indexName = variable_get('fedora_index_name', 'DemoOnLucene');
- $keys = htmlentities(urlencode($keys));
- $searchQuery = NULL;
- if (isset($type) && strcmp($type, ':')) {
- $searchQuery = $type . ':' . $keys;
- }
- else {
- $searchQuery = $keys;
- }
- //$searchQuery.=" AND (PID:vre OR PID:vre:ref OR PID:demo OR PID:changeme)";
-
- $searchUrl = variable_get('fedora_fgsearch_url', 'http://localhost:8080/fedoragsearch/rest');
- $searchString = '?operation=gfindObjects&indexName=' . $indexName . '&restXslt=copyXml&query=' . $searchQuery;
- $searchString .= '&hitPageSize=' . $numberOfHitsPerPage . '&hitPageStart=' . $startPage;
- //$searchString = htmlentities(urlencode($searchString));
- $searchUrl .= $searchString;
- $objectHelper = new ObjectHelper();
- $resultData = do_curl($searchUrl);
-
- $results[] = array(
- array(
- 'data' => $resultData,
- 'colspan' => 2
- )
- );
- return $results;
- }
- } // switch ($op)
+ module_invoke_all('islandora_purge_datastream', $datastream); //notify modules of pending deletion so we can update rels etc
+ $object->deleteDatastream();
}
/**
- * Implementation of hook_search_page().
- * Display the search results
+ *
+ * @global object $user
+ * @param string $object_id
+ *
+ * @return string
*/
-function fedora_repository_search_page($resultData) {
- $path = drupal_get_path('module', 'fedora_repository');
- $isRestricted = variable_get('fedora_namespace_restriction_enforced', TRUE);
- $proc = NULL;
- if (!$resultData[0][0]['data']) {
- return ''; //no results
+function islandora_view_object($object_id) {
+ //return $object_id;
+ if (!isset($object_id)) {
+ drupal_set_message('Cannot view object, object id not set');
+ return;
}
- $text = utf8_encode($resultData[0][0]['data']);
+ $page_number = (empty($_GET['page'])) ? '1' : $_GET['page'];
+ $page_size = (empty($_GET['pagesize'])) ? '10' : $_GET['pagesize'];
+ module_load_include('inc', 'islandora', 'RestConnection');
+ $user = new stdClass();
+ $user->name = 'fedoraAdmin';
+ $user->password = 'fedoraAdmin';
try {
- $proc = new XsltProcessor();
+ $restConnection = new RestConnection($user);
+ $fedora_object = new FedoraObject($object_id, $restConnection->repository);
} catch (Exception $e) {
- $out[] = array(
- array(
- 'data' => $e->getMessage(),
- 'colspan' => 2
- )
- );
- return $out;
- }
-
- //inject into xsl stylesheet
- $proc->setParameter('', 'searchToken', drupal_get_token('search_form')); //token generated by Drupal, keeps tack of what tab etc we are on
- $proc->setParameter('', 'searchUrl', url('search') . '/fedora_repository'); //needed in our xsl
- $proc->setParameter('', 'objectsPage', base_path());
- $proc->setParameter('', 'allowedPidNameSpaces', variable_get('fedora_pids_allowed', 'default: demo: changeme: Islandora: ilives: '));
- $proc->registerPHPFunctions();
- $xsl = new DomDocument();
- if ($isRestricted) {
- $xsl->load($path . '/xsl/results.xsl');
- }
- else {
- $xsl->load($path . '/xsl/unfilteredresults.xsl');
- }
-
- $input = new DomDocument();
- $didLoadOk = $input->loadXML(utf8_encode($resultData[0][0]['data']));
-
- if (!$didLoadOk) {
- $results[] = array(
- array(
- 'data' => 'Error parsing results',
- 'colspan' => 2
- )
- );
+ drupal_set_message(t('Error getting Islandora object %s',array('%s' => $object_id)), 'error');
+ return"";
}
- else {
- $xsl = $proc->importStylesheet($xsl);
- $newdom = $proc->transformToDoc($input);
-
- $results[] = array(
- array(
- 'data' => $newdom->saveHTML(),
- 'colspan' => 2
- )
- );
+ drupal_alter('islandora_view_object', $fedora_object); //modify object if required before it is passed along
+ $arr = module_invoke_all('islandora_view_object', $fedora_object, $user, $page_number, $page_size); //allow submodules to decide how to handle content base on object type
+ if (empty($arr) ) {
+ //TODO: make sure we iterate over the array as they will be more then one cmodel per object
+ drupal_set_message(t('No module registered to handle objects of type %s', array('%s' => $fedora_object->models[0])));
+ return "";
}
-
- $header = array(
- array(
- 'data' => t('Collection results'),
- NULL,
- ),
- (NULL)
- );
-
- $output .= theme('table', $header, $results);
- return $output;
+ //module_invoke_all(islandora_display($arr)),
+ return $arr[0]; //just an example as we could have more then one array element
}
/**
- * Implementation of hook_form_alter().
- * allows the advanced search form in drupal
+ * drupal hook_permissions function
+ * @return array
*/
-function fedora_repository_form_alter(&$form, &$form_state, $form_id) {
- // Advanced node search form
- module_load_include('inc', 'fedora_repository', 'SearchClass');
- $path = drupal_get_path('module', 'fedora_repository');
- if ($form_id == 'search_form' && arg(1) == 'fedora_repository' && user_access('use advanced search')) {
- $default_value = $form['basic']['inline']['keys']['#default_value'];
- $index = strpos($default_value, '.');
- $test = substr($default_value, 0, $index + 1);
- $type = NULL;
- if ($index > 0) {
- $index = strpos($default_value, ':');
- $type = substr($default_value, 0, $index);
- $default_value = substr($default_value, $index + 1);
- }
- $form['basic']['inline']['keys']['#default_value'] = $default_value;
- // Keyword boxes:
- $form['advanced'] = array(
- '#type' => 'fieldset',
- '#title' => t('Advanced search'),
- '#collapsible' => TRUE,
- '#collapsed' => TRUE,
- '#attributes' => array(
- 'class' => 'search-advanced'
- ),
- );
- $form['advanced']['keywords'] = array(
- '#prefix' => '
',
- '#suffix' => '
',
- );
- $xmlDoc = new DomDocument();
- $xmlDoc->load($path . '/searchTerms.xml');
- $nodeList = $xmlDoc->getElementsByTagName('term');
- $searchClass = new SearchClass();
- $types = $searchClass->get_search_terms_array();
-
- $form['advanced']['type'] = array(
- '#type' => 'select',
- '#title' => t('Choose a field to search'),
- '#prefix' => '
', '#suffix' => '
', '#options' => $types,
- '#default_value' => $type,
- );
- $form['advanced']['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Advanced search'),
- '#prefix' => '
', '#suffix' => '
',
- );
- $form['#validate'][] = 'fedora_repository_search_validate';
- }
-}
-
-/**
- * Implementation of hook_search_validate()
- *
- */
-function fedora_repository_search_validate($form, &$form_state) {
- // Initialise using any existing basic search keywords.
- $keys = $form_state['values']['processed_keys'];
-
- if (isset($form_state['values']['type'])) {
- $type = $form_state['values']['type'];
- if ($type) {
- $keys = $type . ':' . $keys;
- }
- }
-
- if (!empty($keys)) {
- form_set_value($form['basic']['inline']['processed_keys'], trim($keys), $form_state); //set the form string
- }
-}
-
-function fedora_repository_block($op = 'list', $delta = 0, $edit = array()) {
- // The $op parameter determines what piece of information is being requested.
- switch ($op) {
- case 'list':
- // If $op is "list", we just need to return a list of block descriptions.
- // This is used to provide a list of possible blocks to the administrator,
- // end users will not see these descriptions.
- $blocks[0] = array(
- 'info' => t('Repository advanced search block'),
- );
- return $blocks;
- case 'configure':
- // If $op is "configure", we need to provide the administrator with a
- // configuration form. The $delta parameter tells us which block is being
- // configured. In this example, we'll allow the administrator to customize
- // the text of the first block.
- $form = array();
- switch ($delta) {
- case 0:
- // All we need to provide is a text field, Drupal will take care of
- // the other block configuration options and the save button.
- $form['fedora_repository_advanced_block_repeat'] = array(
- '#type' => 'textfield',
- '#title' => t('Number of times to repeat search fields'),
- '#size' => 5,
- '#description' => t('The number of times you would like the search blocks to be repeated'),
- '#default_value' => variable_get('fedora_repository_advanced_block_repeat', t('3')),
- );
- break;
- }
- return $form;
- case 'save':
- // If $op is "save", we need to save settings from the configuration form.
- // Since the first block is the only one that allows configuration, we
- // need to check $delta to make sure we only save it.
- switch ($delta) {
- case 0:
- // Have Drupal save the string to the database.
- variable_set('fedora_repository_advanced_block_repeat', $edit['fedora_repository_advanced_block_repeat']);
- break;
- }
- case 'view': default:
- // If $op is "view", then we need to generate the block for display
- // purposes. The $delta parameter tells us which block is being requested.
- switch ($delta) {
- case 0:
- // The subject is displayed at the top of the block. Note that it
- // should be passed through t() for translation.
- $block['subject'] = t('Repository Advanced Search');
- // The content of the block is typically generated by calling a custom
- // function.
- $block['content'] = drupal_get_form('fedora_repository_mnpl_advanced_search_form');
- break;
- }
- return $block;
- }
-}
-
-function fedora_repository_theme() {
+function islandora_permission() {
return array(
- 'fedora_repository_mnpl_advanced_search_form' => array(
- 'arguments' => array(
- 'form' => NULL,
- ),
+ FEDORA_VIEW => array(
+ 'title' => t('View Fedora Repository objects and datastreams'),
+ 'description' => t('Users with this permission will be allowed to view Fedora objects and datastreams. Unless Fedora XACML security policies limits this functionality to certain objects.')
),
- 'fedora_repository_time' => array(
- 'arguments' => array(
- 'element' => NULL
- ),
-
- 'fedora_repository_solution_packs_list' => array(
- 'arguments' => array(
- 'solution_packs' => NULL,
- ),
- ),
+ FEDORA_ADD_DS => array(
+ 'title' => t('Add Fedora streams to Fedora objects'),
+ 'description' => t('Users with this permission will be allowed to add datastreams to Fedora objects. Unless Fedora XACML security policies limits this functionality to certain objects.')
),
- );
-}
-
-/**
- * Get a list of terms from a lucene index
- */
-function fedora_repository_list_terms($field, $startTerm = NULL, $displayName = NULL) {
- module_load_include('inc', 'fedora_repository', 'SearchClass');
- $searchClass = new SearchClass();
- return $searchClass->getTerms($field, $startTerm, $displayName);
-}
-
-function fedora_repository_mnpl_advanced_search_form() {
- module_load_include('inc', 'fedora_repository', 'SearchClass');
- $searchClass = new SearchClass();
- return $searchClass->build_advanced_search_form();
-}
-
-function theme_fedora_repository_mnpl_advanced_search_form($form) {
- module_load_include('inc', 'fedora_repository', 'SearchClass');
- $advanced_search_form = new SearchClass();
- return $advanced_search_form->theme_advanced_search_form($form);
-}
-
-function fedora_repository_mnpl_advanced_search($query, $startPage = 1) {
- module_load_include('inc', 'fedora_repository', 'SearchClass');
- $searchClass = new SearchClass();
- $retVal = $searchClass->custom_search($query, $startPage);
- return $searchClass->custom_search($query, $startPage);
-}
-
-function fedora_repository_mnpl_advanced_search_form_submit($form, &$form_state) {
- $type_id = $form_state['values']['type'];
- $repeat = variable_get('fedora_repository_advanced_block_repeat', t('3'));
- $searchString = $form_state['values']['type1'] . ':' . $form_state['values']['fedora_terms1'];
- if ($form_state['values']['fedora_terms2'] != '') {
- $searchString .=' +' . $form_state['values']['andor1'] . '+' . $form_state['values']['type2'] . ':' . $form_state['values']['fedora_terms2'];
- }
- if ($repeat > 2 && $repeat < 9) {
- for ($i = 3; $i < $repeat + 1; $i++) {
- $t = $i - 1;
- if ($form_state['values']["fedora_terms$i"] != '') {
- $searchString .= '+' . $form_state['values']["andor$t"] . '+' . $form_state['values']["type$i"] . ':' . $form_state['values']["fedora_terms$i"];
- }
- }
- }
- drupal_goto("fedora/repository/mnpl_advanced_search/$searchString");
-}
-
-function fedora_repository_install_demos_page() {
- $output = drupal_get_form('fedora_repository_demo_objects_form');
- return $output;
-}
-
-function fedora_repository_demo_objects_form() {
- module_load_include('inc', 'fedora_repository', 'ObjectHelper');
- module_load_include('inc', 'fedora_repository', 'api/fedora_item');
- $form = array();
- $existing_demos = array();
-
- $form['install_demos'] = array(
- '#title' => t('Islandora Demo Collections'),
- '#type' => 'fieldset',
- '#description' => t('Install demo image and document collections and content models.'),
- );
- $demo_objects = array();
- // Check if the top-level islandora collection exists. If not, display a button to ingest.
-
- $form['install_demos']['demo_collections'] = array(
- '#type' => 'checkboxes',
- '#title' => t('Collections to ingest'),
- '#options' => array(),
- '#description' => t('Choose which demo collections you would like ingested into the repository.'),
- );
-
- foreach (array(
- 'islandora:collectionCModel' => 'Islandora default content models',
- 'islandora:top' => 'Islandora top-level collection',
- 'islandora:demos' => 'Islandora demos collection',
- 'islandora:largeimages' => 'Sample large image content model (requires
Djatoka and
Kakadu.)',
- )
- as $available_demo => $available_demo_desc) {
- try {
- $demo_objects[$available_demo] = new Fedora_Item($available_demo);
- } catch (exception $e) {
-
- }
-
- if (empty($demo_objects[$available_demo]->objectProfile)) {
- //The demo objects collection does not exist in the repository, display a button to ingest them.
- $form['install_demos']['demo_collections']['#options'][$available_demo] = $available_demo_desc;
- }
- else {
- array_push($existing_demos, $demo_objects[$available_demo]);
- }
- }
-
- // Check if the SmileyStuff collectoin exists, and if it has a COLLECTION_VIEW datastream. If it doesn't then we can add it.
-
- $smiley_stuff = new Fedora_Item('demo:SmileyStuff');
- if (!empty($smiley_stuff->objectProfile)) {
- $datastreams_list = $smiley_stuff->get_datastreams_list_as_array();
- if (empty($datastreams_list['COLLECTION_VIEW'])) {
- $form['install_demos']['demo_collections']['#options']['demo:SmileyStuff'] = 'Add Islandora Collection View to Fedora Smiley Stuff Collection';
- }
- else {
- $demo_objects['demo:SmileyStuff'] = $smiley_stuff;
- }
- }
- else {
- $form['install_demos']['smileynote'] = array(
- '#value' => '
If you install the ' . l('fedora demo objects', 'https://wiki.duraspace.org/display/FCR30/Demonstration+Objects') . ' Islandora can display them as a collection.
'
- );
- }
-
- $form['install_demos']['ingest'] = array(
- '#type' => 'submit',
- '#name' => 'install_demos',
- '#value' => 'Install Selected Demos',
- '#disabled' => (empty($form['install_demos']['demo_collections']['#options'])) ? TRUE : FALSE,
- );
-
- $form['existing_demos'] = array(
- '#prefix' => '
Demo collections already installed in this repository:
',
- );
-
- if (!empty($existing_demos)) {
- foreach ($existing_demos as $pid => $demo_object) {
-
- $form['existing_demos'][$demo_object->pid] = array(
- '#prefix' => '
',
- '#value' => l($demo_object->pid, $demo_object->url()),
- '#suffix' => '',
- );
- }
- }
-
- 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
$title
- and ($object
- or $object )
- and $object )
- order by $title', 'QUERY', 'Content Model Collection Query', 'text/plain');
- $cmodel_collection->add_relationship('isMemberOfCollection', 'islandora:top');
- $cmodel_collection->add_relationship('hasModel', 'islandora:collectionCModel', FEDORA_MODEL_URI);
- $cmodel_collection->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_views/simple_list_view.xml', 'COLLECTION_VIEW', 'Collection View', 'text/xml', 'X');
- $cmodel_collection->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/contentModel.jpg', 'TN', 'Thumbnail', 'image/jpg', 'M');
- drupal_set_message("Successfully installed islandora:ContentModelCollection.", 'message');
- } catch (exception $e) {
-
- }
- }
-
- if (!empty($form_state['values']['demo_collections']['islandora:top'])) {
- $new_item = Fedora_Item::ingest_new_item('islandora:top', 'A', 'Islandora Top-level Collection');
- $new_item->add_relationship('hasModel', 'islandora:collectionCModel', FEDORA_MODEL_URI);
- $cp = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_policies/COLLECTION-COLLECTION POLICY.xml', 'COLLECTION_POLICY', 'Collection Policy', 'text/xml', 'X');
- try {
- $tn = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/Gnome-emblem-photos.png', 'TN', 'Thumbnail.png', 'image/png', 'M');
- drupal_set_message("Successfully installed islandora:top.", 'message');
- } catch (exception $e) {
-
- }
- }
-
- if (!empty($form_state['values']['demo_collections']['islandora:demos'])) {
- $new_item = fedora_item::ingest_new_item('islandora:demos', 'A', 'Islandora Demo Collection');
- $new_item->add_relationship('isMemberOfCollection', 'islandora:top');
- $new_item->add_relationship('hasModel', 'islandora:collectionCModel', FEDORA_MODEL_URI);
- $cp = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_policies/COLLECTION-COLLECTION POLICY.xml', 'COLLECTION_POLICY', 'Collection Policy', 'text/xml', 'X');
-
- // $cv = $new_item->add_datastream_from_file( drupal_get_path('module', 'fedora_repository') . '/collection_views/COLLECTION_VIEW.xml', 'COLLECTION_VIEW', 'Collection View.xml', 'text/xml', 'X');
- $tn = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/Gnome-emblem-photos.png', 'TN', 'Thumbnail.png', 'image/png', 'M');
- try {
- $new_item = Fedora_Item::ingest_new_item('islandora:pdf_collection', 'A', 'PDF Collection');
- $new_item->add_relationship('isMemberOfCollection', 'islandora:demos');
- $new_item->add_relationship('hasModel', 'islandora:collectionCModel', FEDORA_MODEL_URI);
- $cp = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_policies/PDF-COLLECTION POLICY.xml', 'COLLECTION_POLICY', 'Collection Policy', 'text/xml', 'X');
- $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("Successfully installed islandora:demos.", 'message');
- } catch (exception $e) {
-
- }
- }
-
- if (!empty($form_state['values']['demo_collections']['demo:SmileyStuff'])) {
- $smiley_stuff = new Fedora_Item('demo:SmileyStuff');
- $new_item = $smiley_stuff->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_views/SmileyStuff-COLLECTION_VIEW.xml', 'COLLECTION_VIEW', 'Collection View', 'text/xml', 'X');
- $smiley_stuff->add_relationship('isMemberOfCollection', 'info:fedora/islandora:demos');
- $tn = $smiley_stuff->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/smileytn.png', 'TN', 'Thumbnail.png', 'image/png', 'M');
- $cp = $smiley_stuff->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_policies/JPG-COLLECTION POLICY.xml', 'COLLECTION_POLICY', 'Collection Policy.xml', 'application/xml', 'X');
-
- $cm = new Fedora_Item('demo:DualResImage');
- 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');
- } catch (exception $e) {
-
- }
- $dual_res_image_collection_cmodel = new Fedora_Item('demo:DualResImageCollection');
- 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');
- drupal_set_message("Successfully installed demo:SmileyStuff collection view.", 'message');
- } catch (exception $e) {
-
- }
- }
-
- if (!empty($form_state['values']['demo_collections']['islandora:largeimages'])) {
- $error = '';
- foreach (array('islandora_jp2Sdep-slideCModel.xml', 'islandora_mods2htmlSdef.xml', 'islandora_mods2htmlSdep.xml',
- 'islandora_slideCModel.xml', 'islandora_viewerSdep-slideCModel.xml', 'ilives_jp2Sdef.xml', 'ilives_viewerSdef.xml') as $foxml_file) {
- try {
- $item = Fedora_Item::ingest_from_FOXML_file(drupal_get_path('module', 'fedora_repository') . '/content_models/' . $foxml_file);
- } catch (exception $e) {
- $error .= " - Problem ingesting $foxml_file";
- }
- }
- try {
- $item = Fedora_Item::ingest_from_FOXML_file(drupal_get_path('module', 'fedora_repository') . '/content_models/islandora_largeimages.xml');
- $tn = $item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/Gnome-emblem-photos.png', 'TN', 'Thumbnail.png', 'image/png', 'M');
- drupal_set_message("Successfully installed islandora:largeimages.", 'message');
- } catch (exception $e) {
- $error .= " - Problem ingesting islandora:largeimages collection";
- }
- }
-
- if (!empty($error)) {
- drupal_set_message('Some problems occurred: ' . $error);
- }
- }
-}
-
-
-function fedora_repository_required_fedora_objects() {
- // array( 'path-to-foxml-file', 'pid', 'dsid', 'path-to-datastream-file', int dsversion, boolean required)
- $module_path = drupal_get_path('module', 'fedora_repository');
- return array (
- 'fedora_repository' => array(
- 'module' => 'fedora_repository',
- 'title' => 'Islandora Core',
- 'objects' => array (
- array (
- 'pid' => 'islandora:collectionCModel',
- 'label' => 'Islandora Collection Content Model',
- 'dsid' => 'ISLANDORACM',
- 'datastream_file' => "$module_path/content_models/COLLECTIONCM.xml",
- 'dsversion' => 2,
- 'cmodel' => 'fedora-system:ContentModel-3.0',
- ),
- array (
- 'pid' => 'islandora:strict_pdf',
- 'label' => 'Islandora strict PDF content model',
- 'dsid' => 'ISLANDORACM',
- 'datastream_file' => "$module_path/content_models/STRICT_PDFCM.xml",
- 'cmodel' => 'fedora-system:ContentModel-3.0',
- ),
- array(
- 'pid' => 'islandora:top',
- 'label' => 'Islandora Top-level Collection',
- 'cmodel' => 'islandora:collectionCModel',
- 'datastreams' => array (
- array (
- 'dsid' => 'COLLECTION_POLICY',
- 'datastream_file' => "$module_path/collection_policies/COLLECTION-COLLECTION POLICY.xml",
- ),
- array (
- 'dsid' => 'TN',
- 'datastream_file' => "$module_path/images/Gnome-emblem-photos.png",
- 'mimetype' => 'image/png',
- ),
- ),
- ),
- array (
- 'pid' => 'islandora:ContentModelCollection',
- 'label' => 'Collection of installed content models',
- 'cmodel' => 'islandora:collectionCModel',
- 'parent' => 'islandora:top',
- 'datastreams' => array (
- array (
- 'dsid' => 'COLLECTION_VIEW',
- 'datastream_file' => "$module_path/collection_views/simple_list_view.xml",
- ),
- array (
- 'dsid' => 'TN',
- 'datastream_file' => "$module_path/images/contentModel.jpg",
- 'mimetype' => 'image/jpeg',
- ),
- array (
- 'dsid' => 'QUERY',
- 'datastream_file' => "$module_path/collection_views/cmodel_collection_query.txt",
- 'mimetype' => 'text/plain',
- ),
- ),
- ),
- array (
- 'pid' => 'islandora:demos',
- 'label' => 'Islandora demos collection',
- 'cmodel' => 'islandora:collectionCModel',
- 'parent' => 'islandora:top',
- 'datastreams' => array (
- array (
- 'dsid' => 'TN',
- 'datastream_file' => "$module_path/images/Gnome-emblem-photos.png",
- 'mimetype' => 'image/png',
- ),
- array (
- 'dsid' => 'COLLECTION_POLICY',
- 'datastream_file' => "$module_path/collection_policies/COLLECTION-COLLECTION POLICY.xml",
- ),
- ),
- ),
- array (
- 'pid' => 'islandora:pdf_collection',
- 'label' => 'Islandora Demo PDF Collection',
- 'cmodel' => 'islandora:collectionCModel',
- 'parent' => 'islandora:demos',
- 'datastreams' => array (
- array (
- 'dsid' => 'TN',
- 'datastream_file' => "$module_path/images/Crystal_Clear_mimetype_pdf.png",
- 'mimetype' => 'image/png',
- ),
- array (
- 'dsid' => 'COLLECTION_POLICY',
- 'datastream_file' => "$module_path/collection_policies/PDF-COLLECTION POLICY.xml",
- ),
- ),
- ),
- array (
- 'pid' => 'demo:DualResImage',
- 'foxml_file' => "$module_path/content_models/demo_DualResImage.xml",
- 'datastreams' => array(
- array (
- 'dsid' => 'ISLANDORACM',
- 'datastream_file' => "$module_path/content_models/STANDARD JPG.xml",
- ),
- ),
- ),
- array (
- 'pid' => 'demo:DualResImageCollection',
- 'foxml_file' => "$module_path/content_models/demo_DualResImageCollection.xml",
- 'datastreams' => array(
- array(
- 'dsid' => 'ISLANDORACM',
- 'datastream_file' => "$module_path/content_models/COLLECTIONCM.xml",
- ),
- ),
- ),
- array (
- 'pid' => 'demo:DualResolution',
- 'foxml_file' => "$module_path/content_models/demo_DualResolution.xml",
- ),
- array (
- 'pid' => 'demo:DualResImageImpl',
- 'foxml_file' => "$module_path/content_models/demo_DualResImageImpl.xml",
- ),
- array (
- 'pid' => 'demo:CollectionImpl',
- 'foxml_file' => "$module_path/content_models/demo_CollectionImpl.xml",
- ),
- array (
- 'pid' => 'demo:Collection',
- 'foxml_file' => "$module_path/content_models/demo_Collection.xml",
- ),
- array (
- 'pid' => 'islandora:demo_image_collection',
- 'label' => 'Demo Image Collection',
- 'cmodel' => 'demo:DualResImageCollection',
- 'parent' => 'islandora:demos',
- 'datastreams' => array (
- array (
- 'dsid' => 'COLLECTION_POLICY',
- 'datastream_file' => "$module_path/collection_policies/JPG-COLLECTION POLICY.xml",
- ),
- array (
- 'dsid' => 'TN',
- 'datastream_file' => "$module_path/images/Gnome-emblem-photos.png",
- 'mimetype' => 'image/png',
- ),
- array (
- 'dsid' => 'COLLECTION_VIEW',
- 'datastream_file' => "$module_path/collection_views/standard_jpeg_collection_view.xml",
- ),
- array (
- 'dsid' => 'QUERY',
- 'datastream_file' => "$module_path/collection_views/standard_jpeg_collection_query.txt",
- 'mimetype' => 'text/plain',
- ),
- array (
- 'dsid' => 'DC',
- 'datastream_file' => "$module_path/collection_views/demo_image_collection_dc_record.xml",
- ),
- ),
- ),
- ),
+ FEDORA_METADATA_EDIT => array(
+ 'title' => t('Edit Fedora Metadata'),
+ 'description' => t('Users with this permission will be allowed to edit Fedora Metadata streams')
+ ),
+ FEDORA_INGEST => array(
+ 'title' => t('Create new Fedora objects'),
+ 'description' => t('Users with this permission will be allowed to create new objects in the Fedora repository')
+ ),
+ FEDORA_PURGE => array(
+ 'title' => t('Permanently remove objects from the Fedora repository'),
+ 'description' => t('Users with this permission will be allowed to Permantly remove objects from the Fedora repository.')
+ ),
+ FEDORA_MODIFY_STATE => array(
+ 'title' => t('Change a Fedora objects state'),
+ 'description' => t('Users with this permission will be allowed to change a Fedora objects state.')
),
);
}
-/*
- * Functions to create a time selector form element type.
+/**
+ *
+ * @param string $object_id
+ * @return type
*/
-
-function fedora_repository_elements() {
- $type['fedora_repository_time'] = array(
- "#input" => TRUE,
- "#process" => array("fedora_repository_expand_time"),
- );
-
- return $type;
-}
-
-function fedora_repository_expand_time($element) {
- // Default to current time, check default_value but set value so that if
- // default value is present it will override value
- if (empty($element['#default_value'])) {
- $element['#value'] = array(
- 'hour' => intval(format_date(time(), 'custom', 'h')),
- 'minute' => intval(format_date(time(), 'custom', 'i')),
- );
- }
-
- $element['#tree'] = TRUE;
-
- foreach ($element['#value'] as $type => $value) {
- switch ($type) {
- case 'hour':
- $options = drupal_map_assoc(range(1, 24));
- break;
- case 'minute':
- $options = range(0, 59);
- break;
- }
-
- if ($type != 'meridiem') {
- foreach ($options as $option) {
- strlen($option) <= 1 ? $options[$option] = 0 . $option : '';
- }
- }
-
- $element[$type] = array(
- '#type' => 'select',
- '#default_value' => $element['#value'][$type],
- '#options' => $options,
- );
- }
-
- return $element;
-}
-
-function fedora_repository_time($element) {
- $output = '' . $element['#children'] . '
';
- return theme('form_element', $element, $output);
-}
-
-function theme_fedora_repository_time($element) {
- $output = '' . $element['#children'] . '
';
- return theme('form_element', $element, $output);
-}
-
-/* Export (basket) functionality */
-
-function fedora_repository_remove_item_from_basket($pid) {
-
- module_load_include('inc', 'fedora_repository', 'ObjectHelper');
- $pids = empty($_SESSION['basket']['processed']) ? array() : $_SESSION['basket']['processed'];
-
- $objectHelper = new ObjectHelper();
- // getting child PIDs if any
- $cpids = $objectHelper->get_child_pids(array($pid));
-
- if (array_key_exists($pid, $pids)) {
- // remove item from basket
- unset($_SESSION['basket']['processed'][$pid]);
- }
- if (!empty($cpids)) { // there are children
- foreach ($cpids as $child_pid => $value) {
- // remove child item from basket recursively
- fedora_repository_remove_item_from_basket($child_pid);
- }
- }
-}
-
-function fedora_repository_basket() {
- $pids = _fedora_repository_get_basket_pids();
- $output = drupal_get_form('fedora_repository_basket_form', $pids);
-
- return $output;
-}
-
-function fedora_repository_basket_form($form_state, $pids) {
- $form = array();
-
- if (!empty($pids)) {
- $form['pid'] = array();
- $form['title'] = array();
- $form['desc'] = array();
- }
- else {
+function islandora_add_datastream($object_id) {
+ if (!isset($object_id)) {
+ drupal_set_message('Cannot add datastream to object, object id not set');
return;
}
+ //send message to synapse
+ $object = new IslandoraObject($object_id);
- ksort($pids);
- foreach ($pids as $pid => $arr) {
- $cbs[$pid] = '';
-
- $form['pid'][$pid] = array('#value' => l($pid, "fedora/repository/$pid"));
- $form['title'][$pid] = array('#value' => $arr['title']);
- $form['desc'][$pid] = array('#value' => $arr['desc']);
- }
-
- $form['remove'] = array(
- '#type' => 'checkboxes',
- '#options' => $cbs,
- );
-
- $form['remove_submit'] = array(
- '#type' => 'submit',
- '#value' => t('Remove selected'),
- );
-
- $form['remove_all'] = array(
- '#type' => 'submit',
- '#value' => t('Empty basket'),
- );
-
- $form['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Export selected'),
- );
-
- $form['submit_all'] = array(
- '#type' => 'submit',
- '#value' => t('Export all'),
- );
-
- return $form;
-}
-
-function theme_fedora_repository_basket_form($form) {
- $header = array(
- theme('table_select_header_cell'),
- t('PID'),
- t('Title'),
- t('Description'),
- );
-
- if (isset($form['pid']) && is_array($form['pid'])) {
- foreach (element_children($form['pid']) as $key) {
- $rows[] = array(
- drupal_render($form['remove'][$key]),
- drupal_render($form['pid'][$key]),
- drupal_render($form['title'][$key]),
- drupal_render($form['desc'][$key]),
- );
- }
- }
- else {
- $rows[] = array(array('data' => t('Your basket is empty.'), 'colspan' => '4'));
- }
-
- $output = theme('table', $header, $rows);
-
- $frm = drupal_render($form);
- $output = $frm . $output . $frm;
-
- return $output;
-}
-
-function fedora_repository_basket_form_validate($form, &$form_state) {
-
-}
-
-function fedora_repository_basket_form_submit($form, &$form_state) {
- if ($form_state['values']['op'] == $form_state['values']['remove_submit']) {
- $pids = $form_state['clicked_button']['#post']['remove'];
-
- if (isset($pids)) {
- foreach ($pids as $pid) {
- fedora_repository_remove_from_basket($pid);
- }
- drupal_set_message(t("Selected objects removed"));
- return;
- }
- }
-
- if ($form_state['values']['op'] == $form_state['values']['remove_all']) {
- _fedora_repository_empty_basket();
- drupal_set_message(t("Basket emptied"));
+ if (!isset($object)) {
+ drupal_set_message('Could not remove object, object not found');
return;
}
-
- if ($form_state['values']['op'] == $form_state['values']['submit_all']) {
- $msg = t("All objects exported to staging area");
- $pids = _fedora_repository_get_basket_pids();
- }
- elseif ($form_state['values']['op'] == $form_state['values']['submit']) {
- $msg = t("Selected objects exported to staging area");
- $pids = array_filter($form_state['values']['remove']);
- }
-
- if (!empty($pids)) {
- global $user;
- $log = array();
- $success = TRUE;
- $export_dir = variable_get('export_area', file_directory_path() . '/fedora_export_area') . '/' . $user->name . '/' . date("Ymd-His");
- $foxml_dir = $export_dir . '/foxml';
-
- if (!file_exists($foxml_dir) && !@mkdir($foxml_dir, 0775, TRUE)) {
- drupal_set_message(t("Failed to create foxml dir %dir. Check that export dir exsits and has correct permissions", array('%dir' => $foxml_dir)), 'error');
- return FALSE;
- }
-
- module_load_include('inc', 'fedora_repository', 'api/fedora_export');
- foreach ($pids as $pid => $arr) {
-
- $objects_dir = $export_dir . '/objects/' . $pid;
- if (!file_exists($objects_dir) && !@mkdir($objects_dir, 0775, TRUE)) {
- drupal_set_message(t("Failed to create objects dir %dir. Check that export dir exsits and has correct permissions", array('%dir' => $objects_dir)), 'error');
- return FALSE;
- }
-
- if (!export_to_export_area($pid, $foxml_dir, $objects_dir, $log)) {
- $success = FALSE;
- }
- }
- $msg = $success ? $msg : t("Failed to export objects to staging area");
- $msg .= ":
" . implode("
", $log);
-
- drupal_set_message($msg, $success ? 'info' : 'error');
- //_fedora_repository_empty_basket();
- }
- else {
- drupal_set_message(t("No objects selected or basket empty"), 'error');
- }
-
- return;
+ module_invoke_all('islandora_add_datastream', $object); //allow submodules to handle add datastream based on object type
}
-/*
- * Get all pids saved to the basket.
- */
-
-function _fedora_repository_get_basket_pids() {
-
- // Set empty defaults if basket elements are missing
- $_SESSION['basket'] = isset($_SESSION['basket']) ? $_SESSION['basket'] : array('processed' => array(), 'unprocessed' => array());
- $_SESSION['basket']['processed'] = isset($_SESSION['basket']['processed']) ? $_SESSION['basket']['processed'] : array();
- $_SESSION['basket']['unprocessed'] = isset($_SESSION['basket']['unprocessed']) ? $_SESSION['basket']['unprocessed'] : array();
-
- $pids = empty($_SESSION['basket']['processed']) ? array() : $_SESSION['basket']['processed'];
-
- module_load_include('inc', 'fedora_repository', 'ObjectHelper');
- $ob = new ObjectHelper();
- foreach ($_SESSION['basket']['unprocessed'] as $pid) {
- // Check if the pid already exists in the tree
- if (array_key_exists($pid, $pids)) {
- continue;
- }
-
- $pids += $ob->get_all_related_pids($pid);
-// $pids += array($pid);
- }
-
- $_SESSION['basket']['processed'] = $pids;
- $_SESSION['basket']['unprocessed'] = array();
-
- return $pids;
-}
-
-function _fedora_repository_empty_basket() {
- unset($_SESSION['basket']);
-}
-
-function fedora_repository_add_to_basket($pid, $warn = TRUE, $searchResultsFlag = FALSE) {
- if ($warn && _is_added_to_basket($pid)) {
- drupal_set_message("Object already in basket");
- }
-
- if (!isset($_SESSION['basket'])) {
- $_SESSION['basket'] = array();
- $_SESSION['basket']['unprocessed'] = array($pid => $pid);
- }
- else {
- $_SESSION['basket']['unprocessed'][$pid] = $pid;
- }
-
- if (!$searchResultsFlag) {
- drupal_goto('fedora/basket');
- }
-}
-
-function fedora_repository_remove_from_basket($pid) {
- if (isset($_SESSION['basket']['unprocessed'][$pid])) {
- unset($_SESSION['basket']['unprocessed'][$pid]);
- }
-
- if (isset($_SESSION['basket']['processed'][$pid])) {
- unset($_SESSION['basket']['processed'][$pid]);
- }
- return;
-}
-
-function theme_add_to_basket_link($pid, $type = 'object') {
- $object = t($type);
- $path = drupal_urlencode($pid);
-
- $save = "export_big.png";
- $saved = "exported_big.png";
-// $path = drupal_get_path('module', 'Fedora_Repository').'/images/'.$save ;
- /*
- var_dump($path);
- var_dump(theme('image',drupal_get_path('module', 'Fedora_Repository').'/images/'.$save));
- die();
- */
- if (!_is_added_to_basket($pid)) {
- return l(
- theme('image', drupal_get_path('module', 'Fedora_Repository') . '/images/' . $save, t("Add to basket"), t("Add this @object to my basket", array('@object' => $object))),
- "fedora/repository/addToBasket/" . $path,
- array('html' => TRUE)
- );
- }
-
- return theme('image', drupal_get_path('module', 'Fedora_Repository') . '/images/' . $saved, t("In basket"), t("This @object is already in your basket", array('@object' => $object)));
-}
-
-function _is_added_to_basket($pid, $account = NULL) {
- return isset($_SESSION['basket']['unprocessed'][$pid]) || isset($_SESSION['basket']['processed'][$pid]);
-// return db_result(db_query("SELECT uid FROM {repository_basket} WHERE uid = %d AND pid = '%s'", $account->uid, $pid));
-}
-
-function fedora_repository_display_schema($file) {
- $path = drupal_get_path('module', 'fedora_repository');
- if (strtolower(substr($file, -3)) == 'xsd' && file_exists($path . '/' . $file)) {
- drupal_goto($path . '/' . $file);
- }
- else {
- drupal_goto();
- }
- return;
-}
-
-
-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_utils');
- if (!empty($object) && is_array($object)) {
- $pid = $object['pid'];
- if (!validPid($pid)) {
- return NULL;
- }
- // Does the object exist? If so, purge it.
- $item = new Fedora_Item($pid);
- if ($item->exists()) {
- $item->purge(t('Remove during re-install batch job'));
- }
-
- // Ingest the object from the source file.
- if (!empty($object['foxml_file'])) {
- $foxml_file = $object['foxml_file'];
- $new_item = Fedora_Item::ingest_from_FOXML_file($foxml_file);
- if ($new_item->exists()) {
- // Batch operation was successful.
- $context['message'][] = "$new_item->pid installed.";
- }
- }
- if (!empty($object['dsid']) && !empty($object['datastream_file'])) {
- $datastreams = array (
- array (
- 'dsid' => $object['dsid'],
- 'datastream_file' => $object['datastream_file'],
- )
- );
- }
- elseif (!empty($object['datastreams'])) {
- $datastreams = $object['datastreams'];
- }
-
- if (!empty($datastreams) && is_array($datastreams)) {
- $label = !empty($object['label']) ? $object['label'] : '';
- if (empty($object['foxml_file']) && !defined($new_item)) {
- $new_item = Fedora_Item::ingest_new_item($object['pid'], 'A', $label);
- }
- if (!empty($object['cmodel'])) {
- $new_item->add_relationship('hasModel', $object['cmodel'], FEDORA_MODEL_URI);
- }
- if (!empty($object['parent'])) {
- $new_item->add_relationship('isMemberOfCollection', $object['parent']);
- }
- foreach($datastreams as $ds) {
- if ($ds['dsid'] == 'DC') {
- $new_item->modify_datastream_by_value(file_get_contents($ds['datastream_file']), $ds['dsid'], $ds['label'], 'text/xml');
- }
- else {
- $new_item->add_datastream_from_file($ds['datastream_file'], $ds['dsid'], !empty($ds['label']) ? $ds['label'] : '', !empty($ds['mimetype']) ? $ds['mimetype'] : 'text/xml');
- }
- }
- }
- }
-}
-
-/**
- * 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:
- * get_datastream_dissemination($dsid));
- } elseif (isset($datastream_file)) {
- $doc = simplexml_load_file($datastream_file);
- }
-
- if (!empty($doc)) {
- $attrs = $doc->attributes();
- foreach($attrs as $name => $value) {
- if ($name == 'version') {
- $return = (int) $value;
- break;
- }
- }
- }
- return $return;
-}
-
-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_utils');
- $output = '';
- $header = array();
- $rows = array();
-
-
-
-
- drupal_add_css(drupal_get_path('module', 'update') .'/update.css');
- return $output;
-}
-
-/**
- * Implementation of hook_forms()
- * @param string $form_id
- * @return array
- */
-function fedora_repository_forms($form_id) {
- $forms = array();
- if (strpos($form_id, 'fedora_repository_solution_pack_form_') === 0) {
- $forms[$form_id] = array(
- 'callback' => 'fedora_repository_solution_pack_form',
- );
- }
- return $forms;
-}
+?>
\ No newline at end of file