Drupal modules for browsing and managing Fedora-based digital repositories.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

156 lines
4.5 KiB

<?php
/*
* @file fedora_repository.module
*
* an Islandora module to handle legacy contentModels (with ISLANDORACM streams)
*
*
* 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/>.
*/
/**
* called by theme function and populates a render array for a table view.
* @param array $metadata
* @param array $render_array
* @return array
*/
function fedora_repository_show_metadata($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
* @param array $variables
* @return string
*/
function theme_fedora_repository_view_object($variables) {
$object = $variables['object'];
//$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);
}
/**
*
* @global object $user
* @param Object $object
* A tuque fedora object
* @param string $render_array
* @return type
*/
function fedora_repository_list_datastreams($object, &$render_array) {
global $user;
$datastreams = $object->datastreams;
if (!isset($datastreams)) {
return $render_array;
}
foreach ($datastreams as $datastream) {
foreach ($datastream as $key => $value) {
if ($key == 'islandora:bookCmodel') {
// $id = $d->getID()->id;
$render_array[(string)$d->getID()] = array('type' => 'markup', '#markup' => '<div class = "cmr-external-link">'.l($d->label, $d->path,array('html'=>TRUE)).'</div>');
}
}
if($key = 'islandora:iaBookCModel'){
$d = new datastream();
$d->find($value);
if(isset($d)){
//@TODO: do something here
}
}
}
}
/**
* Theme registry function
* @return array
*/
function fedora_repository_theme() {
return array(
'fedora_repository_view_objects' => array(
'template' => 'fedora-repository-view-objects',
'variables' => array('objects' => NULL),
),
'fedora_repository_view_object' => array(
'varibles' => array('object'),
)
);
}
/**
* tells the main module what types of objects we support.
* @return array
*/
function fedora_repository_get_types() {
return array('islandora:bookCModel','islandora:isBookCModel');
}
/**
* this modules implentation of view_object will handle objects of type islandora:pdfCmodel as registered in its return types
* Other modules would handle objects
* of other types.
* @param FedoraObject $object
* @param object $user
* @param string $page_number
* @param string $page_size
* @return string
* themed html
*/
function fedora_repository_islandora_view_object($object, $user, $page_number, $page_size) {
//global $user;
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));
//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;
}
?>