From e4d723dc70d6e6f5a58a368f22983d9b8eee714c Mon Sep 17 00:00:00 2001 From: Paul Pound Date: Fri, 18 May 2012 13:56:16 -0300 Subject: [PATCH] added a default view hook to islandora module and theme function and template --- islandora-object-default-view.tpl.php | 30 +++++++++++++++++ islandora.module | 33 +++++++++++++++++-- .../islandora_basic_image.module | 10 +++--- 3 files changed, 67 insertions(+), 6 deletions(-) create mode 100644 islandora-object-default-view.tpl.php diff --git a/islandora-object-default-view.tpl.php b/islandora-object-default-view.tpl.php new file mode 100644 index 00000000..e276636f --- /dev/null +++ b/islandora-object-default-view.tpl.php @@ -0,0 +1,30 @@ +. + */ + + +?> +label .' ' .$object->id); +?> + diff --git a/islandora.module b/islandora.module index 3b8e5412..bc98df81 100644 --- a/islandora.module +++ b/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 diff --git a/islandora_basic_image/islandora_basic_image.module b/islandora_basic_image/islandora_basic_image.module index db653cd7..dcc42273 100644 --- a/islandora_basic_image/islandora_basic_image.module +++ b/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); -} +}*/ /**