You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
101 lines
3.2 KiB
101 lines
3.2 KiB
13 years ago
|
<?php
|
||
|
|
||
12 years ago
|
/**
|
||
|
* @file
|
||
12 years ago
|
*
|
||
12 years ago
|
* This file contains a class to include the Tuque php library.
|
||
|
*/
|
||
|
|
||
12 years ago
|
$islandora_module_path = drupal_get_path('module', 'islandora');
|
||
|
|
||
|
//do this until we expost these in a module or library
|
||
|
@include_once 'sites/all/libraries/tuque/Datastream.php';
|
||
|
@include_once 'sites/all/libraries/tuque/FedoraApi.php';
|
||
|
@include_once 'sites/all/libraries/tuque/FedoraApiSerializer.php';
|
||
|
@include_once 'sites/all/libraries/tuque/Object.php';
|
||
|
@include_once 'sites/all/libraries/tuque/RepositoryConnection.php';
|
||
|
@include_once 'sites/all/libraries/tuque/Cache.php';
|
||
|
@include_once 'sites/all/libraries/tuque/RepositoryException.php';
|
||
|
@include_once 'sites/all/libraries/tuque/Repository.php';
|
||
|
@include_once 'sites/all/libraries/tuque/FedoraRelationships.php';
|
||
|
|
||
|
@include_once "$islandora_module_path/libraries/tuque/Datastream.php";
|
||
|
@include_once "$islandora_module_path/libraries/tuque/FedoraApi.php";
|
||
|
@include_once "$islandora_module_path/libraries/tuque/FedoraApiSerializer.php";
|
||
|
@include_once "$islandora_module_path/libraries/tuque/Object.php";
|
||
|
@include_once "$islandora_module_path/libraries/tuque/RepositoryConnection.php";
|
||
|
@include_once "$islandora_module_path/libraries/tuque/Cache.php";
|
||
|
@include_once "$islandora_module_path/libraries/tuque/RepositoryException.php";
|
||
|
@include_once "$islandora_module_path/libraries/tuque/Repository.php";
|
||
|
@include_once "$islandora_module_path/libraries/tuque/FedoraRelationships.php";
|
||
|
|
||
13 years ago
|
class IslandoraTuque {
|
||
13 years ago
|
|
||
13 years ago
|
/**
|
||
|
* Connection to the repository
|
||
|
*
|
||
|
* @var RepositoryConnection
|
||
|
*/
|
||
13 years ago
|
public $connection = NULL;
|
||
13 years ago
|
|
||
|
/**
|
||
|
* The Fedora API we are using
|
||
|
*
|
||
|
* @var FedoraAPI
|
||
|
*/
|
||
13 years ago
|
public $api = NULL;
|
||
13 years ago
|
|
||
|
/**
|
||
|
* The cache we use to connect.
|
||
|
*
|
||
|
* @var SimpleCache
|
||
|
*/
|
||
13 years ago
|
public $cache = NULL;
|
||
13 years ago
|
|
||
|
/**
|
||
|
* The repository object.
|
||
|
*
|
||
|
* @var FedoraRepository
|
||
|
*/
|
||
13 years ago
|
public $repository = NULL;
|
||
|
|
||
13 years ago
|
function __construct($user = NULL, $url = NULL) {
|
||
12 years ago
|
if (!isset($user)) {
|
||
13 years ago
|
global $user;
|
||
|
}
|
||
12 years ago
|
|
||
12 years ago
|
if ($user->uid == 0) {
|
||
13 years ago
|
$user_string = 'anonymous';
|
||
|
$pass_string = 'anonymous';
|
||
12 years ago
|
}
|
||
|
else {
|
||
13 years ago
|
$user_string = $user->name;
|
||
|
$pass_string = $user->pass;
|
||
|
}
|
||
13 years ago
|
|
||
|
if (!isset($url)) {
|
||
|
$url = variable_get('islandora_base_url', 'http://localhost:8080/fedora');
|
||
|
}
|
||
|
|
||
12 years ago
|
if (self::exists()) {
|
||
12 years ago
|
module_load_include('inc', 'islandora', 'includes/islandora_tuque_wrapper');
|
||
12 years ago
|
$this->connection = new IslandoraRepositoryConnection($url, $user_string, $pass_string);
|
||
13 years ago
|
$this->connection->reuseConnection = TRUE;
|
||
12 years ago
|
$this->api = new IslandoraFedoraApi($this->connection);
|
||
|
$this->cache = new IslandoraSimpleCache();
|
||
|
$this->repository = new IslandoraFedoraRepository($this->api, $this->cache);
|
||
13 years ago
|
}
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
13 years ago
|
static function exists() {
|
||
|
return class_exists('RepositoryConnection');
|
||
|
}
|
||
13 years ago
|
|
||
|
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));
|
||
12 years ago
|
drupal_set_message(filter_xss($message), 'error', FALSE);
|
||
13 years ago
|
}
|
||
13 years ago
|
}
|