Browse Source

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

Conflicts:
	islandora.module
pull/108/head
jonathangreen 13 years ago
parent
commit
f3b587bd9b
  1. 9
      css/islandora.admin.css
  2. 8
      css/islandora.base.css
  3. 8
      css/islandora.theme.css
  4. 59
      islandora-object-edit.tpl.php
  5. 2
      islandora.info
  6. 186
      islandora.module
  7. 9
      islandora_basic_collection/css/islandora_basic_collection.admin.css
  8. 8
      islandora_basic_collection/css/islandora_basic_collection.base.css
  9. 9
      islandora_basic_collection/css/islandora_basic_collection.theme.css
  10. 2
      islandora_basic_collection/islandora_basic_collection.info
  11. 29
      islandora_basic_collection/islandora_basic_collection.module
  12. 8
      islandora_basic_image/css/islandora_basic_image.admin.css
  13. 8
      islandora_basic_image/css/islandora_basic_image.base.css
  14. 8
      islandora_basic_image/css/islandora_basic_image.theme.css
  15. 2
      islandora_basic_image/islandora_basic_image.info
  16. 21
      islandora_basic_image/islandora_basic_image.module

9
css/islandora.admin.css

@ -0,0 +1,9 @@
/*
Document : islandora_basic_collection.admin.css
Created on : May 23, 2012, 11:23:06 AM
Description:
Purpose of the stylesheet follows.
*/

8
css/islandora.base.css

@ -0,0 +1,8 @@
/*
Document : islandora_basic_collection.base.css
Created on : May 23, 2012, 11:22:04 AM
Description:
Purpose of the stylesheet follows.
*/

8
css/islandora.theme.css

@ -0,0 +1,8 @@
/*
Document : islandora_basic_collection.theme
Created on : May 23, 2012, 11:23:56 AM
Description:
Purpose of the stylesheet follows.
*/

59
islandora-object-edit.tpl.php

@ -0,0 +1,59 @@
<?php
/*
* islandora-object.tpl.php
*
*
*
* This file is part of Islandora.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program. If not, see <http ://www.gnu.org/licenses/>.
*/
?>
<?php
/*
* this is a template for objects that do not have a module to registered to build their display.
*
* islandora_object is a fedora tuque Object
* $object->label
* $object->id
* to get the contents of a datastream
* $object['dsid']->content
*
* $dublin_core is a Dublin_Core object
* which is an array of elements, such as dc.title
* 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.
*
* we can get a list of datastreams by doing
* foreach ($object as $ds){
* do something here
* }
*
*/
//dsm($object);
drupal_set_title($islandora_object->label);
$islandora_datastreams = $variables['islandora_datastreams'];
print($islandora_object->label . ' ' . $islandora_object->id);
print('this is the edit template');
print ('<h3>datastreams</h3>');
foreach ($islandora_datastreams as $key => $ds) {
print $key. '<br />';
//do something
}
?>

2
islandora.info

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

186
islandora.module

@ -29,6 +29,8 @@ define('FEDORA_ADD_DS', 'add fedora datastreams');
define('FEDORA_INGEST', 'ingest fedora objects');
define('FEDORA_PURGE', 'delete fedora objects and datastreams');
define('FEDORA_MODIFY_STATE', 'modify fedora state');
define('ISLANDORA_VIEW_HOOK', 'islandora_view_object');
define('ISLANDORA_EDIT_HOOK', 'islandora_edit_object');
/**
* Implementation of hook_menu.
@ -107,24 +109,25 @@ function islandora_menu() {
);
$items['islandora/object/%/view'] = array(
'title' => 'Repository',
'title' => 'View',
'page callback' => 'islandora_view_object',
'page arguments' => array(2),
'type' => MENU_NORMAL_ITEM,
'type' => MENU_DEFAULT_LOCAL_TASK,
'access arguments' => array(FEDORA_VIEW),
);
$items['islandora/object/%/edit'] = array(
'title' => 'Repository',
'title' => 'Edit',
'page callback' => 'islandora_edit_object',
'page arguments' => array(2),
'type' => MENU_NORMAL_ITEM,
'type' => MENU_LOCAL_TASK,
'access arguments' => array(FEDORA_MODIFY_STATE),
);
$items['islandora/object/%/delete'] = array(
'title' => 'Purge object',
'page callback' => 'islandora_purge_object',
'page arguments' => array(2),
'type' => MENU_CALLBACK,
'access arguments' => array(FEDORA_PURGE),
);
@ -158,7 +161,7 @@ function islandora_menu() {
$items['islandora/object/%/datastream/%/edit'] = array(
'title' => 'Edit datastream',
'page callback' => 'islandora_edit_stream',
'page callback' => 'islandora_edit_datastream',
'page arguments' => array(2, 4),
'type' => MENU_CALLBACK,
'access arguments' => array(FEDORA_METADATA_EDIT),
@ -166,7 +169,7 @@ function islandora_menu() {
$items['islandora/object/%/datastream/%/delete'] = array(
'title' => 'Purge data stream',
'page callback' => 'islandora_purge_stream',
'page callback' => 'islandora_purge_datastream',
'page arguments' => array(2, 4),
'type' => MENU_CALLBACK,
'access arguments' => array(FEDORA_PURGE),
@ -215,22 +218,58 @@ function islandora_node_access($op, $pid = NULL, $as_user = NULL) {
}
/**
*
* @param type $object_id
* 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($object_id) {
module_load_include('inc', 'islandora', 'RestConnection');
global $user;
if (!isset($object_id)) {
drupal_set_message(t('Cannot remove object, object id not set'));
return;
}
$object = new Object($object_id);
if (!isset($object)) {
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 remove object, object not found'));
return;
}
module_invoke_all('islandora_purge_object', $object); //notify modules of pending deletion
$object->delete();
$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', array('%s' => $object_id)), 'error');
return "";
}
}
else {
try {
$restConnection->repository->purgeObject($object_id);
} catch (Exception $e) {
drupal_set_message(t('Error purging Islandora object %s', array('%s' => $object_id)), 'error');
return "";
}
}
module_invoke_all('islandora_post_purge_object', $object_id, $content_models); //notify modules post deletion
}
/**
@ -242,22 +281,107 @@ function islandora_get_types() {
}
/**
* a function to call other modules edit page. If there are not any modules
* that handle this function this module will build a default page.
* @global object $user
* @param string $object_id
* @return string
*/
function islandora_edit_object($object_id) {
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_edit_object', $fedora_object);
$arr = module_invoke_all('islandora_edit_object', $fedora_object);
$output = "";
foreach ($arr as $key => $value) {
$output .= $key . '<br />' . $value; //if we have multiple modules handle one cmodel we need to iterate over multiple
}
//we could do another module invoke all here to build the edit tab with a default implemented in this module?
return $output;
}
/**
* builds a default page for the edit tab
* @param object $fedora_object
* A tuque Fedora Object
*/
function islandora_islandora_edit_object($fedora_object) {
$supported_models = islandora_get_types();
$output = "";
foreach ($fedora_object->models as $model) {
if (isset($supported_models[$model][ISLANDORA_EDIT_HOOK]) && $supported_models[$model][ISLANDORA_EDIT_HOOK] == TRUE) {//another module is handling the view
return;
}
}
}
/**
* Gives the option of purging or deleting a datastream.
*
* @paramstring $datastream_id
* @return type
* 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($object_id, $datastream_id) {
module_load_include('inc', 'islandora', 'RestConnection');
global $user;
if (!isset($datastream_id)) {
drupal_set_message(t('Cannot remove datastream, datastream id not set'));
return;
}
$object = new Object($object_id);
if (!isset($object)) {
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 remove object, object not found'));
return;
}
if (!isset($fedora_object)) {
drupal_set_message(t('Could not remove object, object not found'));
return;
}
module_invoke_all('islandora_purge_datastream', $datastream); //notify modules of pending deletion so we can update rels etc
$object->deleteDatastream();
$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', array('%s' => $datastream_id, '%o' => $object_id)), 'error');
return;
}
}
else {
try {
$fedora_object->purgeDatastream($datastream_id);
} catch (Exception $e) {
drupal_set_message(t('Error purging %s datastream from Islandora object %o', array('%s' => $datastream_id, '%o' => $object_id)), 'error');
return;
}
}
module_invoke_all('islandora_post_purge_datastream', $fedora_object, $datastream_id); //notify modules post deletion
}
/**
@ -316,6 +440,11 @@ function islandora_islandora_view_object($object) {
if (empty($combined_list)) {
$output = theme('islandora_default', array('islandora_object' => $object));
return array('Default Output' => $output);
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
return;
}
}
}
}
@ -329,6 +458,10 @@ function islandora_theme() {
'template' => 'islandora-object',
'variables' => array('islandora_object' => NULL),
),
'islandora_default_edit' => array(
'template' => 'islandora-object-edit',
'variables' => array('islandora_object' => NULL),
),
);
}
@ -403,11 +536,14 @@ function islandora_preprocess_islandora_default(&$variables) {
}
}
function islandora_islandora_ingest_registry() {
return array(array('url' => 'islandora/test', 'name' => 'basic collection ingest'));
}
function islandora_test_test($pid) {
return 'jessus';
function islandora_preprocess_islandora_default_edit(&$variables) {
$islandora_object = $variables['islandora_object'];
global $base_url;
$datastreams = array();
foreach ($islandora_object as $ds) {
$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['delete_url'] = $base_url . '/islandora/object/' . $islandora_object->id . 'datastream/' . $ds->id . '/delete';
$variables['islandora_datastreams'][$ds->id] = $datastreams;
}
}

9
islandora_basic_collection/css/islandora_basic_collection.admin.css

@ -0,0 +1,9 @@
/*
Document : islandora_basic_collection.admin.css
Created on : May 23, 2012, 11:23:06 AM
Description:
Purpose of the stylesheet follows.
*/

8
islandora_basic_collection/css/islandora_basic_collection.base.css

@ -0,0 +1,8 @@
/*
Document : islandora_basic_collection.base.css
Created on : May 23, 2012, 11:22:04 AM
Description:
Purpose of the stylesheet follows.
*/

9
islandora_basic_collection/css/islandora_basic_collection.theme.css

@ -0,0 +1,9 @@
/*
Document : islandora_basic_collection.theme
Created on : May 23, 2012, 11:23:56 AM
Description:
Purpose of the stylesheet follows.
*/

2
islandora_basic_collection/islandora_basic_collection.info

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

29
islandora_basic_collection/islandora_basic_collection.module

@ -48,7 +48,11 @@ function islandora_basic_collection_theme($existing, $type, $theme, $path) {
* array of content model pids that this module supports
*/
function islandora_basic_collection_islandora_get_types() {
return array('info:fedora/islandora:collectionCModel');
$types = array();
$types['info:fedora/islandora:collectionCModel'][ISLANDORA_VIEW_HOOK] = TRUE;
$types['info:fedora/islandora:collectionCModel'][ISLANDORA_EDIT_HOOK] = FALSE;
return $types;
}
/**
@ -66,12 +70,14 @@ function islandora_basic_collection_islandora_get_types() {
function islandora_basic_collection_islandora_view_object($object, $user, $page_number, $page_size) {
//global $user;
$cmodel_list = islandora_basic_collection_islandora_get_types();
$combined_list = array_intersect($cmodel_list, $object->models);
if (empty($combined_list)) {
return NULL; //we don't handle any of this objects cmodels
$models = $object->models;
foreach ($object->models as $model) {
if (isset($cmodel_list[$model][ISLANDORA_VIEW_HOOK]) && $cmodel_list[$model][ISLANDORA_VIEW_HOOK] == TRUE) {
$output = theme('islandora_basic_collection', array('islandora_object' => $object));
return array('Basic Collection Output' => $output);
}
}
$output = theme('islandora_basic_collection', array('islandora_object' => $object));
return array('Basic Collection Output' => $output);
return NULL;
}
/**
@ -100,13 +106,12 @@ function islandora_basic_collection_preprocess_islandora_basic_collection(&$vari
if (isset($islandora_object['TN'])) {
$variables['islandora_thumbnail_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/TN/view';
}
if (isset($islandora_object['MEDIUM_SIZE'])){
if (isset($islandora_object['MEDIUM_SIZE'])) {
$variables['islandora_medium_size_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/MEDIUM_SIZE/view';
}
}
function islandora_basic_collection_get_objects($object){
function islandora_basic_collection_get_objects($object) {
$query = 'select $object $title $content from <#ri>
where ($object <fedora-model:label> $title
and $object <fedora-model:hasModel> $content
@ -118,13 +123,13 @@ function islandora_basic_collection_get_objects($object){
$page_number = (empty($_GET['page'])) ? '1' : $_GET['page'];
$page_size = (empty($_GET['pagesize'])) ? '10' : $_GET['pagesize'];
module_load_include('inc', 'islandora', 'RestConnection');
$query_array = array('query' => $query, 'type' => 'itql','pid' => $object->id, 'page_size'=>$page_size, 'page_number' => $page_number);
drupal_alter('islandora_basic_collection_query',$query_array);
$query_array = array('query' => $query, 'type' => 'itql', 'pid' => $object->id, 'page_size' => $page_size, 'page_number' => $page_number);
drupal_alter('islandora_basic_collection_query', $query_array);
global $user;
try {
$restConnection = new RestConnection($user);
$queryObject = new RepositoryQuery($restConnection->connection);
$results = $queryObject->query($query_array['query'],$query_array['type']);
$results = $queryObject->query($query_array['query'], $query_array['type']);
} catch (Exception $e) {
drupal_set_message(t('Islandora Error getting related objects for %s', array('%s' => $object->id)), 'error');
return"";

8
islandora_basic_image/css/islandora_basic_image.admin.css

@ -0,0 +1,8 @@
/*
Document : islandora_basic_collection.admin.css
Created on : May 23, 2012, 11:23:06 AM
Description:
Purpose of the stylesheet follows.
*/

8
islandora_basic_image/css/islandora_basic_image.base.css

@ -0,0 +1,8 @@
/*
Document : islandora_basic_collection.base.css
Created on : May 23, 2012, 11:22:04 AM
Description:
Purpose of the stylesheet follows.
*/

8
islandora_basic_image/css/islandora_basic_image.theme.css

@ -0,0 +1,8 @@
/*
Document : islandora_basic_collection.theme
Created on : May 23, 2012, 11:23:56 AM
Description:
Purpose of the stylesheet follows.
*/

2
islandora_basic_image/islandora_basic_image.info

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

21
islandora_basic_image/islandora_basic_image.module

@ -52,7 +52,10 @@ function islandora_basic_image_theme($existing, $type, $theme, $path) {
* array of content model pids that this module supports
*/
function islandora_basic_image_islandora_get_types() {
return array('info:fedora/islandora:imgageCModel', 'info:fedora/islandora:sp_basic_image');
$types = array();
$types['info:fedora/islandora:sp_basic_image'][ISLANDORA_VIEW_HOOK] = TRUE;
$types['info:fedora/islandora:sp_basic_image'][ISLANDORA_EDIT_HOOK] = FALSE;
return $types;
}
/**
@ -70,13 +73,14 @@ function islandora_basic_image_islandora_get_types() {
function islandora_basic_image_islandora_view_object($object, $user, $page_number, $page_size) {
//global $user;
$cmodel_list = islandora_basic_image_islandora_get_types();
$combined_list = array_intersect($cmodel_list, $object->models);
if (empty($combined_list)) {
return NULL; //we don't handle any of this objects cmodels
$models = $object->models;
foreach ($object->models as $model) {
if (isset($cmodel_list[$model][ISLANDORA_VIEW_HOOK]) && $cmodel_list[$model][ISLANDORA_VIEW_HOOK] == TRUE) {
$output = theme('islandora_basic_image', array('islandora_object' => $object));
return array('Basic Image Output' => $output);
}
}
$output = theme('islandora_basic_image', array('islandora_object' => $object));
return array('Basic Image Output' => $output);
return NULL;
}
/**
@ -104,9 +108,8 @@ function islandora_basic_image_preprocess_islandora_basic_image(&$variables) {
if (isset($islandora_object['TN'])) {
$variables['islandora_thumbnail_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/TN/view';
}
if (isset($islandora_object['MEDIUM_SIZE'])){
if (isset($islandora_object['MEDIUM_SIZE'])) {
$variables['islandora_medium_size_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/MEDIUM_SIZE/view';
}
}

Loading…
Cancel
Save