Browse Source

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

pull/120/head
rwincewicz 12 years ago
parent
commit
97f2062c6b
  1. 3
      includes/datastream.inc
  2. 2
      includes/islandora.ingest.inc
  3. 10
      includes/object_properties.inc
  4. 75
      islandora.module
  5. 27
      islandora_basic_collection/islandora_basic_collection.module
  6. 60
      islandora_basic_image/includes/image_process.inc
  7. 4
      islandora_basic_image/islandora-basic-image.tpl.php
  8. 32
      islandora_basic_image/islandora_basic_image.module

3
includes/datastream.inc

@ -39,9 +39,10 @@ function islandora_datastream_as_attachment($object_id, $dsid) {
} catch (Exception $e) { } catch (Exception $e) {
return drupal_not_found(); return drupal_not_found();
} }
} }
function islandora_get_datastream_parents($islandora_object) { function islandora_datastream_get_parents($islandora_object) {
$parent_collections = array(); $parent_collections = array();
$repository = $islandora_object->repository; $repository = $islandora_object->repository;
$collections1 = $islandora_object->relationships->get(FEDORA_RELS_EXT_URI, 'isMemberOfCollection'); $collections1 = $islandora_object->relationships->get(FEDORA_RELS_EXT_URI, 'isMemberOfCollection');

2
includes/islandora.ingest.inc

@ -21,7 +21,7 @@ function islandora_ingest_get_object($content_models, $collection_pid, $relation
} }
function islandora_ingest_add_object(&$object) { function islandora_ingest_add_object(&$object) {
$object->repository->ingestObject($object); //$object->repository->ingestObject($object);
module_invoke_all('islandora_ingest_post_ingest', $object); module_invoke_all('islandora_ingest_post_ingest', $object);
return $object; return $object;
} }

10
includes/object_properties.inc

@ -53,6 +53,11 @@ function islandora_edit_properties_form_submit($form, &$form_state) {
} }
} }
function islandora_edit_properties_form_delete($form, &$form_state) {
$islandora_object = $form_state['values']['pid'];
drupal_goto("islandora/object/$islandora_object/delete");
}
/** /**
* *
* @param array $form * @param array $form
@ -99,6 +104,11 @@ function islandora_edit_properties_form($form, &$form_state, $object_id) {
'#type' => 'submit', '#type' => 'submit',
'#value' => 'Update Properties', '#value' => 'Update Properties',
); );
$form['delete'] = array(
'#type' => 'submit',
'#value' => t('Delete'),
'#submit' => array('islandora_edit_properties_form_delete'),
);
return $form; return $form;
} }

75
islandora.module

@ -58,31 +58,6 @@ function islandora_menu() {
'type' => MENU_NORMAL_ITEM, 'type' => MENU_NORMAL_ITEM,
'weight' => 0, 'weight' => 0,
); );
/* may not need this
$items['admin/islandora/solution_packs'] = array(
'title' => 'Solution Packs',
'description' => 'Install content models and collections required by installed solution packs.',
'page callback' => 'islandora_solution_packs_page',
'access arguments' => array(FEDORA_ADD_DS),
'file' => 'admin/islandora.solutionpacks.inc',
'type' => MENU_NORMAL_ITEM,
); */
$items['islandoracm.xsd'] = array(
'title' => 'Islandora Content Model XML Schema Definition',
'page callback' => 'islandora_display_schema',
'page arguments' => array('islandoracm.xsd'),
'type' => MENU_CALLBACK,
'access arguments' => array(FEDORA_VIEW),
);
$items['collection_policy.xsd'] = array(
'title' => 'Islandora Content Model XML Schema Definition',
'page callback' => 'islandora_display_schema',
'page arguments' => array('collection_policy.xsd'),
'type' => MENU_CALLBACK,
'access arguments' => array(FEDORA_VIEW),
);
$items['islandora/ingest/%'] = array( $items['islandora/ingest/%'] = array(
'title' => 'Ingest object', 'title' => 'Ingest object',
@ -154,9 +129,9 @@ function islandora_menu() {
); );
$items['islandora/object/%/delete'] = array( $items['islandora/object/%/delete'] = array(
'title' => 'Purge object', 'title' => 'Delete object',
'page callback' => 'islandora_purge_object', 'page callback' => 'drupal_get_form',
'page arguments' => array(2), 'page arguments' => array('islandora_purge_object', 2),
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'access arguments' => array(FEDORA_PURGE), 'access arguments' => array(FEDORA_PURGE),
); );
@ -294,7 +269,10 @@ function islandora_node_access($op, $pid = NULL, $as_user = NULL) {
* ID of the object * ID of the object
* @return type * @return type
*/ */
function islandora_purge_object($object_id) { 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'); module_load_include('inc', 'islandora', 'RestConnection');
global $user; global $user;
if (!isset($object_id)) { if (!isset($object_id)) {
@ -331,7 +309,38 @@ function islandora_purge_object($object_id) {
} }
} }
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'); 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')
);
} }
/** /**
@ -500,14 +509,14 @@ function islandora_view_object($object_id = NULL) {
drupal_set_message(t('Error getting Islandora object %s', array('%s' => $object_id)), 'error'); drupal_set_message(t('Error getting Islandora object %s', array('%s' => $object_id)), 'error');
return""; return"";
} }
drupal_alter('islandora_view_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)) {
//TODO: make sure we iterate over the array as they will be more then one cmodel per object //TODO: make sure we iterate over the array as they will be more then one cmodel per object
drupal_set_message(t('there was an error loading the view for islandora object %s', array('%s' => $object_id)), 'error'); drupal_set_message(t('there was an error loading the view for islandora object %s', array('%s' => $object_id)), 'error');
return ""; return "";
} }
//module_invoke_all(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
@ -600,7 +609,7 @@ function islandora_preprocess_islandora_default(&$variables) {
module_load_include('inc', 'islandora', 'includes/utilities'); module_load_include('inc', 'islandora', 'includes/utilities');
module_load_include('inc', 'islandora', 'includes/datastream'); module_load_include('inc', 'islandora', 'includes/datastream');
$variables['parent_collections'] = islandora_get_datastream_parents($islandora_object); $variables['parent_collections'] = islandora_datastream_get_parents($islandora_object);
$datastreams = array(); $datastreams = array();
foreach ($islandora_object as $ds) { foreach ($islandora_object as $ds) {

27
islandora_basic_collection/islandora_basic_collection.module

@ -61,6 +61,26 @@ function islandora_basic_collection_menu() {
return $items; return $items;
} }
/**
* Implements hook_menu_local_tasks_alter().
*/
function islandora_basic_collection_menu_local_tasks_alter(&$data, $router_item, $root_path) {
if (module_exists('islandora_content_model_forms')) {
// Add action link
if ($root_path == 'islandora/object/%/manage/collection') {
$object_id = $router_item['page_arguments'][0];
$item = menu_get_item("islandora/ingest_form/$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
@ -222,9 +242,10 @@ function islandora_basic_collection_islandora_view_object($object, $user) {
foreach ($object->models as $model) { foreach ($object->models as $model) {
if (isset($cmodel_list[$model][ISLANDORA_VIEW_HOOK]) && $cmodel_list[$model][ISLANDORA_VIEW_HOOK] == TRUE) { if (isset($cmodel_list[$model][ISLANDORA_VIEW_HOOK]) && $cmodel_list[$model][ISLANDORA_VIEW_HOOK] == TRUE) {
$display = (empty($_GET['display'])) ? 'list' : $_GET['display']; $display = (empty($_GET['display'])) ? 'list' : $_GET['display'];
if($display == 'grid'){ if ($display == 'grid') {
$output = theme('islandora_basic_collection_grid', array('islandora_object' => $object)); $output = theme('islandora_basic_collection_grid', array('islandora_object' => $object));
} else { }
else {
$output = theme('islandora_basic_collection', array('islandora_object' => $object)); $output = theme('islandora_basic_collection', array('islandora_object' => $object));
} }
return array('Collection View' => $output); return array('Collection View' => $output);
@ -238,7 +259,7 @@ function islandora_basic_collection_islandora_view_object($object, $user) {
* currently just calls normal view preprocess as variables are the same * currently just calls normal view preprocess as variables are the same
* @param type $variables * @param type $variables
*/ */
function islandora_basic_collection_preprocess_islandora_basic_collection_grid(&$variables){ function islandora_basic_collection_preprocess_islandora_basic_collection_grid(&$variables) {
islandora_basic_collection_preprocess_islandora_basic_collection($variables); islandora_basic_collection_preprocess_islandora_basic_collection($variables);
} }

60
islandora_basic_image/includes/image_process.inc

@ -0,0 +1,60 @@
<?php
function islandora_basic_image_create_all_derivatives($object){
module_load_include('inc', 'islandora', 'includes/MimeClass');
module_load_include('inc', 'islandora_basic_image', 'includes/image_process');
$mime_class = new MimeClass();
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');
return "";
}
$ext = $mime_class->getExtension($object['OBJ']->mimeType);
$file_name = str_replace(':', '-', $object->id);
$original_file = file_save_data($object['OBJ']->content, 'temporary://' . $file_name . 'OBJ.' . $ext);
$tn_file = file_copy($original_file, 'temporary://' . $file_name . 'TN.' . $ext);
if (islandora_basic_image_create_derivative($tn_file, 200, 200)) {
islandora_basic_image_add_datastream($object, 'TN', $tn_file);
}
$medium_file = file_copy($original_file, 'temporary://' . $file_name . 'MEDIUM.' . $ext);
if (islandora_basic_image_create_derivative($medium_file, 500, 700)) {
islandora_basic_image_add_datastream($object, 'MEDIUM_SIZE', $medium_file);
}
}
/**
*
* @param object $file
* stdclass
*/
function islandora_basic_image_create_derivative($file, $width, $height) {
$real_path = drupal_realpath($file->uri);
$image = image_load($real_path);
if (!empty($image)) {
$scale = image_scale($image, $width, $height, TRUE);
if($scale){
return image_save($image);
}
}
return FALSE;
}
/**
* adds a datastream and deletes the tmp file from local file system
* @param object $object
* @param string $dsid
* @param object $file
*/
function islandora_basic_image_add_datastream($object, $dsid, $file) {
try {
$ds = $object->constructDatastream($dsid, 'M');
$ds->label = $dsid;
$ds->mimeType = $object['OBJ']->mimeType;
$ds->setContentFromFile(drupal_realpath($file->uri));
$object->ingestDatastream($ds);
file_delete($file);
} catch (exception $e) {
drupal_set_message(t('@message', array('@message' => check_plain($e->getMessage()))), 'error');
}
}

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

@ -21,11 +21,11 @@
* 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(""); ?> <?php drupal_set_title("$islandora_object_label"); ?>
<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 print $islandora_medium_img; ?> <?php print l($islandora_medium_img, $islandora_full_url, array('html' => TRUE)); ?>
</div> </div>
<div class="islandora-basic-image-sidebar"> <div class="islandora-basic-image-sidebar">
<h1 class="title"><?php print $islandora_object_label; ?></h1> <h1 class="title"><?php print $islandora_object_label; ?></h1>

32
islandora_basic_image/islandora_basic_image.module

@ -64,7 +64,7 @@ function islandora_basic_image_menu() {
'type' => MENU_LOCAL_TASK, 'type' => MENU_LOCAL_TASK,
'access callback' => 'islandora_basic_image_access', 'access callback' => 'islandora_basic_image_access',
'access arguments' => array(2), 'access arguments' => array(2),
);*/ ); */
return $items; return $items;
} }
@ -78,9 +78,9 @@ function islandora_basic_image_menu() {
* @return string * @return string
*/ */
/* /*
function islandora_basic_image_manage_object($object_id){ function islandora_basic_image_manage_object($object_id){
return 'Image CModel edit function '.$object_id; return 'Image CModel edit function '.$object_id;
}*/ } */
/** /**
* /** * /**
@ -90,9 +90,9 @@ function islandora_basic_image_manage_object($object_id){
* @return string * @return string
*/ */
/* /*
function islandora_basic_image_view1($object_id){ function islandora_basic_image_view1($object_id){
return 'A view returned by the image cmodel'; return 'A view returned by the image cmodel';
}*/ } */
/** /**
* An example function needed by this modules hook_menu * An example function needed by this modules hook_menu
@ -100,9 +100,9 @@ function islandora_basic_image_view1($object_id){
* @return string * @return string
*/ */
/* /*
function islandora_basic_image_view2($object_id){ function islandora_basic_image_view2($object_id){
return 'Another view returned by the image cmodel'; return 'Another view returned by the image cmodel';
}*/ } */
/** /**
* determines whether or not to show this modules manage tab * determines whether or not to show this modules manage tab
@ -110,7 +110,7 @@ function islandora_basic_image_view2($object_id){
* @param string $object_id * @param string $object_id
* @return boolean * @return boolean
*/ */
function islandora_basic_image_access($object_id){ function islandora_basic_image_access($object_id) {
module_load_include('inc', 'islandora', 'RestConnection'); module_load_include('inc', 'islandora', 'RestConnection');
global $user; global $user;
try { try {
@ -125,7 +125,7 @@ function islandora_basic_image_access($object_id){
$models = $fedora_object->models; $models = $fedora_object->models;
$cmodel_list = islandora_basic_image_islandora_get_types(); $cmodel_list = islandora_basic_image_islandora_get_types();
foreach ($fedora_object->models as $model) { foreach ($fedora_object->models as $model) {
if (isset($cmodel_list[$model])){ if (isset($cmodel_list[$model])) {
return user_access(FEDORA_MODIFY_STATE); return user_access(FEDORA_MODIFY_STATE);
} }
} }
@ -193,6 +193,17 @@ function islandora_basic_image_islandora_view_object($object, $user, $page_numbe
return NULL; return NULL;
} }
function islandora_basic_image_islandora_ingest_post_ingest($object) {
$cmodel_list = islandora_basic_image_islandora_get_types();
$models = $object->models;
foreach ($object->models as $model) {
if (isset($cmodel_list[$model])) {
module_load_include('inc', 'islandora_basic_image', 'includes/image_process');
islandora_basic_image_create_all_derivatives($object);
}
}
}
/** /**
* *
* @global type $base_url * @global type $base_url
@ -217,10 +228,11 @@ function islandora_basic_image_preprocess_islandora_basic_image(&$variables) {
$variables['dc_array'] = $dc_object->as_formatted_array(); $variables['dc_array'] = $dc_object->as_formatted_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);
$variables['parent_collections'] = islandora_get_datastream_parents($islandora_object); $variables['parent_collections'] = islandora_datastream_get_parents($islandora_object);
global $base_url; global $base_url;
if (isset($islandora_object['OBJ'])) { if (isset($islandora_object['OBJ'])) {
$full_size_url = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/OBJ/view'; $full_size_url = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/OBJ/view';
$variables['islandora_full_url'] = $full_size_url;
$variables['islandora_full_img'] = '<img src="' . $full_size_url . '"/>'; $variables['islandora_full_img'] = '<img src="' . $full_size_url . '"/>';
} }
if (isset($islandora_object['TN'])) { if (isset($islandora_object['TN'])) {

Loading…
Cancel
Save