From d1df5e69c8e5fb6d26b3aa5f7887ef61e48cb736 Mon Sep 17 00:00:00 2001 From: Paul Pound Date: Fri, 18 May 2012 17:09:14 -0300 Subject: [PATCH] start of preprocessor functions --- islandora-object-default-view.tpl.php | 15 +++++++++++- islandora.module | 2 +- .../islandora-basic-image-view-object.tpl.php | 2 +- .../islandora_basic_image.module | 23 +++++++++++++++++-- 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/islandora-object-default-view.tpl.php b/islandora-object-default-view.tpl.php index e276636f..dc350009 100644 --- a/islandora-object-default-view.tpl.php +++ b/islandora-object-default-view.tpl.php @@ -24,7 +24,20 @@ ?> label + * $object->id + * to get the contents of a datastream + * $object['dsid']->content + * etc. + * + */ + + $mods = $variables['object']; + $title = $mods['title']; + //dsm($object); + print('this is the default view for '. $object->label .' ' .$object->id); + //print($object['MODS']->contentasJson->'key') ?> diff --git a/islandora.module b/islandora.module index ecaad679..d53356f6 100644 --- a/islandora.module +++ b/islandora.module @@ -266,7 +266,7 @@ function islandora_view_object($object_id) { module_load_include('inc', 'islandora', 'RestConnection'); $user = new stdClass(); $user->name = 'fedoraAdmin'; - $user->password = 'fedoraAdmin'; + $user->password = 'islandora'; try { $restConnection = new RestConnection($user); $fedora_object = new FedoraObject($object_id, $restConnection->repository); diff --git a/islandora_basic_image/islandora-basic-image-view-object.tpl.php b/islandora_basic_image/islandora-basic-image-view-object.tpl.php index df8ea626..6a03a0df 100644 --- a/islandora_basic_image/islandora-basic-image-view-object.tpl.php +++ b/islandora_basic_image/islandora-basic-image-view-object.tpl.php @@ -24,7 +24,7 @@ ?> label); ?> diff --git a/islandora_basic_image/islandora_basic_image.module b/islandora_basic_image/islandora_basic_image.module index 31eed28a..ce3d5ff5 100644 --- a/islandora_basic_image/islandora_basic_image.module +++ b/islandora_basic_image/islandora_basic_image.module @@ -83,7 +83,7 @@ function islandora_basic_image_theme() { ), 'islandora_basic_image_view_object' => array( 'template' => 'islandora-basic-image-view-object', - 'variables' => array('objects' => NULL), + 'variables' => array('object' => NULL), ) ); } @@ -97,6 +97,8 @@ function islandora_basic_image_islandora_get_types() { return array('info:fedora/islandora:imgageCModel', 'info:fedora/islandora:sp_basic_image'); } + + /** * this modules implentation of view_object will handle objects of type islandora:basicImageCModel and info:fedora/islandora:sp_basic_image * as registered in its return types @@ -116,9 +118,26 @@ function islandora_basic_image_islandora_view_object($object, $user, $page_numbe if (empty($combined_list)) { return NULL;//we don't handle any of this objects cmodels } - $output = theme('islandora_basic_image_view_object', array('objects' => $object)); + $output = theme('islandora_basic_image_view_object', array('object' => $object)); return $output; } +function islandora_preprocess_islandora_basic_image_view_object(&$variables){ + $object = $variables['object']; + try{ + $dc = $object['DC']->content; + $dc_xml = simplexml_load_string($dc); + $dc_json = json_decode(json_encode((array)simplexml_load_string($dc)),1); + }catch(Exception $e){ + drupal_set_message(t('Error retrieving object %s %t', array('%s' => $object->id,'%t'=>$e->getMessage())),'error'); + } + $variables['dc'] = $dc_json; + $variables['label'] = $object->label; + global $base_url; + $variables['image_url'] = $base_url.'islandora/object/'.$object->id.'/datastream/OBJ/view'; + $variables['thumbnail_url'] = $base_url.'islandora/object/'.$object->id.'datastream/TN/view'; + //return; +} + ?>