Browse Source

Merge remote-tracking branch 'upstream/7.x' into 7.x

pull/123/head
krisbulman 13 years ago
parent
commit
fd79918344
  1. 13
      admin/islandora.admin.inc
  2. 50
      includes/utilities.inc
  3. 102
      islandora.api.php
  4. 1
      islandora.info
  5. 8
      islandora_basic_collection/includes/change_content_models.inc
  6. 19
      islandora_basic_collection/includes/child_collection.inc
  7. 4
      islandora_basic_collection/includes/collection_management.inc
  8. 6
      islandora_basic_collection/includes/delete_collection.inc
  9. 4
      islandora_basic_collection/includes/manage_policies.inc
  10. 1
      islandora_basic_collection/includes/move_collection.inc
  11. 1
      islandora_basic_collection/islandora_basic_collection.info
  12. 1
      islandora_basic_image/islandora_basic_image.info

13
admin/islandora.admin.inc

@ -8,6 +8,7 @@
function islandora_repository_admin($form, &$form_state) {
module_load_include('inc', 'islandora', 'includes/tuque');
module_load_include('inc', 'islandora', 'includes/utilities');
if (!IslandoraTuque::exists()) {
$message = t('This module requires the !url. Please install sites all libraries folder before continuing.', array('!url' => l(t('Tuque Fedora API'), 'http://github.com/islandora/tuque')));
@ -24,16 +25,10 @@ function islandora_repository_admin($form, &$form_state) {
$url = variable_get('islandora_base_url', 'http://localhost:8080/fedora');
}
$connection = new IslandoraTuque(NULL, $url);
try {
$info = $connection->api->a->describeRepository();
$connected = TRUE;
}
catch (RepositoryException $e) {
$connected = FALSE;
}
// Connect to Fedora
$info = islandora_describe_repository($url);
if($connected) {
if($info) {
$confirmation_message = '<img src="' . url('misc/watchdog-ok.png') . '"/>'
. t('Successfully connected to Fedora Server (Version !version).', array('!version' => $info['repositoryVersion']));
}

50
includes/utilities.inc

@ -46,3 +46,53 @@ function islandora_control_group_to_human_readable($control_group) {
return $control_group;
}
}
/**
* valid pid ??
* @param type $pid
* @return boolean
*/
function islandora_validate_pid($pid) {
$valid = FALSE;
if (strlen(trim($pid)) <= 64 && preg_match('/^([A-Za-z0-9]|-|\.)+:(([A-Za-z0-9])|-|\.|~|_|(%[0-9A-F]{2}))+$/', trim($pid))) {
$valid = TRUE;
}
return $valid;
}
/**
* Valid Dsid ??
* @param type $dsid
* @return boolean
*/
function islandora_validate_dsid($dsid) {
$valid = FALSE;
if (strlen(trim($dsid)) <= 64 && preg_match('/^[a-zA-Z0-9\_\-\.]+$/', trim($dsid))) {
$valid = TRUE;
}
return $valid;
}
/* Helper function to describe a Fedora repository.
*
* Can be used to check if Fedora is available.
*
* @param $url
* A url to a Fedora repository.
* @return
* Returns an array describing the repository. Returns FALSE if Fedora is down
* or if the url is incorrect.
*/
function islandora_describe_repository($url) {
$connection = new IslandoraTuque(NULL, $url);
try {
$info = $connection->api->a->describeRepository();
return $info;
}
catch (RepositoryException $e) {
return FALSE;
}
}

102
islandora.api.php

@ -1,23 +1,83 @@
<?php
/**
* remove a datastream from a repository object
* @param object $fedora_object
* tuque FedoraObject
* @param string $datastream_id
*/
function hook_islandora_purge_datastream ($fedora_object, $datastream_id){}
function hook_islandora_purge_datastream ($object_id, $datastream_id){}
function hook_islandora_purge_object($object_id) {}
/**
*
* @param type $object
* tuque FedoraObject
*/
function hook_islandora_purge_object($islandora_object) {}
function hook_islandora_view_object($object_id){}
/**
* allows modules to add to a repository objects display. If you implement this
* hook you should also register your module for view with the get types hook.
*
* islandora gets all displays back in an array and iterates over them. the order
* they are displayed is based on the order of the key of the array that each
* module returns.
*
* your module may also want to register a varible that says whether or not it
* should be part of the default display. Modules can also add secondary tabs as
* a way to add there output to an islandora display. the basic image module has
* samples of both (the secondary tabs examples are commented out)
*
* @param type $islandora_object
* tuque FedoraObject
*/
function hook_islandora_view_object($islandora_object){}
/**
* returns an array listing object types provided by sub modules
* Ex. array($types['islandora:collectionCModel'][ISLANDORA_VIEW_HOOK] = variable_get('islandora_basic_collection_use_for_default_tab', TRUE);
* $types['islandora:collectionCModel'][ISLANDORA_EDIT_HOOK] = FALSE;
*
* @return array
*/
function hook_islandora_get_types(){}
function hook_islandora_add_datastream($object_id) {}
/**
* allows modules to define an object edit page by cmodel
*
* your module should return true for ISLANDORA_EDIT_HOOK in its get_types function
*
* islandora provides a default implementation that should work for most use cases
* @param string $islandora_object
* @return string
*
*/
function hook_islandora_edit_object($islandora_object){}
/**
* allows modules to alter the fedora object before it is pass through the edit
* hooks
* @param type $islandora_object
* a tugue FedoraObject
*/
function islandora_islandora_edit_object_alter ($islandora_object){}
/**
* creates and populates a php Fedora object.
*/
function hook_islandora_preingest_alter(){}
function hook_islandora_postingest($object){}
function hook_islandora_datastream_edit($object, $dsid){}
/**
* modules can implement this hook to add or remove datastreams after an
* object has been ingested.
*
* Each module should check for the newly ingested repository objects content
* model to make sure it is a type of object they want to act on.
*
* @param type $islandora_object
* tugue FeodoraObject
*/
function hook_islandora_postingest($islandora_object){}
/**
* Register potential ingest routes. Implementations should return an array containing possible routes.
@ -26,3 +86,29 @@ function hook_islandora_datastream_edit($object, $dsid){}
* );
*/
function hook_islandora_ingest_registry($collection_object) {}
/**
* alter an object before it gets used further down the stack
* @param type $object
* a tuque FedoraObject
*/
function hook_islandora_object_alter ($fedora_object){}
/**
* insert or remove rendered elements by implementing this function
* in your module
* @param type $arr
* an arr of rendered views
*/
function hook_islandora_display_alter ($arr){}
/**
*
* @param type $islandora_object
* a tuque FedoraObject
* @param array $content_models
* @param string $collection_pid
*/
function hook_islandora_ingest_pre_ingest($islandora_object, $content_models, $collection_pid){}

1
islandora.info

@ -3,5 +3,6 @@ description = "View and manage Fedora objects"
package = Islandora
version = 7.x-dev
core = 7.x
configure = admin/islandora/configure
stylesheets[all][] = css/islandora.base.css
stylesheets[all][] = css/islandora.theme.css

8
islandora_basic_collection/includes/change_content_models.inc

@ -86,7 +86,7 @@ function islandora_change_content_models_form_submit($form, &$form_state) {
$collection_pid = $form_state['values']['collection_pid'];
$current_content_model_object = islandora_object_load($current_content_model);
$collection_object = islandora_load_object($form_state['values']['collection_pid']);
$collection_object = islandora_object_load($form_state['values']['collection_pid']);
$collection_policy_datastream = $collection_object->getDatastream(variable_get('Islandora_Collection_Policy_DSID', 'COLLECTION_POLICY'));
$policy = new CollectionPolicy($collection_policy_datastream->content);
@ -105,7 +105,7 @@ function islandora_change_content_models_form_submit($form, &$form_state) {
}
}
if ($add_to_policy) {
$new_content_model_object = new FedoraObject($new_content_model, $rest_connection->repository);
$new_content_model_object = islandora_object_load($new_content_model);
$new_content_model_datastream = $new_content_model_object->getDatastream(variable_get('Islandora_Content_Model_DSID', 'ISLANDORACM'));
$content_models_element = $collection_policy_xml->getElementsByTagName('content_models');
$content_model_element = $content_models_element->item(0)->getElementsByTagName('content_model');
@ -129,14 +129,14 @@ function islandora_change_content_models_form_submit($form, &$form_state) {
or \$object <info:fedora/fedora-system:def/relations-external#isMemberOf> <info:fedora/$collection_pid>)
and \$object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)";
$objects = $rest_connection->repository->ri->itqlQuery($query, 'unlimited', '0');
$objects = $collection_object->repository->ri->itqlQuery($query, 'unlimited', '0');
$count = 0;
foreach ($objects as $object) {
if (!$object['object']['value']) {
continue;
}
$fedora_item = new FedoraObject($object['object']['value'], $rest_connection->repository);
$fedora_item = islandora_object_load($object['object']['value']);
$fedora_item->relationships->remove(FEDORA_MODEL_URI, 'hasModel', $current_content_model);
$fedora_item->relationships->add(FEDORA_MODEL_URI, 'hasModel', $new_content_model);
$count++;

19
islandora_basic_collection/includes/child_collection.inc

@ -119,7 +119,20 @@ function islandora_create_child_collection_form($form, &$form_state, $collection
}
function islandora_create_child_collection_form_validate($form, &$form_state) {
module_load_include('inc', 'islandora', 'includes/utilities');
$new_collection_pid = $form_state['values']['new_collection_pid'];
if($new_collection_pid) {
$valid = islandora_validate_pid($new_collection_pid);
if(!$valid) {
form_set_error('new_collection_pid', 'Collection PID is Invalid.');
}
else {
$object = islandora_object_load($new_collection_pid);
if($object !== NULL) {
form_set_error('new_collection_pid', 'Collection PID already exists.');
}
}
}
}
/**
@ -136,7 +149,7 @@ function islandora_create_child_collection_form_submit($form, &$form_state) {
$new_collection_pid = $form_state['values']['new_collection_pid'];
$this_collection_pid = $form_state['values']['current'];
if(empty($new_collection_pid)) {
$collection_namespace = substr($this_collection_pid, 0, strpos($this_collection_pid, ":"));
$new_collection_pid = substr($this_collection_pid, 0, strpos($this_collection_pid, ":"));
}
$new_collection_label = $form_state['values']['collection_name'];
$namespace = $form_state['values']['collection_namespace'];
@ -185,5 +198,5 @@ function islandora_create_child_collection_form_submit($form, &$form_state) {
$fedora_object->ingestDatastream($policy_datastream);
$new_fedora_object = islandora_ingest_add_object($fedora_object);
drupal_goto('/islandora/object/' . $new_collection_pid);
drupal_goto('/islandora/object/' . $fedora_object->id);
}

4
islandora_basic_collection/includes/collection_management.inc

@ -37,7 +37,7 @@ function get_child_collections($object) {
$query = <<<EOD
select \$object from <#ri>
where \$object <info:fedora/fedora-system:def/model#hasModel> <info:fedora/islandora:collectionCModel>
and \$object <info:fedora/fedora-system:def/relations-external#isMemberOfCollection> <info:fedora/$collection_pid>
and \$object <info:fedora/fedora-system:def/relations-external#isMemberOfCollection> <info:fedora/$object->id>
EOD;
$lines = $object->repository->ri->itqlQuery($query, 'unlimited', '0');
@ -49,7 +49,7 @@ function islandora_collections_get_collection_from_pid($object) {
$query = 'select $parent from <#ri>
where ($object <fedora-rels-ext:isMemberOf> $parent
or $object <fedora-rels-ext:isMemberOfCollection> $parent)
and $object <dc:identifier> \'' . $pid . '\'
and $object <dc:identifier> \'' . $object->id . '\'
order by $object';
$object_pids = $object->repository->ri->itqlQuery($query, 'unlimited', '0');

6
islandora_basic_collection/includes/delete_collection.inc

@ -67,7 +67,7 @@ function islandora_collection_deletion_form($form, &$form_state, $object) {
function islandora_collection_deletion_form_submit($form, &$form_state) {
$collection_pid = $form_state['values']['current'];
$fedora_object = islandora_object_load($collection_object);
$fedora_object = islandora_object_load($collection_pid);
$parents = $fedora_object->relationships->get(NULL, 'isMemberOfCollection');
$parents = islandora_collections_get_collection_from_pid($fedora_object);
@ -77,14 +77,14 @@ function islandora_collection_deletion_form_submit($form, &$form_state) {
drupal_goto("islandora/object/" . $parents[0]['parent']['value']);
}
$child_collections = get_child_collections($collection_pid);
$child_collections = get_child_collections($fedora_object);
$populated_child_collections = array();
$pids = @array_filter($form_state['values']['table']);
if (!empty($child_collections)) {
foreach ($child_collections as $child) {
$child_pids = get_related_items_as_array(islandora_object_load($child), 'isMemberOfCollection');
$child_pids = get_related_items_as_array(islandora_object_load($child['object']['value']), 'isMemberOfCollection');
if (!empty($child_pids)) {
$populated_child_collections[] = $child;
}

4
islandora_basic_collection/includes/manage_policies.inc

@ -137,6 +137,7 @@ function islandora_manage_policies_form_validate($form, &$form_state) {
* @param array $form_state
*/
function islandora_manage_policies_form_submit($form, &$form_state) {
module_load_include('module', 'islandora', 'islandora');
$collection_pid = $form_state['values']['parent_collection'];
$collection_object = islandora_object_load($collection_pid);
@ -166,7 +167,8 @@ function islandora_manage_policies_form_submit($form, &$form_state) {
$cp_namespace = $form_state['values']['new_cp_namespace'];
$cp_content_model = $form_state['values']['content_model_to_add'];
$content_model_object = new FedoraObject($cp_content_model, $rest_connection->repository);
$content_model_object = islandora_object_load($cp_content_model);
$content_model_datastream = $content_model_object->getDatastream(variable_get('Islandora_Content_Model_DSID', 'ISLANDORACM'));
$content_models_element = $collection_policy_xml->getElementsByTagName('content_models');

1
islandora_basic_collection/includes/move_collection.inc

@ -64,7 +64,6 @@ function islandora_collection_migrate_form($form, &$form_state, $object) {
* @param array $form_state
*/
function islandora_collection_migrate_form_submit($form, &$form_state) {
$pids = array_filter($form_state['values']['table']);
$new_collection = $form_state['values']['new_collection'];
$current = $form_state['values']['current'];

1
islandora_basic_collection/islandora_basic_collection.info

@ -3,5 +3,6 @@ description = "A default Islandora Repository module to handle simple collection
dependencies[] = islandora
package = Islandora
core = 7.x
configure = admin/islandora/basic_collection
stylesheets[all][] = css/islandora_basic_collection.base.css
stylesheets[all][] = css/islandora_basic_collection.theme.css

1
islandora_basic_image/islandora_basic_image.info

@ -3,5 +3,6 @@ description = "A default Islandora Repository module to handle images"
dependencies[] = islandora
package = Islandora
core = 7.x
configure = admin/islandora/basic_image
stylesheets[all][] = css/islandora_basic_image.base.css
stylesheets[all][] = css/islandora_basic_image.theme.css
Loading…
Cancel
Save