Browse Source

added a default view hook to islandora module and theme function and template

pull/108/head
Paul Pound 13 years ago
parent
commit
e4d723dc70
  1. 30
      islandora-object-default-view.tpl.php
  2. 33
      islandora.module
  3. 10
      islandora_basic_image/islandora_basic_image.module

30
islandora-object-default-view.tpl.php

@ -0,0 +1,30 @@
<?php
/*
* islandora-object-default-view.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['object'];
print('this is the default view for '. $object->label .' ' .$object->id);
?>

33
islandora.module

@ -246,7 +246,8 @@ function islandora_purge_datastream($object_id, $datastream_id) {
}
/**
*
* The view entry point. modules should implement hook_islandora_view_object for the Fedora Content models that
* there modules want to provide a view for.
* @global object $user
* @param string $object_id
*
@ -276,13 +277,41 @@ function islandora_view_object($object_id) {
$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) ) {
//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])));
drupal_set_message(t('there was an error loading the view for islandora object %s',array('%s' => $object_id)),'error');
return "";
}
//module_invoke_all(islandora_display($arr)),
return $arr[0]; //just an example as we could have more then one array element
}
/**
* the default view hook. If there are no modules registered to handle this objects cmodels or there are
* not any cmodels specified this will create a default display.
* @param string $object_id
* @return string
*/
function islandora_islandora_view_object($object){
$supported_models = islandora_get_types();
$object_models = $object->models;
$combined_list = array_intersect($supported_models, $object->models);
if (empty($combined_list)) {
return theme('islandora_object_default_view', array('object' => $object));
}
}
/**
* Theme registry function
* @return array
*/
function islandora_theme() {
return array(
'islandora_object_default_view' => array(
'template' => 'islandora-object-default-view',
'variables' => array('object' => NULL),
),
);
}
/**
* drupal hook_permissions function
* @return array

10
islandora_basic_image/islandora_basic_image.module

@ -30,10 +30,11 @@
* @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();
$rows = array();
foreach ($metadata as $key => $value) {
if (isset($value) && is_array($value)) {
$item_list = array('#items' => $value, '#theme' => 'item_list');
@ -44,10 +45,10 @@ function islandora_basic_image_render_object($metadata, &$render_array) {
}
}
$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
@ -55,6 +56,7 @@ function islandora_basic_image_render_object($metadata, &$render_array) {
* @param array $variables
* @return string
*/
/*
function theme_islandora_basic_image_view_object($variables) {
$object = $variables['object'];
//$metadata = $object->metadata;
@ -66,7 +68,7 @@ function theme_islandora_basic_image_view_object($variables) {
islandora_basic_image_render_object($object, $render_array);
return drupal_render($render_array);
}
}*/
/**

Loading…
Cancel
Save