Drupal modules for browsing and managing Fedora-based digital repositories.
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.
 
 
 
 

115 lines
4.3 KiB

<?php
/**
* @file
* 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
*/
function islandora_basic_image_install() {
module_load_include('inc', 'islandora', 'includes/tuque');
global $base_root;
try {
$restConnection = new IslandoraTuque();
} catch (Exception $e) {
drupal_set_message(t('Unable to connect to the repository %e', array('%e' => $e)), 'error');
return;
}
$content_model_query = $restConnection->api->a->findObjects('query', 'pid=islandora:sp_basic_image');
if (empty($content_model_query['results'])) {
try {
$xml = file_get_contents(drupal_get_path('module', 'islandora_basic_image') . '/xml/simple_islandora_basic_imageCM.xml');
$restConnection->api->m->ingest(array('string' => $xml));
} catch (Exception $e) {
drupal_set_message(t('Unable to install content models for the basic image module %e', array('%e' => $e)), 'error');
return;
}
drupal_set_message(t('Content models for the basic image module installed!'));
}
else {
drupal_set_message(t('Content models for the basic image module already exist!'), 'warning');
}
$collection_query = $restConnection->api->a->findObjects('query', 'pid=islandora:sp_basic_image_collection');
if (empty($collection_query['results'])) {
try {
$xml = file_get_contents(drupal_get_path('module', 'islandora_basic_image') . '/xml/islandora_basic_image_collection.xml');
$restConnection->api->m->ingest(array('string' => $xml));
$fedora_object = new FedoraObject('islandora:sp_basic_image_collection', $restConnection->repository);
$datastream = new NewFedoraDatastream('TN', 'M', $fedora_object, $restConnection->repository);
$file_path = $base_root . '/' . drupal_get_path('module', 'islandora_basic_image') . '/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(t('Unable to install collections for the basic image module %e', array('%e' => $e)), 'error');
return;
}
drupal_set_message(t('Collections for the basic image module installed!'));
}
else {
drupal_set_message(t('Collections for the basic image module already exist!'), 'warning');
}
}
/**
* Implements hook_uninstall
*/
function islandora_basic_image_uninstall() {
module_load_include('inc', 'islandora', 'includes/tuque');
global $user;
try {
$restConnection = new IslandoraTuque($user);
} catch (Exception $e) {
drupal_set_message(t('Unable to connect to the repository %e', array('%e' => $e)), 'error');
return;
}
$content_model_query = $restConnection->api->a->findObjects('query', 'pid=islandora:sp_basic_image');
if (!empty($content_model_query['results'])) {
try {
$restConnection->repository->purgeObject('islandora:sp_basic_image');
} catch (Exception $e) {
drupal_set_message(t('Unable to purge content models for the basic image module %e', array('%e' => $e)), 'error');
return;
}
drupal_set_message(t('Content models for the basic image module purged!'));
}
else {
drupal_set_message(t('Content models for the basic image module don\'t exist!'), 'warning');
}
$collection_query = $restConnection->api->a->findObjects('query', 'pid=islandora:sp_basic_image_collection');
if (!empty($collection_query['results'])) {
try {
$restConnection->repository->purgeObject('islandora:sp_basic_image_collection');
} catch (Exception $e) {
drupal_set_message(t('Unable to purge collections for the basic image module %e', array('%e' => $e)), 'error');
return;
}
drupal_set_message(t('Collections for the basic image module purged!'));
}
else {
drupal_set_message(t('Collections for the basic image module don\'t exist!'), 'warning');
}
}