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. 42
      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 * 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 * 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 * 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/>. * along with the program. If not, see <http ://www.gnu.org/licenses/>.
*/ */
/**
*
* @author paul
*/
?> ?>
<?php print $variables['count']; <?php print $variables['count'];
foreach($variables['results'] as $object){ foreach($variables['results'] as $object){

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

@ -3,9 +3,9 @@
/* /*
* fedora-repository-object.tpl.php * 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 * 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 * it under the terms of the GNU General Public License as published by

42
fedora_repository/fedora_repository.module

@ -3,9 +3,9 @@
/* /*
* @file fedora_repository.module * @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 * 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 * 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) { function fedora_repository_show_metadata($metadata, &$render_array) {
$header = array(t('Label'), t('Value')); $header = array(t('Label'), t('Value'));
$table_attributes = array('class' => array('cmr_metadata')); $table_attributes = array('class' => array('islandora_metadata'));
$rows = array(); /*$rows = array();
foreach ($metadata as $key => $value) { foreach ($metadata as $key => $value) {
if (isset($value) && is_array($value)) { if (isset($value) && is_array($value)) {
$item_list = array('#items' => $value, '#theme' => 'item_list'); $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); $render_array['metadata'] = array('#header' => $header, '#theme' => 'table', '#rows' => $rows, '#attributes' => $table_attributes);
return $render_array; */
return $render_array;
} }
/** /**
@ -53,11 +55,12 @@ function fedora_repository_show_metadata($metadata, &$render_array) {
*/ */
function theme_fedora_repository_view_object($variables) { function theme_fedora_repository_view_object($variables) {
$object = $variables['object']; $object = $variables['object'];
$metadata = $object->metadata; //$metadata = $object->metadata;
$render_array = array('title' => array( $render_array = array('title' => array(
'#type' => 'markup', '#type' => 'markup',
'#markup' => '<h2>' . $object->label . '</h2>', '#markup' => '<h2>' . $object->label . '</h2>',
)); ));
fedora_repository_show_metadata($metadata, $render_array); fedora_repository_show_metadata($metadata, $render_array);
fedora_repository_list_datastreams($object, $render_array); fedora_repository_list_datastreams($object, $render_array);
return drupal_render($render_array); return drupal_render($render_array);
@ -134,25 +137,22 @@ function fedora_repository_get_types() {
* @return string * @return string
* themed html * 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; //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; return NULL;
} }
$output = theme('fedora_repository_view_object', array('object' => $object)); $output = theme('fedora_repository_view_object', array('object' => $object));
$api = new CmrAPIDrupal($user); //$api = new CmrAPIDrupal($user);
try {
$results = $api->listObjectsByRelationship($object, 'cmr:isPartOf', $user, array('offset' => $page_number, 'limit' => $page_size)); //pager_default_initialize($results['count'], $page_size);
} catch (CmrRelationshipException $e) { //$pager = theme('pager', array('quantity' => $results['count']));
drupal_set_message(t('error executing list objects query, %s', array('%s' => $e))); //$output .= $pager;
} //if ($results['count'] > 0) {
pager_default_initialize($results['count'], $page_size); // $output .= theme('fedora_repository_view_objects', $results);
$pager = theme('pager', array('quantity' => $results['count'])); //}
$output .= $pager; //$output .= $pager;
if ($results['count'] > 0) {
$output .= theme('fedora_repository_view_objects', $results);
}
$output .= $pager;
return $output; 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 * @paramstring $datastream_id
* @return type * @return type
*/ */
@ -256,7 +256,6 @@ function islandora_view_object($object_id) {
try { try {
$restConnection = new RestConnection($user); $restConnection = new RestConnection($user);
$fedora_object = new FedoraObject($object_id, $restConnection->repository); $fedora_object = new FedoraObject($object_id, $restConnection->repository);
//return $restConnection->api->a->getDatastreamDissemination($object_id, 'MODS');
} catch (Exception $e) { } catch (Exception $e) {
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"";
@ -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 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) ) {
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 ""; return "";
} }
//module_invoke_all(islandora_display($arr)), //module_invoke_all(islandora_display($arr)),

Loading…
Cancel
Save