Browse Source

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

pull/108/head
jonathangreen 13 years ago
parent
commit
3d5a47d4f2
  1. 2
      islandora-object.tpl.php
  2. 54
      islandora.module
  3. 50
      islandora_basic_collection/islandora-basic-collection.tpl.php
  4. 5
      islandora_basic_collection/islandora_basic_collection.info
  5. 134
      islandora_basic_collection/islandora_basic_collection.module
  6. 55
      islandora_basic_image/islandora-basic-image--islandora-27.tpl.php
  7. 1
      islandora_basic_image/islandora_basic_image.info
  8. 103
      islandora_basic_image/islandora_basic_image.module
  9. 17
      utils/datastream.inc

2
islandora-object.tpl.php

@ -1,7 +1,7 @@
<?php <?php
/* /*
* islandora-object-default-view.tpl.php * islandora-object.tpl.php
* *
* *
* *

54
islandora.module

@ -62,7 +62,7 @@ function islandora_menu() {
'file' => 'admin/islandora.solutionpacks.inc', 'file' => 'admin/islandora.solutionpacks.inc',
'type' => MENU_NORMAL_ITEM, 'type' => MENU_NORMAL_ITEM,
); );
$items['islandoracm.xsd'] = array( $items['islandoracm.xsd'] = array(
'title' => 'Islandora Content Model XML Schema Definition', 'title' => 'Islandora Content Model XML Schema Definition',
'page callback' => 'islandora_display_schema', 'page callback' => 'islandora_display_schema',
@ -78,16 +78,16 @@ function islandora_menu() {
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'access arguments' => array(FEDORA_VIEW), 'access arguments' => array(FEDORA_VIEW),
); );
$items['islandora/ingest/%'] = array( $items['islandora/ingest/%'] = array(
'title' => t('Ingest object'), 'title' => 'Ingest 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_CALLBACK,
'access arguments' => array(FEDORA_INGEST), 'access arguments' => array(FEDORA_INGEST),
); );
$items['islandora/object/%'] = array( $items['islandora/object/%'] = array(
'title' => 'Repository', 'title' => 'Repository',
'page callback' => 'islandora_view_object', 'page callback' => 'islandora_view_object',
@ -105,7 +105,7 @@ function islandora_menu() {
'type' => MENU_NORMAL_ITEM, 'type' => MENU_NORMAL_ITEM,
'access arguments' => array(FEDORA_ADD_DS) 'access arguments' => array(FEDORA_ADD_DS)
); );
$items['islandora/object/%/view'] = array( $items['islandora/object/%/view'] = array(
'title' => 'Repository', 'title' => 'Repository',
'page callback' => 'islandora_view_object', 'page callback' => 'islandora_view_object',
@ -113,7 +113,7 @@ function islandora_menu() {
'type' => MENU_NORMAL_ITEM, 'type' => MENU_NORMAL_ITEM,
'access arguments' => array(FEDORA_VIEW), 'access arguments' => array(FEDORA_VIEW),
); );
$items['islandora/object/%/edit'] = array( $items['islandora/object/%/edit'] = array(
'title' => 'Repository', 'title' => 'Repository',
'page callback' => 'islandora_edit_object', 'page callback' => 'islandora_edit_object',
@ -121,14 +121,14 @@ function islandora_menu() {
'type' => MENU_NORMAL_ITEM, 'type' => MENU_NORMAL_ITEM,
'access arguments' => array(FEDORA_MODIFY_STATE), 'access arguments' => array(FEDORA_MODIFY_STATE),
); );
$items['islandora/object/%/delete'] = array( $items['islandora/object/%/delete'] = array(
'title' => 'Purge object', 'title' => 'Purge object',
'page callback' => 'islandora_purge_object', 'page callback' => 'islandora_purge_object',
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'access arguments' => array(FEDORA_PURGE), 'access arguments' => array(FEDORA_PURGE),
); );
$items['islandora/object/%/datastream/%'] = array( $items['islandora/object/%/datastream/%'] = array(
'title' => 'View datastream', 'title' => 'View datastream',
'page callback' => 'islandora_datastream_as_attachment', 'page callback' => 'islandora_datastream_as_attachment',
@ -137,7 +137,7 @@ function islandora_menu() {
'file' => 'utils/datastream.inc', 'file' => 'utils/datastream.inc',
'access arguments' => array(FEDORA_VIEW), 'access arguments' => array(FEDORA_VIEW),
); );
$items['islandora/object/%/datastream/%/view'] = array( $items['islandora/object/%/datastream/%/view'] = array(
'title' => 'View datastream', 'title' => 'View datastream',
'page callback' => 'islandora_datastream_as_attachment', 'page callback' => 'islandora_datastream_as_attachment',
@ -146,7 +146,7 @@ function islandora_menu() {
'file' => 'utils/datastream.inc', 'file' => 'utils/datastream.inc',
'access arguments' => array(FEDORA_VIEW), 'access arguments' => array(FEDORA_VIEW),
); );
$items['islandora/object/%/datastream/%/download'] = array( $items['islandora/object/%/datastream/%/download'] = array(
'title' => 'Download datastream', 'title' => 'Download datastream',
'page callback' => 'islandora_datastream_as_attachment', 'page callback' => 'islandora_datastream_as_attachment',
@ -155,7 +155,7 @@ function islandora_menu() {
'file' => 'utils/datastream.inc', 'file' => 'utils/datastream.inc',
'access arguments' => array(FEDORA_VIEW), 'access arguments' => array(FEDORA_VIEW),
); );
$items['islandora/object/%/datastream/%/edit'] = array( $items['islandora/object/%/datastream/%/edit'] = array(
'title' => 'Edit datastream', 'title' => 'Edit datastream',
'page callback' => 'islandora_edit_stream', 'page callback' => 'islandora_edit_stream',
@ -163,7 +163,7 @@ function islandora_menu() {
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'access arguments' => array(FEDORA_METADATA_EDIT), 'access arguments' => array(FEDORA_METADATA_EDIT),
); );
$items['islandora/object/%/datastream/%/delete'] = array( $items['islandora/object/%/datastream/%/delete'] = array(
'title' => 'Purge data stream', 'title' => 'Purge data stream',
'page callback' => 'islandora_purge_stream', 'page callback' => 'islandora_purge_stream',
@ -280,15 +280,15 @@ function islandora_view_object($object_id) {
} }
drupal_alter('islandora_view_object', $fedora_object); //modify object if required before it is passed along drupal_alter('islandora_view_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)), //module_invoke_all(islandora_display($arr)),
$output = ""; $output = "";
foreach($arr as $key => $value){ foreach ($arr as $key => $value) {
$output .= $key .'<br />'.$value; //if we have multiple modules handle one cmodel we need to iterate over multiple $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? //we could do another module invoke all here to build the edit tab with a default implemented in this module?
return $output; //just an example as we could have more then one array element return $output; //just an example as we could have more then one array element
@ -300,14 +300,14 @@ function islandora_view_object($object_id) {
* @param string $object_id * @param string $object_id
* @return string * @return string
*/ */
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; $object_models = $object->models;
$combined_list = array_intersect($supported_models, $object->models); $combined_list = array_intersect($supported_models, $object->models);
$output = ""; $output = "";
if (empty($combined_list)) { if (empty($combined_list)) {
$output = theme('islandora_default', array('islandora_object' => $object)); $output = theme('islandora_default', array('islandora_object' => $object));
return array ('Default Output' => $output); return array('Default Output' => $output);
} }
} }
@ -321,7 +321,7 @@ function islandora_theme() {
'template' => 'islandora-object', 'template' => 'islandora-object',
'variables' => array('islandora_object' => NULL), 'variables' => array('islandora_object' => NULL),
), ),
); );
} }
/** /**
@ -377,20 +377,20 @@ function islandora_add_datastream($object_id) {
module_invoke_all('islandora_add_datastream', $object); //allow submodules to handle add datastream based on object type module_invoke_all('islandora_add_datastream', $object); //allow submodules to handle add datastream based on object type
} }
function islandora_preprocess_islandora_default(&$variables){ function islandora_preprocess_islandora_default(&$variables) {
$islandora_object = $variables['islandora_object']; $islandora_object = $variables['islandora_object'];
module_load_include('inc','islandora','utils/islandora_dublin_core'); module_load_include('inc', 'islandora', 'utils/islandora_dublin_core');
try{ try {
$dc = $islandora_object['DC']->content; $dc = $islandora_object['DC']->content;
//$dc_xml = simplexml_load_string($dc); //$dc_xml = simplexml_load_string($dc);
$dc_object = Dublin_Core::import_from_xml_string($dc); $dc_object = Dublin_Core::import_from_xml_string($dc);
}catch(Exception $e){ } catch (Exception $e) {
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;
$variables['islandora_object_label'] = $islandora_object->label; $variables['islandora_object_label'] = $islandora_object->label;
global $base_url; global $base_url;
if(isset($islandora_object['TN'])){ if (isset($islandora_object['TN'])) {
$variables['islandora_thumbnail_url'] = $base_url.'/islandora/object/'.$islandora_object->id.'/datastream/TN/view'; $variables['islandora_thumbnail_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/TN/view';
} }
} }

50
islandora_basic_collection/islandora-basic-collection.tpl.php

@ -0,0 +1,50 @@
<?php
/*
* islandora-basic-collection.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
$object = $variables['islandora_object'];
$image_url = $variables['islandora_thumbnail_url'];
drupal_set_title($object->label);
foreach ($variables['islandora_dublin_core'] as $element) {
if (!empty($element)) {
foreach ($element as $key => $value) {
foreach ($value as $v) {
if (!empty($v)) {
print '<strong>' . ($key) . '</strong>: ';
print($v) . '<br />';
}
}
}
}
}
print('<img src = "' . $image_url . '"/>');
print('<h3>Associated Objects</h3>');
foreach($variables['islandora_associated_objects'] as $associated_objects){
global $base_url;
$link = l($associated_objects['title']['value'],$base_url.'/islandora/object/'.$associated_objects['object']['value']);
print ($link).'<br />';
}
?>

5
islandora_basic_collection/islandora_basic_collection.info

@ -0,0 +1,5 @@
name = "Islandora Basic Collection"
description = "A default Islandora Repository module to handle simple collections"
dependencies[] = islandora
package = Islandora
core = 7.x

134
islandora_basic_collection/islandora_basic_collection.module

@ -0,0 +1,134 @@
<?php
/*
* @file islandora_basic_image.module
*
* an Islandora module to handle basic image cmodels
*
*
* 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/>.
*/
/**
* Theme registry function
* We supply a pattern so we can overide templates at the theme level if needed.
* we can append a pid to a template and the new template file will be called (the pids
* colon should be replaced with a dash)
* @return array
*/
function islandora_basic_collection_theme($existing, $type, $theme, $path) {
return array(
'islandora_basic_collection' => array(
'template' => 'islandora-basic-collection',
'pattern' => 'islandora_basic_collection__', //we can add pids to the end of this pattern in our preprocess function
// and templates will be able to have have a pid appended to the template name to overide a template on a per object basis
//an example template would be named islandora-basic-image--islandora-27.tpl.phps
'variables' => array('islandora_object' => NULL),
)
);
}
/**
* tells the main module what types of objects we support. This is used to determine whether or not
* this module should attempt to respond.
* @return array
* array of content model pids that this module supports
*/
function islandora_basic_collection_islandora_get_types() {
return array('info:fedora/islandora:collectionCModel');
}
/**
* this modules implentation of view_object hook will handle objects of type islandora:basicImageCModel and info:fedora/islandora:sp_basic_image
* as registered in its return types
* Other modules would handle objects of other types.
* @param Object $object
* a tuque fedora object
* @param object $user
* @param string $page_number
* @param string $page_size
* @return string
* themed html
*/
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
}
$output = theme('islandora_basic_collection', array('islandora_object' => $object));
return array('Basic Collection Output' => $output);
}
/**
*
* @global type $base_url
* @param array $variables
* an array of variables that will be passed to the theme function
*/
function islandora_basic_collection_preprocess_islandora_basic_collection(&$variables) {
$islandora_object = $variables['islandora_object'];
module_load_include('inc', 'islandora', 'utils/islandora_dublin_core');
try {
$dc = $islandora_object['DC']->content;
$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['islandora_associated_objects'] = islandora_basic_collection_get_objects($islandora_object);
$variables['islandora_dublin_core'] = $dc_object;
$variables['islandora_object_label'] = $islandora_object->label;
$variables['theme_hook_suggestions'][] = 'islandora_basic_collection__' . str_replace(':', '_', $islandora_object->id);
global $base_url;
if (isset($islandora_object['OBJ'])) {
$variables['islandora_image_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/OBJ/view';
}
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'])){
$variables['islandora_medium_size_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/MEDIUM_SIZE/view';
}
}
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
and ($object <fedora-rels-ext:isMemberOfCollection> <info:fedora/' . $object->id . '>
or $object <fedora-rels-ext:isMemberOf> <info:fedora/' . $object->id . '>)
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)
minus $content <mulgara:is> <info:fedora/fedora-system:FedoraObject-3.0>
order by $title';
$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);
global $user;
try {
$restConnection = new RestConnection($user);
$queryObject = new RepositoryQuery($restConnection->connection);
$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"";
}
return $results;
}

55
islandora_basic_image/islandora-basic-image--islandora-27.tpl.php

@ -0,0 +1,55 @@
<?php
/*
* fedora-repository-view-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 template is an example of overiding a template by pid
*
* This template must be placed in your themes template directory and
* allows you to override a template file for a specific object
* an example use case would be for theming a collection object differently
* based on the actual collection object.
*
* Best practice would be to create a new cmodel if you have many objects that
* need to be themed differently but if you only have a few objects that need different
* templates this method would work.
*/
$object = $variables['islandora_object'];
$image_url = $variables['islandora_image_url'];
drupal_set_title($object->label);
print ('This template has been overridden by a theme suggestion');
foreach ($variables['islandora_dublin_core'] as $element) {
if (!empty($element)) {
foreach ($element as $key => $value) {
foreach ($value as $v) {
if (!empty($v)) {
print '<strong>' . ($key) . '</strong>: ';
print($v) . '<br />';
}
}
}
}
}
print('<img src = "' . $image_url . '"/>');
?>

1
islandora_basic_image/islandora_basic_image.info

@ -1,4 +1,5 @@
name = "Islandora Basic Image" name = "Islandora Basic Image"
description = "A default Islandora Repository module to handle images" description = "A default Islandora Repository module to handle images"
dependencies[] = islandora dependencies[] = islandora
package = Islandora
core = 7.x core = 7.x

103
islandora_basic_image/islandora_basic_image.module

@ -3,7 +3,7 @@
/* /*
* @file islandora_basic_image.module * @file islandora_basic_image.module
* *
* an Islandora module to handle basic image cmodels (with ISLANDORACM streams) * an Islandora module to handle basic image cmodels
* *
* *
* This file is part of Islandora. * This file is part of Islandora.
@ -22,60 +22,14 @@
* along with the program. If not, see <http ://www.gnu.org/licenses/>. * along with the program. If not, see <http ://www.gnu.org/licenses/>.
*/ */
/**
* called by theme function and populates a render array for a table view.
* See theme registry. This is also an example function.
* @param array $metadata
* @param array $render_array
* @return array
*/
/*
function islandora_basic_image_render_object($metadata, &$render_array) {
$header = array(t('Label'), t('Value'));
$table_attributes = array('class' => array('islandora_metadata'));
$rows = array();
foreach ($metadata as $key => $value) {
if (isset($value) && is_array($value)) {
$item_list = array('#items' => $value, '#theme' => 'item_list');
$rows[] = array($key, array('data' => $item_list));
}
else {
$rows[] = array($key, $value);
}
}
$render_array['metadata'] = array('#header' => $header, '#theme' => 'table', '#rows' => $rows, '#attributes' => $table_attributes);
return $render_array;
}*/
/**
* returns a drupal render array as a html string
* This is an example function. We probably want to use a template
* @param array $variables
* @return string
*/
/*
function theme_islandora_basic_image_view_object($variables) {
$object = $variables['object'];
//$metadata = $object->metadata;
$render_array = array('title' => array(
'#type' => 'markup',
'#markup' => '<h2>' . $object->label . '</h2>',
));
islandora_basic_image_render_object($object, $render_array);
return drupal_render($render_array);
}*/
/** /**
* Theme registry function * Theme registry function
* We supply a pattern so we can overide templates at the theme level if needed.
* we can append a pid to a template and the new template file will be called (the pids
* colon should be replaced with a dash)
* @return array * @return array
*/ */
function islandora_basic_image_theme() { function islandora_basic_image_theme($existing, $type, $theme, $path) {
return array( return array(
'islandora_basic_image_objects' => array( 'islandora_basic_image_objects' => array(
'template' => 'islandora-basic-image-view-objects', 'template' => 'islandora-basic-image-view-objects',
@ -83,6 +37,9 @@ function islandora_basic_image_theme() {
), ),
'islandora_basic_image' => array( 'islandora_basic_image' => array(
'template' => 'islandora-basic-image', 'template' => 'islandora-basic-image',
'pattern' => 'islandora_basic_image__', //we can add pids to the end of this pattern in our preprocess function
// and templates will be able to have have a pid appended to the template name to overide a template on a per object basis
//an example template would be named islandora-basic-image--islandora-27.tpl.phps
'variables' => array('islandora_object' => NULL), 'variables' => array('islandora_object' => NULL),
) )
); );
@ -92,15 +49,14 @@ function islandora_basic_image_theme() {
* tells the main module what types of objects we support. This is used to determine whether or not * tells the main module what types of objects we support. This is used to determine whether or not
* this module should attempt to respond. * this module should attempt to respond.
* @return array * @return array
* array of content model pids that this module supports
*/ */
function islandora_basic_image_islandora_get_types() { function islandora_basic_image_islandora_get_types() {
return array('info:fedora/islandora:imgageCModel', 'info:fedora/islandora:sp_basic_image'); return array('info:fedora/islandora:imgageCModel', 'info:fedora/islandora:sp_basic_image');
} }
/** /**
* this modules implentation of view_object will handle objects of type islandora:basicImageCModel and info:fedora/islandora:sp_basic_image * this modules implentation of view_object hook will handle objects of type islandora:basicImageCModel and info:fedora/islandora:sp_basic_image
* as registered in its return types * as registered in its return types
* Other modules would handle objects of other types. * Other modules would handle objects of other types.
* @param Object $object * @param Object $object
@ -116,30 +72,41 @@ function islandora_basic_image_islandora_view_object($object, $user, $page_numbe
$cmodel_list = islandora_basic_image_islandora_get_types(); $cmodel_list = islandora_basic_image_islandora_get_types();
$combined_list = array_intersect($cmodel_list, $object->models); $combined_list = array_intersect($cmodel_list, $object->models);
if (empty($combined_list)) { if (empty($combined_list)) {
return NULL;//we don't handle any of this objects cmodels return NULL; //we don't handle any of this objects cmodels
} }
$output = theme('islandora_basic_image', array('islandora_object' => $object)); $output = theme('islandora_basic_image', array('islandora_object' => $object));
return array('Basic Image Output' =>$output); return array('Basic Image Output' => $output);
} }
function islandora_preprocess_islandora_basic_image(&$variables){ /**
*
* @global type $base_url
* @param array $variables
* an array of variables that will be passed to the theme function
*/
function islandora_basic_image_preprocess_islandora_basic_image(&$variables) {
$islandora_object = $variables['islandora_object']; $islandora_object = $variables['islandora_object'];
module_load_include('inc','islandora','utils/islandora_dublin_core'); module_load_include('inc', 'islandora', 'utils/islandora_dublin_core');
try{ try {
$dc = $islandora_object['DC']->content; $dc = $islandora_object['DC']->content;
//$dc_xml = simplexml_load_string($dc);
$dc_object = Dublin_Core::import_from_xml_string($dc); $dc_object = Dublin_Core::import_from_xml_string($dc);
}catch(Exception $e){ } catch (Exception $e) {
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;
$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);
global $base_url; global $base_url;
$variables['islandora_image_url'] = $base_url.'/islandora/object/'.$islandora_object->id.'/datastream/OBJ/view'; if (isset($islandora_object['OBJ'])) {
$variables['islandora_thumbnail_url'] = $base_url.'/islandora/object/'.$islandora_object->id.'/datastream/TN/view'; $variables['islandora_image_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/OBJ/view';
$variables['islandora_medium_size_url'] = $base_url . '/islandora/object/'.$islandora_object->id.'/datastream/MEDIUM/view'; }
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'])){
$variables['islandora_medium_size_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/MEDIUM_SIZE/view';
}
} }
?>

17
utils/datastream.inc

@ -1,4 +1,5 @@
<?php <?php
/** /**
* @file datastream.inc * @file datastream.inc
*/ */
@ -9,9 +10,9 @@
* @param string $object_id * @param string $object_id
* @param string $dsid * @param string $dsid
* @return stream * @return stream
* printsdatastream to browser * prints datastream to browser
*/ */
function islandora_datastream_as_attachment($object_id, $dsid){ function islandora_datastream_as_attachment($object_id, $dsid) {
module_load_include('inc', 'islandora', 'RestConnection'); module_load_include('inc', 'islandora', 'RestConnection');
global $user; global $user;
try { try {
@ -21,14 +22,14 @@ function islandora_datastream_as_attachment($object_id, $dsid){
drupal_set_message(t('Error getting Islanndora datastream $d for object %s', array('%s' => $object_id, '%d' => $dsid)), 'error'); drupal_set_message(t('Error getting Islanndora datastream $d for object %s', array('%s' => $object_id, '%d' => $dsid)), 'error');
return""; return"";
} }
header('Content-type: '.$fedora_object[$dsid]->mimetype); header('Content-type: ' . $fedora_object[$dsid]->mimetype);
header('Content-length: '.$fedora_object[$dsid]->size); header('Content-length: ' . $fedora_object[$dsid]->size);
header("Cache-control: private"); header("Cache-control: private");
$method = arg(5); $method = arg(5);
if($method =='download'){ if (isset($method) && $method == 'download') {
header("Content-Disposition: attachment; filename=\"".$fedora_object[$dsid]->label); header("Content-Disposition: attachment; filename=\"" . $fedora_object[$dsid]->label);
} }
print ($fedora_object[$dsid]->content); print($fedora_object[$dsid]->content);
exit(); exit();
} }
?>

Loading…
Cancel
Save