Browse Source

Merge branch '7.x' of github.com:Islandora/islandora into 7.x

pull/122/head
rwincewicz 13 years ago
parent
commit
5a7f421732
  1. 11
      RestConnection.inc
  2. 251
      admin/islandora.admin.inc
  3. 210
      admin/islandora.solutionpacks.inc
  4. BIN
      images/Crystal_Clear_action_filenew.png
  5. 5
      includes/breadcrumb.inc
  6. 151
      includes/datastream.inc
  7. 11
      includes/ingest-menu.inc
  8. 20
      includes/islandora_dublin_core.inc
  9. 2
      includes/mime.detect.inc
  10. 19
      includes/object_properties.inc
  11. 159
      includes/purge.form.inc
  12. 2
      islandora.api.php
  13. 484
      islandora.module
  14. 17
      islandora_basic_collection/admin/islandora_basic_collection.admin.inc
  15. 12
      islandora_basic_collection/includes/child_collection.inc
  16. 18
      islandora_basic_collection/includes/collection_management.inc
  17. 4
      islandora_basic_collection/includes/collection_manager_table.inc
  18. 28
      islandora_basic_collection/islandora_basic_collection.module
  19. 1
      islandora_basic_collection/theme/islandora-basic-collection-wrapper.tpl.php
  20. 19
      islandora_basic_collection/theme/islandora_basic_collection.theme.inc
  21. 19
      islandora_basic_image/includes/image.process.inc
  22. 34
      islandora_basic_image/islandora-basic-image.tpl.php
  23. 2
      islandora_basic_image/islandora_basic_image.module
  24. 0
      theme/islandora-object-edit.tpl.php
  25. 0
      theme/islandora-object.tpl.php
  26. 91
      theme/islandora.theme.inc

11
RestConnection.inc

@ -41,7 +41,7 @@ class RestConnection {
*/ */
public $repository = NULL; public $repository = NULL;
function RestConnection($user = NULL) { function __construct($user = NULL, $url = NULL) {
if(!isset($user)) { if(!isset($user)) {
global $user; global $user;
} }
@ -53,7 +53,11 @@ class RestConnection {
$user_string = $user->name; $user_string = $user->name;
$pass_string = $user->pass; $pass_string = $user->pass;
} }
$url = variable_get('islandora_base_url', 'http://localhost:8080/fedora');
if (!isset($url)) {
$url = variable_get('islandora_base_url', 'http://localhost:8080/fedora');
}
$this->connection = new RepositoryConnection($url, $user_string, $pass_string); $this->connection = new RepositoryConnection($url, $user_string, $pass_string);
$this->connection->reuseConnection = TRUE; $this->connection->reuseConnection = TRUE;
$this->api = new FedoraApi($this->connection); $this->api = new FedoraApi($this->connection);
@ -61,5 +65,8 @@ class RestConnection {
$this->repository = new FedoraRepository($this->api, $this->cache); $this->repository = new FedoraRepository($this->api, $this->cache);
} }
static function exists() {
return class_exists('RepositoryConnection');
}
} }

251
admin/islandora.admin.inc

@ -6,139 +6,144 @@
* @return array * @return array
*/ */
function islandora_repository_admin() { function islandora_repository_admin($form, &$form_state) {
if (!user_access('administer site configuration')) { module_load_include('inc', 'islandora', 'RestConnection');
drupal_set_message(t('You must be a site administrator to edit the Fedora collections list.'), 'error');
return;
}
$form = array();
$form['islandora_repository_pid'] = array(
'#type' => 'textfield',
'#title' => t('Root Collection PID'),
'#default_value' => variable_get('islandora_repository_pid', 'islandora:root'),
'#description' => t('The PID of the Root Collection Object'),
'#required' => TRUE,
'#weight' => -18
);
$form['islandora_base_url'] = array(
'#type' => 'textfield',
'#title' => t('Fedora base URL'),
'#default_value' => variable_get('islandora_base_url', 'http://localhost:8080/fedora'),
'#description' => t('The URL to use for REST-type connections'),
'#required' => TRUE,
'#weight' => -16,
);
$form['islandora_repository_url'] = array( if (!RestConnection::exists()) {
'#type' => 'textfield', $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')));
'#title' => t('Fedora RISearch URL'), drupal_set_message(check_plain($message));
'#default_value' => variable_get('islandora_repository_url', 'http://localhost:8080/fedora/risearch'), return;
'#description' => t('The url of the Fedora server'), '#required' => TRUE, }
'#weight' => -14
);
$form['islandora_soap_url'] = array( $form = array();
'#type' => 'textfield',
'#title' => t('Fedora SOAP Url'),
'#default_value' => variable_get('islandora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl'),
'#description' => t('The URL to use for SOAP connections'),
'#required' => TRUE,
'#weight' => -12,
);
$form['islandora_soap_manage_url'] = array(
'#type' => 'textfield',
'#title' => t('Fedora SOAP management URL'),
'#default_value' => variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/wsdl?api=API-M'), '#description' => t('The URL to use for SOAP API-M connections'),
'#required' => TRUE,
'#weight' => -10
);
// will allow admin user to remove namepsace restrictions if not explicitly disallowed in settings.php if(isset($form_state['values']['islandora_base_url'])) {
if (variable_get('allow_open_namespace', TRUE)) { $url = $form_state['values']['islandora_base_url'];
$form['islandora_namespace'] = array( }
'#type' => 'fieldset', else {
); $url = variable_get('islandora_base_url', 'http://localhost:8080/fedora');
}
$form['islandora_namespace']['islandora_namespace_restriction_enforced'] = array(
'#weight' => -1,
'#type' => 'radios',
'#title' => t('Enforce namespace restrictions'),
'#options' => array(
TRUE => t('Enabled'),
FALSE => t('Disabled')
),
'#description' => t('Allow administrator to restrict user\'s access to the PID namepaces listed below'),
'#default_value' => variable_get('islandora_namespace_restriction_enforced', TRUE)
);
$form['islandora_namespace']['fedora_pids_allowed'] = array(
'#type' => 'textfield',
'#title' => t('PID namespaces allowed in this Drupal install'),
'#default_value' => variable_get('islandora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: '),
'#description' => t('A space separated list of PID namespaces that users are permitted to access from this Drupal installation. <br /> This could be more than a simple namespace ie demo:mydemos.'),
'#weight' => 0
);
}
else {
$form['islandora_pids_allowed'] = array(
'#type' => 'textfield',
'#title' => t('PID namespaces allowed in this Drupal install'),
'#default_value' => variable_get('islandora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: '),
'#description' => t('A space separated list of PID namespaces that users are permitted to access from this Drupal installation. <br /> This could be more than a simple namespace ie demo:mydemos.'),
'#weight' => 0
);
}
//have tabs options (like disable)
$form['tabs'] = array(
'#type' => 'fieldset',
'#title' => t('Tabs Configuration'),
'#description' => t('Configure the tabs avaialble when viewing Fedora objects.'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
//when checked show object details tab
$form['tabs']['islandora_repository_show_object_details_tab'] = array(
'#type' => 'checkbox',
'#title' => t('Show Object Details Tab'),
'#default_value' => variable_get('islandora_repository_show_object_details_tab', TRUE),
'#description' => t("When enabled, the 'Object Details' tab will be visible to users with the correct permissions when viewing an object in the repository"),
);
$form['advanced'] = array( module_load_include('inc', 'islandora', 'RestConnection');
'#type' => 'fieldset', $connection = new RestConnection(NULL, $url);
'#title' => t('Advanced configuration options'), try {
'#description' => t('Advanced configuration. Under normal circumstances these will not be touched'), $info = $connection->api->a->describeRepository();
'#collapsible' => TRUE, $connected = TRUE;
'#collapsed' => TRUE, }
); catch (RepositoryException $e) {
$connected = FALSE;
}
if($connected) {
$confirmation_message = '<img src="' . url('misc/watchdog-ok.png') . '"/>'
. t('Successfully connected to Fedora Server (Version !version).', array('!version' => $info['repositoryVersion']));
}
else {
$confirmation_message = '<img src="' . url('misc/watchdog-error.png') . '"/> '
. t('Unable to connect to Fedora server at !islandora_url', array('!islandora_url' => $url));
}
$form['islandora_tabs'] = array(
'#type' => 'vertical_tabs',
);
$form['islandora_tabs']['islandora_general'] = array(
'#type' => 'fieldset',
'#title' => t('General Configuarion'),
);
// ajax wrapper for url checking
$form['islandora_tabs']['islandora_general']['wrapper'] = array(
'#prefix' => '<div id="islandora-url">',
'#suffix' => '</div>',
'#type' => 'markup',
);
$form['islandora_tabs']['islandora_general']['wrapper']['islandora_base_url'] = array(
'#type' => 'textfield',
'#title' => t('Fedora base URL'),
'#default_value' => variable_get('islandora_base_url', 'http://localhost:8080/fedora'),
'#description' => t('The URL to use for REST connections <br>' . $confirmation_message),
'#required' => TRUE,
'#ajax' => array(
'callback' => 'islandora_update_url_div',
'wrapper' => 'islandora-url',
'effect' => 'fade',
'event' => 'blur',
'progress' => array('type' => 'throbber'),
),
);
$form['islandora_tabs']['islandora_general']['islandora_repository_pid'] = array(
'#type' => 'textfield',
'#title' => t('Root Collection PID'),
'#default_value' => variable_get('islandora_repository_pid', 'islandora:root'),
'#description' => t('The PID of the Root Collection Object'),
'#required' => TRUE,
);
$form['islandora_tabs']['islandora_namespace'] = array(
'#type' => 'fieldset',
'#title' => t('Namespaces'),
);
$form['islandora_tabs']['islandora_namespace']['wrapper'] = array(
'#type' => 'markup',
'#prefix' => '<div id="islandora-namespace">',
'#suffix' => '</div>',
);
$form['islandora_tabs']['islandora_namespace']['wrapper']['islandora_namespace_restriction_enforced'] = array(
'#weight' => -1,
'#type' => 'checkbox',
'#title' => t('Enforce namespace restrictions'),
'#description' => t('Allow administrator to restrict user\'s access to the PID namepaces listed below'),
'#default_value' => variable_get('islandora_namespace_restriction_enforced', FALSE),
'#ajax' => array(
'callback' => 'islandora_update_namespace_div',
'wrapper' => 'islandora-namespace',
'effect' => 'fade',
'event' => 'change',
'progress' => array('type' => 'throbber'),
),
);
if(isset($form_state['values']['islandora_namespace_restriction_enforced'])) {
$namespaces = $form_state['values']['islandora_namespace_restriction_enforced'];
}
else {
$namespaces = variable_get('islandora_namespace_restriction_enforced', FALSE);
}
$form['advanced']['islandora_object_restrict_datastreams'] = array( if($namespaces) {
'#type' => 'checkbox', $form['islandora_tabs']['islandora_namespace']['wrapper']['islandora_pids_allowed'] = array(
'#title' => t('Restrict Access to Fedora Object Datastreams'), '#type' => 'textfield',
'#default_value' => variable_get('islandora_object_restrict_datastreams', FALSE), '#title' => t('PID namespaces allowed in this Drupal install'),
'#description' => t('When enabled, restricts access to fedora object datastreams that are not listed in the Islandora Content Model for the object (unless the user is an administrator).'), '#default_value' => variable_get('islandora_pids_allowed', 'default: demo: changeme: ilives: islandora-book: books: newspapers: '),
'#description' => t('A space separated list of PID namespaces that users are permitted to access from this Drupal installation. <br /> This could be more than a simple namespace ie demo:mydemos. <br> islandora: is reserved and is always allowed.'),
'#weight' => 0,
); );
}
return system_settings_form($form);
}
/**
* Checks url validity and refreshes requestHandler dropdown list
*/
function islandora_update_url_div($form, $form_state) {
unset($form_state['submit_handlers']);
$form_state['rebuild'] = TRUE;
//Export functionality return $form['islandora_tabs']['islandora_general']['wrapper'];
//$form['advanced']['module']['islandora_export_area'] = array( }
// '#type' => 'textfield',
// '#title' => t('Export area'),
// '#default_value' => variable_get('islandora_export_area', file_directory_path() . '/fedora_export_area'),
// '#description' => t("Path to the export area. It must be accessible by druapl (i.e. apache user)."),
// '#required' => TRUE,
//);
$form['#attributes'] = array('enctype' => "multipart/form-data");
/**
* Checks url validity and refreshes requestHandler dropdown list
*/
function islandora_update_namespace_div($form, $form_state) {
unset($form_state['submit_handlers']);
$form_state['rebuild'] = TRUE;
return system_settings_form($form); return $form['islandora_tabs']['islandora_namespace']['wrapper'];
} }

210
admin/islandora.solutionpacks.inc

@ -1,210 +0,0 @@
<?php
/**
* @file
* Invokes a hook to any dependent modules asking them if their installations require
* any fedora objects to be present. Modules implementing this hook should return an array
* of arrays of the form:
*
* array( 'pid', 'path-to-foxml-file', 'dsid', 'path-to-datastream-file', int dsversion)
*
* where the last three options are optional. A module can either point to a simple
* foxml file to install, or can specify a datastreamstream to check for, with a
* path to load the datastream from if it isn't there. Optionally a version number
* can be included, to enable updating of content model or collection policy streams
* that may have been updated. THis is a simple whole number that should be incremented
* when changed. This value appears in as an attribute of the topmost element of the stream,
* e.g.,:
*
* <?xml version="1.0" encoding="utf-8"?> <content_model name="Collection" version="2" ...
*
* Datastreams which don't have this element are assumed to be at version 0.
*/
function fedora_repository_solution_packs_page() {
$enabled_solution_packs = module_invoke_all('required_fedora_objects');
$output = '';
foreach ($enabled_solution_packs as $solution_pack_module => $solution_pack_info) {
$objects = array();
foreach ($solution_pack_info as $field => $value) {
switch ($field) {
case 'title':
$solution_pack_name = $value;
break;
case 'objects':
$objects = $value;
break;
}
}
$output .= drupal_get_form('fedora_repository_solution_pack_form_' . $solution_pack_module, $solution_pack_module, $solution_pack_name, $objects);
}
return $output;
}
/**
* Check for installed objects and add a 'Update' or 'Install' button if some objects are missing.
* @param array $solution_pack
*/
function fedora_repository_solution_pack_form(&$form_state, $solution_pack_module, $solution_pack_name, $objects = array()) {
// Check each object to see if it is in the repository.
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
global $base_path;
$needs_update = FALSE;
$needs_install = FALSE;
$form = array();
$form['solution_pack_module'] = array(
'#type' => 'hidden',
'#value' => $solution_pack_module,
);
if (!$form_state['submitted']) {
$form['solution_pack_name'] = array(
'#type' => 'markup',
'#value' => t($solution_pack_name),
'#prefix' => '<h3>',
'#suffix' => '</h3>',
);
$form['objects'] = array(
'#type' => 'fieldset',
'#title' => "Objects",
'#weight' => 10,
'#attributes' => array('class' => 'collapsed'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$table_header = array('PID', 'Status');
$table_rows = array();
foreach ($objects as $object) {
$datastreams = NULL;
if (isset($object['pid'])) {
$pid = $object['pid'];
$item = new Fedora_Item($pid);
$table_row = array($object['pid']);
$object_status = t('Up-to-date');
if (!$item->exists()) {
$object_status = 'Missing';
$needs_install = TRUE;
}
else {
if (isset($object['dsid']) && isset($object['datastream_file']) && isset($object['dsversion'])) {
$datastreams = array(
array(
'dsid' => $object['dsid'],
'datastream_file' => $object['datastream_file'],
'dsversion' => $object['dsversion'],
),
);
}
elseif (!empty($object['datastreams'])) {
$datastreams = $object['datastreams'];
}
if (!empty($datastreams) && is_array($datastreams)) {
foreach ($datastreams as $ds) {
$ds_list = $item->get_datastreams_list_as_array();
if (!array_key_exists($ds['dsid'], $ds_list)) {
$needs_update = TRUE;
$object_status = 'Missing datastream';
break;
}
elseif (isset($ds['dsversion'])) {
// Check if the datastream is versioned and needs updating.
$installed_version = fedora_repository_get_islandora_datastream_version($item, $ds['dsid']);
$available_version = fedora_repository_get_islandora_datastream_version(NULL, NULL, $ds['datastream_file']);
if ($available_version > $installed_version) {
$needs_update = TRUE;
$object_status = 'Out of date';
break;
}
}
}
}
}
array_push($table_row, $object_status);
$table_rows[] = $table_row;
}
}
$form['objects']['table'] = array(
'#type' => 'markup',
'#value' => theme_table($table_header, $table_rows),
);
}
$form['install_status'] = array(
'#type' => 'markup',
'#prefix' => '<strong>' . t('Object status:') . '&nbsp;</strong>',
'#suffix' => '&nbsp;',
);
if (!$needs_install && !$needs_update) {
$form['install_status']['#value'] = theme_image('misc/watchdog-ok.png') . t('All required objects are installed and up-to-date.');
$submit_button_text = t("Force Reinstallation of Fedora Objects");
}
else {
$form['install_status']['#value'] = theme_image('misc/watchdog-warning.png') . t('Some objects must be re-ingested. See Objects list for details.');
$submit_button_text = t("Install Fedora Objects");
}
$form['submit'] = array(
'#value' => $submit_button_text,
'#type' => 'submit',
'#name' => $solution_pack_module,
);
$form['#submit'] = array(
'fedora_repository_solution_pack_form_submit',
);
return $form;
}
function fedora_repository_solution_pack_form_submit($form, &$form_state) {
$what = $form_state;
$module_name = $form_state['values']['solution_pack_module'];
// This should be replaced with module_invoke
//$solution_pack_info = call_user_func($module_name . '_required_fedora_objects');
$solution_pack_info = module_invoke($module_name, 'required_fedora_objects');
$batch = array(
'title' => t('Installing / updating solution pack objects'),
'file' => drupal_get_path('module', 'fedora_repository') . '/fedora_repository.module',
'operations' => array(),
);
foreach ($solution_pack_info[$module_name]['objects'] as $object) {
// Add this object to the batch job queue.
$batch['operations'][] = array('fedora_repository_batch_reingest_object', array($object));
}
batch_set($batch);
}
function solution_pack_add_form($form_name, $form_xml) {
$result = db_result(db_query('Select name from {xml_forms} where name = "%s"', $form_name));
if (!$result) {
$object = new stdClass();
$object->name = $form_name;
$object->form = $form_xml;
$result = drupal_write_record('xml_forms', $object);
drupal_set_message(t("Added @name", array("@name" => $form_name)));
}
}
function solution_pack_add_form_association($content_model, $form_name) {
$result = db_result(db_query('Select content_model from {islandora_content_model_forms} where content_model = "%s" and form_name = "%s"',
$content_model, $form_name));
if (!$result) {
$object = new stdClass();
$object->content_model = $content_model;
$object->form_name = $form_name;
$object->dsid = 'MODS';
$object->title_field = "['titleInfo']['title']";
$object->transform = 'mods_to_dc.xsl';
$result = drupal_write_record('islandora_content_model_forms', $object);
drupal_set_message(t("Added association between @cm and @name", array("@cm" => $content_model, "@name"=>$form_name)));
}
}

BIN
images/Crystal_Clear_action_filenew.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

5
includes/Breadcrumbs.inc → includes/breadcrumb.inc

@ -1,11 +1,10 @@
<?php <?php
function islandora_get_breadcrumbs($pid) { function islandora_get_breadcrumbs($object) {
module_load_include('inc', 'islandora', 'RestConnection');
$breadcrumbs = array(); $breadcrumbs = array();
$connection = new RestConnection(); $connection = new RestConnection();
islandora_get_breadcrumbs_recursive($pid, $breadcrumbs, $connection->repository); islandora_get_breadcrumbs_recursive($object->id, $breadcrumbs, $object->repository);
if(isset($breadcrumbs[0])) { if(isset($breadcrumbs[0])) {
unset($breadcrumbs[0]); unset($breadcrumbs[0]);

151
includes/datastream.inc

@ -13,33 +13,22 @@ define('DS_COMP_STREAM', 'DS-COMPOSITE-MODEL');
* @return stream * @return stream
* prints datastream to browser * prints datastream to browser
*/ */
function islandora_datastream_as_attachment($object_id, $dsid) { function islandora_view_datastream($object, $dsid, $method = 'view') {
module_load_include('inc', 'islandora', 'RestConnection'); // if the object exists but the datastream doesn't
global $user; if(!isset($object[$dsid])) {
try {
$restConnection = new RestConnection($user);
$fedora_object = new FedoraObject($object_id, $restConnection->repository);
// if the object exists but the datastream doesn't
if(!isset($fedora_object[$dsid])) {
return drupal_not_found();
}
header('Content-type: ' . $fedora_object[$dsid]->mimetype);
if($fedora_object[$dsid]->controlGroup == 'M' || $fedora_object[$dsid]->controlGroup == 'X') {
header('Content-length: ' . $fedora_object[$dsid]->size);
}
header("Cache-control: private");
$method = arg(5);
if (isset($method) && $method == 'download') {
header("Content-Disposition: attachment; filename=\"" . $fedora_object[$dsid]->label);
}
print($fedora_object[$dsid]->content);
exit();
} catch (Exception $e) {
return drupal_not_found(); return drupal_not_found();
} }
header('Content-type: ' . $object[$dsid]->mimetype);
if($object[$dsid]->controlGroup == 'M' || $object[$dsid]->controlGroup == 'X') {
header('Content-length: ' . $object[$dsid]->size);
}
if ($method == 'download') {
header("Content-Disposition: attachment; filename=\"" . $object[$dsid]->label);
}
print($object[$dsid]->content);
exit();
} }
function islandora_datastream_get_parents($islandora_object) { function islandora_datastream_get_parents($islandora_object) {
@ -94,26 +83,19 @@ function islandora_get_defined_dsids_array(&$arr, $ds_comp_stream) {
* @param string $object_id * @param string $object_id
* @return string|array * @return string|array
*/ */
function islandora_get_unused_dsids($object_id) { function islandora_get_unused_dsids($object) {
module_load_include('inc', 'islandora', 'RestConnection');
global $user;
try {
$restConnection = new RestConnection($user);
$fedora_object = new FedoraObject($object_id, $restConnection->repository);
} catch (Exception $e) {
drupal_set_message(t('Error getting Islandora object %s ', array('%s' => $object_id)), 'error');
return;
}
if (!isset($fedora_object)) {
drupal_set_message(t('Could not create add datastream form for %s'), array('%s' => $object_id));
return;
}
$models = $fedora_object->models;
$defined_dsids = array(); $defined_dsids = array();
if(!$object) {
return $defined_dsids;
}
$models = $object->models;
if (isset($models)) { if (isset($models)) {
foreach ($models as $model) { foreach ($models as $model) {
try { try {
$model_object = new FedoraObject($model, $restConnection->repository); $model_object = $object->repository->getObject($model);
if (isset($model_object[DS_COMP_STREAM])) { if (isset($model_object[DS_COMP_STREAM])) {
$dscomposite_stream = $model_object[DS_COMP_STREAM]->content; $dscomposite_stream = $model_object[DS_COMP_STREAM]->content;
islandora_get_defined_dsids_array($defined_dsids, $dscomposite_stream); islandora_get_defined_dsids_array($defined_dsids, $dscomposite_stream);
@ -138,8 +120,8 @@ function islandora_get_unused_dsids($object_id) {
* @return array * @return array
* a form ready to be rendered with a call to Drupal render * a form ready to be rendered with a call to Drupal render
*/ */
function islandora_get_add_datastream_form($object_id, &$form_state) { function islandora_get_add_datastream_form($object, &$form_state) {
$unused_dsids = islandora_get_unused_dsids($object_id); //$defined_dsids; $unused_dsids = islandora_get_unused_dsids($object);
$form = array(); $form = array();
$form['add_fieldset'] = array( $form['add_fieldset'] = array(
'#type' => 'fieldset', '#type' => 'fieldset',
@ -222,8 +204,8 @@ function islandora_add_datastream_form_submit($form, &$form_state) {
return; return;
} }
module_load_include('inc', 'islandora', 'includes/MimeClass'); module_load_include('inc', 'islandora', 'includes/mime.detect');
$mimetype = new MimeClass(); $mimetype = new MimeDetect();
$file = $form_state['values']['add-stream-file-location']; $file = $form_state['values']['add-stream-file-location'];
$file = drupal_realpath($file); $file = drupal_realpath($file);
@ -260,9 +242,9 @@ function islandora_add_datastream_form_submit($form, &$form_state) {
* @return boolean * @return boolean
*/ */
function islandora_add_datastream_form_validate($form, &$form_state) { function islandora_add_datastream_form_validate($form, &$form_state) {
module_load_include('inc', 'islandora', 'includes/MimeClass'); module_load_include('inc', 'islandora', 'includes/mime.detect');
module_load_include('inc', 'islandora', 'RestConnection'); module_load_include('inc', 'islandora', 'RestConnection');
$mimetype = new MimeClass(); $mimetype = new MimeDetect();
if ($form_state['clicked_button']['#value'] == 'OK') { if ($form_state['clicked_button']['#value'] == 'OK') {
$form_state['rebuild'] = TRUE; $form_state['rebuild'] = TRUE;
return; return;
@ -295,8 +277,9 @@ function islandora_add_datastream_form_validate($form, &$form_state) {
return FALSE; return FALSE;
} }
$mimetype = new MimeClass(); $mimetype = new MimeDetect();
$unused_dsids = islandora_get_unused_dsids($form_state['values']['pid']); $object = islandora_object_load($form_state['values']['pid']);
$unused_dsids = islandora_get_unused_dsids($object);
if(isset($unused_dsids[$dsid])) { if(isset($unused_dsids[$dsid])) {
$types_allowed = $unused_dsids[$dsid]; $types_allowed = $unused_dsids[$dsid];
$arr = array(); $arr = array();
@ -329,8 +312,8 @@ function islandora_add_datastream_form_validate($form, &$form_state) {
* @return array * @return array
* a form ready to be rendered with a call to Drupal render * a form ready to be rendered with a call to Drupal render
*/ */
function islandora_add_datastream_form($form, &$form_state, $object_id) { function islandora_add_datastream_form($form, &$form_state, $object) {
$unused_dsids = islandora_get_unused_dsids($object_id); //$defined_dsids; $unused_dsids = islandora_get_unused_dsids($object); //$defined_dsids;
$form = array(); $form = array();
$form['add_fieldset'] = array( $form['add_fieldset'] = array(
'#type' => 'fieldset', '#type' => 'fieldset',
@ -345,7 +328,7 @@ function islandora_add_datastream_form($form, &$form_state, $object_id) {
$form['pid'] = array( $form['pid'] = array(
'#type' => 'hidden', '#type' => 'hidden',
'#value' => "$object_id" '#value' => "$object->id"
); );
$form['add_fieldset']['stream_label'] = array( $form['add_fieldset']['stream_label'] = array(
@ -363,13 +346,13 @@ function islandora_add_datastream_form($form, &$form_state, $object_id) {
// '#required'=>'TRUE', // '#required'=>'TRUE',
'#description' => t('The file to upload.') '#description' => t('The file to upload.')
); );
$form['#redirect'] = "islandora/object/$object_id/"; $form['#redirect'] = "islandora/object/$object->id/";
$form['add_fieldset']['submit'] = array( $form['add_fieldset']['submit'] = array(
'#type' => 'submit', '#type' => 'submit',
'#value' => t('Add Datastream') '#value' => t('Add Datastream')
); );
$unused_dsids = islandora_get_unused_dsids($object_id); $unused_dsids = islandora_get_unused_dsids($object);
$dsidsForForm = ''; $dsidsForForm = '';
$i = 0; $i = 0;
foreach ($unused_dsids as $key => $value) { foreach ($unused_dsids as $key => $value) {
@ -385,13 +368,13 @@ function islandora_add_datastream_form($form, &$form_state, $object_id) {
'#description' => t('An ID for this stream that is unique to this object. Must start with a letter and contain only alphanumeric characters and dashes and underscores. Datastreams that are defined by the content model dont currently exist: <b>' . $dsidsForForm . '</b>.'), '#description' => t('An ID for this stream that is unique to this object. Must start with a letter and contain only alphanumeric characters and dashes and underscores. Datastreams that are defined by the content model dont currently exist: <b>' . $dsidsForForm . '</b>.'),
'#type' => 'textfield', '#type' => 'textfield',
'#weight' => -1, '#weight' => -1,
'#autocomplete_path' => "islandora/object/$object_id/manage/datastreams/add/autocomplete", '#autocomplete_path' => "islandora/object/$object->id/manage/datastreams/add/autocomplete",
); );
return $form; return $form;
} }
function islandora_datastream_autocomplete_callback($object_id, $string = '') { function islandora_datastream_autocomplete_callback($object, $string = '') {
$dsids = islandora_get_unused_dsids($object_id); $dsids = islandora_get_unused_dsids($object);
$output = array(); $output = array();
foreach($dsids as $id => $ds) { foreach($dsids as $id => $ds) {
if(trim($string) == '') { if(trim($string) == '') {
@ -428,6 +411,21 @@ function islandora_datastream_get_url($ds, $type = 'download') {
} }
} }
function islandora_datastream_get_delete_link($ds) {
$datastreams = module_invoke_all('islandora_undeletable_datastreams', $ds->parent->models);
if(in_array($ds->id, $datastreams)) {
return '';
}
else {
return l(t('delete'), 'islandora/object/' . $ds->parent->id . '/datastream/' . $ds->id . '/delete');
}
}
function islandora_islandora_undeletable_datastreams($models) {
return array('DC');
}
function islandora_datastream_edit_get_link($object, $ds_id) { function islandora_datastream_edit_get_link($object, $ds_id) {
$edit_registry = module_invoke_all('islandora_edit_datastream_registry', $object, $ds_id); $edit_registry = module_invoke_all('islandora_edit_datastream_registry', $object, $ds_id);
if (count($edit_registry) > 0 && user_access(FEDORA_METADATA_EDIT)) { if (count($edit_registry) > 0 && user_access(FEDORA_METADATA_EDIT)) {
@ -438,34 +436,23 @@ function islandora_datastream_edit_get_link($object, $ds_id) {
} }
} }
function islandora_edit_datastream($object_id, $ds_id) { function islandora_edit_datastream($object, $ds_id) {
global $user; $edit_registry = module_invoke_all('islandora_edit_datastream_registry', $object, $ds_id);
try { $edit_count = count($edit_registry);
module_load_include('inc', 'islandora', 'RestConnection');
$restConnection = new RestConnection($user);
$object = new FedoraObject($object_id, $restConnection->repository);
$edit_registry = module_invoke_all('islandora_edit_datastream_registry', $object, $ds_id);
$edit_count = count($edit_registry);
if ($edit_count == 0) { if ($edit_count == 0) {
// No edit implementations. // No edit implementations.
drupal_set_message(t('There are no edit methods specified for this datastream.')); drupal_set_message(t('There are no edit methods specified for this datastream.'));
drupal_goto('islandora/object/' . $object->id . '/manage/datastreams'); drupal_goto('islandora/object/' . $object->id . '/manage/datastreams');
} }
elseif ($edit_count == 1) { elseif ($edit_count == 1) {
// One registry implementation, go there // One registry implementation, go there
drupal_goto($edit_registry[0]['url']); drupal_goto($edit_registry[0]['url']);
} }
else { else {
// Multiple edit routes registered // Multiple edit routes registered
return islandora_edit_datastream_registry_render($edit_registry); return islandora_edit_datastream_registry_render($edit_registry);
}
} catch (Exception $e) {
drupal_set_message(t('Error getting Islandora edit method for %s ', array('%s' => $object_id)), 'error');
return;
} }
} }
//@TODO: theme / preprocess //@TODO: theme / preprocess

11
includes/ingest-menu.inc

@ -10,15 +10,18 @@
* @TODO: validate?: pid, registry return * @TODO: validate?: pid, registry return
* @param string $pid * @param string $pid
*/ */
function islandora_ingest_callback($collection_pid) { function islandora_ingest_callback($collection_object) {
$ingest_registry = module_invoke_all('islandora_ingest_registry', $collection_pid); if(!$collection_object) {
return drupal_not_found();
}
$ingest_registry = module_invoke_all('islandora_ingest_registry', $collection_object);
$registry_count = count($ingest_registry); $registry_count = count($ingest_registry);
if ($registry_count == 0) { if ($registry_count == 0) {
// No ingest implementations. // No ingest implementations.
drupal_set_message(t('There are no ingest methods specified for this collection.')); drupal_set_message(t('There are no ingest methods specified for @name.', array('@name', $collection_object->label)));
drupal_goto('islandora/object/' . $collection_pid); drupal_goto('islandora/object/' . $collection_object->id);
} }
elseif ($registry_count == 1) { elseif ($registry_count == 1) {
// One registry implementation, go there // One registry implementation, go there

20
includes/islandora_dublin_core.inc

@ -103,15 +103,27 @@ class Dublin_Core {
$dc_array = array(); $dc_array = array();
foreach ($this as $element) { foreach ($this as $element) {
if (!empty($element)) { if (!empty($element)) {
foreach ($element as $field => $value) { foreach ($element as $field => $values) {
// split value if the result value is an array // split value if the result value is an array
if (is_array($value)) { if (is_array($values)) {
$value = implode(", ", $value); $value = '';
$i = 0;
foreach($values as $piece) {
if(!empty($piece)) {
if($i++) {
$value .= ", ";
}
$value .= $piece;
}
}
}
else {
$value = $values;
} }
$dc_label = explode(':', $field); $dc_label = explode(':', $field);
$element_label = ucfirst($dc_label[1]); $element_label = ucfirst($dc_label[1]);
$dc_array[$field]['label'] = $element_label; $dc_array[$field]['label'] = $element_label;
$dc_array[$field]['value'] = strip_tags($value); $dc_array[$field]['value'] = $value;
$dc_array[$field]['class'] = strtolower(preg_replace('/[^A-Za-z0-9]/', '-', $field)); $dc_array[$field]['class'] = strtolower(preg_replace('/[^A-Za-z0-9]/', '-', $field));
} }
} }

2
includes/MimeClass.inc → includes/mime.detect.inc

@ -22,7 +22,7 @@
* *
*/ */
class MimeClass { class MimeDetect {
protected $protectedMimeTypes = array( protected $protectedMimeTypes = array(
/* /*

19
includes/object_properties.inc

@ -10,7 +10,7 @@
* @return boolean * @return boolean
*/ */
function islandora_edit_properties_form_validate($form, &$form_state) { function islandora_edit_properties_form_validate($form, &$form_state) {
$islandora_object = islandora_get_object($form_state['values']['pid']); $islandora_object = islandora_object_load($form_state['values']['pid']);
if (!isset($islandora_object)) { if (!isset($islandora_object)) {
form_set_error('', t('Could not update properties object not found.')); form_set_error('', t('Could not update properties object not found.'));
return FALSE; return FALSE;
@ -23,7 +23,7 @@ function islandora_edit_properties_form_validate($form, &$form_state) {
* @param array $form_state * @param array $form_state
*/ */
function islandora_edit_properties_form_submit($form, &$form_state) { function islandora_edit_properties_form_submit($form, &$form_state) {
$islandora_object = islandora_get_object($form_state['values']['pid']); $islandora_object = islandora_object_load($form_state['values']['pid']);
$owner = $form_state['values']['object_owner']; $owner = $form_state['values']['object_owner'];
$state = $form_state['values']['object_state']; $state = $form_state['values']['object_state'];
$label = $form_state['values']['object_label']; $label = $form_state['values']['object_label'];
@ -66,35 +66,34 @@ function islandora_edit_properties_form_delete($form, &$form_state) {
* an object id * an object id
* @return array * @return array
*/ */
function islandora_edit_properties_form($form, &$form_state, $object_id) { function islandora_edit_properties_form($form, &$form_state, $object) {
$form = array(); $form = array();
$islandora_object = islandora_get_object($object_id); if (!isset($object)) {
drupal_set_title($islandora_object->label);
if (!isset($islandora_object)) {
return NULL; return NULL;
} }
drupal_set_title($object->label);
$form['pid'] = array( $form['pid'] = array(
'#type' => 'hidden', '#type' => 'hidden',
'#value' => $object_id, '#value' => $object->id,
); );
$form['object_label'] = array( $form['object_label'] = array(
'#title' => t('Item Label'), '#title' => t('Item Label'),
'#default_value' => $islandora_object->label, '#default_value' => $object->label,
'#required' => 'TRUE', '#required' => 'TRUE',
'#description' => t('A Human readable label'), '#description' => t('A Human readable label'),
'#type' => 'textfield' '#type' => 'textfield'
); );
$form['object_owner'] = array( $form['object_owner'] = array(
'#title' => t('Owner'), '#title' => t('Owner'),
'#default_value' => $islandora_object->owner, '#default_value' => $object->owner,
'#required' => FALSE, '#required' => FALSE,
'#description' => t('The owner id'), '#description' => t('The owner id'),
'#type' => 'textfield', '#type' => 'textfield',
); );
$form['object_state'] = array( $form['object_state'] = array(
'#title' => t('State'), '#title' => t('State'),
'#default_value' => $islandora_object->state, '#default_value' => $object->state,
'#required' => TRUE, '#required' => TRUE,
'#description' => t('The items state one of active, inactive or deleted'), '#description' => t('The items state one of active, inactive or deleted'),
'#type' => 'select', '#type' => 'select',

159
includes/purge.form.inc

@ -0,0 +1,159 @@
<?php
/**
* Gives the option of deleting or purging and object.
*
* The default behaviour is to purge the object to reduce maintenance.
* If a solution pack wants to change this behaviour and have the object set to deleted then
* it can respond to the 'islandora_pre_purge_object' hook with an array containing the pair
* 'delete' => TRUE.
* Once the object has been deleted/purged then a second call lets the solution packs know that
* the object has been dealt with. In this call the object id and content models are sent out so
* that the solution packs can act on this news. There is no guarantee that the object still exists
* and so the object object isn't sent.
*
* @param string $object_id
* ID of the object
* @return type
*/
function islandora_purge_object_submit($form, &$form_state) {
$object_id = $form_state['values']['pid'];
$collection = $form_state['values']['col'];
if (!isset($object_id)) {
drupal_set_message(t('Cannot remove object, object id not set'));
return;
}
$object = islandora_object_load($object_id);
if (!isset($fedora_object)) {
drupal_set_message(t('Could not remove object, object not found'));
return;
}
$content_models = $fedora_object->models;
$arr = module_invoke_all('islandora_pre_purge_object', $fedora_object); //notify modules of pending deletion
if (isset($arr['delete']) && $arr['delete']) {
try {
$fedora_object->delete();
} catch (Exception $e) {
drupal_set_message(t('Error deleting Islandora object %s %e', array('%s' => $object_id, '%e' => $e)), 'error');
return "";
}
}
else {
try {
$restConnection->repository->purgeObject($object_id);
} catch (Exception $e) {
drupal_set_message(t('Error purging Islandora object %s %e', array('%s' => $object_id, '%e' => $e)), 'error');
return "";
}
}
module_invoke_all('islandora_post_purge_object', $object_id, $content_models); //notify modules post deletion
drupal_goto($collection);
}
function islandora_purge_object($form, &$form_state, $object) {
module_load_include('inc', 'islandora', 'includes/datastream');
$parent = islandora_datastream_get_parents($object);
$key = array_keys($parent);
if (count($key) > 0) {
$redirect = "islandora/object/$key[0]";
}
else {
$redirect = "islandora";
}
$form['pid'] = array('#type' => 'value', '#value' => $object->id);
$form['col'] = array('#type' => 'value', '#value' => $redirect);
return confirm_form($form,
t('Are you sure you want to delete %title?', array('%title' => $object->label)),
"islandora/object/$object->id",
t('This action cannot be undone.'),
t('Delete'),
t('Cancel')
);
}
function islandora_purge_datastream($form, &$form_state, $object, $datastream_id) {
module_load_include('inc', 'islandora', 'includes/datastream');
$datastream = $object->getDatastream($datastream_id);
$redirect = "islandora/object/$object->id";
$form['pid'] = array('#type' => 'value', '#value' => $object->id);
$form['dsid'] = array('#type' => 'value', '#value' => $datastream_id);
$form['col'] = array('#type' => 'value', '#value' => $redirect);
return confirm_form($form,
t('Are you sure you want to delete the %dsid datastream?', array('%dsid' => $datastream->id)),
"islandora/object/$object->id",
t('This action cannot be undone.'),
t('Delete'),
t('Cancel')
);
}
/**
* Gives the option of purging or deleting a datastream.
*
* The default behaviour is to purge the datastream but this can be overridden using the
* 'islandora_pre_purge_datastream' hook. The returned array can include a 'block' => TRUE
* pair which will prevent the datastream from being deleted if it particularly needed for
* a certain function. Returning 'delete' => TRUE will cause the datastream to be put into
* a deleted state.
*
* @param string $object_id
* ID of the object
* @param string $datastream_id
* ID of the datastream
*
*/
function islandora_purge_datastream_submit($form, &$form_state) {
$object_id = $form_state['values']['pid'];
$datastream_id = $form_state['values']['dsid'];
if (!isset($datastream_id)) {
drupal_set_message(t('Cannot remove datastream, datastream id not set'));
return;
}
$object = islandora_object_load($object_id);
if (!isset($object)) {
drupal_set_message(t('Could not remove object, object not found'));
return;
}
//notify modules of pending deletion so we can update rels etc
$arr = module_invoke_all('islandora_pre_purge_datastream', $object[$datastream_id]);
if (isset($arr['block']) && $arr['block']) {
drupal_set_message(t('Purging of the %d datastream was blocked', array('%d' => $datastream_id)), 'warning');
return;
}
if (isset($arr['delete']) && $arr['delete']) {
try {
$object[$datastream_id]->state = 'D';
} catch (Exception $e) {
drupal_set_message(t('Error deleting %s datastream from Islandora object %o %e', array('%s' => $datastream_id, '%o' => $object->id, '%e' => $e)), 'error');
return;
}
}
else {
try {
$object->purgeDatastream($datastream_id);
} catch (Exception $e) {
drupal_set_message(t('Error purging %s datastream from Islandora object %o %e', array('%s' => $datastream_id, '%o' => $object_id, '%e' => $e)), 'error');
return;
}
}
//notify modules post deletion
module_invoke_all('islandora_post_purge_datastream', $object, $datastream_id);
drupal_set_message(t('%d datastream sucessfully purged from Islandora object %o', array('%d' => $datastream_id, '%o' => $object->label)));
drupal_goto('islandora/object/' . $object->id);
}

2
islandora.api.php

@ -25,4 +25,4 @@ function hook_islandora_datastream_edit($object, $dsid){}
* array('name' => t('Ingest Route Name'), 'url' => 'ingest_route/url', 'weight' => 0), * array('name' => t('Ingest Route Name'), 'url' => 'ingest_route/url', 'weight' => 0),
* ); * );
*/ */
function hook_islandora_ingest_registry($collection_pid) {} function hook_islandora_ingest_registry($collection_object) {}

484
islandora.module

@ -56,16 +56,17 @@ function islandora_menu() {
'file' => 'admin/islandora.admin.inc', 'file' => 'admin/islandora.admin.inc',
'access arguments' => array('administer site configuration'), 'access arguments' => array('administer site configuration'),
'type' => MENU_NORMAL_ITEM, 'type' => MENU_NORMAL_ITEM,
'weight' => 0, 'weight' => -1,
); );
$items['islandora/ingest/%'] = array( $items['islandora/object/%islandora_object/manage/ingest'] = array(
'title' => 'Ingest object', 'title' => 'Add an object',
'page callback' => 'islandora_ingest_callback', 'page callback' => 'islandora_ingest_callback',
'page arguments' => array(2), 'page arguments' => array(2),
'file' => 'includes/ingest-menu.inc', 'file' => 'includes/ingest-menu.inc',
'type' => MENU_CALLBACK, 'type' => MENU_LOCAL_ACTION,
'access arguments' => array(FEDORA_INGEST), 'access callback' => 'islandora_ingest_access_callback',
'access arguments' => array(2, FEDORA_INGEST),
); );
$items['islandora'] = array( $items['islandora'] = array(
@ -75,151 +76,135 @@ function islandora_menu() {
'access arguments' => array(FEDORA_VIEW), 'access arguments' => array(FEDORA_VIEW),
); );
$items['islandora/object/%'] = array( $items['islandora/object/%islandora_object'] = array(
'title' => 'Repository', 'title' => 'Repository',
'page callback' => 'islandora_view_object', 'page callback' => 'islandora_view_object',
'page arguments' => array(2), 'page arguments' => array(2),
'type' => MENU_NORMAL_ITEM, 'type' => MENU_NORMAL_ITEM,
'access arguments' => array(FEDORA_VIEW), 'access callback' => 'islandora_access_callback',
'access arguments' => array(2, FEDORA_VIEW),
); );
$items['islandora/object/%/view'] = array( $items['islandora/object/%islandora_object/view'] = array(
'title' => 'View', 'title' => 'View',
//'page callback' => 'islandora_view_object',
'page arguments' => array(2),
'type' => MENU_DEFAULT_LOCAL_TASK, 'type' => MENU_DEFAULT_LOCAL_TASK,
'access arguments' => array(FEDORA_VIEW), 'weight' => -1,
'weight' => -10
); );
$items['islandora/object/%/view/default'] = array(
$items['islandora/object/%islandora_object/view/default'] = array(
'title' => 'View', 'title' => 'View',
'page callback' => 'islandora_view_object', 'type' => MENU_DEFAULT_LOCAL_TASK,
'page arguments' => array(2), 'weight' => -1,
'type' => MENU_LOCAL_TASK,
'access arguments' => array(FEDORA_VIEW),
'weight' => -10,
); );
$items['islandora/object/%/manage'] = array( $items['islandora/object/%islandora_object/manage'] = array(
'title' => 'Manage', 'title' => 'Manage',
'page callback' => 'islandora_edit_object', 'page callback' => 'islandora_edit_object',
'page arguments' => array(2), 'page arguments' => array(2),
'type' => MENU_LOCAL_TASK, 'type' => MENU_LOCAL_TASK,
'access arguments' => array(FEDORA_MODIFY_STATE), 'access callback' => 'islandora_access_callback',
'access arguments' => array(2, FEDORA_MODIFY_STATE),
); );
$items['islandora/object/%/manage/datastreams'] = array( $items['islandora/object/%islandora_object/manage/datastreams'] = array(
'title' => 'Datastreams', 'title' => 'Datastreams',
//'page callback' => 'islandora_edit_object',
'page arguments' => array(2),
'type' => MENU_DEFAULT_LOCAL_TASK, 'type' => MENU_DEFAULT_LOCAL_TASK,
'access arguments' => array(FEDORA_PURGE),
'weight' => -10, 'weight' => -10,
); );
$items['islandora/object/%/manage/properties'] = array( $items['islandora/object/%islandora_object/manage/properties'] = array(
'title' => 'Properties', 'title' => 'Properties',
'page callback' => 'drupal_get_form', 'page callback' => 'drupal_get_form',
'file' => 'includes/object_properties.inc', 'file' => 'includes/object_properties.inc',
'page arguments' => array('islandora_edit_properties_form', 2), 'page arguments' => array('islandora_edit_properties_form', 2),
'type' => MENU_LOCAL_TASK, 'type' => MENU_LOCAL_TASK,
'access arguments' => array(FEDORA_MODIFY_STATE), 'access callback' => 'islandora_access_callback',
'access arguments' => array(2, FEDORA_MODIFY_STATE),
'weight' => -5, 'weight' => -5,
); );
$items['islandora/object/%/delete'] = array( $items['islandora/object/%islandora_object/delete'] = array(
'title' => 'Delete object', 'title' => 'Delete object',
'file' => 'includes/purge.form.inc',
'page callback' => 'drupal_get_form', 'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_purge_object', 2), 'page arguments' => array('islandora_purge_object', 2),
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'access arguments' => array(FEDORA_PURGE), 'access callback' => 'islandora_access_callback',
'access arguments' => array(2, FEDORA_PURGE),
); );
$items['islandora/object/%/manage/datastreams/add'] = array( $items['islandora/object/%islandora_object/manage/datastreams/add'] = array(
'title' => 'Add a datastream', 'title' => 'Add a datastream',
'file' => 'includes/datastream.inc', 'file' => 'includes/datastream.inc',
'page callback' => 'drupal_get_form', 'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_add_datastream_form', 2), 'page arguments' => array('islandora_add_datastream_form', 2),
'type' => MENU_NORMAL_ITEM, 'type' => MENU_LOCAL_ACTION,
'access arguments' => array(FEDORA_ADD_DS) 'access callback' => 'islandora_access_callback',
'access arguments' => array(2, FEDORA_ADD_DS)
); );
$items['islandora/object/%/manage/datastreams/add/autocomplete'] = array( $items['islandora/object/%islandora_object/manage/datastreams/add/autocomplete'] = array(
'file' => 'includes/datastream.inc', 'file' => 'includes/datastream.inc',
'page callback' => 'islandora_datastream_autocomplete_callback', 'page callback' => 'islandora_datastream_autocomplete_callback',
'page arguments' => array(2), 'page arguments' => array(2),
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'access arguments' => array(FEDORA_ADD_DS) 'access callback' => 'islandora_access_callback',
'access arguments' => array(2, FEDORA_ADD_DS)
); );
$items['islandora/object/%/datastream/%'] = array( $items['islandora/object/%islandora_object/datastream/%'] = array(
'title' => 'View datastream', 'title' => 'View datastream',
'page callback' => 'islandora_datastream_as_attachment', 'page callback' => 'islandora_view_datastream',
'page arguments' => array(2, 4), 'page arguments' => array(2, 4),
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'file' => 'includes/datastream.inc', 'file' => 'includes/datastream.inc',
'access arguments' => array(FEDORA_VIEW), 'access callback' => 'islandora_access_callback',
'access arguments' => array(2, FEDORA_VIEW),
); );
$items['islandora/object/%/datastream/%/view'] = array( $items['islandora/object/%islandora_object/datastream/%/view'] = array(
'title' => 'View datastream', 'title' => 'View datastream',
'page callback' => 'islandora_datastream_as_attachment', 'type' => MENU_DEFAULT_LOCAL_TASK,
'page arguments' => array(2, 4),
'type' => MENU_CALLBACK,
'file' => 'includes/datastream.inc',
'access arguments' => array(FEDORA_VIEW),
); );
$items['islandora/object/%/datastream/%/download'] = array( $items['islandora/object/%islandora_object/datastream/%/download'] = array(
'title' => 'Download datastream', 'title' => 'Download datastream',
'page callback' => 'islandora_datastream_as_attachment', 'page callback' => 'islandora_view_datastream',
'page arguments' => array(2, 4), 'page arguments' => array(2, 4, 5),
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'file' => 'includes/datastream.inc', 'file' => 'includes/datastream.inc',
'access arguments' => array(FEDORA_VIEW), 'access callback' => 'islandora_access_callback',
'access arguments' => array(2, FEDORA_VIEW),
); );
$items['islandora/object/%/datastream/%/edit'] = array( $items['islandora/object/%islandora_object/datastream/%/edit'] = array(
'title' => 'Edit datastream', 'title' => 'Edit datastream',
'page callback' => 'islandora_edit_datastream', 'page callback' => 'islandora_edit_datastream',
'page arguments' => array(2, 4), 'page arguments' => array(2, 4),
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'file' => 'includes/datastream.inc', 'file' => 'includes/datastream.inc',
'access arguments' => array(FEDORA_METADATA_EDIT), 'access callback' => 'islandora_access_callback',
'access arguments' => array(2, FEDORA_METADATA_EDIT),
); );
$items['islandora/object/%/datastream/%/delete'] = array( $items['islandora/object/%islandora_object/datastream/%/delete'] = array(
'title' => 'Purge data stream', 'title' => 'Purge data stream',
'page callback' => 'drupal_get_form', 'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_purge_datastream', 2, 4), 'page arguments' => array('islandora_purge_datastream', 2, 4),
'file' => 'includes/purge.form.inc',
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'access arguments' => array(FEDORA_PURGE), 'access callback' => 'islandora_access_callback',
'access arguments' => array(2, FEDORA_PURGE),
); );
return $items; return $items;
} }
function islandora_admin_paths_alter(&$paths) { function islandora_admin_paths() {
$paths = array();
$paths['*/manage*'] = TRUE; $paths['*/manage*'] = TRUE;
} return $paths;
/**
* Implements hook_menu_local_tasks_alter().
*/
function islandora_menu_local_tasks_alter(&$data, $router_item, $root_path) {
// Add action link 'islandora/object/%/manage/datastreams'.
if ($root_path == 'islandora/object/%/manage') {
$object_id = $router_item['page_arguments'][0];
$item = menu_get_item("islandora/object/$object_id/manage/datastreams/add");
if ($item['access']) {
$data['actions']['output'][] = array(
'#theme' => 'menu_local_action',
'#link' => $item,
);
}
}
} }
/** /**
@ -231,116 +216,23 @@ function islandora_menu_local_tasks_alter(&$data, $router_item, $root_path) {
* *
* @return boolean * @return boolean
*/ */
function islandora_node_access($op, $pid = NULL, $as_user = NULL) { function islandora_access_callback($pid = NULL, $perm = NULL) {
//$returnValue = FALSE; if(!$pid || !$perm) {
return FALSE;
if ($pid == NULL) {
$pid = variable_get('fedora_repository_pid', 'islandora:root');
} }
$isRestricted = variable_get('fedora_namespace_restriction_enforced', TRUE); $isRestricted = variable_get('islandora_namespace_restriction_enforced', FALSE);
$namespace_access = NULL;
if (!$isRestricted) { if (!$isRestricted) {
$namespace_access = TRUE; $namespace_access = TRUE;
} }
else { else {
$pid_namespace = substr($pid, 0, strpos($pid, ':') + 1); //Get the namespace (with colon) $pid_namespace = substr($pid, 0, strpos($pid, ':') + 1); //Get the namespace (with colon)
$allowed_namespaces = explode(" ", variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: ')); $allowed_namespaces = explode(" ", variable_get('islandora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: '));
$namespace_access = in_array($pid_namespace, $allowed_namespaces); $namespace_access = in_array($pid_namespace, $allowed_namespaces);
} }
return ($namespace_access && user_access($op, $as_user)); return ($namespace_access && user_access($perm));
}
/**
* Gives the option of deleting or purging and object.
*
* The default behaviour is to purge the object to reduce maintenance.
* If a solution pack wants to change this behaviour and have the object set to deleted then
* it can respond to the 'islandora_pre_purge_object' hook with an array containing the pair
* 'delete' => TRUE.
* Once the object has been deleted/purged then a second call lets the solution packs know that
* the object has been dealt with. In this call the object id and content models are sent out so
* that the solution packs can act on this news. There is no guarantee that the object still exists
* and so the object object isn't sent.
*
* @param string $object_id
* ID of the object
* @return type
*/
function islandora_purge_object_submit($form, &$form_state) {
$object_id = $form_state['values']['pid'];
$collection = $form_state['values']['col'];
module_load_include('inc', 'islandora', 'RestConnection');
global $user;
if (!isset($object_id)) {
drupal_set_message(t('Cannot remove object, object id not set'));
return;
}
try {
$restConnection = new RestConnection($user);
$fedora_object = new FedoraObject($object_id, $restConnection->repository);
} catch (Exception $e) {
drupal_set_message(t('Error getting Islandora object %s %e', array('%s' => $object_id, '%e' => $e)), 'error');
return "";
}
if (!isset($fedora_object)) {
drupal_set_message(t('Could not remove object, object not found'));
return;
}
$content_models = $fedora_object->models;
$arr = module_invoke_all('islandora_pre_purge_object', $fedora_object); //notify modules of pending deletion
if (isset($arr['delete']) && $arr['delete']) {
try {
$fedora_object->delete();
} catch (Exception $e) {
drupal_set_message(t('Error deleting Islandora object %s %e', array('%s' => $object_id, '%e' => $e)), 'error');
return "";
}
}
else {
try {
$restConnection->repository->purgeObject($object_id);
} catch (Exception $e) {
drupal_set_message(t('Error purging Islandora object %s %e', array('%s' => $object_id, '%e' => $e)), 'error');
return "";
}
}
module_invoke_all('islandora_post_purge_object', $object_id, $content_models); //notify modules post deletion
drupal_goto($collection);
}
function islandora_purge_object($form, &$form_state, $pid) {
module_load_include('inc', 'islandora', 'RestConnection');
module_load_include('inc', 'islandora', 'includes/datastream');
$connection = new RestConnection();
$object = $connection->repository->getObject($pid);
$parent = islandora_datastream_get_parents($object);
$key = array_keys($parent);
if(count($key) > 0) {
$redirect = "islandora/object/$key[0]";
}
else {
$redirect = "islandora";
}
// Always provide entity id in the same form key as in the entity edit form.
$form['pid'] = array('#type' => 'value', '#value' => $pid);
$form['col'] = array('#type' => 'value', '#value' => $redirect);
return confirm_form($form,
t('Are you sure you want to delete %title?', array('%title' => $object->label)),
"islandora/object/$pid",
t('This action cannot be undone.'),
t('Delete'),
t('Cancel')
);
} }
/** /**
@ -364,18 +256,12 @@ function islandora_init() {
* @param string $object_id * @param string $object_id
* @return string * @return string
*/ */
function islandora_edit_object($object_id) { function islandora_edit_object($object) {
module_load_include('inc', 'islandora', 'RestConnection'); if(!$object) {
global $user; return drupal_not_found();
try {
$restConnection = new RestConnection($user);
$fedora_object = new FedoraObject($object_id, $restConnection->repository);
} catch (Exception $e) {
drupal_set_message(t('Error getting Islandora object %s', array('%s' => $object_id)), 'error');
return"";
} }
drupal_alter('islandora_edit_object', $fedora_object); drupal_alter('islandora_edit_object', $object);
$arr = module_invoke_all('islandora_edit_object', $fedora_object); $arr = module_invoke_all('islandora_edit_object', $object);
$output = ""; $output = "";
foreach ($arr as $key => $value) { foreach ($arr as $key => $value) {
$output .= $value; //if we have multiple modules handle one cmodel we need to iterate over multiple $output .= $value; //if we have multiple modules handle one cmodel we need to iterate over multiple
@ -390,7 +276,7 @@ function islandora_edit_object($object_id) {
* @return string * @return string
*/ */
function islandora_edit_properties($object_id) { function islandora_edit_properties($object_id) {
$object = islandora_get_object($object_id); $object = islandora_object_load($object_id);
if (isset($object)) { if (isset($object)) {
module_load_include('inc', 'islandora', 'includes/object_properties'); module_load_include('inc', 'islandora', 'includes/object_properties');
$form = drupal_get_form('islandora_edit_properties_form', $object); $form = drupal_get_form('islandora_edit_properties_form', $object);
@ -418,97 +304,6 @@ function islandora_islandora_edit_object($fedora_object) {
return array('Default Edit output' => $output); return array('Default Edit output' => $output);
} }
function islandora_purge_datastream($form, &$form_state, $object_id, $datastream_id) {
module_load_include('inc', 'islandora', 'RestConnection');
module_load_include('inc', 'islandora', 'includes/datastream');
$connection = new RestConnection();
$object = $connection->repository->getObject($object_id);
$datastream = $object->getDatastream($datastream_id);
$redirect = "islandora/object/$object_id";
// Always provide entity id in the same form key as in the entity edit form.
$form['pid'] = array('#type' => 'value', '#value' => $object_id);
$form['dsid'] = array('#type' => 'value', '#value' => $datastream_id);
$form['col'] = array('#type' => 'value', '#value' => $redirect);
return confirm_form($form,
t('Are you sure you want to delete the %dsid datastream?', array('%dsid' => $datastream->id)),
"islandora/object/$object_id",
t('This action cannot be undone.'),
t('Delete'),
t('Cancel')
);
}
/**
* Gives the option of purging or deleting a datastream.
*
* The default behaviour is to purge the datastream but this can be overridden using the
* 'islandora_pre_purge_datastream' hook. The returned array can include a 'block' => TRUE
* pair which will prevent the datastream from being deleted if it particularly needed for
* a certain function. Returning 'delete' => TRUE will cause the datastream to be put into
* a deleted state.
*
* @param string $object_id
* ID of the object
* @param string $datastream_id
* ID of the datastream
*
*/
function islandora_purge_datastream_submit($form, &$form_state) {
module_load_include('inc', 'islandora', 'RestConnection');
$object_id = $form_state['values']['pid'];
$datastream_id = $form_state['values']['dsid'];
global $user;
if (!isset($datastream_id)) {
drupal_set_message(t('Cannot remove datastream, datastream id not set'));
return;
}
try {
$restConnection = new RestConnection($user);
$fedora_object = new FedoraObject($object_id, $restConnection->repository);
} catch (Exception $e) {
drupal_set_message(t('Error getting Islandora object %s %e', array('%s' => $object_id, '%e' => $e)), 'error');
return "";
}
if (!isset($fedora_object)) {
drupal_set_message(t('Could not remove object, object not found'));
return;
}
if (!isset($fedora_object)) {
drupal_set_message(t('Could not remove object, object not found'));
return;
}
$arr = module_invoke_all('islandora_pre_purge_datastream', $fedora_object, $datastream_id); //notify modules of pending deletion so we can update rels etc
if (isset($arr['block']) && $arr['block']) {
drupal_set_message(t('Purging of the %d datastream was blocked', array('%d' => $datastream_id)), 'warning');
return;
}
if (isset($arr['delete']) && $arr['delete']) {
try {
$datastream = new FedoraDatastream($datastream_id, $fedora_object, $restConnection->repository);
$datastream->state = 'D';
} catch (Exception $e) {
drupal_set_message(t('Error deleting %s datastream from Islandora object %o %e', array('%s' => $datastream_id, '%o' => $object_id, '%e' => $e)), 'error');
return;
}
}
else {
try {
$fedora_object->purgeDatastream($datastream_id);
} catch (Exception $e) {
drupal_set_message(t('Error purging %s datastream from Islandora object %o %e', array('%s' => $datastream_id, '%o' => $object_id, '%e' => $e)), 'error');
return;
}
}
module_invoke_all('islandora_post_purge_datastream', $fedora_object, $datastream_id); //notify modules post deletion
drupal_set_message(t('%d datastream sucessfully purged from Islandora object %o', array('%d' => $datastream_id, '%o' => $object_id)));
drupal_goto('islandora/object/' . $object_id);
}
function islandora_view_default_object() { function islandora_view_default_object() {
$pid = variable_get('islandora_repository_pid', 'islandora:root'); $pid = variable_get('islandora_repository_pid', 'islandora:root');
drupal_goto("islandora/object/$pid"); drupal_goto("islandora/object/$pid");
@ -522,26 +317,19 @@ function islandora_view_default_object() {
* *
* @return string * @return string
*/ */
function islandora_view_object($object_id = NULL) { function islandora_view_object($fedora_object = NULL) {
module_load_include('inc', 'islandora', 'includes/Breadcrumbs'); module_load_include('inc', 'islandora', 'includes/breadcrumb');
drupal_set_breadcrumb(islandora_get_breadcrumbs($object_id)); global $user;
//return $object_id;
if (!isset($object_id)) { if(!$fedora_object) {
$object_id = variable_get('islandora_repository_pid', 'islandora:root'); return drupal_not_found();
//return;
} }
drupal_set_breadcrumb(islandora_get_breadcrumbs($fedora_object));
$page_number = (empty($_GET['page'])) ? '1' : $_GET['page']; $page_number = (empty($_GET['page'])) ? '1' : $_GET['page'];
$page_size = (empty($_GET['pagesize'])) ? '10' : $_GET['pagesize']; $page_size = (empty($_GET['pagesize'])) ? '10' : $_GET['pagesize'];
module_load_include('inc', 'islandora', 'RestConnection');
global $user;
try {
$restConnection = new RestConnection($user);
$fedora_object = new FedoraObject($object_id, $restConnection->repository);
} catch (Exception $e) {
drupal_set_message(t('Error getting Islandora object %s', array('%s' => $object_id)), 'error');
return"";
}
drupal_alter('islandora_object', $fedora_object); //modify object if required before it is passed along drupal_alter('islandora_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 $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)) { if (empty($arr)) {
@ -550,7 +338,7 @@ function islandora_view_object($object_id = NULL) {
return ""; return "";
} }
arsort($arr); arsort($arr);
drupal_alter('islandora_display',$arr); drupal_alter('islandora_display', $arr);
$output = ""; $output = "";
foreach ($arr as $key => $value) { foreach ($arr as $key => $value) {
$output .= $value; //if we have multiple modules handle one cmodel we need to iterate over multiple $output .= $value; //if we have multiple modules handle one cmodel we need to iterate over multiple
@ -583,11 +371,13 @@ function islandora_islandora_view_object($object) {
function islandora_theme() { function islandora_theme() {
return array( return array(
'islandora_default' => array( 'islandora_default' => array(
'template' => 'islandora-object', 'file' => 'theme/islandora.theme.inc',
'template' => 'theme/islandora-object',
'variables' => array('islandora_object' => NULL), 'variables' => array('islandora_object' => NULL),
), ),
'islandora_default_edit' => array( 'islandora_default_edit' => array(
'template' => 'islandora-object-edit', 'file' => 'theme/islandora.theme.inc',
'template' => 'theme/islandora-object-edit',
'variables' => array('islandora_object' => NULL), 'variables' => array('islandora_object' => NULL),
), ),
); );
@ -630,110 +420,40 @@ function islandora_permission() {
); );
} }
/**
* preprocess for the default view template
* @global string $base_url
* @param array $variables
*/
function islandora_preprocess_islandora_default(&$variables) {
drupal_add_js('misc/form.js');
drupal_add_js('misc/collapse.js');
$islandora_object = $variables['islandora_object'];
module_load_include('inc', 'islandora', 'includes/islandora_dublin_core');
module_load_include('inc', 'islandora', 'includes/utilities');
module_load_include('inc', 'islandora', 'includes/datastream');
$variables['parent_collections'] = islandora_datastream_get_parents($islandora_object);
$datastreams = array();
foreach ($islandora_object as $ds) {
$pid = $islandora_object->id;
$id = $ds->id;
$label = $ds->label;
$download_path = islandora_datastream_get_url($ds, 'download');
$datastreams[$id]['id'] = $id;
$datastreams[$id]['label'] = $label;
$datastreams[$id]['label_link'] = l($label, $download_path);
$datastreams[$id]['download_url'] = $download_path;
$datastreams[$id]['mimetype'] = $ds->mimetype;
$datastreams[$id]['size'] = islandora_datastream_get_human_readable_size($ds);
$datastreams[$id]['created_date'] = $ds->createdDate->format("Y-m-d");
$datastreams[$id]['class'] = strtolower(preg_replace('/[^A-Za-z0-9]/', '-', $id));
}
$variables['datastreams'] = $datastreams;
try {
$dc = $islandora_object['DC']->content;
//$dc_xml = simplexml_load_string($dc);
$dc_object = Dublin_Core::import_from_xml_string($dc);
} catch (Exception $e) {
drupal_set_message(t('Error retrieving object %s %t', array('%s' => $islandora_object->id, '%t' => $e->getMessage())), 'error');
}
$variables['dc_array'] = $dc_object->as_formatted_array();
$variables['islandora_dublin_core'] = $dc_object;
$variables['islandora_object_label'] = $islandora_object->label;
global $base_url;
if (isset($islandora_object['TN'])) {
$variables['islandora_thumbnail_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/TN/view';
}
}
/** /**
* a helper function to get a connection and return an object * a helper function to get a connection and return an object
* @global object $user * @global object $user
* @param string $object_id * @param string $object_id
* @return FedoraObject * @return FedoraObject
*/ */
function islandora_get_object($object_id) { function islandora_object_load($object_id) {
module_load_include('inc', 'islandora', 'RestConnection'); module_load_include('inc', 'islandora', 'RestConnection');
global $user; static $restConnection = NULL;
if(!$restConnection) {
$restConnection = new RestConnection();
}
try { try {
$restConnection = new RestConnection($user); $fedora_object = $restConnection->repository->getObject($object_id);
$fedora_object = new FedoraObject($object_id, $restConnection->repository);
} catch (Exception $e) { } catch (Exception $e) {
drupal_set_message(t('Error getting Islandora object %s', array('%s' => $object_id)), 'error');
return NULL; return NULL;
} }
return $fedora_object; return $fedora_object;
} }
/** function islandora_ingest_access_callback($object, $perm) {
* preprocess the edit template if(islandora_access_callback($object, $perm) === FALSE) {
* @global string $base_url return FALSE;
* @param array $variables }
* theme variables for the edit template
*/ $ingest_registry = module_invoke_all('islandora_ingest_registry', $object);
function islandora_preprocess_islandora_default_edit(&$variables) {
$islandora_object = $variables['islandora_object']; if(count($ingest_registry) > 0) {
global $base_url; return TRUE;
$datastreams = array(); }
$variables['islandora_editmetadata_url'] = $base_url . '/islandora/edit_form/' . $islandora_object->id; else {
module_load_include('inc', 'islandora', 'includes/datastream'); return FALSE;
module_load_include('inc', 'islandora', 'includes/utilities');
// $variables['add_datastream_form'] = drupal_get_form('islandora_add_datastream_form', $islandora_object->id);
$header = array(
array('data' => t('ID')),
array('data' => t('Label')),
array('data' => t('Type')),
array('data' => t('Mime type')),
array('data' => t('Size')),
array('data' => t('Operations'), 'colspan' => '3'),
//array('data' => t('Delete')),
);
$table_attributes = array('class' => array('manage-datastreams'));
$rows = array();
foreach ($islandora_object as $ds) {
$rows[] = array(
array('class' => 'datastream-id', 'data' => l($ds->id, islandora_datastream_get_url($ds, 'view'))),
array('class' => 'datastream-label', 'data' => $ds->label),
array('class' => 'datastream-control', 'data' => islandora_control_group_to_human_readable($ds->controlGroup)),
array('class' => 'datastream-mime', 'data' => $ds->mimeType),
array('class' => 'datastream-size', 'data' => islandora_datastream_get_human_readable_size($ds)),
array('class' => 'datastream-download', 'data' => l(t('download'), islandora_datastream_get_url($ds, 'download'))),
array('class' => 'datstream-edit', 'data' => islandora_datastream_edit_get_link($islandora_object, $ds->id)),
array('class' => 'datastream-delete', 'data' => l(t('delete'), $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/delete')),
);
} }
$caption = $islandora_object->label . ' - ' . $islandora_object->id;
$table = array('colgroups' => NULL, 'sticky' => TRUE, 'empty' => 'Error loading datastreams', 'caption' => $caption, 'header' => $header, 'rows' => $rows, 'attributes' => $table_attributes);
$variables['datastream_table'] = theme_table($table);
} }

17
islandora_basic_collection/admin/islandora_basic_collection.admin.inc

@ -26,6 +26,23 @@ function islandora_basic_collection_admin() {
'#description' => t('The default number of object to show in a collection view.'), '#description' => t('The default number of object to show in a collection view.'),
'#weight' => -10 '#weight' => -10
); );
$form['islandora_basic_collection_disable_collection_policy_delete'] = array(
'#type' => 'checkbox',
'#title' => t('Disable deleting the collection policy'),
'#default_value' => variable_get('islandora_basic_collection_disable_collection_policy_delete', TRUE),
'#description' => t('This will disable the delete link for the COLLECTION_POLICY in the manage tab.'),
'#weight' => -10
);
$form['islandora_basic_collection_default_view'] = array(
'#type' => 'select',
'#title' => t('Select the default collection view style.'),
'#default_value' => variable_get('islandora_basic_collection_default_view', 'grid'),
'#options' => array(
'list' => t('List'),
'grid' => t('Grid'),
),
'#weight' => -10
);
return system_settings_form($form); return system_settings_form($form);
} }

12
islandora_basic_collection/includes/child_collection.inc

@ -46,9 +46,9 @@ function islandora_create_child_collection_form($form, &$form_state, $this_colle
return $form; return $form;
} }
$restricted = FALSE; $restricted = FALSE;
if (variable_get('fedora_namespace_restriction_enforced', TRUE)) { if (variable_get('islandora_namespace_restriction_enforced', FALSE)) {
$restricted = TRUE; $restricted = TRUE;
$allowed_string = variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora:'); $allowed_string = variable_get('islandora_pids_allowed', 'default: demo: changeme: islandora:');
$namespaces = explode(':', $allowed_string); $namespaces = explode(':', $allowed_string);
foreach ($namespaces as $namespace) { foreach ($namespaces as $namespace) {
if ($namespace) { if ($namespace) {
@ -77,8 +77,8 @@ function islandora_create_child_collection_form($form, &$form_state, $this_colle
'#title' => "Collection PID", '#title' => "Collection PID",
'#type' => 'textfield', '#type' => 'textfield',
'#size' => 15, '#size' => 15,
'#default_value' => $rest_connection->repository->api->m->getNextPid($collection_namespace), '#default_value' => '',
'#description' => t("Unique PID for this collection. <br />Pids take the general form of namespace:collection (eg. islandora:pamphlets)"), '#description' => t("Unique PID for this collection. Leave blank for default. <br />Pids take the general form of namespace:collection (eg. islandora:pamphlets)"),
); );
if (!$restricted) { if (!$restricted) {
@ -136,6 +136,10 @@ function islandora_create_child_collection_form_submit($form, &$form_state) {
module_load_include('inc', 'islandora', '/includes/islandora.ingest'); module_load_include('inc', 'islandora', '/includes/islandora.ingest');
$thumbnail = $base_url . '/' . drupal_get_path('module', 'islandora_basic_collection') . '/Crystal_Clear_filesystem_folder_grey.png'; $thumbnail = $base_url . '/' . drupal_get_path('module', 'islandora_basic_collection') . '/Crystal_Clear_filesystem_folder_grey.png';
$new_collection_pid = $form_state['values']['new_collection_pid']; $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_label = $form_state['values']['collection_name']; $new_collection_label = $form_state['values']['collection_name'];
$namespace = $form_state['values']['collection_namespace']; $namespace = $form_state['values']['collection_namespace'];
$all_cModels = get_content_models_as_option_array(); $all_cModels = get_content_models_as_option_array();

18
islandora_basic_collection/includes/collection_management.inc

@ -25,11 +25,13 @@ where (\$object <info:fedora/fedora-system:def/relations-external#isMemberOf> <i
$model_pids = $rest_connection->repository->ri->itqlQuery($query, 'unlimited', '0'); $model_pids = $rest_connection->repository->ri->itqlQuery($query, 'unlimited', '0');
$represented_models = array(); $represented_models = array();
foreach ($model_pids as $model_pid) { foreach ($model_pids as $model_pid) {
if ($model_pid['model']['value'] && $model_pid['model']['value'] != 'fedora-system:FedoraObject-3.0') { if ($model_pid['model']['value'] && $model_pid['model']['value'] != 'fedora-system:FedoraObject-3.0') {
$fedora_object = new FedoraObject($model_pid['model']['value'], $rest_connection->repository); try {
$content_model_title = $fedora_object->label; $fedora_object = new FedoraObject($model_pid['model']['value'], $rest_connection->repository);
$represented_models[$model_pid['model']['value']] = $model_pid['model']['value'] . ' ~ ' . $content_model_title; $content_model_title = $fedora_object->label;
$represented_models[$model_pid['model']['value']] = $model_pid['model']['value'] . ' ~ ' . $content_model_title;
}
catch (RepositoryException $e) {}
} }
} }
return $represented_models; return $represented_models;
@ -134,14 +136,14 @@ function get_related_items_as_array($collection_pid, $relationship = array('isMe
function fedora_repository_access($permission, $pid) { function fedora_repository_access($permission, $pid) {
global $user; global $user;
$name_space_access = FALSE; $name_space_access = FALSE;
$is_restricted = variable_get('islandora_namespace_restriction_enforced', TRUE); $is_restricted = variable_get('islandora_namespace_restriction_enforced', FALSE);
if (!$is_restricted) { if (!$is_restricted) {
$name_space_access = TRUE; $name_space_access = TRUE;
} }
if ($pid == NULL) { if ($pid == NULL) {
$pid = variable_get('islandora_repository_pid', 'islandora:root'); $pid = variable_get('islandora_repository_pid', 'islandora:root');
} }
$name_space_allowed = explode(" ", variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: ')); $name_space_allowed = explode(" ", variable_get('islandora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: '));
$pos = NULL; $pos = NULL;
foreach ($name_space_allowed as $name_space) { foreach ($name_space_allowed as $name_space) {
$pos = stripos($pid, $name_space); $pos = stripos($pid, $name_space);
@ -206,8 +208,8 @@ function get_content_models_as_option_array() {
$rest_connection = new RestConnection(); $rest_connection = new RestConnection();
require_once 'sites/all/libraries/tuque/RepositoryQuery.php'; require_once 'sites/all/libraries/tuque/RepositoryQuery.php';
$restricted = variable_get('fedora_namespace_restriction_enforced', TRUE); $restricted = variable_get('islandora_namespace_restriction_enforced', FALSE);
$allowed_string = variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora:'); $allowed_string = variable_get('islandora_pids_allowed', 'default: demo: changeme: islandora:');
$namespaces = explode(':', $allowed_string); $namespaces = explode(':', $allowed_string);
foreach ($namespaces as $namespace) { foreach ($namespaces as $namespace) {
if ($namespace) { if ($namespace) {

4
islandora_basic_collection/includes/collection_manager_table.inc

@ -90,8 +90,8 @@ function get_collections_as_option_array() {
module_load_include('inc', 'islandora', 'RestConnection'); module_load_include('inc', 'islandora', 'RestConnection');
require_once 'sites/all/libraries/tuque/RepositoryQuery.php'; require_once 'sites/all/libraries/tuque/RepositoryQuery.php';
$restricted = variable_get('fedora_namespace_restriction_enforced', TRUE); $restricted = variable_get('islandora_namespace_restriction_enforced', FALSE);
$allowed_string = variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora:'); $allowed_string = variable_get('islandora_pids_allowed', 'default: demo: changeme: islandora:');
$namespaces = explode(':', $allowed_string); $namespaces = explode(':', $allowed_string);
$rest_connection = new RestConnection(); $rest_connection = new RestConnection();

28
islandora_basic_collection/islandora_basic_collection.module

@ -30,7 +30,7 @@
function islandora_basic_collection_menu() { function islandora_basic_collection_menu() {
$items = array(); $items = array();
$items['islandora/object/%/manage/collection'] = array( $items['islandora/object/%/manage/collection'] = array(
'title' => 'Collection related', 'title' => 'Collection',
'page callback' => 'islandora_basic_collection_manage_object', 'page callback' => 'islandora_basic_collection_manage_object',
'page arguments' => array(2), 'page arguments' => array(2),
'type' => MENU_LOCAL_TASK, 'type' => MENU_LOCAL_TASK,
@ -67,24 +67,6 @@ function islandora_basic_collection_init() {
} }
} }
/**
* Implements hook_menu_local_tasks_alter().
*/
function islandora_basic_collection_menu_local_tasks_alter(&$data, $router_item, $root_path) {
// Add action link
if ($root_path == 'islandora/object/%/manage/collection') {
$object_id = $router_item['page_arguments'][0];
$item = menu_get_item("islandora/ingest/$object_id");
$item['title'] = 'Add a repository item';
if ($item['access']) {
$data['actions']['output'][] = array(
'#theme' => 'menu_local_action',
'#link' => $item,
);
}
}
}
/** /**
* This function is where we create the view for the related menu item * This function is where we create the view for the related menu item
* @param type $object_id * @param type $object_id
@ -328,3 +310,11 @@ function islandora_basic_collection_islandora_ingest_get_information($models, $o
} }
} }
} }
function islandora_basic_collection_islandora_undeletable_datastreams($models) {
if(in_array('islandora:collectionCModel', $models)) {
if(variable_get('islandora_basic_collection_disable_collection_policy_delete', TRUE)) {
return array('COLLECTION_POLICY');
}
}
}

1
islandora_basic_collection/theme/islandora-basic-collection-wrapper.tpl.php

@ -25,6 +25,7 @@
<div class="islandora-basic-collection-wrapper"> <div class="islandora-basic-collection-wrapper">
<div class="islandora-basic-collection clearfix"> <div class="islandora-basic-collection clearfix">
<?php print ($switch_view_link) ?>
<?php print($collection_pager); ?> <?php print($collection_pager); ?>
<?php print ($collection_content); ?> <?php print ($collection_content); ?>
<?php print($collection_pager); ?> <?php print($collection_pager); ?>

19
islandora_basic_collection/theme/islandora_basic_collection.theme.inc

@ -17,13 +17,26 @@ function islandora_basic_collection_preprocess_islandora_basic_collection_wrappe
$total_count = count($results); $total_count = count($results);
pager_default_initialize($total_count, $page_size); pager_default_initialize($total_count, $page_size);
$variables['collection_pager'] = theme('pager', array('quantity' => 10)); $variables['collection_pager'] = theme('pager', array('quantity' => 10));
$display = (empty($_GET['display'])) ? 'list' : $_GET['display']; $display = (empty($_GET['display'])) ? variable_get('islandora_basic_collection_default_view', 'grid') : $_GET['display'];
$link_text = (empty($_GET['display'])) ? 'grid' : $_GET['display'];
$query_params = drupal_get_query_parameters($_GET);
if ($display == 'grid') { if ($display == 'grid') {
$query_params['display'] = 'list';
$link_text = 'List View';
$link_class = 'islandora-view-default';
$collection_content = theme('islandora_basic_collection_grid', array('islandora_object' => $islandora_object, 'collection_results' => $results)); $collection_content = theme('islandora_basic_collection_grid', array('islandora_object' => $islandora_object, 'collection_results' => $results));
} }
else { else {
$query_params['display'] = 'grid';
$link_text = 'Grid View';
$link_class = 'islandora-view-grid';
$collection_content = theme('islandora_basic_collection', array('islandora_object' => $islandora_object, 'collection_results' => $results)); $collection_content = theme('islandora_basic_collection', array('islandora_object' => $islandora_object, 'collection_results' => $results));
} }
global $base_url;
$link = l($link_text, $base_url . '/islandora/object/' . $islandora_object->id, array('attributes' => array('class' => $link_class),
'query' => $query_params));
$variables['switch_view_link'] = $link;
$variables['collection_content'] = $collection_content; $variables['collection_content'] = $collection_content;
} }
@ -101,8 +114,8 @@ function islandora_basic_collection_preprocess_islandora_basic_collection(&$vari
$thumbnail_img = '<img src="' . $base_path . $object_url . '/datastream/TN/view"' . '/>'; $thumbnail_img = '<img src="' . $base_path . $object_url . '/datastream/TN/view"' . '/>';
} }
else { else {
//TODO: change this default image url $image_path = drupal_get_path('module', 'islandora');
$thumbnail_img = '<img src="http://codesprint-centos.islandora.ca/islandora/object/islandora%3A52/datastream/TN"' . '/>'; $thumbnail_img = '<img src="' . $base_path . $image_path . '/images/Crystal_Clear_action_filenew.png"/>';
} }
$associated_objects_array[$pid]['thumbnail'] = $thumbnail_img; $associated_objects_array[$pid]['thumbnail'] = $thumbnail_img;
$associated_objects_array[$pid]['title_link'] = l($title, $object_url, array('html' => TRUE, 'attributes' => array('title' => $title))); $associated_objects_array[$pid]['title_link'] = l($title, $object_url, array('html' => TRUE, 'attributes' => array('title' => $title)));

19
islandora_basic_image/includes/image_process.inc → islandora_basic_image/includes/image.process.inc

@ -1,11 +1,17 @@
<?php <?php
/**
* @file
*
* This file contains all the functions for image manipulation used in the
* basic image solution pack.
*/
function islandora_basic_image_create_all_derivatives($object){ function islandora_basic_image_create_all_derivatives($object) {
module_load_include('inc', 'islandora', 'includes/MimeClass'); module_load_include('inc', 'islandora', 'includes/mime.detect');
module_load_include('inc', 'islandora_basic_image', 'includes/image_process'); module_load_include('inc', 'islandora_basic_image', 'includes/image_process');
$mime_class = new MimeClass(); $mime_class = new MimeDetect();
if(!isset($object['OBJ'])){ if (!isset($object['OBJ'])) {
drupal_set_message(t('Could not create image derivatives for %s. No image file was uploaded.',array('%s' => $object->id)),'error'); drupal_set_message(t('Could not create image derivatives for %s. No image file was uploaded.', array('%s' => $object->id)),'error');
return ""; return "";
} }
$ext = $mime_class->getExtension($object['OBJ']->mimeType); $ext = $mime_class->getExtension($object['OBJ']->mimeType);
@ -19,6 +25,7 @@ function islandora_basic_image_create_all_derivatives($object){
if (islandora_basic_image_create_derivative($medium_file, 500, 700)) { if (islandora_basic_image_create_derivative($medium_file, 500, 700)) {
islandora_basic_image_add_datastream($object, 'MEDIUM_SIZE', $medium_file); islandora_basic_image_add_datastream($object, 'MEDIUM_SIZE', $medium_file);
} }
file_delete($original_file);
} }
@ -32,7 +39,7 @@ function islandora_basic_image_create_derivative($file, $width, $height) {
$image = image_load($real_path); $image = image_load($real_path);
if (!empty($image)) { if (!empty($image)) {
$scale = image_scale($image, $width, $height, TRUE); $scale = image_scale($image, $width, $height, TRUE);
if($scale){ if ($scale) {
return image_save($image); return image_save($image);
} }
} }

34
islandora_basic_image/islandora-basic-image.tpl.php

@ -21,28 +21,34 @@
* along with the program. If not, see <http ://www.gnu.org/licenses/>. * along with the program. If not, see <http ://www.gnu.org/licenses/>.
*/ */
?> ?>
<?php drupal_set_title("$islandora_object_label"); ?> <?php if(isset($islandora_object_label)): ?>
<?php drupal_set_title("$islandora_object_label"); ?>
<?php endif; ?>
<div class="islandora-basic-image-object islandora"> <div class="islandora-basic-image-object islandora">
<div class="islandora-basic-image-content clearfix"> <div class="islandora-basic-image-content clearfix">
<?php if(isset($islandora_full_url)): ?> <?php if(isset($islandora_full_url)): ?>
<?php print l($islandora_medium_img, $islandora_full_url, array('html' => TRUE)); ?> <?php print l($islandora_medium_img, $islandora_full_url, array('html' => TRUE)); ?>
<?php else: ?> <?php elseif(isset($islandora_medium_img)): ?>
<?php print $islandora_medium_img; ?> <?php print $islandora_medium_img; ?>
<?php else: ?>
<?php endif; ?> <?php endif; ?>
</div> </div>
<div class="islandora-basic-image-sidebar"> <div class="islandora-basic-image-sidebar">
<h1 class="title"><?php print $islandora_object_label; ?></h1> <?php if($dc_array['dc:description']['value']): ?>
<h3><?php print $dc_array['dc:description']['label']; ?></h3> <h3><?php print $dc_array['dc:description']['label']; ?></h3>
<p><?php print $dc_array['dc:description']['value']; ?></p> <p><?php print $dc_array['dc:description']['value']; ?></p>
<div> <?php endif; ?>
<h3>In Collections</h3> <?php if(empty($parent_collections)): ?>
<ul> <div>
<?php foreach($parent_collections as $key => $value): ?> <h3>In Collections</h3>
<li><?php print $value['label_link'] ?></li> <ul>
<?php endforeach; ?> <?php foreach($parent_collections as $key => $value): ?>
</ul> <li><?php print $value['label_link'] ?></li>
</div> <?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
</div> </div>
<fieldset class="collapsible collapsed islandora-basic-image-metadata"> <fieldset class="collapsible collapsed islandora-basic-image-metadata">

2
islandora_basic_image/islandora_basic_image.module

@ -210,7 +210,7 @@ function islandora_basic_image_islandora_ingest_post_ingest($object) {
} }
foreach ($models as $model) { foreach ($models as $model) {
if (isset($cmodel_list[$model])) { if (isset($cmodel_list[$model])) {
module_load_include('inc', 'islandora_basic_image', 'includes/image_process'); module_load_include('inc', 'islandora_basic_image', 'includes/image.process');
islandora_basic_image_create_all_derivatives($object); islandora_basic_image_create_all_derivatives($object);
} }
} }

0
islandora-object-edit.tpl.php → theme/islandora-object-edit.tpl.php

0
islandora-object.tpl.php → theme/islandora-object.tpl.php

91
theme/islandora.theme.inc

@ -0,0 +1,91 @@
<?php
/**
* preprocess the edit template
* @global string $base_url
* @param array $variables
* theme variables for the edit template
*/
function islandora_preprocess_islandora_default_edit(&$variables) {
$islandora_object = $variables['islandora_object'];
global $base_url;
$datastreams = array();
$variables['islandora_editmetadata_url'] = $base_url . '/islandora/edit_form/' . $islandora_object->id;
module_load_include('inc', 'islandora', 'includes/datastream');
module_load_include('inc', 'islandora', 'includes/utilities');
// $variables['add_datastream_form'] = drupal_get_form('islandora_add_datastream_form', $islandora_object->id);
$header = array(
array('data' => t('ID')),
array('data' => t('Label')),
array('data' => t('Type')),
array('data' => t('Mime type')),
array('data' => t('Size')),
array('data' => t('Operations'), 'colspan' => '3'),
//array('data' => t('Delete')),
);
$table_attributes = array('class' => array('manage-datastreams'));
$rows = array();
foreach ($islandora_object as $ds) {
$rows[] = array(
array('class' => 'datastream-id', 'data' => l($ds->id, islandora_datastream_get_url($ds, 'view'))),
array('class' => 'datastream-label', 'data' => $ds->label),
array('class' => 'datastream-control', 'data' => islandora_control_group_to_human_readable($ds->controlGroup)),
array('class' => 'datastream-mime', 'data' => $ds->mimeType),
array('class' => 'datastream-size', 'data' => islandora_datastream_get_human_readable_size($ds)),
array('class' => 'datastream-download', 'data' => l(t('download'), islandora_datastream_get_url($ds, 'download'))),
array('class' => 'datstream-edit', 'data' => islandora_datastream_edit_get_link($islandora_object, $ds->id)),
array('class' => 'datastream-delete', 'data' => islandora_datastream_get_delete_link($ds)),
);
}
$caption = $islandora_object->label . ' - ' . $islandora_object->id;
$table = array('colgroups' => NULL, 'sticky' => TRUE, 'empty' => 'Error loading datastreams', 'caption' => $caption, 'header' => $header, 'rows' => $rows, 'attributes' => $table_attributes);
$variables['datastream_table'] = theme_table($table);
}
/**
* preprocess for the default view template
* @global string $base_url
* @param array $variables
*/
function islandora_preprocess_islandora_default(&$variables) {
drupal_add_js('misc/form.js');
drupal_add_js('misc/collapse.js');
$islandora_object = $variables['islandora_object'];
module_load_include('inc', 'islandora', 'includes/islandora_dublin_core');
module_load_include('inc', 'islandora', 'includes/utilities');
module_load_include('inc', 'islandora', 'includes/datastream');
$variables['parent_collections'] = islandora_datastream_get_parents($islandora_object);
$datastreams = array();
foreach ($islandora_object as $ds) {
$pid = $islandora_object->id;
$id = $ds->id;
$label = $ds->label;
$download_path = islandora_datastream_get_url($ds, 'download');
$datastreams[$id]['id'] = $id;
$datastreams[$id]['label'] = $label;
$datastreams[$id]['label_link'] = l($label, $download_path);
$datastreams[$id]['download_url'] = $download_path;
$datastreams[$id]['mimetype'] = $ds->mimetype;
$datastreams[$id]['size'] = islandora_datastream_get_human_readable_size($ds);
$datastreams[$id]['created_date'] = $ds->createdDate->format("Y-m-d");
$datastreams[$id]['class'] = strtolower(preg_replace('/[^A-Za-z0-9]/', '-', $id));
}
$variables['datastreams'] = $datastreams;
try {
$dc = $islandora_object['DC']->content;
//$dc_xml = simplexml_load_string($dc);
$dc_object = Dublin_Core::import_from_xml_string($dc);
} catch (Exception $e) {
drupal_set_message(t('Error retrieving object %s %t', array('%s' => $islandora_object->id, '%t' => $e->getMessage())), 'error');
}
$variables['dc_array'] = $dc_object->as_formatted_array();
$variables['islandora_dublin_core'] = $dc_object;
$variables['islandora_object_label'] = $islandora_object->label;
global $base_url;
if (isset($islandora_object['TN'])) {
$variables['islandora_thumbnail_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/TN/view';
}
}
Loading…
Cancel
Save