Browse Source

updated fedora_repository module so its hook_islandora_view_object listens to bookCModel and iabookCmodel

pull/105/merge
Paul Pound 13 years ago
parent
commit
51f1c8afee
  1. 9
      fedora_repository/fedora-repository-view-object.tpl.php
  2. 4
      fedora_repository/fedora-repository-view-objects.tpl.php
  3. 40
      fedora_repository/fedora_repository.module
  4. 6
      islandora.module

9
fedora_repository/fedora-repository-view-object.tpl.php

@ -3,9 +3,9 @@
/*
* fedora-repository-view-object.tpl.php
*
* Copyright (c) 2012 Paul Pound.
*
* This file is part of CMR.
*
* 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
@ -21,10 +21,7 @@
* along with the program. If not, see <http ://www.gnu.org/licenses/>.
*/
/**
*
* @author paul
*/
?>
<?php print $variables['count'];
foreach($variables['results'] as $object){

4
fedora_repository/fedora-repository-view-objects.tpl.php

@ -3,9 +3,9 @@
/*
* fedora-repository-object.tpl.php
*
* Copyright (c) 2012 Paul Pound.
*
* This file is part of CMR.
*
* 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

40
fedora_repository/fedora_repository.module

@ -3,9 +3,9 @@
/*
* @file fedora_repository.module
*
* Copyright (c) 2012 Paul Pound.
*
* This file is part of CMR.
*
* 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
@ -31,8 +31,8 @@
*/
function fedora_repository_show_metadata($metadata, &$render_array) {
$header = array(t('Label'), t('Value'));
$table_attributes = array('class' => array('cmr_metadata'));
$rows = array();
$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');
@ -43,7 +43,9 @@ function fedora_repository_show_metadata($metadata, &$render_array) {
}
}
$render_array['metadata'] = array('#header' => $header, '#theme' => 'table', '#rows' => $rows, '#attributes' => $table_attributes);
*/
return $render_array;
}
/**
@ -53,11 +55,12 @@ function fedora_repository_show_metadata($metadata, &$render_array) {
*/
function theme_fedora_repository_view_object($variables) {
$object = $variables['object'];
$metadata = $object->metadata;
//$metadata = $object->metadata;
$render_array = array('title' => array(
'#type' => 'markup',
'#markup' => '<h2>' . $object->label . '</h2>',
));
fedora_repository_show_metadata($metadata, $render_array);
fedora_repository_list_datastreams($object, $render_array);
return drupal_render($render_array);
@ -134,25 +137,22 @@ function fedora_repository_get_types() {
* @return string
* themed html
*/
function fedora_repository_view_object($object, $user, $page_number, $page_size) {
function fedora_repository_islandora_view_object($object, $user, $page_number, $page_size) {
//global $user;
if ($object->type != 'islandora:pdfCModel' && $object->type != 'cmr:basicObject') {
if (!in_array('info:fedora/islandora_bookCmodel', $object->models) && !in_array('info:fedora/islandora:iaBookCModel', $object->models)) {
return NULL;
}
$output = theme('fedora_repository_view_object', array('object' => $object));
$api = new CmrAPIDrupal($user);
try {
$results = $api->listObjectsByRelationship($object, 'cmr:isPartOf', $user, array('offset' => $page_number, 'limit' => $page_size));
} catch (CmrRelationshipException $e) {
drupal_set_message(t('error executing list objects query, %s', array('%s' => $e)));
}
pager_default_initialize($results['count'], $page_size);
$pager = theme('pager', array('quantity' => $results['count']));
$output .= $pager;
if ($results['count'] > 0) {
$output .= theme('fedora_repository_view_objects', $results);
}
$output .= $pager;
//$api = new CmrAPIDrupal($user);
//pager_default_initialize($results['count'], $page_size);
//$pager = theme('pager', array('quantity' => $results['count']));
//$output .= $pager;
//if ($results['count'] > 0) {
// $output .= theme('fedora_repository_view_objects', $results);
//}
//$output .= $pager;
return $output;
}

6
islandora.module

@ -215,7 +215,7 @@ function islandora_get_types() {
}
/**
* DO WE EVEN WANT TO DEFINE THIS HERE OR SHOULD EACH MODULE HANDLE IT EVEN AT THE MENU/PATH LEVEL?
*
* @paramstring $datastream_id
* @return type
*/
@ -256,7 +256,6 @@ function islandora_view_object($object_id) {
try {
$restConnection = new RestConnection($user);
$fedora_object = new FedoraObject($object_id, $restConnection->repository);
//return $restConnection->api->a->getDatastreamDissemination($object_id, 'MODS');
} catch (Exception $e) {
drupal_set_message(t('Error getting Islandora object %s',array('%s' => $object_id)), 'error');
return"";
@ -264,7 +263,8 @@ function islandora_view_object($object_id) {
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
if (empty($arr) ) {
drupal_set_message(t('No module registered to handle objects of type %s', array('%s' => $fedora_object->objectProfile->objModels[0])));
//TODO: make sure we iterate over the array as they will be more then one cmodel per object
drupal_set_message(t('No module registered to handle objects of type %s', array('%s' => $fedora_object->models[0])));
return "";
}
//module_invoke_all(islandora_display($arr)),

Loading…
Cancel
Save