From 9ab4df219937bb2e91adc07877f07185e6131bcd Mon Sep 17 00:00:00 2001 From: jonathangreen Date: Fri, 1 Jun 2012 14:29:41 -0300 Subject: [PATCH] Updated to give warnings about tuque. --- admin/islandora.admin.inc | 3 +- includes/tuque.inc | 37 ++++++++++++------- islandora.module | 15 +++++--- .../islandora_basic_collection.install | 13 +++++++ .../islandora_basic_image.install | 13 +++++++ 5 files changed, 60 insertions(+), 21 deletions(-) diff --git a/admin/islandora.admin.inc b/admin/islandora.admin.inc index 8194520e..e22fa433 100644 --- a/admin/islandora.admin.inc +++ b/admin/islandora.admin.inc @@ -11,8 +11,7 @@ function islandora_repository_admin($form, &$form_state) { module_load_include('inc', 'islandora', 'includes/utilities'); if (!IslandoraTuque::exists()) { - $message = t('This module requires the !url. Please install sites all libraries folder before continuing.', array('!url' => l(t('Tuque Fedora API'), 'http://github.com/islandora/tuque'))); - drupal_set_message(check_plain($message)); + IslandoraTuque::getError(); return; } diff --git a/includes/tuque.inc b/includes/tuque.inc index d87c5845..37a6a013 100644 --- a/includes/tuque.inc +++ b/includes/tuque.inc @@ -1,15 +1,15 @@ connection = new RepositoryConnection($url, $user_string, $pass_string); - $this->connection->reuseConnection = TRUE; - $this->api = new FedoraApi($this->connection); - $this->cache = new SimpleCache(); - $this->repository = new FedoraRepository($this->api, $this->cache); + if(self::exists()) { + $this->connection = new RepositoryConnection($url, $user_string, $pass_string); + $this->connection->reuseConnection = TRUE; + $this->api = new FedoraApi($this->connection); + $this->cache = new SimpleCache(); + $this->repository = new FedoraRepository($this->api, $this->cache); + } } static function exists() { return class_exists('RepositoryConnection'); } + + static function getError() { + $islandora_doc_link = l(t('Islandora documentation'), 'https://wiki.duraspace.org/display/ISLANDORA/Islandora'); + $tuque_link = l(t('Tuque Fedora API'), 'http://github.com/islandora/tuque'); + $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); + } } diff --git a/islandora.module b/islandora.module index 1a6f33ca..7ed87813 100644 --- a/islandora.module +++ b/islandora.module @@ -434,13 +434,18 @@ function islandora_object_load($object_id) { $islandora_tuque = new IslandoraTuque(); } - try { - $fedora_object = $islandora_tuque->repository->getObject($object_id); - } catch (Exception $e) { + 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; } - - return $fedora_object; } function islandora_ingest_access_callback($object, $perm) { diff --git a/islandora_basic_collection/islandora_basic_collection.install b/islandora_basic_collection/islandora_basic_collection.install index eb9f1efe..724b76f4 100644 --- a/islandora_basic_collection/islandora_basic_collection.install +++ b/islandora_basic_collection/islandora_basic_collection.install @@ -1,5 +1,18 @@ 'Tuque', + 'description' => 'The Islandora Collection solution pack requires the Tuque library.', + 'severity' => REQUIREMENT_ERROR, + )); + } + } +} + /** * @file * islandora_basic_collection.install diff --git a/islandora_basic_image/islandora_basic_image.install b/islandora_basic_image/islandora_basic_image.install index 2ab629d9..3f2c2e28 100644 --- a/islandora_basic_image/islandora_basic_image.install +++ b/islandora_basic_image/islandora_basic_image.install @@ -5,6 +5,19 @@ * islandora-basic-image.install */ +function islandora_basic_image_requirements($phase) { + if($phase == 'install') { + module_load_include('inc', 'islandora', 'includes/tuque'); + if(!IslandoraTuque::exists()) { + return array(array( + 'title' => 'Tuque', + 'description' => 'The Islandora Collection solution pack requires the Tuque library.', + 'severity' => REQUIREMENT_ERROR, + )); + } + } +} + /** * Implements hook_install */