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.

213 lines
6.5 KiB

<?php
/**
* @file
*
*/
14 years ago
/**
* @file
* Herbarium class
*/
/**
* Herbarium ???
*/
class Herbarium {
14 years ago
function __construct($pid = '') {
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
if (!empty($pid)) {
$this->pid = $pid;
$this->item = new Fedora_Item($pid);
}
}
14 years ago
/**
* Build a drupal form ??
* @param type $form
* @param type $form_state
* @return type
*/
public function buildDrupalForm($form = array(), $form_state = array()) {
// We don't need to add anything beyond the standard Darwin Core form so just pass this through
// If we wanted to we could add other fields.
module_load_include('inc', 'fedora_repository', 'plugins/DarwinCore');
14 years ago
$dwc = new DarwinCore($this->item);
return $dwc->buildDrupalForm($form);
}
14 years ago
/**
* Build edit metadata form
* @param type $form
* @return type
*/
public function buildEditMetadataForm($form = array()) {
$form['submit'] = array(
'#type' => 'submit',
'#weight' => 10,
'#value' => 'Update'
);
$form['pid'] = array(
'#type' => 'hidden',
'#value' => $this->pid,
);
$form['dsid'] = array(
'#type' => 'hidden',
'#value' => "DARWIN_CORE",
);
14 years ago
return $this->buildDrupalForm($form);
}
14 years ago
/**
* handle edit metadata form ??
* @global type $user
* @param type $form_id
* @param type $form_values
* @return type
*/
public function handleEditMetadataForm($form_id, $form_values) {
/*
* Process the metadata form
* Update the datastreams
*/
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
module_load_include('inc', 'fedora_repository', 'plugins/DarwinCore');
module_load_include('inc', 'fedora_repository', 'MimeClass');
global $user;
$mimetype = new MimeClass();
$dwc = new DarwinCore($this->item);
$dwc->handleForm($form_values);
$this->item->purge_datastream('DARWIN_CORE');
$this->item->add_datastream_from_string($dwc->darwinCoreXML, 'DARWIN_CORE',
'Darwin Core Metadata', 'text/xml', 'X');
return TRUE;
}
14 years ago
/**
* Handle Ingest Form
* @global type $user
* @param type $form_values
*/
public function handleIngestForm($form_values) {
/*
* process the metadata form
* Create fedora object
* Add the datastreams
*/
module_load_include('inc', 'fedora_repository', 'MimeClass');
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
module_load_include('inc', 'fedora_repository', 'plugins/DarwinCore');
global $user;
$mimetype = new MimeClass();
$dwc = new DarwinCore();
$dwc->handleForm($form_values);
$label = $form_values['dwc:institutionCode'] . ':'
. $form_values['dwc:collectionCode'] . ':'
. $form_values['dwc:catalogNumber'];
$new_item = Fedora_Item::ingest_new_item($form_values['pid'], 'A', $label,
$user->name);
$new_item->add_datastream_from_string($dwc->darwinCoreXML, 'DARWIN_CORE',
'Darwin Core Metadata', 'text/xml', 'X');
$file = $form_values['ingest-file-location'];
14 years ago
if (!empty($file)) {
$dformat = $mimetype->getType($file);
$new_item->add_datastream_from_file($file, 'FULL_SIZE',
"$label-full-size", $dformat, 'M');
}
$new_item->add_relationship('hasModel', $form_values['content_model_pid'], FEDORA_MODEL_URI);
$new_item->add_relationship(!empty($form_values['relationship']) ? $form_values['relationship'] : 'isMemberOfCollection', $form_values['collection_pid']);
14 years ago
if (!empty($_SESSION['fedora_ingest_files'])) {
foreach ($_SESSION['fedora_ingest_files'] as $dsid => $created_file) {
$created_file_format = $mimetype->getType($created_file);
$created_filename = strstr($created_file, $file);
$new_item->add_datastream_from_file($created_file, $dsid,
$created_filename, $created_file_format, 'M');
}
}
}
14 years ago
/**
* Show Field Sets
* @global type $base_url
* @global type $user
* @return string
*/
public function showFieldSets() {
module_load_include('inc', 'fedora_repository', 'plugins/tagging_form');
module_load_include('inc', 'fedora_repository', 'plugins/DarwinCore');
global $base_url;
$tabset = array();
14 years ago
global $user;
$qs = '';
if ($user->uid != 0) {
14 years ago
$qs = '?uid=' . base64_encode($user->name . ':' . $user->pass);
}
14 years ago
$viewer_url = variable_get('fedora_base_url', '') . '/get/' . $this->pid . '/ilives:viewerSdef/getViewer' . $qs;
$html = '<iframe src="' . $viewer_url . '" scrolling="no" frameborder="0" style="width: 100%; height: 800px;">Errors: unable to load viewer</iframe>';
$tabset['second_tab'] = array(
// $collection_fieldset = array (
'#type' => 'tabpage',
'#title' => t('Full-size'),
'#content' => $html
);
$tabset['first_tab'] = array(
// #type and #title are the minimum requirements.
'#type' => 'tabpage',
'#title' => t('View'),
// This will be the content of the tab.
14 years ago
'#content' => '<a href="' . $base_url . '/fedora/repository/' . $this->pid . '/FULL_JPG/"><img src="' . $base_url . '/fedora/imageapi/' .
$this->pid . '/JPG/JPG.jpg' . '" /></a>' . '<p>' . drupal_get_form('fedora_repository_image_tagging_form', $this->pid) . '</p>',
);
$dwc = new DarwinCore($this->item);
$tabset['third_tab'] = array(
'#type' => 'tabpage',
'#title' => t('Description'),
);
$tabset['third_tab']['tabset'] = array(
'#type' => 'tabset',
);
14 years ago
$tabset['third_tab']['tabset']['view'] = array(
'#type' => 'tabpage',
'#title' => t('Darwin Core'),
'#content' => $dwc->asHTML(),
);
module_load_include('inc', 'fedora_repository', 'ObjectHelper');
$obj = new ObjectHelper();
if (fedora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $this->pid, $user)) {
$editform = drupal_get_form('fedora_repository_edit_qdc_form', $this->pid, 'DARWIN_CORE');
$tabset['third_tab']['tabset']['edit'] = array(
'#type' => 'tabpage',
'#title' => t('Edit'),
'#content' => $editform,
);
$tabset['third_tab']['tabset']['source'] = array(
'#type' => 'tabpage',
'#title' => t('Vew Source'),
);
$xmlsrc = $dwc->asXML();
$tabset['third_tab']['tabset']['source']['srctext'] = array(
'#name' => 'source',
'#type' => 'textarea',
'#value' => $xmlsrc,
'#id' => 'source',
'#height' => 50,
);
}
return $tabset;
}
14 years ago
}