From 9e5ad2b345032afdb93e5ce9f24ce3cfb13ae069 Mon Sep 17 00:00:00 2001 From: Jordan Dukart Date: Tue, 12 Jun 2012 16:14:33 -0300 Subject: [PATCH] Added the islandora_object_load function to the tuque wrapper --- api/tuque.inc | 61 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 18 deletions(-) diff --git a/api/tuque.inc b/api/tuque.inc index 74dfa730..08eb7c7f 100644 --- a/api/tuque.inc +++ b/api/tuque.inc @@ -26,31 +26,31 @@ $islandora_module_path = drupal_get_path('module', 'fedora_repository'); class IslandoraTuque { /** - * Connection to the repository - * - * @var RepositoryConnection - */ +* Connection to the repository +* +* @var RepositoryConnection +*/ public $connection = NULL; /** - * The Fedora API we are using - * - * @var FedoraAPI - */ +* The Fedora API we are using +* +* @var FedoraAPI +*/ public $api = NULL; /** - * The cache we use to connect. - * - * @var SimpleCache - */ +* The cache we use to connect. +* +* @var SimpleCache +*/ public $cache = NULL; /** - * The repository object. - * - * @var FedoraRepository - */ +* The repository object. +* +* @var FedoraRepository +*/ public $repository = NULL; function __construct($user = NULL, $url = NULL) { @@ -77,8 +77,9 @@ class IslandoraTuque { $this->cache = new SimpleCache(); $this->repository = new FedoraRepository($this->api, $this->cache); } - } - + + } + static function exists() { return class_exists('RepositoryConnection'); } @@ -89,5 +90,29 @@ class IslandoraTuque { $message = t('Islandora requires the !tuque_url. Please install in /sites/all/libraries/tuque before continuing. See the !islandora_url.', array( '!tuque_url' => $tuque_link, '!islandora_url' => $islandora_doc_link)); drupal_set_message($message, 'error', FALSE); } + + } +function islandora_object_load($object_id) { + static $islandora_tuque = NULL; + + if(!$islandora_tuque) { + $islandora_tuque = new IslandoraTuque(); + } + + if(IslandoraTuque::exists()) { + try { + $fedora_object = $islandora_tuque->repository->getObject($object_id); + } catch (Exception $e) { + return NULL; + } + return $fedora_object; + } + else { + IslandoraTuque::getError(); + return NULL; + } + } + +