|
|
|
<?php
|
|
|
|
|
|
|
|
function islandora_basic_collection_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,
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* islandora_basic_collection.install
|
|
|
|
*/
|
|
|
|
function islandora_basic_collection_install() {
|
|
|
|
module_load_include('inc', 'islandora', 'includes/tuque');
|
|
|
|
global $base_root;
|
|
|
|
|
|
|
|
try {
|
|
|
|
$rest_connection = new IslandoraTuque();
|
|
|
|
} catch (Exception $e) {
|
|
|
|
drupal_set_message(st('Unable to connect to the repository %e', array('%e' => $e)), 'error');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$content_model_query = $rest_connection->api->a->findObjects('query', 'pid=islandora:collectionCModel');
|
|
|
|
if (empty($content_model_query['results'])) {
|
|
|
|
try {
|
|
|
|
$xml = file_get_contents(drupal_get_path('module', 'islandora_basic_collection') . '/xml/islandora_collection_CModel.xml');
|
|
|
|
$rest_connection->api->m->ingest(array('string' => $xml));
|
|
|
|
} catch (Exception $e) {
|
|
|
|
drupal_set_message(st('Unable to install content models %e', array('%e' => $e)), 'error');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
drupal_set_message(st('Content models for the basic collection module installed!'));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
drupal_set_message(st('Content models for the basic collection module already exist!'), 'warning');
|
|
|
|
}
|
|
|
|
|
|
|
|
$collection_query = $rest_connection->api->a->findObjects('query', 'pid=islandora:root');
|
|
|
|
if (empty($collection_query['results'])) {
|
|
|
|
try {
|
|
|
|
$xml = file_get_contents(drupal_get_path('module', 'islandora_basic_collection') . '/xml/islandora_root_collection.xml');
|
|
|
|
$rest_connection->api->m->ingest(array('string' => $xml));
|
|
|
|
$fedora_object = new FedoraObject('islandora:root', $rest_connection->repository);
|
|
|
|
$datastream = new NewFedoraDatastream('TN', 'M', $fedora_object, $rest_connection->repository);
|
|
|
|
$file_path = $base_root . '/' . drupal_get_path('module', 'islandora_basic_collection') . '/Crystal_Clear_filesystem_folder_grey.png';
|
|
|
|
$datastream->label = 'Thumbnail';
|
|
|
|
$datastream->mimetype = 'image/png';
|
|
|
|
$datastream->setContentFromUrl($file_path);
|
|
|
|
$fedora_object->ingestDatastream($datastream);
|
|
|
|
} catch (Exception $e) {
|
|
|
|
drupal_set_message(st('Unable to install collections for the basic collection module %e', array('%e' => $e)), 'error');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
drupal_set_message(st('Collections installed for the basic collection module!'));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
drupal_set_message(st('Collections already exist for the basic collection module!'), 'warning');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function islandora_basic_collection_uninstall() {
|
|
|
|
module_load_include('inc', 'islandora', 'includes/tuque');
|
|
|
|
try {
|
|
|
|
$rest_connection = new IslandoraTuque();
|
|
|
|
} catch (Exception $e) {
|
|
|
|
drupal_set_message(st('Unable to connect to the repository %e', array('%e' => $e)), 'error');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$content_model_query = $rest_connection->api->a->findObjects('query', 'pid=islandora:collectionCModel');
|
|
|
|
if (!empty($content_model_query['results'])) {
|
|
|
|
try {
|
|
|
|
$rest_connection->repository->purgeObject('islandora:collectionCModel');
|
|
|
|
} catch (Exception $e) {
|
|
|
|
drupal_set_message(st('Unable to purge content models for the basic collection module %e', array('%e' => $e)), 'error');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
drupal_set_message(st('Content models for the basic collection module purged!'));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
drupal_set_message(st('Content models for the basic collection module don\'t exist!'), 'warning');
|
|
|
|
}
|
|
|
|
|
|
|
|
$collection_query = $rest_connection->api->a->findObjects('query', 'pid=islandora:root');
|
|
|
|
if (!empty($collection_query['results'])) {
|
|
|
|
try {
|
|
|
|
$rest_connection->repository->purgeObject('islandora:root');
|
|
|
|
} catch (Exception $e) {
|
|
|
|
drupal_set_message(st('Unable to purge collections for the basic collection module %e', array('%e' => $e)), 'error');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
drupal_set_message(st('Collections for the basic collection module purged!'));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
drupal_set_message(st('Collections for the basic collection module don\'t exist!'), 'warning');
|
|
|
|
}
|
|
|
|
}
|