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.

120 lines
3.1 KiB

<?php
/**
* @file
* This is the new Islandora Collection module.
*/
define('ISLANDORA_COLLECTION_CONTENT_TYPE', 'islandora_collection');
define('ISLANDORA_COLLECTION_RDF_TYPE', 'islandora:collection');
/**
* Implements hook_views_api().
*/
function islandora_collection_views_api() {
return array(
'api' => 3.0,
'path' => drupal_get_path('module', 'islandora_collection') . '/include',
);
}
/**
* Implements hook_node_info().
*/
function islandora_collection_node_info() {
return array(
ISLANDORA_COLLECTION_CONTENT_TYPE => array(
'name' => t("Collection"),
'base' => ISLANDORA_COLLECTION_CONTENT_TYPE,
'description' => t("A Drupal node modeling an pcdm:Collection."),
),
);
}
/**
* Implements hook_form().
*/
function islandora_collection_form($node, array &$form_state) {
$form = node_content_form($node, $form_state);
$form['title']['#weight'] = -10;
$form['obj'] = array(
'#name' => 'obj',
'#type' => 'file',
'#title' => t('Image'),
'#description' => t('This file will be set as the "obj" pcdm:File for this object.'),
'#weight' => -5,
);
return $form;
}
function islandora_collection_form_node_form_alter(&$form, &$form_state) {
$form['actions']['submit']['#submit'][0] = 'islandora_collection_node_form_submit';
}
function islandora_collection_node_form_submit($form, &$form_state) {
//dsm($_SERVER);
//dsm($_POST);
//dsm($_FILES);
//dsm($form);
//dsm($form_state);
$url_front = "http://localhost:8080/islandora-services/rest/collection";
$options['method'] = 'POST';
$options['data'] = array(
'node' => json_encode($form['#node']),
'files' => array(
'obj' => $_FILES['obj']['tmp_name'],
),
);
httprl_request($url_front, $options);
$request = httprl_send_request();
//echo httprl_pr($request);
dsm("IN THE SUBMIT");
}
/**
* Implements hook_rdf_mapping().
*/
function islandora_collection_rdf_mapping() {
module_load_include('inc', 'islandora', 'include/rdf_mapping');
$rdf_types = array(
ISLANDORA_PCDM_COLLECTION_RDF_TYPE,
ISLANDORA_COLLECTION_RDF_TYPE,
);
return islandora_get_default_rdf_mapping(ISLANDORA_COLLECTION_CONTENT_TYPE, $rdf_types);
}
/**
* Implements hook_node_postinsert().
*/
function islandora_collection_node_postinsert($node) {
// Exit early if it's not a collection.
if (strcmp($node->type, ISLANDORA_COLLECTION_CONTENT_TYPE) != 0) {
return;
}
10 years ago
$nodes = entity_uuid_load('node', array($node->uuid));
// Exit early if the node never was successfully inserted in the database.
if (empty($nodes)) {
return;
}
$node = array_pop($nodes);
$node->rdf_namespaces = rdf_get_namespaces();
$response = drupal_http_request("http://localhost:8080/islandora-services/rest/collection",
array(
'method' => 'POST',
'data' => json_encode($node),
));
dd("RESPONSE");
dd($response->data);
}
/**
* Implements hook_update().
*/
function islandora_collection_node_postupdate($node) {
dd("FROM POST UPDATE HOOK");
}