Browse Source

added some comments and cleaned up code based on coders feedback

pull/108/merge
Paul Pound 14 years ago
parent
commit
01c7eba4b1
  1. 2
      islandora-object.tpl.php
  2. 2
      islandora.module
  3. 22
      islandora_basic_image/islandora_basic_image.module
  4. 5
      utils/datastream.inc

2
islandora-object.tpl.php

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

2
islandora.module

@ -80,7 +80,7 @@ function islandora_menu() {
); );
$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',

22
islandora_basic_image/islandora_basic_image.module

@ -70,12 +70,14 @@ function theme_islandora_basic_image_view_object($variables) {
return drupal_render($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 +85,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,13 +97,12 @@ 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 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
@ -123,23 +127,27 @@ function islandora_basic_image_islandora_view_object($object, $user, $page_numbe
return array('Basic Image Output' => $output); return array('Basic Image Output' => $output);
} }
/**
*
* @global type $base_url
* @param array $variables
* an array of variables that will be passed to the theme function
*/
function islandora_preprocess_islandora_basic_image(&$variables) { function islandora_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'; $variables['islandora_image_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/OBJ/view';
$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';
$variables['islandora_medium_size_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/MEDIUM/view'; $variables['islandora_medium_size_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/MEDIUM/view';
} }
?>

5
utils/datastream.inc

@ -1,4 +1,5 @@
<?php <?php
/** /**
* @file datastream.inc * @file datastream.inc
*/ */
@ -25,10 +26,10 @@ function islandora_datastream_as_attachment($object_id, $dsid){
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