Browse Source

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

pull/109/head
jonathangreen 13 years ago
parent
commit
31c7ab74f2
  1. 9
      RestConnection.inc
  2. 17
      islandora-object-edit.tpl.php
  3. 35
      islandora.module
  4. 15
      islandora_basic_image/islandora_basic_image.module

9
RestConnection.inc

@ -42,8 +42,15 @@ class RestConnection {
public $repository = NULL; public $repository = NULL;
function RestConnection($user) { function RestConnection($user) {
if(!isset($user) || $user->uid == 0){
$user_string = 'anonymous';
$pass_string = 'anonymous';
} else {
$user_string = $user->name;
$pass_string = $user->pass;
}
$url = variable_get('islandora_base_url', 'http://localhost:8080/fedora'); $url = variable_get('islandora_base_url', 'http://localhost:8080/fedora');
$this->connection = new RepositoryConnection($url, $user->name, $user->pass); $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);
$this->cache = new SimpleCache(); $this->cache = new SimpleCache();

17
islandora-object-edit.tpl.php

@ -1,7 +1,7 @@
<?php <?php
/* /*
* islandora-object.tpl.php * islandora-object-edit.tpl.php
* *
* *
* *
@ -37,10 +37,7 @@
* and each element has an array of values. dc.title can have none, one or many titles * and each element has an array of values. dc.title can have none, one or many titles
* this is the case for all dc elements. * this is the case for all dc elements.
* *
* we can get a list of datastreams by doing *
* foreach ($object as $ds){
* do something here
* }
* *
*/ */
@ -49,11 +46,13 @@
drupal_set_title($islandora_object->label); drupal_set_title($islandora_object->label);
$islandora_datastreams = $variables['islandora_datastreams']; $islandora_datastreams = $variables['islandora_datastreams'];
print($islandora_object->label . ' ' . $islandora_object->id); print($islandora_object->label . ' ' . $islandora_object->id);
print('this is the edit template');
print ('<h3>datastreams</h3>'); print ('<h3>datastreams</h3>');
foreach ($islandora_datastreams as $key => $ds) { foreach ($islandora_datastreams as $dsid => $ds) {
print $key. '<br />'; print (l($ds['label'],$ds['view_url']));
//do something print (' ' . l('download', $ds['download_url']));
print (' ' . l('delete', $ds['delete_url']));
print ('<br />');
} }
print (l(t('Edit Metadata'),$variables['islandora_editmetadata_url']));
?> ?>

35
islandora.module

@ -243,7 +243,7 @@ function islandora_purge_object($object_id) {
$restConnection = new RestConnection($user); $restConnection = new RestConnection($user);
$fedora_object = new FedoraObject($object_id, $restConnection->repository); $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'); drupal_set_message(t('Error getting Islandora object %s %e', array('%s' => $object_id, '%e' => $e)), 'error');
return ""; return "";
} }
if (!isset($fedora_object)) { if (!isset($fedora_object)) {
@ -256,7 +256,7 @@ function islandora_purge_object($object_id) {
try { try {
$fedora_object->delete(); $fedora_object->delete();
} catch (Exception $e) { } catch (Exception $e) {
drupal_set_message(t('Error deleting Islandora object %s', array('%s' => $object_id)), 'error'); drupal_set_message(t('Error deleting Islandora object %s %e', array('%s' => $object_id, '%e' => $e)), 'error');
return ""; return "";
} }
} }
@ -264,11 +264,12 @@ function islandora_purge_object($object_id) {
try { try {
$restConnection->repository->purgeObject($object_id); $restConnection->repository->purgeObject($object_id);
} catch (Exception $e) { } catch (Exception $e) {
drupal_set_message(t('Error purging Islandora object %s', array('%s' => $object_id)), 'error'); drupal_set_message(t('Error purging Islandora object %s %e', array('%s' => $object_id, '%e' => $e)), 'error');
return ""; return "";
} }
} }
module_invoke_all('islandora_post_purge_object', $object_id, $content_models); //notify modules post deletion module_invoke_all('islandora_post_purge_object', $object_id, $content_models); //notify modules post deletion
drupal_goto('islandora');
} }
/** /**
@ -319,6 +320,8 @@ function islandora_islandora_edit_object($fedora_object) {
return; return;
} }
} }
$output = theme('islandora_default_edit', array('islandora_object' => $fedora_object));
return array('Default Edit output' => $output);
} }
/** /**
@ -347,7 +350,7 @@ function islandora_purge_datastream($object_id, $datastream_id) {
$restConnection = new RestConnection($user); $restConnection = new RestConnection($user);
$fedora_object = new FedoraObject($object_id, $restConnection->repository); $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'); drupal_set_message(t('Error getting Islandora object %s %e', array('%s' => $object_id, '%e' => $e)), 'error');
return ""; return "";
} }
if (!isset($fedora_object)) { if (!isset($fedora_object)) {
@ -368,7 +371,7 @@ function islandora_purge_datastream($object_id, $datastream_id) {
$datastream = new FedoraDatastream($datastream_id, $fedora_object, $restConnection->repository); $datastream = new FedoraDatastream($datastream_id, $fedora_object, $restConnection->repository);
$datastream->state = 'D'; $datastream->state = 'D';
} catch (Exception $e) { } catch (Exception $e) {
drupal_set_message(t('Error deleting %s datastream from Islandora object %o', array('%s' => $datastream_id, '%o' => $object_id)), 'error'); drupal_set_message(t('Error deleting %s datastream from Islandora object %o %e', array('%s' => $datastream_id, '%o' => $object_id, '%e' => $e)), 'error');
return; return;
} }
} }
@ -376,11 +379,13 @@ function islandora_purge_datastream($object_id, $datastream_id) {
try { try {
$fedora_object->purgeDatastream($datastream_id); $fedora_object->purgeDatastream($datastream_id);
} catch (Exception $e) { } catch (Exception $e) {
drupal_set_message(t('Error purging %s datastream from Islandora object %o', array('%s' => $datastream_id, '%o' => $object_id)), 'error'); drupal_set_message(t('Error purging %s datastream from Islandora object %o %e', array('%s' => $datastream_id, '%o' => $object_id, '%e' => $e)), 'error');
return; return;
} }
} }
module_invoke_all('islandora_post_purge_datastream', $fedora_object, $datastream_id); //notify modules post deletion 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() {
@ -390,7 +395,7 @@ function islandora_view_default_object() {
/** /**
* The view entry point. modules should implement hook_islandora_view_object for the Fedora Content models that * The view entry point. modules should implement hook_islandora_view_object for the Fedora Content models that
* there modules want to provide a view for. * their modules want to provide a view for.
* @global object $user * @global object $user
* @param string $object_id * @param string $object_id
* *
@ -438,18 +443,14 @@ function islandora_view_object($object_id) {
*/ */
function islandora_islandora_view_object($object) { function islandora_islandora_view_object($object) {
$supported_models = islandora_get_types(); $supported_models = islandora_get_types();
$object_models = $object->models;
$combined_list = array_intersect($supported_models, $object->models);
$output = ""; $output = "";
if (empty($combined_list)) {
$output = theme('islandora_default', array('islandora_object' => $object));
return array('Default Output' => $output);
foreach ($object->models as $model) { foreach ($object->models as $model) {
if (isset($supported_models[$model][ISLANDORA_VIEW_HOOK]) && $supported_models[$model][ISLANDORA_VIEW_HOOK] == TRUE) {//another module is handling the view if (isset($supported_models[$model][ISLANDORA_VIEW_HOOK]) && $supported_models[$model][ISLANDORA_VIEW_HOOK] == TRUE) {//another module is handling the view
return; return;
} }
} }
} $output = theme('islandora_default', array('islandora_object' => $object));
return array('Default Output' => $output);
} }
/** /**
@ -544,10 +545,12 @@ function islandora_preprocess_islandora_default_edit(&$variables) {
$islandora_object = $variables['islandora_object']; $islandora_object = $variables['islandora_object'];
global $base_url; global $base_url;
$datastreams = array(); $datastreams = array();
$variables['islandora_editmetadata_url'] = $base_url . '/islandora/edit_form/' . $islandora_object->id;
foreach ($islandora_object as $ds) { foreach ($islandora_object as $ds) {
$datastreams['download_url'] = $base_url . '/islandora/object/' . $islandora_object->id . 'datastream/' . $ds->id . '/download'; $datastreams['download_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id .'/download';
$datastreams['view_url'] = $base_url . '/islandora/object/' . $islandora_object->id . 'datastream/' . $ds->id . '/view'; $datastreams['view_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id .'/view';
$datastreams['delete_url'] = $base_url . '/islandora/object/' . $islandora_object->id . 'datastream/' . $ds->id . '/delete'; $datastreams['delete_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id .'/delete';
$datastreams['label'] = $ds->label;
$variables['islandora_datastreams'][$ds->id] = $datastreams; $variables['islandora_datastreams'][$ds->id] = $datastreams;
} }
} }

15
islandora_basic_image/islandora_basic_image.module

@ -99,6 +99,21 @@ function islandora_basic_image_preprocess_islandora_basic_image(&$variables) {
drupal_set_message(t('Error retrieving object %s %t', array('%s' => $islandora_object->id, '%t' => $e->getMessage())), 'error'); drupal_set_message(t('Error retrieving object %s %t', array('%s' => $islandora_object->id, '%t' => $e->getMessage())), 'error');
} }
$variables['islandora_dublin_core'] = $dc_object; $variables['islandora_dublin_core'] = $dc_object;
//create a nicer array for themers
//TODO: give this a better home
$dc_array = array();
foreach ($dc_object as $element) {
if (!empty($element)) {
foreach ($element as $key => $value) {
foreach ($value as $v) {
if (!empty($v)) {
$dc_array[] = array($key => $v);
}
}
}
}
}
$variables['dc_array'] = $dc_array;
$variables['islandora_object_label'] = $islandora_object->label; $variables['islandora_object_label'] = $islandora_object->label;
$variables['theme_hook_suggestions'][] = 'islandora_basic_image__' . str_replace(':', '_', $islandora_object->id); $variables['theme_hook_suggestions'][] = 'islandora_basic_image__' . str_replace(':', '_', $islandora_object->id);
global $base_url; global $base_url;

Loading…
Cancel
Save