Browse Source

Merge pull request #4 from bwoodhead/6.x

6.x
pull/5/merge
Ben Woodhead 14 years ago
parent
commit
65eed8f424
  1. 19
      api/dublin_core.inc
  2. 21
      api/fedora_collection.inc
  3. 38
      api/fedora_export.inc
  4. 166
      api/fedora_item.inc
  5. 42
      api/fedora_utils.inc
  6. 20
      api/rels-ext.inc
  7. 23
      api/tagging.inc
  8. 24
      plugins/CollectionFormBuilder.inc
  9. 26
      plugins/CreateCollection.inc
  10. 37
      plugins/DarwinCore.inc
  11. 24
      plugins/DemoFormBuilder.inc
  12. 20
      plugins/DocumentConverter.inc
  13. 27
      plugins/Exiftool.inc
  14. 25
      plugins/Ffmpeg.inc
  15. 55
      plugins/Flv.inc
  16. 18
      plugins/FlvFormBuilder.inc
  17. 79
      plugins/FormBuilder.inc
  18. 65
      plugins/ImageManipulation.inc
  19. 155
      plugins/ModsFormBuilder.inc
  20. 64
      plugins/PersonalCollectionClass.inc
  21. 35
      plugins/QtFormBuilder.php
  22. 70
      plugins/Refworks.inc
  23. 22
      plugins/ShowDemoStreamsInFieldSets.inc
  24. 69
      plugins/ShowStreamsInFieldSets.inc
  25. 21
      plugins/fedoraObject.inc
  26. 55
      plugins/herbarium.inc
  27. 21
      plugins/map_viewer.inc
  28. 48
      plugins/qt_viewer.inc
  29. 20
      plugins/slide_viewer.inc
  30. 30
      plugins/tagging_form.inc

19
api/dublin_core.inc

@ -1,13 +1,19 @@
<?php <?php
// $Id$ // $Id$
/* /**
* @file
* Implements a simple class for working with Dublin Core data and exporting it * Implements a simple class for working with Dublin Core data and exporting it
* back to XML. Inspiration and design shamelessly stolen from the pyfedora * back to XML. Inspiration and design shamelessly stolen from the pyfedora
* project at http://pypi.python.org/pypi/pyfedora/0.1.0 * project at http://pypi.python.org/pypi/pyfedora/0.1.0
*/ */
/**
* Dublin Core Class
*/
class Dublin_Core { class Dublin_Core {
public $dc = array( public $dc = array(
'dc:title' => array(), 'dc:title' => array(),
'dc:creator' => array(), 'dc:creator' => array(),
@ -41,7 +47,7 @@ class Dublin_Core {
} }
/** /**
* * Add Elements
* @param <type> $element_name * @param <type> $element_name
* @param <type> $value * @param <type> $value
*/ */
@ -67,6 +73,8 @@ class Dublin_Core {
/** /**
* Serialize this object to XML and return it. * Serialize this object to XML and return it.
* @param type $with_preamble
* @return type
*/ */
function as_xml($with_preamble = FALSE) { function as_xml($with_preamble = FALSE) {
$dc_xml = new DomDocument(); $dc_xml = new DomDocument();
@ -88,10 +96,17 @@ class Dublin_Core {
return $dc_xml->saveXML(); return $dc_xml->saveXML();
} }
/**
* Create dc from dict ( does nothing )
*/
static function create_dc_from_dict() { static function create_dc_from_dict() {
} }
/**
* Save ??
* @param type $alt_owner
*/
function save($alt_owner = NULL) { function save($alt_owner = NULL) {
$item_to_update = (!empty($alt_owner) ? $alt_owner : $this->owner); $item_to_update = (!empty($alt_owner) ? $alt_owner : $this->owner);
// My Java roots showing, trying to do polymorphism in PHP. // My Java roots showing, trying to do polymorphism in PHP.

21
api/fedora_collection.inc

@ -1,10 +1,11 @@
<?php <?php
// $Id$ // $Id$
/* /**
* @file
* Operations that affect a Fedora repository at a collection level. * Operations that affect a Fedora repository at a collection level.
*/ */
module_load_include('inc', 'fedora_repository', 'CollectionClass'); module_load_include('inc', 'fedora_repository', 'CollectionClass');
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
@ -13,7 +14,10 @@ module_load_include('module', 'fedora_repository');
/** /**
* Exports a fedora collection object and all of its children in a format * Exports a fedora collection object and all of its children in a format
* that will let you import them into another repository. * that will let you import them into another repository.
* @param <type> $format * @param type $collection_pid
* @param type $relationship
* @param type $format
* @return type
*/ */
function export_collection($collection_pid, $relationship = 'isMemberOfCollection', $format = 'info:fedora/fedora-system:FOXML-1.1') { function export_collection($collection_pid, $relationship = 'isMemberOfCollection', $format = 'info:fedora/fedora-system:FOXML-1.1') {
$collection_item = new Fedora_Item($collection_pid); $collection_item = new Fedora_Item($collection_pid);
@ -117,6 +121,17 @@ function get_related_items_as_xml($collection_pid, $relationship = array('isMemb
return $content; return $content;
} }
/**
* Get Related Items as Arrays
* @param type $collection_pid
* @param type $relationship
* @param type $limit
* @param type $offset
* @param type $active_objects_only
* @param type $cmodel
* @param type $orderby
* @return type
*/
function get_related_items_as_array($collection_pid, $relationship = 'isMemberOfCollection', $limit = 10000, $offset = 0, $active_objects_only = TRUE, $cmodel = NULL, $orderby = '$title') { function get_related_items_as_array($collection_pid, $relationship = 'isMemberOfCollection', $limit = 10000, $offset = 0, $active_objects_only = TRUE, $cmodel = NULL, $orderby = '$title') {
$content = get_related_items_as_xml($collection_pid, $relationship, $limit, $offset, $active_objects_only, $cmodel, $orderby); $content = get_related_items_as_xml($collection_pid, $relationship, $limit, $offset, $active_objects_only, $cmodel, $orderby);
if (empty($content)) { if (empty($content)) {

38
api/fedora_export.inc

@ -2,6 +2,10 @@
// $Id$ // $Id$
/**
* @file
* Fedora Export
*/
define('FOXML_10', 'info:fedora/fedora-system:FOXML-1.0'); define('FOXML_10', 'info:fedora/fedora-system:FOXML-1.0');
define('FOXML_11', 'info:fedora/fedora-system:FOXML-1.1'); define('FOXML_11', 'info:fedora/fedora-system:FOXML-1.1');
define('METS_10', 'info:fedora/fedora-system:METSFedoraExt-1.0'); define('METS_10', 'info:fedora/fedora-system:METSFedoraExt-1.0');
@ -11,6 +15,11 @@ define('ATOMZip_11', 'info:fedora/fedora-system:ATOMZip-1.1');
/** /**
* Function to to export all objects assocoiated with a given pid to the export area * Function to to export all objects assocoiated with a given pid to the export area
* @param type $pid
* @param type $foxml_dir
* @param type $ob_dir
* @param type $log
* @return type
*/ */
function export_to_export_area($pid, $foxml_dir, $ob_dir, &$log = array()) { function export_to_export_area($pid, $foxml_dir, $ob_dir, &$log = array()) {
if (!$paths = export_objects_for_pid($pid, $ob_dir, $log)) { if (!$paths = export_objects_for_pid($pid, $ob_dir, $log)) {
@ -24,6 +33,13 @@ function export_to_export_area($pid, $foxml_dir, $ob_dir, &$log = array()) {
return TRUE; return TRUE;
} }
/**
* Export objects for pids ??
* @param type $pid
* @param type $dir
* @param type $log
* @return string
*/
function export_objects_for_pid($pid, $dir, &$log) { function export_objects_for_pid($pid, $dir, &$log) {
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$item = new Fedora_Item($pid); $item = new Fedora_Item($pid);
@ -58,6 +74,16 @@ function export_objects_for_pid($pid, $dir, &$log) {
return $paths; return $paths;
} }
/**
* Export foxml for pid
* @param type $pid
* @param type $dir
* @param type $paths
* @param type $log
* @param type $format
* @param type $remove_islandora
* @return type
*/
function export_foxml_for_pid($pid, $dir, $paths, &$log, $format = FOXML_11, $remove_islandora = FALSE) { function export_foxml_for_pid($pid, $dir, $paths, &$log, $format = FOXML_11, $remove_islandora = FALSE) {
module_load_include('inc', 'fedora_repository', 'ObjectHelper'); module_load_include('inc', 'fedora_repository', 'ObjectHelper');
$ob_helper = new ObjectHelper(); $ob_helper = new ObjectHelper();
@ -170,10 +196,22 @@ function export_foxml_for_pid($pid, $dir, $paths, &$log, $format = FOXML_11, $re
return TRUE; return TRUE;
} }
/**
* Get file extension
* @param type $mimeType
* @return type
*/
function get_file_extension($mimeType) { function get_file_extension($mimeType) {
return substr(strstr($mimeType, '/'), 1); return substr(strstr($mimeType, '/'), 1);
} }
/**
* Log line
* @param type $msg
* @param type $severity
* @param type $sep
* @return type
*/
function log_line($msg, $severity = 'info', $sep = "\t") { function log_line($msg, $severity = 'info', $sep = "\t") {
return date("Y-m-d H:i:s") . $sep . ucfirst($severity) . $sep . $msg; return date("Y-m-d H:i:s") . $sep . ucfirst($severity) . $sep . $msg;
} }

166
api/fedora_item.inc

@ -2,9 +2,16 @@
// $Id$ // $Id$
/**
* @file
* Fedora Item
*/
define('RELS_EXT_URI', 'info:fedora/fedora-system:def/relations-external#'); define('RELS_EXT_URI', 'info:fedora/fedora-system:def/relations-external#');
define("FEDORA_MODEL_URI", 'info:fedora/fedora-system:def/model#'); define("FEDORA_MODEL_URI", 'info:fedora/fedora-system:def/model#');
/**
* Fedora Item Class
*/
class Fedora_Item { class Fedora_Item {
public $pid = NULL; // The $pid of the fedora object represented by an instance of this class. public $pid = NULL; // The $pid of the fedora object represented by an instance of this class.
@ -51,10 +58,24 @@ class Fedora_Item {
} }
} }
/**
* Exists
* @return type
*/
function exists() { function exists() {
return (!empty($this->objectProfile)); return (!empty($this->objectProfile));
} }
/**
* Add datastream from file
* @param type $datastream_file
* @param type $datastream_id
* @param type $datastream_label
* @param type $datastream_mimetype
* @param type $controlGroup
* @param type $logMessage
* @return type
*/
function add_datastream_from_file($datastream_file, $datastream_id, $datastream_label = NULL, $datastream_mimetype = '', $controlGroup = 'M', $logMessage = null) { function add_datastream_from_file($datastream_file, $datastream_id, $datastream_label = NULL, $datastream_mimetype = '', $controlGroup = 'M', $logMessage = null) {
module_load_include('inc', 'fedora_repository', 'MimeClass'); module_load_include('inc', 'fedora_repository', 'MimeClass');
if (empty($datastream_mimetype)) { if (empty($datastream_mimetype)) {
@ -76,6 +97,16 @@ class Fedora_Item {
return $return_value; return $return_value;
} }
/**
* Add datastream from url
* @param type $datastream_url
* @param type $datastream_id
* @param type $datastream_label
* @param type $datastream_mimetype
* @param type $controlGroup
* @param type $logMessage
* @return type
*/
function add_datastream_from_url($datastream_url, $datastream_id, $datastream_label = NULL, $datastream_mimetype = '', $controlGroup = 'M', $logMessage = null) { function add_datastream_from_url($datastream_url, $datastream_id, $datastream_label = NULL, $datastream_mimetype = '', $controlGroup = 'M', $logMessage = null) {
if (empty($datastream_label)) { if (empty($datastream_label)) {
$datastream_label = $datastream_id; $datastream_label = $datastream_id;
@ -99,9 +130,18 @@ class Fedora_Item {
return $this->soap_call('addDataStream', $params); return $this->soap_call('addDataStream', $params);
} }
/**
* Add datastream from string
* @param type $str
* @param type $datastream_id
* @param type $datastream_label
* @param type $datastream_mimetype
* @param type $controlGroup
* @param type $logMessage
* @return type
*/
function add_datastream_from_string($str, $datastream_id, $datastream_label = NULL, $datastream_mimetype = 'text/xml', $controlGroup = 'M', $logMessage = null) { function add_datastream_from_string($str, $datastream_id, $datastream_label = NULL, $datastream_mimetype = 'text/xml', $controlGroup = 'M', $logMessage = null) {
$dir = sys_get_temp_dir(); $dir = sys_get_temp_dir();
$tmpfilename = tempnam($dir, 'fedoratmp'); $tmpfilename = tempnam($dir, 'fedoratmp');
@ -116,8 +156,9 @@ class Fedora_Item {
/** /**
* Add a relationship string to this object's RELS-EXT. * Add a relationship string to this object's RELS-EXT.
* does not support rels-int yet. * does not support rels-int yet.
* @param string $relationship * @param type $relationship
* @param <type> $object * @param type $object
* @param type $namespaceURI
*/ */
function add_relationship($relationship, $object, $namespaceURI = RELS_EXT_URI) { function add_relationship($relationship, $object, $namespaceURI = RELS_EXT_URI) {
$ds_list = $this->get_datastreams_list_as_array(); $ds_list = $this->get_datastreams_list_as_array();
@ -214,6 +255,10 @@ class Fedora_Item {
//print ($description->dump_node()); //print ($description->dump_node());
} }
/**
* Export as foxml
* @return type
*/
function export_as_foxml() { function export_as_foxml() {
$params = array( $params = array(
'pid' => $this->pid, 'pid' => $this->pid,
@ -290,6 +335,12 @@ class Fedora_Item {
return $results; return $results;
} }
/**
* Get datastream dissemination
* @param type $dsid
* @param type $as_of_date_time
* @return string
*/
function get_datastream_dissemination($dsid, $as_of_date_time = "") { function get_datastream_dissemination($dsid, $as_of_date_time = "") {
$params = array( $params = array(
'pid' => $this->pid, 'pid' => $this->pid,
@ -307,6 +358,12 @@ class Fedora_Item {
return $content; return $content;
} }
/**
* Get datastream
* @param type $dsid
* @param type $as_of_date_time
* @return type
*/
function get_datastream($dsid, $as_of_date_time = "") { function get_datastream($dsid, $as_of_date_time = "") {
$params = array( $params = array(
'pid' => $this->pid, 'pid' => $this->pid,
@ -318,6 +375,11 @@ class Fedora_Item {
return $object->datastream; return $object->datastream;
} }
/**
* Get datastream history
* @param type $dsid
* @return type
*/
function get_datastream_history($dsid) { function get_datastream_history($dsid) {
$params = array( $params = array(
'pid' => $this->pid, 'pid' => $this->pid,
@ -332,6 +394,14 @@ class Fedora_Item {
return $ret; return $ret;
} }
/**
* Get dissemination
* @param type $service_definition_pid
* @param type $method_name
* @param type $parameters
* @param type $as_of_date_time
* @return string
*/
function get_dissemination($service_definition_pid, $method_name, $parameters = array(), $as_of_date_time = null) { function get_dissemination($service_definition_pid, $method_name, $parameters = array(), $as_of_date_time = null) {
$params = array( $params = array(
'pid' => $this->pid, 'pid' => $this->pid,
@ -530,6 +600,9 @@ class Fedora_Item {
/** /**
* Removes this object form the repository. * Removes this object form the repository.
* @param type $log_message
* @param type $force
* @return type
*/ */
function purge($log_message = 'Purged using Islandora API.', $force = FALSE) { function purge($log_message = 'Purged using Islandora API.', $force = FALSE) {
$params = array( $params = array(
@ -541,6 +614,15 @@ class Fedora_Item {
return $this->soap_call('purgeObject', $params); return $this->soap_call('purgeObject', $params);
} }
/**
* Purge datastream
* @param type $dsID
* @param type $start_date
* @param type $end_date
* @param type $log_message
* @param type $force
* @return type
*/
function purge_datastream($dsID, $start_date = NULL, $end_date = NULL, $log_message = 'Purged datastream using Islandora API', $force = FALSE) { function purge_datastream($dsID, $start_date = NULL, $end_date = NULL, $log_message = 'Purged datastream using Islandora API', $force = FALSE) {
$params = array( $params = array(
'pid' => $this->pid, 'pid' => $this->pid,
@ -553,11 +635,21 @@ class Fedora_Item {
return $this->soap_call('purgeDatastream', $params); return $this->soap_call('purgeDatastream', $params);
} }
/**
* URL
* @global type $base_url
* @return type
*/
function url() { function url() {
global $base_url; global $base_url;
return $base_url . '/fedora/repository/' . $this->pid . (!empty($this->objectProfile) ? '/-/' . drupal_urlencode($this->objectProfile->objLabel) : ''); return $base_url . '/fedora/repository/' . $this->pid . (!empty($this->objectProfile) ? '/-/' . drupal_urlencode($this->objectProfile->objLabel) : '');
} }
/**
* Get Next PID in Namespace
* @param type $pid_namespace
* @return type
*/
static function get_next_PID_in_namespace($pid_namespace = '') { static function get_next_PID_in_namespace($pid_namespace = '') {
if (empty($pid_namespace)) { if (empty($pid_namespace)) {
@ -581,18 +673,32 @@ class Fedora_Item {
return $result->pid; return $result->pid;
} }
/**
* ingest from FOXML
* @param type $foxml
* @return Fedora_Item
*/
static function ingest_from_FOXML($foxml) { static function ingest_from_FOXML($foxml) {
$params = array('objectXML' => $foxml->saveXML(), 'format' => "info:fedora/fedora-system:FOXML-1.1", 'logMessage' => "Fedora Object Ingested"); $params = array('objectXML' => $foxml->saveXML(), 'format' => "info:fedora/fedora-system:FOXML-1.1", 'logMessage' => "Fedora Object Ingested");
$object = self::soap_call('ingest', $params); $object = self::soap_call('ingest', $params);
return new Fedora_Item($object->objectPID); return new Fedora_Item($object->objectPID);
} }
/**
* ingest from FOXML file
* @param type $foxml_file
* @return type
*/
static function ingest_from_FOXML_file($foxml_file) { static function ingest_from_FOXML_file($foxml_file) {
$foxml = new DOMDocument(); $foxml = new DOMDocument();
$foxml->load($foxml_file); $foxml->load($foxml_file);
return self::ingest_from_FOXML($foxml); return self::ingest_from_FOXML($foxml);
} }
/**
* ingest from FOXML files in directory
* @param type $path
*/
static function ingest_from_FOXML_files_in_directory($path) { static function ingest_from_FOXML_files_in_directory($path) {
// Open the directory // Open the directory
$dir_handle = @opendir($path); $dir_handle = @opendir($path);
@ -612,6 +718,15 @@ class Fedora_Item {
closedir($dir_handle); closedir($dir_handle);
} }
/**
* Modify Object
* @param type $label
* @param type $state
* @param type $ownerId
* @param type $logMessage
* @param type $quiet
* @return type
*/
function modify_object($label = '', $state = null, $ownerId = null, $logMessage = 'Modified by Islandora API', $quiet=TRUE) { function modify_object($label = '', $state = null, $ownerId = null, $logMessage = 'Modified by Islandora API', $quiet=TRUE) {
$params = array( $params = array(
@ -625,6 +740,17 @@ class Fedora_Item {
return self::soap_call('modifyObject', $params, $quiet); return self::soap_call('modifyObject', $params, $quiet);
} }
/**
* Modify datastream by reference
* @param type $external_url
* @param type $dsid
* @param type $label
* @param type $mime_type
* @param type $force
* @param type $logMessage
* @param type $quiet
* @return type
*/
function modify_datastream_by_reference($external_url, $dsid, $label, $mime_type, $force = FALSE, $logMessage = 'Modified by Islandora API', $quiet=FALSE) { function modify_datastream_by_reference($external_url, $dsid, $label, $mime_type, $force = FALSE, $logMessage = 'Modified by Islandora API', $quiet=FALSE) {
$params = array( $params = array(
'pid' => $this->pid, 'pid' => $this->pid,
@ -642,6 +768,17 @@ class Fedora_Item {
return self::soap_call('modifyDatastreamByReference', $params, $quiet); return self::soap_call('modifyDatastreamByReference', $params, $quiet);
} }
/**
* Modify datastream by value
* @param type $content
* @param type $dsid
* @param type $label
* @param type $mime_type
* @param type $force
* @param type $logMessage
* @param type $quiet
* @return type
*/
function modify_datastream_by_value($content, $dsid, $label, $mime_type, $force = FALSE, $logMessage = 'Modified by Islandora API', $quiet=FALSE) { function modify_datastream_by_value($content, $dsid, $label, $mime_type, $force = FALSE, $logMessage = 'Modified by Islandora API', $quiet=FALSE) {
$params = array( $params = array(
'pid' => $this->pid, 'pid' => $this->pid,
@ -659,6 +796,13 @@ class Fedora_Item {
return self::soap_call('modifyDatastreamByValue', $params, $quiet); return self::soap_call('modifyDatastreamByValue', $params, $quiet);
} }
/**
* Soap call
* @param type $function_name
* @param type $params_array
* @param type $quiet
* @return type
*/
static function soap_call($function_name, $params_array, $quiet = FALSE) { static function soap_call($function_name, $params_array, $quiet = FALSE) {
if (!self::$connection_helper) { if (!self::$connection_helper) {
module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); module_load_include('inc', 'fedora_repository', 'ConnectionHelper');
@ -730,6 +874,9 @@ class Fedora_Item {
* *
* @param string $pid if none given, getnextpid will be called. * @param string $pid if none given, getnextpid will be called.
* @param string $state The initial state, A - Active, I - Inactive, D - Deleted * @param string $state The initial state, A - Active, I - Inactive, D - Deleted
* @param type $label
* @param type $owner
* @return DOMDocument
*/ */
static function create_object_FOXML($pid = '', $state = 'A', $label = 'Untitled', $owner = '') { static function create_object_FOXML($pid = '', $state = 'A', $label = 'Untitled', $owner = '') {
$foxml = new DOMDocument("1.0", "UTF-8"); $foxml = new DOMDocument("1.0", "UTF-8");
@ -778,10 +925,23 @@ class Fedora_Item {
return $foxml; return $foxml;
} }
/**
* ingest new item
* @param type $pid
* @param type $state
* @param type $label
* @param type $owner
* @return type
*/
static function ingest_new_item($pid = '', $state = 'A', $label = '', $owner = '') { static function ingest_new_item($pid = '', $state = 'A', $label = '', $owner = '') {
return self::ingest_from_FOXML(self::create_object_FOXML($pid, $state, $label, $owner)); return self::ingest_from_FOXML(self::create_object_FOXML($pid, $state, $label, $owner));
} }
/**
* fedora item exists
* @param type $pid
* @return type
*/
static function fedora_item_exists($pid) { static function fedora_item_exists($pid) {
$item = new Fedora_Item($pid); $item = new Fedora_Item($pid);
return $item->exists(); return $item->exists();

42
api/fedora_utils.inc

@ -1,13 +1,17 @@
<?php <?php
// $Id$ // $Id$
// @file fedora_utils.inc /**
// Base utilities used by the Islansora fedora module. * @file
* Base utilities used by the Islandora fedora module.
*/
/* /*
* Functions that emulate php5.3 functionality for backwards compatiablity * Functions that emulate php5.3 functionality for backwards compatiablity
*/ */
if (!function_exists('str_getcsv')) { if (!function_exists('str_getcsv')) {
function str_getcsv($input, $delimiter=',', $enclosure='"', $escape=null, $eol=null) { function str_getcsv($input, $delimiter=',', $enclosure='"', $escape=null, $eol=null) {
$temp = fopen("php://memory", "rw"); $temp = fopen("php://memory", "rw");
fwrite($temp, $input); fwrite($temp, $input);
@ -16,7 +20,9 @@ if (!function_exists('str_getcsv')) {
fclose($temp); fclose($temp);
return $r; return $r;
} }
} }
/* /*
* Functions that emulate php5.3 functionality for backwards compatiablity * Functions that emulate php5.3 functionality for backwards compatiablity
*/ */
@ -25,7 +31,15 @@ if (!function_exists('str_getcsv')) {
* Static functions used by the Fedora PHP API. * Static functions used by the Fedora PHP API.
*/ */
/**
* do curl
* @global type $user
* @param type $url
* @param type $return_to_variable
* @param type $number_of_post_vars
* @param type $post
* @return type
*/
function do_curl($url, $return_to_variable = 1, $number_of_post_vars = 0, $post = NULL) { function do_curl($url, $return_to_variable = 1, $number_of_post_vars = 0, $post = NULL) {
global $user; global $user;
// Check if we are inside Drupal and there is a valid user. // Check if we are inside Drupal and there is a valid user.
@ -65,14 +79,16 @@ function do_curl($url, $return_to_variable = 1, $number_of_post_vars = 0, $post
} }
} }
/**
* Fedora available
* @return type
*/
function fedora_available() { function fedora_available() {
$response = do_curl(variable_get('fedora_base_url', 'http://localhost:8080/fedora') . '/describe'); $response = do_curl(variable_get('fedora_base_url', 'http://localhost:8080/fedora') . '/describe');
return strstr($response, 'Repository Information HTML Presentation') !== FALSE; return strstr($response, 'Repository Information HTML Presentation') !== FALSE;
} }
/** /**
* Returns a UTF-8-encoded transcripiton of the string given in $in_str. * Returns a UTF-8-encoded transcripiton of the string given in $in_str.
* @param string $in_str * @param string $in_str
@ -88,6 +104,11 @@ function fix_encoding($in_str) {
} }
} }
/**
* valid pid ??
* @param type $pid
* @return boolean
*/
function validPid($pid) { function validPid($pid) {
$valid = FALSE; $valid = FALSE;
if (strlen(trim($pid)) <= 64 && preg_match('/^([A-Za-z0-9]|-|\.)+:(([A-Za-z0-9])|-|\.|~|_|(%[0-9A-F]{2}))+$/', trim($pid))) { if (strlen(trim($pid)) <= 64 && preg_match('/^([A-Za-z0-9]|-|\.)+:(([A-Za-z0-9])|-|\.|~|_|(%[0-9A-F]{2}))+$/', trim($pid))) {
@ -97,6 +118,11 @@ function validPid($pid) {
return $valid; return $valid;
} }
/**
* Valid Dsid ??
* @param type $dsid
* @return boolean
*/
function validDsid($dsid) { function validDsid($dsid) {
$valid = FALSE; $valid = FALSE;
if (strlen(trim($dsid)) <= 64 && preg_match('/^[a-zA-Z0-9\_\-\.]+$/', trim($dsid))) { if (strlen(trim($dsid)) <= 64 && preg_match('/^[a-zA-Z0-9\_\-\.]+$/', trim($dsid))) {
@ -106,6 +132,11 @@ function validDsid($dsid) {
return $valid; return $valid;
} }
/**
* fixDsid ??
* @param type $dsid
* @return string
*/
function fixDsid($dsid) { function fixDsid($dsid) {
$new_dsid = trim($dsid); $new_dsid = trim($dsid);
@ -123,6 +154,5 @@ function fixDsid($dsid) {
$new_dsid = 'item' . rand(1, 100); $new_dsid = 'item' . rand(1, 100);
return $new_dsid; return $new_dsid;
} }

20
api/rels-ext.inc

@ -1,32 +1,35 @@
<?php <?php
// $Id$ // $Id$
/* /**
* To change this template, choose Tools | Templates * @file
* and open the template in the editor. * RelsExt class
*/ */
/** /**
* Description of relsext * RelsExt class
*
* @author aoneill
*/ */
class RelsExt { class RelsExt {
// Instance variables // Instance variables
public $relsExtArray = array(); public $relsExtArray = array();
private $originalRelsExtArray = array(); // Used to determine the result of modified() funciton. private $originalRelsExtArray = array(); // Used to determine the result of modified() funciton.
// Member functions
/** /**
* Constructor that builds itself by retrieving the RELS-EXT stream from * Constructor that builds itself by retrieving the RELS-EXT stream from
* the repository for the given Fedora_Item. * the repository for the given Fedora_Item.
* @param Fedora_Item $item * @param Fedora_Item $item
*/ */
function RelsExt($item) { function RelsExt($item) {
$relsextxml = $item->get_datastream_dissemination('RELS-EXT'); $relsextxml = $item->get_datastream_dissemination('RELS-EXT');
} }
/**
* modified
* @return type
*/
function modified() { function modified() {
return!(empty(array_diff($this->relsExtArray, $this->originalRelsExtArray)) && return!(empty(array_diff($this->relsExtArray, $this->originalRelsExtArray)) &&
empty(array_diff($this->originalRelsExtArray, $this->relsExtArray))); empty(array_diff($this->originalRelsExtArray, $this->relsExtArray)));
@ -39,5 +42,6 @@ class RelsExt {
function save() { function save() {
} }
} }

23
api/tagging.inc

@ -1,20 +1,25 @@
<?php <?php
// $Id$ // $Id$
/* /**
* @file tagging.inc * @file
* TagSet Class
*/ */
/** /**
* Description of tagging * TagSet Class
*
* @author aoneill
*/ */
class TagSet { class TagSet {
public $tags = array(); public $tags = array();
public $item = NULL; public $item = NULL;
public $tagsDSID = 'TAGS'; public $tagsDSID = 'TAGS';
/**
* Constructor
* @param type $item
*/
function TagSet($item = NULL) { function TagSet($item = NULL) {
if (!empty($item) && get_class($item) == 'Fedora_Item') { if (!empty($item) && get_class($item) == 'Fedora_Item') {
$this->item = $item; $this->item = $item;
@ -22,6 +27,10 @@ class TagSet {
} }
} }
/**
* Load ??
* @return type
*/
function load() { function load() {
$tagsxml = isset($this->item->datastreams[$this->tagsDSID]) ? $this->item->get_datastream_dissemination($this->tagsDSID) : NULL; $tagsxml = isset($this->item->datastreams[$this->tagsDSID]) ? $this->item->get_datastream_dissemination($this->tagsDSID) : NULL;
if (empty($tagsxml)) { if (empty($tagsxml)) {
@ -59,11 +68,11 @@ class TagSet {
else { else {
$this->item->modify_datastream_by_value($tagdoc->saveXML(), $this->tagsDSID, 'Tags', 'text/xml', 'X'); $this->item->modify_datastream_by_value($tagdoc->saveXML(), $this->tagsDSID, 'Tags', 'text/xml', 'X');
} }
} } catch (exception $e) {
catch (exception $e) {
drupal_set_message('There was an error saving the tags datastream: !e', array('!e' => $e), 'error'); drupal_set_message('There was an error saving the tags datastream: !e', array('!e' => $e), 'error');
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
} }
} }

24
plugins/CollectionFormBuilder.inc

@ -1,20 +1,35 @@
<?php <?php
// $Id$ // $Id$
/**
* @file
* Collection Form Builder
*/
module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder'); module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder');
/*
* Created on 19-Feb-08 /**
*
*
* implements methods from content model ingest form xml * implements methods from content model ingest form xml
* builds a dc metadata form * builds a dc metadata form
*/ */
class CollectionFormBuilder extends FormBuilder { class CollectionFormBuilder extends FormBuilder {
/**
* Constructor
*/
function CollectionFormBuilder() { function CollectionFormBuilder() {
module_load_include('inc', 'CollectionFormBuilder', ''); module_load_include('inc', 'CollectionFormBuilder', '');
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
} }
/**
* Create Fedora Datastream
* @global type $base_url
* @param type $form_values
* @param type $dom
* @param type $rootElement
*/
function createFedoraDataStreams($form_values, &$dom, &$rootElement) { function createFedoraDataStreams($form_values, &$dom, &$rootElement) {
module_load_include('inc', 'fedora_repository', 'MimeClass'); module_load_include('inc', 'fedora_repository', 'MimeClass');
global $base_url; global $base_url;
@ -42,4 +57,5 @@ class CollectionFormBuilder extends FormBuilder {
$ds1v->appendChild($ds1content); $ds1v->appendChild($ds1content);
$rootElement->appendChild($ds1); $rootElement->appendChild($ds1);
} }
} }

26
plugins/CreateCollection.inc

@ -1,22 +1,34 @@
<?php <?php
// $Id$ // $Id$
/* /**
* * @file
* * Create Collection Class
* This Class implements the methods defined in the STANDARD_IMAGE content model
*/ */
/**
* This Class implements the methods defined in the STANDARD_IMAGE content model
*/
class CreateCollection { class CreateCollection {
function CreateCollection() {
/**
* Constructor
*/
function CreateCollection() {
} }
/**
* ingest collection policy ???
* @param type $parameterArray
* @param type $dsid
* @param type $file
* @param type $file_ext
* @return type
*/
function ingestCollectionPolicy($parameterArray = NULL, $dsid, $file, $file_ext = NULL) { function ingestCollectionPolicy($parameterArray = NULL, $dsid, $file, $file_ext = NULL) {
return TRUE; //nothing needed here as we are not transforming any files return TRUE; //nothing needed here as we are not transforming any files
} }
} }

37
plugins/DarwinCore.inc

@ -2,8 +2,20 @@
// $Id$ // $Id$
/**
* @file
* Darwin Core class
*/
/**
* Darwin Core ???
*/
class DarwinCore { class DarwinCore {
/**
* Constructor
* @param type $item
*/
function __construct($item = NULL) { function __construct($item = NULL) {
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
if (!empty($item)) { if (!empty($item)) {
@ -17,6 +29,11 @@ class DarwinCore {
} }
} }
/**
* Build Drupal Form
* @param type $form
* @return int
*/
public function buildDrupalForm($form = array()) { public function buildDrupalForm($form = array()) {
$dwc_xml = $this->darwinCoreXML; $dwc_xml = $this->darwinCoreXML;
@ -173,6 +190,11 @@ class DarwinCore {
return $form; return $form;
} }
/**
* Handle Form ??
* @global type $user
* @param type $form_values
*/
public function handleForm($form_values) { public function handleForm($form_values) {
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
global $user; global $user;
@ -208,10 +230,18 @@ class DarwinCore {
$this->darwinCoreXML = $dwc->saveXML(); $this->darwinCoreXML = $dwc->saveXML();
} }
/**
* asXML ??
* @return type
*/
public function asXML() { public function asXML() {
return $this->darwinCoreXML; return $this->darwinCoreXML;
} }
/**
* asHTML ??
* @return type
*/
public function asHTML() { public function asHTML() {
$path = drupal_get_path('module', 'Fedora_Repository'); $path = drupal_get_path('module', 'Fedora_Repository');
module_load_include('inc', 'fedora_repository', 'ObjectHelper'); module_load_include('inc', 'fedora_repository', 'ObjectHelper');
@ -226,8 +256,7 @@ class DarwinCore {
try { try {
$proc = new XsltProcessor(); $proc = new XsltProcessor();
} } catch (Exception $e) {
catch (Exception $e) {
drupal_set_message(t("!e", array('!e' => $e->getMessage())), 'error'); drupal_set_message(t("!e", array('!e' => $e->getMessage())), 'error');
return " "; return " ";
} }
@ -256,9 +285,7 @@ class DarwinCore {
'MachineObservation' => 'MachineObservation', 'MachineObservation' => 'MachineObservation',
'NomenclaturalChecklist' => 'NomenclaturalChecklist', 'NomenclaturalChecklist' => 'NomenclaturalChecklist',
), ),
); );
public $dwcFields = array( public $dwcFields = array(
'dc:type', 'dc:type',
'dc:language', 'dc:language',
@ -283,8 +310,6 @@ class DarwinCore {
'dwc:eventDate', 'dwc:eventDate',
'dwc:eventTime', 'dwc:eventTime',
); );
public $darwinCoreXML = ' public $darwinCoreXML = '
<SimpleDarwinRecordSet xmlns="http://rs.tdwg.org/dwc/xsd/simpledarwincore/" xmlns:dc="http://purl.org/dc/terms/" xmlns:dwc="http://rs.tdwg.org/dwc/terms/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://rs.tdwg.org/dwc/xsd/simpledarwincore/ http://rs.tdwg.org/dwc/xsd/tdwg_dwc_simple.xsd"> <SimpleDarwinRecordSet xmlns="http://rs.tdwg.org/dwc/xsd/simpledarwincore/" xmlns:dc="http://purl.org/dc/terms/" xmlns:dwc="http://rs.tdwg.org/dwc/terms/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://rs.tdwg.org/dwc/xsd/simpledarwincore/ http://rs.tdwg.org/dwc/xsd/tdwg_dwc_simple.xsd">
<SimpleDarwinRecord> <SimpleDarwinRecord>

24
plugins/DemoFormBuilder.inc

@ -1,21 +1,34 @@
<?php <?php
// $Id$ // $Id$
module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder'); /**
/* * @file
* Created on 19-Feb-08
*
* *
*/
module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder');
/**
* implements methods from content model ingest form xml * implements methods from content model ingest form xml
* builds a dc metadata form * builds a dc metadata form
*/ */
class DemoFormBuilder extends FormBuilder { class DemoFormBuilder extends FormBuilder {
/**
* Constructor
*/
function DemoFormBuilder() { function DemoFormBuilder() {
module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder'); module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder');
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
} }
//Override this so we can specify the datastream id of FULL_SIZE should make this easier /**
* Override this so we can specify the datastream id of FULL_SIZE should make this easier
* @global type $base_url
* @param type $form_values
* @param type $dom
* @param type $rootElement
*/
function createFedoraDataStreams($form_values, &$dom, &$rootElement) { function createFedoraDataStreams($form_values, &$dom, &$rootElement) {
module_load_include('inc', 'fedora_repository', 'MimeClass'); module_load_include('inc', 'fedora_repository', 'MimeClass');
global $base_url; global $base_url;
@ -73,5 +86,6 @@ class DemoFormBuilder extends FormBuilder {
} }
} }
} }
} }

20
plugins/DocumentConverter.inc

@ -3,20 +3,35 @@
// $Id$ // $Id$
/** /**
* * @file
* Document Converter Class
*/
/**
* This class implements document (doc, odt, pdf, etc.) conversion for a generic * This class implements document (doc, odt, pdf, etc.) conversion for a generic
* multi-format document collection. * multi-format document collection.
*/ */
class DocumentConverter { class DocumentConverter {
private $converter_service_url = "http://localhost:8080/converter/service"; private $converter_service_url = "http://localhost:8080/converter/service";
/**
* Constructor
* @param type $converter_url
*/
public function __construct($converter_url = NULL) { public function __construct($converter_url = NULL) {
if (!empty($converter_url)) if (!empty($converter_url))
$this->converter_service_url = $converter_url; $this->converter_service_url = $converter_url;
} }
/**
* Convert ???
* @param type $parameterArray
* @param type $dsid
* @param type $file
* @param type $output_ext
* @return string
*/
function convert($parameterArray = NULL, $dsid, $file, $output_ext) { function convert($parameterArray = NULL, $dsid, $file, $output_ext) {
module_load_include('inc', 'fedora_repository', 'MimeClass'); module_load_include('inc', 'fedora_repository', 'MimeClass');
@ -69,6 +84,7 @@ class DocumentConverter {
return FALSE; return FALSE;
} }
} }
} }
/* /*

27
plugins/Exiftool.inc

@ -1,17 +1,24 @@
<?php <?php
// $Id$ // $Id$
/* /**
* * @file
* * Exiftool
* This Class implements the methods defined in the STANDARD_IMAGE content model
*/ */
/**
* This Class implements the methods defined in the STANDARD_IMAGE content model
*/
class Exiftool { class Exiftool {
private $pid = NULL; private $pid = NULL;
private $item = NULL; private $item = NULL;
/**
* Constructor
* @param type $pid
*/
function __construct($pid) { function __construct($pid) {
//drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); //drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$this->pid = $pid; $this->pid = $pid;
@ -19,6 +26,14 @@ class Exiftool {
$this->item = new Fedora_Item($this->pid); $this->item = new Fedora_Item($this->pid);
} }
/**
* extract metadata ??
* @param type $parameterArray
* @param type $dsid
* @param type $file
* @param type $file_ext
* @return type
*/
function extractMetadata($parameterArray, $dsid, $file, $file_ext) { function extractMetadata($parameterArray, $dsid, $file, $file_ext) {
$system = getenv('System'); $system = getenv('System');
$file_suffix = '_' . $dsid . '.xml'; $file_suffix = '_' . $dsid . '.xml';
@ -30,6 +45,10 @@ class Exiftool {
return TRUE; return TRUE;
} }
/**
* display metadata ???
* @return type
*/
function displayMetadata() { function displayMetadata() {
$output = ''; $output = '';
$exif = $this->item->get_datastream_dissemination('EXIF'); $exif = $this->item->get_datastream_dissemination('EXIF');

25
plugins/Ffmpeg.inc

@ -1,16 +1,34 @@
<?php <?php
// $Id$ // $Id$
/* /**
* * @file
* Ffmpeg wrapper class
*/
/**
* FFMpeg wrapper class for generating movie thumbnails
* *
* This Class implements the methods defined in the STANDARD_QT content model * This Class implements the methods defined in the STANDARD_QT content model
*/ */
class Ffmpeg { class Ffmpeg {
/**
* Default constructor
*/
function Ffmpeg() { function Ffmpeg() {
} }
/**
* Extract a thumbnail from the movie
* @param type $parameterArray
* @param type $dsid
* @param type $file
* @param type $file_ext
* @return type
*/
function extract_thumbnail($parameterArray, $dsid, $file, $file_ext) { function extract_thumbnail($parameterArray, $dsid, $file, $file_ext) {
$defaults = array('ss' => '00:00:10', 's' => null); $defaults = array('ss' => '00:00:10', 's' => null);
$params = array_merge($defaults, $parameterArray); $params = array_merge($defaults, $parameterArray);
@ -32,4 +50,5 @@ class Ffmpeg {
$_SESSION['fedora_ingest_files']["$dsid"] = $file . $file_suffix; $_SESSION['fedora_ingest_files']["$dsid"] = $file . $file_suffix;
return TRUE; return TRUE;
} }
} }

55
plugins/Flv.inc

@ -1,18 +1,31 @@
<?php <?php
// $Id$ // $Id$
/* /**
* Created on 19-Feb-08 * @file
* * Form Builder class
* */
/**
* implements method from content model ingest form xml * implements method from content model ingest form xml
*/ */
class FormBuilder { class FormBuilder {
/**
* Constructor
*/
function FormBuilder() { function FormBuilder() {
module_load_include('inc', 'Flv', ''); module_load_include('inc', 'Flv', '');
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
} }
/**
* Create QDC Stream ???
* @param type $form_values
* @param type $dom
* @param type $rootElement
*/
function createQDCStream($form_values, &$dom, &$rootElement) { function createQDCStream($form_values, &$dom, &$rootElement) {
$datastream = $dom->createElement("foxml:datastream"); $datastream = $dom->createElement("foxml:datastream");
$datastream->setAttribute("ID", "QDC"); $datastream->setAttribute("ID", "QDC");
@ -52,8 +65,7 @@ class FormBuilder {
$previousElement = $dom->createElement($key, $value); $previousElement = $dom->createElement($key, $value);
$oai->appendChild($previousElement); $oai->appendChild($previousElement);
} }
} } catch (exception $e) {
catch (exception $e) {
drupal_set_message(t("!e", array('!e' => $e->getMessage())), 'error'); drupal_set_message(t("!e", array('!e' => $e->getMessage())), 'error');
continue; continue;
} }
@ -62,6 +74,11 @@ class FormBuilder {
} }
} }
/**
* Handle QDC Form ???
* @param type $form_values
* @return type
*/
function handleQDCForm($form_values) { function handleQDCForm($form_values) {
$dom = new DomDocument("1.0", "UTF-8"); $dom = new DomDocument("1.0", "UTF-8");
$dom->formatOutput = TRUE; $dom->formatOutput = TRUE;
@ -102,13 +119,18 @@ class FormBuilder {
} }
unlink($form_values['fullpath']); unlink($form_values['fullpath']);
} }
} } catch (exception $e) {
catch (exception $e) {
drupal_set_message(t('Error ingesting object: !e', array('!e' => $e->getMessage())), 'error'); drupal_set_message(t('Error ingesting object: !e', array('!e' => $e->getMessage())), 'error');
return; return;
} }
} }
/**
* Create Fedora DataStream
* @param type $form_values
* @param type $dom
* @param type $rootElement
*/
function createFedoraDataStreams($form_values, &$dom, &$rootElement) { function createFedoraDataStreams($form_values, &$dom, &$rootElement) {
module_load_include('inc', 'fedora_repository', 'MimeClass'); module_load_include('inc', 'fedora_repository', 'MimeClass');
$mimetype = new MimeClass(); $mimetype = new MimeClass();
@ -161,6 +183,9 @@ class FormBuilder {
/** /**
* creates the RELS-EXT for the foxml * creates the RELS-EXT for the foxml
* @param type $form_values
* @param type $dom
* @param type $rootElement
*/ */
function createRelationShips($form_values, &$dom, &$rootElement) { function createRelationShips($form_values, &$dom, &$rootElement) {
$drdf = $dom->createElement("foxml:datastream"); $drdf = $dom->createElement("foxml:datastream");
@ -190,11 +215,13 @@ class FormBuilder {
$rdf->appendChild($rdfdesc); $rdf->appendChild($rdfdesc);
$rdfdesc->appendChild($member); $rdfdesc->appendChild($member);
$rootElement->appendChild($drdf); $rootElement->appendChild($drdf);
} }
/** /**
* creates the standard foxml properties * creates the standard foxml properties
* @param type $form_values
* @param type $dom
* @param type $rootElement
*/ */
function createStandardFedoraStuff($form_values, &$dom, &$rootElement) { function createStandardFedoraStuff($form_values, &$dom, &$rootElement) {
/* foxml object properties section */ /* foxml object properties section */
@ -222,7 +249,13 @@ class FormBuilder {
$rootElement->appendChild($objproperties); $rootElement->appendChild($objproperties);
} }
/**
* Build QDC Form
* @param type $form
* @param type $ingest_form_definition
* @param type $form_values
* @return type
*/
function buildQDCForm(&$form, $ingest_form_definition, &$form_values) { function buildQDCForm(&$form, $ingest_form_definition, &$form_values) {
$form['indicator2'] = array( $form['indicator2'] = array(
'#type' => 'fieldset', '#type' => 'fieldset',
@ -253,7 +286,6 @@ class FormBuilder {
'#type' => $type, '#type' => $type,
'#options' => $options, '#options' => $options,
); );
} }
else { else {
$form['indicator2']["$name"] = array( $form['indicator2']["$name"] = array(
@ -269,3 +301,4 @@ class FormBuilder {
} }
} }

18
plugins/FlvFormBuilder.inc

@ -1,20 +1,33 @@
<?php <?php
// $Id$ // $Id$
/**
* @file
* FLVFormBuilder
*/
module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder'); module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder');
/* /**
* implements methods from content model ingest form xml * implements methods from content model ingest form xml
* builds a dc metadata form * builds a dc metadata form
*/ */
class FlvFormBuilder extends FormBuilder { class FlvFormBuilder extends FormBuilder {
/**
* Constructor
*/
function FlvFormBuilder() { function FlvFormBuilder() {
module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder'); module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder');
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
} }
/* /**
* method overrides method in FormBuilder. We changed the dsid from OBJ to FLV and added the TN datastream * method overrides method in FormBuilder. We changed the dsid from OBJ to FLV and added the TN datastream
* @global type $base_url
* @param type $form_values
* @param type $dom
* @param type $rootElement
*/ */
function createFedoraDataStreams($form_values, &$dom, &$rootElement) { function createFedoraDataStreams($form_values, &$dom, &$rootElement) {
module_load_include('inc', 'fedora_repository', 'MimeClass'); module_load_include('inc', 'fedora_repository', 'MimeClass');
@ -60,5 +73,6 @@ class FlvFormBuilder extends FormBuilder {
$ds1v->appendChild($ds1content); $ds1v->appendChild($ds1content);
$rootElement->appendChild($ds1); $rootElement->appendChild($ds1);
} }
} }

79
plugins/FormBuilder.inc

@ -2,19 +2,31 @@
// $Id$ // $Id$
/* /**
* Created on 19-Feb-08 * @file
* * FormBuilder class
* */
/**
* implements methods from content model ingest form xml * implements methods from content model ingest form xml
* builds a dc metadata form * builds a dc metadata form
*/ */
class FormBuilder { class FormBuilder {
/**
* Constructor
*/
function FormBuilder() { function FormBuilder() {
module_load_include('inc', 'FormBuilder', ''); module_load_include('inc', 'FormBuilder', '');
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
} }
/**
* Create QDC Stream ??
* @param type $form_values
* @param type $dom
* @param type $rootElement
*/
function createQDCStream($form_values, &$dom, &$rootElement) { function createQDCStream($form_values, &$dom, &$rootElement) {
$datastream = $dom->createElement("foxml:datastream"); $datastream = $dom->createElement("foxml:datastream");
$datastream->setAttribute("ID", "DC"); $datastream->setAttribute("ID", "DC");
@ -55,18 +67,22 @@ class FormBuilder {
$previousElement = $dom->createElement($key, $value); $previousElement = $dom->createElement($key, $value);
$oai->appendChild($previousElement); $oai->appendChild($previousElement);
} }
} } catch (exception $e) {
catch (exception $e) {
drupal_set_message(t("!e", array('!e' => $e->getMessage())), 'error'); drupal_set_message(t("!e", array('!e' => $e->getMessage())), 'error');
continue; continue;
} }
} }
$rootElement->appendChild($datastream); $rootElement->appendChild($datastream);
} }
} }
//create the security Policy /**
* Create the security policy
* @param type $collectionPid
* @param type $dom
* @param type $rootElement
* @return type
*/
function createPolicy($collectionPid, &$dom, &$rootElement) { function createPolicy($collectionPid, &$dom, &$rootElement) {
module_load_include('inc', 'fedora_repository', 'ObjectHelper'); module_load_include('inc', 'fedora_repository', 'ObjectHelper');
$objectHelper = new ObjectHelper(); $objectHelper = new ObjectHelper();
@ -78,8 +94,7 @@ class FormBuilder {
} }
try { try {
$xml = new SimpleXMLElement($policyStreamDoc); $xml = new SimpleXMLElement($policyStreamDoc);
} } catch (Exception $e) {
catch (Exception $e) {
watchdog(t("Fedora_Repository"), t("Problem getting security policy."), NULL, WATCHDOG_ERROR); watchdog(t("Fedora_Repository"), t("Problem getting security policy."), NULL, WATCHDOG_ERROR);
drupal_set_message(t('Problem getting security policy: !e', array('!e' => $e->getMessage())), 'error'); drupal_set_message(t('Problem getting security policy: !e', array('!e' => $e->getMessage())), 'error');
return FALSE; return FALSE;
@ -114,7 +129,11 @@ class FormBuilder {
return TRUE; return TRUE;
} }
/**
* Handle QDC Form ??
* @param type $form_values
* @return type
*/
function handleQDCForm($form_values) { function handleQDCForm($form_values) {
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
module_load_include('inc', 'fedora_repository', 'CollectionPolicy'); module_load_include('inc', 'fedora_repository', 'CollectionPolicy');
@ -162,14 +181,20 @@ class FormBuilder {
} }
} }
file_delete($form_values['ingest-file-location']); file_delete($form_values['ingest-file-location']);
} } catch (exception $e) {
catch (exception $e) {
drupal_set_message(t('Error ingesting object: !e', array('!e' => $e->getMessage())), 'error'); drupal_set_message(t('Error ingesting object: !e', array('!e' => $e->getMessage())), 'error');
watchdog(t("Fedora_Repository"), t("Error ingesting object: !e", array('!e' => $e->getMessage())), NULL, WATCHDOG_ERROR); watchdog(t("Fedora_Repository"), t("Error ingesting object: !e", array('!e' => $e->getMessage())), NULL, WATCHDOG_ERROR);
return; return;
} }
} }
/**
* Create Fedora Data stream
* @global type $base_url
* @param type $form_values
* @param type $dom
* @param type $rootElement
*/
function createFedoraDataStreams($form_values, &$dom, &$rootElement) { function createFedoraDataStreams($form_values, &$dom, &$rootElement) {
module_load_include('inc', 'fedora_repository', 'MimeClass'); module_load_include('inc', 'fedora_repository', 'MimeClass');
global $base_url; global $base_url;
@ -208,11 +233,8 @@ class FormBuilder {
} }
if (!empty($_SESSION['fedora_ingest_files'])) { if (!empty($_SESSION['fedora_ingest_files'])) {
foreach ($_SESSION['fedora_ingest_files'] as $dsid => $createdFile) { foreach ($_SESSION['fedora_ingest_files'] as $dsid => $createdFile) {
if (!empty($file)) { if (!empty($file)) {
$found = strstr($createdFile, $file); $found = strstr($createdFile, $file);
if ($found !== FALSE) { if ($found !== FALSE) {
@ -250,9 +272,11 @@ class FormBuilder {
} }
} }
/** /**
* Creates the RELS-EXT for the foxml * Creates the RELS-EXT for the foxml
* @param type $form_values
* @param type $dom
* @param type $rootElement
*/ */
function createRelationShips($form_values, &$dom, &$rootElement) { function createRelationShips($form_values, &$dom, &$rootElement) {
$drdf = $dom->createElement("foxml:datastream"); $drdf = $dom->createElement("foxml:datastream");
@ -293,9 +317,11 @@ class FormBuilder {
$rootElement->appendChild($drdf); $rootElement->appendChild($drdf);
} }
/** /**
* Creates the standard foxml properties * Creates the standard foxml properties
* @param type $form_values
* @param type $dom
* @param type $rootElement
*/ */
function createStandardFedoraStuff($form_values, &$dom, &$rootElement) { function createStandardFedoraStuff($form_values, &$dom, &$rootElement) {
// Foxml object properties section // Foxml object properties section
@ -315,7 +341,13 @@ class FormBuilder {
$rootElement->appendChild($objproperties); $rootElement->appendChild($objproperties);
} }
/**
* Build QDC Form
* @param type $form
* @param type $elements
* @param type $form_values
* @return string
*/
function buildQDCForm(&$form, $elements, &$form_values) { function buildQDCForm(&$form, $elements, &$form_values) {
$form['#multistep'] = TRUE; // used so that it triggers a form rebuild every time. $form['#multistep'] = TRUE; // used so that it triggers a form rebuild every time.
$form['indicator2'] = array( $form['indicator2'] = array(
@ -327,7 +359,8 @@ class FormBuilder {
if ($element['type'] == 'markup') { if ($element['type'] == 'markup') {
$el = array('#value' => $element['description']); $el = array('#value' => $element['description']);
} else { }
else {
$el = array( $el = array(
'#title' => $element['label'], '#title' => $element['label'],
'#required' => ($element['required'] ? 1 : 0), '#required' => ($element['required'] ? 1 : 0),
@ -347,9 +380,11 @@ class FormBuilder {
foreach ($element['parameters'] as $key => $val) { foreach ($element['parameters'] as $key => $val) {
if ($key == '#autocomplete_path') { if ($key == '#autocomplete_path') {
$autocomplete_path = $val; $autocomplete_path = $val;
} elseif ($key == '#autocomplete_omit_collection') { }
elseif ($key == '#autocomplete_omit_collection') {
$autocomplete_omit_collection = TRUE; $autocomplete_omit_collection = TRUE;
} else { }
else {
$el[$key] = $val; $el[$key] = $val;
} }
} }

65
plugins/ImageManipulation.inc

@ -2,18 +2,31 @@
// $Id$ // $Id$
/* /**
* * @file
* * Image Manipulation class
* This Class implements the methods defined in the STANDARD_IMAGE content model
*/ */
/**
* This Class implements the methods defined in the STANDARD_IMAGE content model
*/
class ImageManipulation { class ImageManipulation {
/**
* Constructor
*/
function ImageManipulation() { function ImageManipulation() {
module_load_include('inc', 'fedora_repository', 'ObjectHelper'); module_load_include('inc', 'fedora_repository', 'ObjectHelper');
} }
/**
* Create a preview ??
* @param type $parameterArray
* @param type $dsid
* @param type $file
* @param type $file_ext
* @return string
*/
function createPreview($parameterArray, $dsid, $file, $file_ext) { function createPreview($parameterArray, $dsid, $file, $file_ext) {
$system = getenv('System'); $system = getenv('System');
$file_suffix = '_' . $dsid . '.' . $file_ext; $file_suffix = '_' . $dsid . '.' . $file_ext;
@ -21,7 +34,8 @@ class ImageManipulation {
if (!isset($parameterArray['height'])) { if (!isset($parameterArray['height'])) {
$height = $width; $height = $width;
} else { }
else {
$height = $parameterArray['height']; $height = $parameterArray['height'];
} }
@ -49,6 +63,14 @@ class ImageManipulation {
} }
} }
/**
* Create PNG
* @param type $parameterArray
* @param type $dsid
* @param type $file
* @param type $file_ext
* @return string
*/
function createPNG($parameterArray = NULL, $dsid, $file, $file_ext) { function createPNG($parameterArray = NULL, $dsid, $file, $file_ext) {
$file_suffix = '_' . $dsid . '.' . $file_ext; $file_suffix = '_' . $dsid . '.' . $file_ext;
$returnValue = TRUE; $returnValue = TRUE;
@ -69,6 +91,14 @@ class ImageManipulation {
} }
} }
/**
* Create JPEG 2000
* @param type $parameterArray
* @param type $dsid
* @param type $file
* @param type $file_ext
* @return type
*/
function createJP2($parameterArray = NULL, $dsid, $file, $file_ext) { function createJP2($parameterArray = NULL, $dsid, $file, $file_ext) {
$file_suffix = "_$dsid.$file_ext"; $file_suffix = "_$dsid.$file_ext";
$return_value = TRUE; $return_value = TRUE;
@ -115,7 +145,14 @@ class ImageManipulation {
} }
} }
//use imagemapi to manipulate images instead of going directly to imagemagick or whatever /**
* use imagemapi to manipulate images instead of going directly to imagemagick or whatever
* @param type $parameterArray
* @param type $dsid
* @param type $file
* @param type $file_ext
* @return type
*/
function manipulateImage($parameterArray = NULL, $dsid, $file, $file_ext) { function manipulateImage($parameterArray = NULL, $dsid, $file, $file_ext) {
$height = $parameterArray['height']; $height = $parameterArray['height'];
$width = $parameterArray['width']; $width = $parameterArray['width'];
@ -151,6 +188,14 @@ class ImageManipulation {
} }
} }
/**
* Create Thumbnail from PDF
* @param type $parameterArray
* @param type $dsid
* @param type $file
* @param type $file_ext
* @return boolean
*/
function createThumbnailFromPDF($parameterArray, $dsid, $file, $file_ext) { function createThumbnailFromPDF($parameterArray, $dsid, $file, $file_ext) {
$height = $parameterArray['height']; $height = $parameterArray['height'];
$width = $parameterArray['width']; $width = $parameterArray['width'];
@ -185,6 +230,14 @@ class ImageManipulation {
} }
} }
/**
* Create Thumbnail
* @param type $parameterArray
* @param type $dsid
* @param type $file
* @param type $file_ext
* @return boolean
*/
function createThumbnail($parameterArray, $dsid, $file, $file_ext) { function createThumbnail($parameterArray, $dsid, $file, $file_ext) {
// var_dump($parameterArray);exit(0); // var_dump($parameterArray);exit(0);
$file_suffix = '_' . $dsid . '.' . $file_ext; $file_suffix = '_' . $dsid . '.' . $file_ext;

155
plugins/ModsFormBuilder.inc

@ -2,18 +2,29 @@
// $Id$ // $Id$
/**
* @file
* ModsFormBuilder class
*/
module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder'); module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder');
/**
* ModsFormBuilder class ???
*/
class ModsFormBuilder extends FormBuilder { class ModsFormBuilder extends FormBuilder {
static $MODS_NS = 'http://www.loc.gov/mods/v3'; static $MODS_NS = 'http://www.loc.gov/mods/v3';
protected $cm; protected $cm;
protected $item; protected $item;
protected $pid; protected $pid;
function __construct($pid=null) /**
{ * Constructor
* @param type $pid
*/
function __construct($pid=null) {
parent::__construct(); parent::__construct();
if ($pid !== null) if ($pid !== null) {
{
module_load_include('inc', 'fedora_repository', 'ContentModel'); module_load_include('inc', 'fedora_repository', 'ContentModel');
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
@ -23,8 +34,13 @@ class ModsFormBuilder extends FormBuilder {
} }
} }
function handleEditMetadataForm(&$form_id, &$form_values, &$soap_client) /**
{ * Handle Edit Metadata Form ???
* @param &$form_id
* @param &$form_values
* @param &$soap_client
*/
function handleEditMetadataForm(&$form_id, &$form_values, &$soap_client) {
$dom = new DomDocument("1.0", "UTF-8"); $dom = new DomDocument("1.0", "UTF-8");
$dom->formatOutput = TRUE; $dom->formatOutput = TRUE;
$mods = $this->modsFromForm($form_values, $dom); $mods = $this->modsFromForm($form_values, $dom);
@ -36,8 +52,11 @@ class ModsFormBuilder extends FormBuilder {
drupal_goto('/fedora/repository/' . $this->pid); drupal_goto('/fedora/repository/' . $this->pid);
} }
function buildEditMetadataForm() /**
{ * Build Edit Metadata Form
* @return array
*/
function buildEditMetadataForm() {
$form['#multistep'] = TRUE; // used so that it triggers a form rebuild every time. $form['#multistep'] = TRUE; // used so that it triggers a form rebuild every time.
$form['indicator2'] = array( $form['indicator2'] = array(
'#type' => 'fieldset', '#type' => 'fieldset',
@ -92,25 +111,24 @@ class ModsFormBuilder extends FormBuilder {
// echo $nodeList->item(0)->nodeValue.' '; // echo $nodeList->item(0)->nodeValue.' ';
// echo '<br/>'; // echo '<br/>';
if (is_string($nodeList)) if (is_string($nodeList)) {
{
$el['#default_value'] = $nodeList; $el['#default_value'] = $nodeList;
} else if ($nodeList->length > 1) }
{ else if ($nodeList->length > 1) {
$el['#default_value'] = array(); $el['#default_value'] = array();
foreach ($nodeList as $node) foreach ($nodeList as $node) {
{
$el['#default_value'][] = $node->nodeValue; $el['#default_value'][] = $node->nodeValue;
} }
} else if ($nodeList->length > 0) }
{ else if ($nodeList->length > 0) {
if ($el['#type'] == 'list') { if ($el['#type'] == 'list') {
$values = array(); $values = array();
for ($i = 0; $i < $nodeList->length; $i++) { for ($i = 0; $i < $nodeList->length; $i++) {
$values[] = $nodeList->item($i)->nodeValue; $values[] = $nodeList->item($i)->nodeValue;
} }
$el['#default_value'] = join('; ', $values); $el['#default_value'] = join('; ', $values);
} else { }
else {
$el['#default_value'] = $nodeList->item(0)->nodeValue; $el['#default_value'] = $nodeList->item(0)->nodeValue;
} }
} }
@ -120,11 +138,9 @@ class ModsFormBuilder extends FormBuilder {
if ($key != '#sticky') { if ($key != '#sticky') {
$el[$key] = $val; $el[$key] = $val;
} }
} }
if ($element['type'] == 'people') if ($element['type'] == 'people') {
{
$names = $xpath->evaluate('/mods:mods/mods:name'); $names = $xpath->evaluate('/mods:mods/mods:name');
$people = array(); $people = array();
@ -134,20 +150,23 @@ class ModsFormBuilder extends FormBuilder {
$role = $mname->getElementsByTagName('roleTerm')->item(0)->nodeValue; $role = $mname->getElementsByTagName('roleTerm')->item(0)->nodeValue;
$nameParts = $mname->getElementsByTagName('namePart'); $nameParts = $mname->getElementsByTagName('namePart');
foreach ($nameParts as $namePart) foreach ($nameParts as $namePart) {
{
switch ($namePart->getAttribute('type')) { switch ($namePart->getAttribute('type')) {
case 'given': $given = $namePart->nodeValue; break; case 'given': $given = $namePart->nodeValue;
case 'family': $family = $namePart->nodeValue; break; break;
case 'termsOfAddress': $title = $namePart->nodeValue; break; case 'family': $family = $namePart->nodeValue;
case 'date': $date = $namePart->nodeValue; break; break;
default: $name = $namePart->nodeValue; break; case 'termsOfAddress': $title = $namePart->nodeValue;
break;
case 'date': $date = $namePart->nodeValue;
break;
default: $name = $namePart->nodeValue;
break;
} }
} }
$person = array('role' => $role); $person = array('role' => $role);
switch ($type) switch ($type) {
{
case 'personal': case 'personal':
if (isset($given) && isset($family) && !isset($name)) { if (isset($given) && isset($family) && !isset($name)) {
$name = (isset($title) ? $title . ' ' : '') . $family . ', ' . $family; $name = (isset($title) ? $title . ' ' : '') . $family . ', ' . $family;
@ -172,20 +191,23 @@ class ModsFormBuilder extends FormBuilder {
$type = $mname->getAttribute('type'); $type = $mname->getAttribute('type');
$nameParts = $mname->getElementsByTagName('namePart'); $nameParts = $mname->getElementsByTagName('namePart');
foreach ($nameParts as $namePart) foreach ($nameParts as $namePart) {
{
switch ($namePart->getAttribute('type')) { switch ($namePart->getAttribute('type')) {
case 'given': $given = $namePart->nodeValue; break; case 'given': $given = $namePart->nodeValue;
case 'family': $family = $namePart->nodeValue; break; break;
case 'termsOfAddress': $title = $namePart->nodeValue; break; case 'family': $family = $namePart->nodeValue;
case 'date': $date = $namePart->nodeValue; break; break;
default: $name = $namePart->nodeValue; break; case 'termsOfAddress': $title = $namePart->nodeValue;
break;
case 'date': $date = $namePart->nodeValue;
break;
default: $name = $namePart->nodeValue;
break;
} }
} }
$person = array('subject' => 1); $person = array('subject' => 1);
switch ($type) switch ($type) {
{
case 'personal': case 'personal':
if (isset($given) && isset($family) && !isset($name)) { if (isset($given) && isset($family) && !isset($name)) {
$name = (isset($title) ? $title . ' ' : '') . $family . ', ' . $family; $name = (isset($title) ? $title . ' ' : '') . $family . ', ' . $family;
@ -205,7 +227,6 @@ class ModsFormBuilder extends FormBuilder {
} }
$el['#default_value'] = $people; $el['#default_value'] = $people;
} }
@ -225,12 +246,15 @@ class ModsFormBuilder extends FormBuilder {
); );
return $form; return $form;
} }
} }
} }
/**
* Handle Mods Form
* @param &$form_values
* @param &$form_state
*/
function handleModsForm(&$form_values, &$form_state) { function handleModsForm(&$form_values, &$form_state) {
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
module_load_include('inc', 'fedora_repository', 'CollectionPolicy'); module_load_include('inc', 'fedora_repository', 'CollectionPolicy');
@ -291,15 +315,19 @@ class ModsFormBuilder extends FormBuilder {
} }
} }
file_delete($form_values['ingest-file-location']); file_delete($form_values['ingest-file-location']);
} } catch (exception $e) {
catch (exception $e) {
drupal_set_message(t('Error ingesting object: !e', array('!e' => $e->getMessage())), 'error'); drupal_set_message(t('Error ingesting object: !e', array('!e' => $e->getMessage())), 'error');
watchdog(t("Fedora_Repository"), t("Error ingesting object: !e", array('!e' => $e->getMessage())), NULL, WATCHDOG_ERROR); watchdog(t("Fedora_Repository"), t("Error ingesting object: !e", array('!e' => $e->getMessage())), NULL, WATCHDOG_ERROR);
return; return;
} }
} }
/**
* Create Collection Policy ??
* @param $form_values
* @param &$dom
* @param &$rootElement
*/
function createCollectionPolicy($form_values, &$dom, &$rootElement) { function createCollectionPolicy($form_values, &$dom, &$rootElement) {
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$model = new fedora_item($form_values['content_model_pid']); $model = new fedora_item($form_values['content_model_pid']);
@ -329,6 +357,12 @@ class ModsFormBuilder extends FormBuilder {
} }
} }
/**
* Create Workflow Stream ??
* @param $form_values
* @param &$dom
* @param &$rootElement
*/
function createWorkflowStream($form_values, &$dom, &$rootElement) { function createWorkflowStream($form_values, &$dom, &$rootElement) {
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$model = new fedora_item($form_values['content_model_pid']); $model = new fedora_item($form_values['content_model_pid']);
@ -358,6 +392,12 @@ class ModsFormBuilder extends FormBuilder {
} }
} }
/**
* Create mods Stream ??
* @param $form_values
* @param &$dom
* @param &$rootElement
*/
function createModsStream($form_values, &$dom, &$rootElement) { function createModsStream($form_values, &$dom, &$rootElement) {
$datastream = $dom->createElement("foxml:datastream"); $datastream = $dom->createElement("foxml:datastream");
@ -378,9 +418,13 @@ class ModsFormBuilder extends FormBuilder {
$rootElement->appendChild($datastream); $rootElement->appendChild($datastream);
} }
/**
function modsFromForm(&$form_values,&$dom) * Mods From From ?????
{ * @param type $form_values
* @param type $dom
* @return type
*/
function modsFromForm(&$form_values, &$dom) {
///begin writing MODS ///begin writing MODS
$mods = $dom->createElement("mods:mods"); $mods = $dom->createElement("mods:mods");
@ -489,7 +533,8 @@ class ModsFormBuilder extends FormBuilder {
} }
$originInfo->appendChild($date); $originInfo->appendChild($date);
$addOriginInfo = TRUE; $addOriginInfo = TRUE;
} else { }
else {
if (isset($form_values['mods_createdDate'])) { if (isset($form_values['mods_createdDate'])) {
$date = $dom->createElement('mods:createdDate', htmlspecialchars(trim($form_values['mods_createdDate']))); $date = $dom->createElement('mods:createdDate', htmlspecialchars(trim($form_values['mods_createdDate'])));
$originInfo->appendChild($date); $originInfo->appendChild($date);
@ -513,7 +558,6 @@ class ModsFormBuilder extends FormBuilder {
$originInfo->appendChild($date); $originInfo->appendChild($date);
$addOriginInfo = TRUE; $addOriginInfo = TRUE;
} }
} }
if (isset($form_values['mods_pubinfo_journalFreq']) && trim($form_values['mods_pubinfo_journalFreq']) != '') { if (isset($form_values['mods_pubinfo_journalFreq']) && trim($form_values['mods_pubinfo_journalFreq']) != '') {
@ -550,11 +594,9 @@ class ModsFormBuilder extends FormBuilder {
} }
if (isset($form_values['mods_language']) && trim($form_values['mods_language']) != '') if (isset($form_values['mods_language']) && trim($form_values['mods_language']) != '') {
{
$languageList = explode(';', htmlspecialchars($form_values['mods_language'])); $languageList = explode(';', htmlspecialchars($form_values['mods_language']));
foreach ($languageList as $lang) foreach ($languageList as $lang) {
{
$language = $dom->createElement('mods:language'); $language = $dom->createElement('mods:language');
$langTerm = $dom->createElement('mods:languageTerm', htmlspecialchars($lang)); $langTerm = $dom->createElement('mods:languageTerm', htmlspecialchars($lang));
$langTerm->setAttribute('type', 'text'); $langTerm->setAttribute('type', 'text');
@ -637,6 +679,7 @@ class ModsFormBuilder extends FormBuilder {
$modifications = trim($form_values['mods_cc']['cc']['cc_modifications']); $modifications = trim($form_values['mods_cc']['cc']['cc_modifications']);
$jurisdiction = trim($form_values['mods_cc']['cc']['cc_jurisdiction']); $jurisdiction = trim($form_values['mods_cc']['cc']['cc_jurisdiction']);
// Include islandora form elements only if needed ??
module_load_include('inc', 'islandora_form_elements', 'includes/creative_commons.inc'); module_load_include('inc', 'islandora_form_elements', 'includes/creative_commons.inc');
if (!isset(CreativeCommons::$cc_jurisdiction_vals[$jurisdiction])) if (!isset(CreativeCommons::$cc_jurisdiction_vals[$jurisdiction]))
@ -648,8 +691,6 @@ class ModsFormBuilder extends FormBuilder {
$accessCondition = $dom->createElement('mods:accessCondition', htmlspecialchars($license)); $accessCondition = $dom->createElement('mods:accessCondition', htmlspecialchars($license));
$accessCondition->setAttribute('type', 'Creative Commons License'); $accessCondition->setAttribute('type', 'Creative Commons License');
$mods->appendChild($accessCondition); $mods->appendChild($accessCondition);
} }
if (isset($form_values['mods_rights']) && trim($form_values['mods_rights']) != '') { if (isset($form_values['mods_rights']) && trim($form_values['mods_rights']) != '') {
@ -706,11 +747,11 @@ class ModsFormBuilder extends FormBuilder {
if (isset($val['subject'])) { if (isset($val['subject'])) {
$subject->appendChild($name); $subject->appendChild($name);
$hasSubject = TRUE; $hasSubject = TRUE;
} else { }
else {
$mods->appendChild($name); $mods->appendChild($name);
} }
} }
} }
} }

64
plugins/PersonalCollectionClass.inc

@ -1,11 +1,31 @@
<?php <?php
// $Id$ // $Id$
/**
* @file
* PersonalCollectionClass class
*/
/**
* Personal Collection Class
*/
class PersonalCollectionClass { class PersonalCollectionClass {
/**
* Constructor
*/
function PersonalCollectionClass() { function PersonalCollectionClass() {
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
} }
/**
* Create collection
* @param type $theUser
* @param type $pid
* @param type $soapClient
* @return type
*/
function createCollection($theUser, $pid, $soapClient) { function createCollection($theUser, $pid, $soapClient) {
$dom = new DomDocument("1.0", "UTF-8"); $dom = new DomDocument("1.0", "UTF-8");
$dom->formatOutput = TRUE; $dom->formatOutput = TRUE;
@ -36,21 +56,25 @@ class PersonalCollectionClass {
$object = $soapClient->__soapCall('ingest', array( $object = $soapClient->__soapCall('ingest', array(
$params $params
)); ));
} catch (exception $e) {
}
catch (exception $e) {
drupal_set_message(t('Error ingesting personal collection object: !e', array('!e' => $e->getMessage())), 'error'); drupal_set_message(t('Error ingesting personal collection object: !e', array('!e' => $e->getMessage())), 'error');
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
} }
/**
* Create Collection Policy Stream ??
* @param type $user
* @param type $dom
* @param type $rootElement
* @return type
*/
function createCollectionPolicyStream($user, $dom, $rootElement) { function createCollectionPolicyStream($user, $dom, $rootElement) {
$collectionTemplate = file_get_contents(drupal_get_path('module', 'Fedora_Repository') . '/collection_policies/PERSONAL-COLLECTION-POLICY.xml'); $collectionTemplate = file_get_contents(drupal_get_path('module', 'Fedora_Repository') . '/collection_policies/PERSONAL-COLLECTION-POLICY.xml');
try { try {
$xml = new SimpleXMLElement($collectionTemplate); $xml = new SimpleXMLElement($collectionTemplate);
} } catch (Exception $e) {
catch (Exception $e) {
watchdog(t("Fedora_Repository"), t("Problem creating personal collection policy, could not parse collection policy stream."), NULL, WATCHDOG_ERROR); watchdog(t("Fedora_Repository"), t("Problem creating personal collection policy, could not parse collection policy stream."), NULL, WATCHDOG_ERROR);
drupal_set_message(t('Problem creating personal collection policy, could not parse collection policy stream: !e', array('!e' => $e->getMessage())), 'error'); drupal_set_message(t('Problem creating personal collection policy, could not parse collection policy stream: !e', array('!e' => $e->getMessage())), 'error');
return FALSE; return FALSE;
@ -88,6 +112,13 @@ class PersonalCollectionClass {
return TRUE; return TRUE;
} }
/**
* Create Policy Stream ??
* @param type $user
* @param type $dom
* @param type $rootElement
* @return type
*/
function createPolicyStream($user, $dom, $rootElement) { function createPolicyStream($user, $dom, $rootElement) {
module_load_include('inc', 'fedora_repository', 'SecurityClass'); module_load_include('inc', 'fedora_repository', 'SecurityClass');
@ -114,8 +145,14 @@ class PersonalCollectionClass {
return $this->createChildPolicyStream($dom, $rootElement, $policyStream->cloneNode(TRUE)); return $this->createChildPolicyStream($dom, $rootElement, $policyStream->cloneNode(TRUE));
} }
//right now this is the same as the policy stream for this object, may change /**
//objects in this collection will reference this datastream as their own POLICY stream * right now this is the same as the policy stream for this object, may change
* objects in this collection will reference this datastream as their own POLICY stream ???
* @param type $dom
* @param type $rootElement
* @param type $policyStream
* @return type
*/
function createChildPolicyStream($dom, $rootElement, $policyStream) { function createChildPolicyStream($dom, $rootElement, $policyStream) {
$ds1 = $dom->createElement("foxml:datastream"); $ds1 = $dom->createElement("foxml:datastream");
@ -135,6 +172,12 @@ class PersonalCollectionClass {
return TRUE; return TRUE;
} }
/**
* Create standard fedora stuff ??????????????????
* @param type $user
* @param type $dom
* @param type $rootElement
*/
function createStandardFedoraStuff($user, & $dom, & $rootElement) { function createStandardFedoraStuff($user, & $dom, & $rootElement) {
/* foxml object properties section */ /* foxml object properties section */
$objproperties = $dom->createElement("foxml:objectProperties"); $objproperties = $dom->createElement("foxml:objectProperties");
@ -161,6 +204,13 @@ class PersonalCollectionClass {
$rootElement->appendChild($objproperties); $rootElement->appendChild($objproperties);
} }
/**
* Create DC Stream ???
* @global type $user
* @param type $theUser
* @param type $dom
* @param type $rootElement
*/
function createDCStream($theUser, & $dom, & $rootElement) { function createDCStream($theUser, & $dom, & $rootElement) {
global $user; global $user;
$datastream = $dom->createElement("foxml:datastream"); $datastream = $dom->createElement("foxml:datastream");

35
plugins/QtFormBuilder.php

@ -1,21 +1,33 @@
<?php <?php
// $Id$
/**
* @file
* QTFormBuilder class
*/
module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder'); module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder');
/*
* /**
* * Implements methods from content model ingest form xml
*
* implements methods from content model ingest form xml
* builds a dc metadata form * builds a dc metadata form
*/ */
class QtFormBuilder extends FormBuilder { class QtFormBuilder extends FormBuilder {
/**
* Constructor
*/
function QtFormBuilder() { function QtFormBuilder() {
module_load_include('php', 'Fedora_Repository', 'plugins/FormBuilder'); module_load_include('php', 'Fedora_Repository', 'plugins/FormBuilder');
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
} }
/* /**
* method overrides method in FormBuilder. We changed the dsid from OBJ to OBJ and added the TN datastream * method overrides method in FormBuilder. We changed the dsid from OBJ to OBJ and added the TN datastream
* @global type $base_url
* @param type $form_values
* @param type $dom
* @param type $rootElement
*/ */
function createFedoraDataStreams($form_values, &$dom, &$rootElement) { function createFedoraDataStreams($form_values, &$dom, &$rootElement) {
module_load_include('inc', 'fedora_repository', 'MimeClass'); module_load_include('inc', 'fedora_repository', 'MimeClass');
@ -65,8 +77,6 @@ if(empty($_SESSION['fedora_ingest_files']) || !isset($_SESSION['fedora_ingest_fi
if (!empty($_SESSION['fedora_ingest_files'])) { if (!empty($_SESSION['fedora_ingest_files'])) {
foreach ($_SESSION['fedora_ingest_files'] as $dsid => $createdFile) { foreach ($_SESSION['fedora_ingest_files'] as $dsid => $createdFile) {
$createdFile = strstr($createdFile, $file); $createdFile = strstr($createdFile, $file);
$dformat = $mimetype->getType($createdFile); $dformat = $mimetype->getType($createdFile);
@ -91,12 +101,7 @@ if(empty($_SESSION['fedora_ingest_files']) || !isset($_SESSION['fedora_ingest_fi
$rootElement->appendChild($ds1); $rootElement->appendChild($ds1);
} }
} }
} }
} }
?> ?>

70
plugins/Refworks.inc

@ -1,25 +1,39 @@
<?php <?php
// $Id$ // $Id$
/* /**
* Created on 26-Feb-08 * @file
* * Refworks class
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/ */
module_load_include('inc', 'fedora_repository', 'SecurityClass'); module_load_include('inc', 'fedora_repository', 'SecurityClass');
/**
* Refworks class ???
*/
class Refworks { class Refworks {
private $romeoUrlString = ""; private $romeoUrlString = "";
private $referenceList; private $referenceList;
private $securityHelper; private $securityHelper;
private $collectionPolicyStream; private $collectionPolicyStream;
private $issn = ''; private $issn = '';
/**
* Constructor
*/
function Refworks() { function Refworks() {
$this->romeoUrlString = "http://www.sherpa.ac.uk/romeo/api24.php?issn="; $this->romeoUrlString = "http://www.sherpa.ac.uk/romeo/api24.php?issn=";
} }
/**
* Build Form ??
* @param type $form
* @param type $ingest_form_definition
* @param type $form_values
* @return type
*/
function buildForm(&$form, $ingest_form_definition, &$form_values) { function buildForm(&$form, $ingest_form_definition, &$form_values) {
$form['indicator2'] = array( $form['indicator2'] = array(
'#type' => 'fieldset', '#type' => 'fieldset',
@ -68,8 +82,7 @@ class Refworks {
//$xml=simplexml_load_string(trim(file_get_contents($file),NULL,TRUE)); //$xml=simplexml_load_string(trim(file_get_contents($file),NULL,TRUE));
//$dom = dom_import_simplexml($xml);//test to see if it behaves better //$dom = dom_import_simplexml($xml);//test to see if it behaves better
//$xml = new SimpleXMLElement(trim(file_get_contents($file))); //$xml = new SimpleXMLElement(trim(file_get_contents($file)));
} } catch (Exception $e) {
catch (Exception $e) {
drupal_set_message(t('Error processing Refworks file: ') . $e->getMessage()); drupal_set_message(t('Error processing Refworks file: ') . $e->getMessage());
return FALSE; return FALSE;
} }
@ -81,7 +94,13 @@ class Refworks {
return $this->referenceList; return $this->referenceList;
} }
//create A DC stream with ID of DC /**
* Create a DC stream with ID of DC ???
* @param type $dom
* @param type $rootElement
* @param type $reference
* @return type
*/
function createQDCStream(&$dom, &$rootElement, $reference) { function createQDCStream(&$dom, &$rootElement, $reference) {
$datastream = $dom->createElement("foxml:datastream"); $datastream = $dom->createElement("foxml:datastream");
$datastream->setAttribute("ID", "DC"); $datastream->setAttribute("ID", "DC");
@ -196,6 +215,11 @@ class Refworks {
return $datastream; return $datastream;
} }
/**
* Handle Form ??
* @param type $form_values
* @return type
*/
function handleForm(&$form_values) { function handleForm(&$form_values) {
$errorMessage = NULL; $errorMessage = NULL;
module_load_include('inc', 'fedora_repository', 'CollectionClass'); module_load_include('inc', 'fedora_repository', 'CollectionClass');
@ -278,8 +302,7 @@ class Refworks {
if ($deleteFiles > 0) { if ($deleteFiles > 0) {
unlink($form_values['fullpath']); unlink($form_values['fullpath']);
} }
} } catch (exception $e) {
catch (exception $e) {
$errors++; $errors++;
$errorMessage = 'yes'; $errorMessage = 'yes';
watchdog(t("FEDORA_REPOSITORY"), t("Error during ingest !it !e", array('!it' => $item_title, '!e' => $e)), NULL, WATCHDOG_ERROR); watchdog(t("FEDORA_REPOSITORY"), t("Error during ingest !it !e", array('!it' => $item_title, '!e' => $e)), NULL, WATCHDOG_ERROR);
@ -290,12 +313,15 @@ class Refworks {
drupal_set_message(t('Error ingesting one or more records! Check Drupal watchdog logs for more info'), 'error'); drupal_set_message(t('Error ingesting one or more records! Check Drupal watchdog logs for more info'), 'error');
} }
$endTime = time(); $endTime = time();
drupal_set_message(t('Successfull ingest of %success records. %errors records failed. Ingest took %seconds seconds', drupal_set_message(t('Successfull ingest of %success records. %errors records failed. Ingest took %seconds seconds', array('%success' => $success - $errors, '%errors' => $errors, '%seconds' => $endTime - $startTime)), 'info');
array('%success' => $success-$errors, '%errors' => $errors, '%seconds' => $endTime-$startTime)) , 'info');
} }
/** /**
* Creates the RELS-EXT for the foxml * Creates the RELS-EXT for the foxml
* @param type $form_values
* @param type $dom
* @param type $rootElement
* @param type $pid
*/ */
function createRelationShips($form_values, &$dom, &$rootElement, $pid = NULL) { function createRelationShips($form_values, &$dom, &$rootElement, $pid = NULL) {
$drdf = $dom->createElement("foxml:datastream"); $drdf = $dom->createElement("foxml:datastream");
@ -326,9 +352,13 @@ class Refworks {
$rdfdesc->appendChild($member); $rdfdesc->appendChild($member);
$rdfdesc->appendChild($model); $rdfdesc->appendChild($model);
$rootElement->appendChild($drdf); $rootElement->appendChild($drdf);
} }
/**
* Create Romeo Datastream
* @param type $dom
* @param type $rootElement
*/
function createRomeoDataStream(&$dom, &$rootElement) { function createRomeoDataStream(&$dom, &$rootElement) {
$ds1 = $dom->createElement("foxml:datastream"); $ds1 = $dom->createElement("foxml:datastream");
$ds1->setAttribute("ID", "ROMEO"); $ds1->setAttribute("ID", "ROMEO");
@ -348,6 +378,14 @@ class Refworks {
$rootElement->appendChild($ds1); $rootElement->appendChild($ds1);
} }
/**
* Create Fedora Datastream
* @global type $base_url
* @param type $form_values
* @param type $dom
* @param type $rootElement
* @param type $reference
*/
function createFedoraDataStreams($form_values, &$dom, &$rootElement, $reference) { function createFedoraDataStreams($form_values, &$dom, &$rootElement, $reference) {
global $base_url; global $base_url;
module_load_include('inc', 'fedora_repository', 'MimeClass'); module_load_include('inc', 'fedora_repository', 'MimeClass');
@ -374,6 +412,10 @@ class Refworks {
/** /**
* Creates the standard foxml properties * Creates the standard foxml properties
* @param type $form_values
* @param type $dom
* @param type $rootElement
* @param type $reference
*/ */
function createStandardFedoraStuff($form_values, &$dom, &$rootElement, $reference) { function createStandardFedoraStuff($form_values, &$dom, &$rootElement, $reference) {
// Foxml object properties section // Foxml object properties section
@ -397,7 +439,6 @@ class Refworks {
$rootElement->appendChild($objproperties); $rootElement->appendChild($objproperties);
} }
/** /**
* Read the list of Users from the U1 field and Roles from the U2 field and add elements * Read the list of Users from the U1 field and Roles from the U2 field and add elements
* to the security policy record for this item, then add the record as the security policy datastream. * to the security policy record for this item, then add the record as the security policy datastream.
@ -446,4 +487,5 @@ class Refworks {
$rootElement->appendChild($ds1); $rootElement->appendChild($ds1);
$ds1content->appendChild($dom->importNode(dom_import_simplexml($custom_policy_sxe), TRUE)); $ds1content->appendChild($dom->importNode(dom_import_simplexml($custom_policy_sxe), TRUE));
} }
} }

22
plugins/ShowDemoStreamsInFieldSets.inc

@ -1,18 +1,32 @@
<?php <?php
// $Id$ // $Id$
/* /**
* Created on 17-Apr-08 * @file
* * ShowDemoStreamsInFieldSets class
* */
/**
* Show Demo Streams in Field Sets ???
*/ */
class ShowDemoStreamsInFieldSets { class ShowDemoStreamsInFieldSets {
private $pid = NULL; private $pid = NULL;
/**
* Constructor
* @param type $pid
*/
function ShowDemoStreamsInFieldSets($pid) { function ShowDemoStreamsInFieldSets($pid) {
//drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); //drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$this->pid = $pid; $this->pid = $pid;
} }
/**
* Show Medium Size ??
* @global type $base_url
* @return type
*/
function showMediumSize() { function showMediumSize() {
global $base_url; global $base_url;
$collection_fieldset = array( $collection_fieldset = array(

69
plugins/ShowStreamsInFieldSets.inc

@ -1,15 +1,31 @@
<?php <?php
// $Id$ // $Id$
/* /**
* Created on 17-Apr-08 * @file
* ShowStreamsInFieldSets class
*/
/**
* Show Streams In Field Sets ??
*/ */
class ShowStreamsInFieldSets { class ShowStreamsInFieldSets {
private $pid = NULL; private $pid = NULL;
/**
* Constructor
* @param type $pid
*/
function ShowStreamsInFieldSets($pid) { function ShowStreamsInFieldSets($pid) {
$this->pid = $pid; $this->pid = $pid;
} }
/**
* Show the FLV ??
* @return type
*/
function showFlv() { function showFlv() {
//FLV is the datastream id //FLV is the datastream id
$path = drupal_get_path('module', 'Fedora_Repository'); $path = drupal_get_path('module', 'Fedora_Repository');
@ -30,6 +46,11 @@ class ShowStreamsInFieldSets {
return theme('fieldset', $collection_fieldset); return theme('fieldset', $collection_fieldset);
} }
/**
* Show the TN ??
* @global type $base_url
* @return type
*/
function showTN() { function showTN() {
global $base_url; global $base_url;
$collection_fieldset = array( $collection_fieldset = array(
@ -41,8 +62,11 @@ class ShowStreamsInFieldSets {
return theme('fieldset', $collection_fieldset); return theme('fieldset', $collection_fieldset);
} }
/**
// Same as showTN but artinventory stores the image in a dsid of IMAGE instead of OBJ * Same as showTN but artinventory stores the image in a dsid of IMAGE instead of OBJ
* @global type $base_url
* @return type
*/
function showArtInventoryTN() { function showArtInventoryTN() {
global $base_url; global $base_url;
$collection_fieldset = array( $collection_fieldset = array(
@ -54,6 +78,10 @@ class ShowStreamsInFieldSets {
/** /**
* Embed Google Docs' PDF viewer into the page. * Embed Google Docs' PDF viewer into the page.
* @global type $base_url
* @global type $base_path
* @global type $user
* @return type
*/ */
function showPDFPreview() { function showPDFPreview() {
global $base_url; global $base_url;
@ -109,7 +137,10 @@ class ShowStreamsInFieldSets {
return $tabset; return $tabset;
} }
/**
* Show QDC ??
* @return type
*/
function showQdc() { function showQdc() {
module_load_include('inc', 'fedora_repository', 'ObjectHelper'); module_load_include('inc', 'fedora_repository', 'ObjectHelper');
$objectHelper = new ObjectHelper(); $objectHelper = new ObjectHelper();
@ -123,6 +154,11 @@ class ShowStreamsInFieldSets {
return theme('fieldset', $collection_fieldset); return theme('fieldset', $collection_fieldset);
} }
/**
* Show Object Link ??
* @global type $base_url
* @return type
*/
function showOBJLink() { function showOBJLink() {
global $base_url; global $base_url;
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
@ -131,8 +167,10 @@ class ShowStreamsInFieldSets {
return "<a href='" . $base_url . "/fedora/repository/" . $this->pid . "/OBJ/" . $streams['OBJ']['label'] . "'>" . $streams['OBJ']['label'] . "</a>"; return "<a href='" . $base_url . "/fedora/repository/" . $this->pid . "/OBJ/" . $streams['OBJ']['label'] . "'>" . $streams['OBJ']['label'] . "</a>";
} }
/**
* Show REF works ??
* @return type
*/
function showRefworks() { function showRefworks() {
$path = drupal_get_path('module', 'fedora_repository'); $path = drupal_get_path('module', 'fedora_repository');
module_load_include('inc', 'fedora_repository', 'ObjectHelper'); module_load_include('inc', 'fedora_repository', 'ObjectHelper');
@ -144,8 +182,7 @@ class ShowStreamsInFieldSets {
} }
try { try {
$proc = new XsltProcessor(); $proc = new XsltProcessor();
} } catch (Exception $e) {
catch (Exception $e) {
drupal_set_message(t("!e", array('!e' => $e->getMessage())), 'error'); drupal_set_message(t("!e", array('!e' => $e->getMessage())), 'error');
return " "; return " ";
} }
@ -165,6 +202,11 @@ class ShowStreamsInFieldSets {
return theme('fieldset', $collection_fieldset); return theme('fieldset', $collection_fieldset);
} }
/**
* Show JP2000
* @param type $collapsed
* @return type
*/
function showJP2($collapsed = FALSE) { function showJP2($collapsed = FALSE) {
$viewer_url = variable_get('fedora_base_url', '') . '/get/' . $this->pid . '/ilives:viewerSdef/getViewer'; $viewer_url = variable_get('fedora_base_url', '') . '/get/' . $this->pid . '/ilives:viewerSdef/getViewer';
$html = '<iframe src="' . $viewer_url . '" frameborder="0" style="width: 100%; height: 400px;">Errors: unable to load viewer</iframe>'; $html = '<iframe src="' . $viewer_url . '" frameborder="0" style="width: 100%; height: 400px;">Errors: unable to load viewer</iframe>';
@ -177,6 +219,11 @@ class ShowStreamsInFieldSets {
return theme('fieldset', $fieldset); return theme('fieldset', $fieldset);
} }
/**
* Show Romeo ??
* @param type $collapsed
* @return type
*/
function showRomeo($collapsed = FALSE) { function showRomeo($collapsed = FALSE) {
$path = drupal_get_path('module', 'Fedora_Repository'); $path = drupal_get_path('module', 'Fedora_Repository');
module_load_include('inc', 'fedora_repository', 'CollectionClass'); module_load_include('inc', 'fedora_repository', 'CollectionClass');
@ -189,8 +236,7 @@ class ShowStreamsInFieldSets {
try { try {
$proc = new XsltProcessor(); $proc = new XsltProcessor();
} } catch (Exception $e) {
catch (Exception $e) {
drupal_set_message(t("!e", array('!e' => $e->getMessage())), 'error'); drupal_set_message(t("!e", array('!e' => $e->getMessage())), 'error');
return; return;
} }
@ -210,4 +256,5 @@ class ShowStreamsInFieldSets {
); );
return theme('fieldset', $collection_fieldset); return theme('fieldset', $collection_fieldset);
} }
} }

21
plugins/fedoraObject.inc

@ -1,6 +1,21 @@
<?php <?php
// $Id$
/**
* @file
* FedoraObject class
*/
/**
* Fedora Object class ??
*/
class FedoraObject { class FedoraObject {
/**
* Constructor
* @param type $pid
*/
function __construct($pid = '') { function __construct($pid = '') {
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
if (!empty($pid)) { if (!empty($pid)) {
@ -10,6 +25,11 @@ class FedoraObject {
} }
} }
/**
* Show Field Sets
* @global type $user
* @return type
*/
public function showFieldSets() { public function showFieldSets() {
global $user; global $user;
$objectHelper = new ObjectHelper(); $objectHelper = new ObjectHelper();
@ -49,4 +69,5 @@ class FedoraObject {
return $tabset; return $tabset;
} }
} }

55
plugins/herbarium.inc

@ -2,7 +2,16 @@
// $Id$ // $Id$
/**
* @file
* Herbarium class
*/
/**
* Herbarium ???
*/
class Herbarium { class Herbarium {
function __construct($pid = '') { function __construct($pid = '') {
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
if (!empty($pid)) { if (!empty($pid)) {
@ -11,6 +20,12 @@ class Herbarium {
} }
} }
/**
* Build a drupal form ??
* @param type $form
* @param type $form_state
* @return type
*/
public function buildDrupalForm($form = array(), $form_state = array()) { 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 // 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. // If we wanted to we could add other fields.
@ -20,6 +35,11 @@ class Herbarium {
return $dwc->buildDrupalForm($form); return $dwc->buildDrupalForm($form);
} }
/**
* Build edit metadata form
* @param type $form
* @return type
*/
public function buildEditMetadataForm($form = array()) { public function buildEditMetadataForm($form = array()) {
$form['submit'] = array( $form['submit'] = array(
'#type' => 'submit', '#type' => 'submit',
@ -38,6 +58,13 @@ class Herbarium {
return $this->buildDrupalForm($form); return $this->buildDrupalForm($form);
} }
/**
* handle edit metadata form ??
* @global type $user
* @param type $form_id
* @param type $form_values
* @return type
*/
public function handleEditMetadataForm($form_id, $form_values) { public function handleEditMetadataForm($form_id, $form_values) {
/* /*
* Process the metadata form * Process the metadata form
@ -51,11 +78,15 @@ class Herbarium {
$dwc = new DarwinCore($this->item); $dwc = new DarwinCore($this->item);
$dwc->handleForm($form_values); $dwc->handleForm($form_values);
$this->item->purge_datastream('DARWIN_CORE'); $this->item->purge_datastream('DARWIN_CORE');
$this->item->add_datastream_from_string($dwc->darwinCoreXML, 'DARWIN_CORE', $this->item->add_datastream_from_string($dwc->darwinCoreXML, 'DARWIN_CORE', 'Darwin Core Metadata', 'text/xml', 'X');
'Darwin Core Metadata', 'text/xml', 'X');
return TRUE; return TRUE;
} }
/**
* Handle Ingest Form
* @global type $user
* @param type $form_values
*/
public function handleIngestForm($form_values) { public function handleIngestForm($form_values) {
/* /*
* process the metadata form * process the metadata form
@ -73,17 +104,14 @@ class Herbarium {
. $form_values['dwc:collectionCode'] . ':' . $form_values['dwc:collectionCode'] . ':'
. $form_values['dwc:catalogNumber']; . $form_values['dwc:catalogNumber'];
$new_item = Fedora_Item::ingest_new_item($form_values['pid'], 'A', $label, $new_item = Fedora_Item::ingest_new_item($form_values['pid'], 'A', $label, $user->name);
$user->name);
$new_item->add_datastream_from_string($dwc->darwinCoreXML, 'DARWIN_CORE', $new_item->add_datastream_from_string($dwc->darwinCoreXML, 'DARWIN_CORE', 'Darwin Core Metadata', 'text/xml', 'X');
'Darwin Core Metadata', 'text/xml', 'X');
$file = $form_values['ingest-file-location']; $file = $form_values['ingest-file-location'];
if (!empty($file)) { if (!empty($file)) {
$dformat = $mimetype->getType($file); $dformat = $mimetype->getType($file);
$new_item->add_datastream_from_file($file, 'FULL_SIZE', $new_item->add_datastream_from_file($file, 'FULL_SIZE', "$label-full-size", $dformat, 'M');
"$label-full-size", $dformat, 'M');
} }
$new_item->add_relationship('hasModel', $form_values['content_model_pid'], FEDORA_MODEL_URI); $new_item->add_relationship('hasModel', $form_values['content_model_pid'], FEDORA_MODEL_URI);
@ -93,13 +121,17 @@ class Herbarium {
foreach ($_SESSION['fedora_ingest_files'] as $dsid => $created_file) { foreach ($_SESSION['fedora_ingest_files'] as $dsid => $created_file) {
$created_file_format = $mimetype->getType($created_file); $created_file_format = $mimetype->getType($created_file);
$created_filename = strstr($created_file, $file); $created_filename = strstr($created_file, $file);
$new_item->add_datastream_from_file($created_file, $dsid, $new_item->add_datastream_from_file($created_file, $dsid, $created_filename, $created_file_format, 'M');
$created_filename, $created_file_format, 'M');
} }
} }
} }
/**
* Show Field Sets
* @global type $base_url
* @global type $user
* @return string
*/
public function showFieldSets() { public function showFieldSets() {
module_load_include('inc', 'fedora_repository', 'plugins/tagging_form'); module_load_include('inc', 'fedora_repository', 'plugins/tagging_form');
module_load_include('inc', 'fedora_repository', 'plugins/DarwinCore'); module_load_include('inc', 'fedora_repository', 'plugins/DarwinCore');
@ -168,4 +200,5 @@ class Herbarium {
} }
return $tabset; return $tabset;
} }
} }

21
plugins/map_viewer.inc

@ -1,13 +1,33 @@
<?php <?php
// $Id$ // $Id$
/**
* @file
* ShowMapStreamsInFieldSets class
*/
/**
* Show Map Streams in Field Sets Class ??
*/
class ShowMapStreamsInFieldSets { class ShowMapStreamsInFieldSets {
private $pid = NULL; private $pid = NULL;
/**
* Constructor
* @param type $pid
*/
function ShowMapStreamsInFieldSets($pid) { function ShowMapStreamsInFieldSets($pid) {
$this->pid = $pid; $this->pid = $pid;
} }
/**
* Show JPEG
* @global type $base_url
* @global type $user
* @return type
*/
function showJPG() { function showJPG() {
module_load_include('inc', 'fedora_repository', 'plugins/tagging_form'); module_load_include('inc', 'fedora_repository', 'plugins/tagging_form');
module_load_include('inc', 'fedora_repository', 'plugins/ShowStreamsInFieldSets'); module_load_include('inc', 'fedora_repository', 'plugins/ShowStreamsInFieldSets');
@ -51,4 +71,5 @@ class ShowMapStreamsInFieldSets {
// Render the tabset. // Render the tabset.
return tabs_render($tabset); return tabs_render($tabset);
} }
} }

48
plugins/qt_viewer.inc

@ -1,17 +1,41 @@
<?php <?php
// $Id$ // $Id$
/**
* @file
* ShowQTStreamsInFieldSets class
*/
/**
* Show QT Stream in Field Sets
*/
class ShowQtStreamsInFieldSets { class ShowQtStreamsInFieldSets {
private $pid = NULL; private $pid = NULL;
/**
* Constructor
* @param type $pid
*/
function ShowQtStreamsInFieldSets($pid) { function ShowQtStreamsInFieldSets($pid) {
$this->pid = $pid; $this->pid = $pid;
} }
/**
* Returna a new Fedora Object with the QT movie ???
* @return fedora_item
*/
function fedoraObject() { function fedoraObject() {
return new fedora_item($this->pid); return new fedora_item($this->pid);
} }
/**
* Tecnical metadata ??
* @param type $defaults
* @param type $dsid
* @return type
*/
function technicalMetadata($defaults = array(), $dsid = 'OBJ_EXIFTOOL') { function technicalMetadata($defaults = array(), $dsid = 'OBJ_EXIFTOOL') {
$data = $defaults; $data = $defaults;
@ -26,7 +50,8 @@ class ShowQtStreamsInFieldSets {
if (strpos($mime, 'audio/') !== false) { if (strpos($mime, 'audio/') !== false) {
$data['width'] = 300; $data['width'] = 300;
$data['height'] = 0; $data['height'] = 0;
} else { }
else {
$size = reset($doc->xpath('//Composite:ImageSize/text()')); $size = reset($doc->xpath('//Composite:ImageSize/text()'));
list($width, $height) = explode('x', $size); list($width, $height) = explode('x', $size);
$data['width'] = $width; $data['width'] = $width;
@ -41,6 +66,11 @@ class ShowQtStreamsInFieldSets {
return $data; return $data;
} }
/**
* Get Poster Frame Datastream Information ??
* @param type $dsid
* @return type
*/
function getPosterFrameDatastreamInfo($dsid = 'FULL_SIZE') { function getPosterFrameDatastreamInfo($dsid = 'FULL_SIZE') {
$p = ObjectHelper::getDatastreamInfo($this->pid, $dsid); $p = ObjectHelper::getDatastreamInfo($this->pid, $dsid);
if (empty($p) || $p == ' ' || $p === false) { if (empty($p) || $p == ' ' || $p === false) {
@ -49,6 +79,12 @@ class ShowQtStreamsInFieldSets {
return $p; return $p;
} }
/**
* Get Media Datastream Information ??
* @param type $dsid
* @param type $alt
* @return type
*/
function getMediaDatastreamInfo($dsid = 'OBJ', $alt = array('')) { function getMediaDatastreamInfo($dsid = 'OBJ', $alt = array('')) {
$p = ObjectHelper::getDatastreamInfo($this->pid, $dsid); $p = ObjectHelper::getDatastreamInfo($this->pid, $dsid);
if (empty($p) || $p == ' ' || $p === false) { if (empty($p) || $p == ' ' || $p === false) {
@ -62,10 +98,19 @@ class ShowQtStreamsInFieldSets {
return $p; return $p;
} }
/**
* Is download enabled. It always returns false. ???
* @return FALSE
*/
function enableDownload() { function enableDownload() {
return false; return false;
} }
/**
* Show the QT ???
* @global type $base_url
* @return type
*/
function showQt() { function showQt() {
module_load_include('inc', 'fedora_repository', 'plugins/tagging_form'); module_load_include('inc', 'fedora_repository', 'plugins/tagging_form');
module_load_include('inc', 'fedora_repository', 'plugins/ShowStreamsInFieldSets'); module_load_include('inc', 'fedora_repository', 'plugins/ShowStreamsInFieldSets');
@ -135,4 +180,5 @@ EOD;
'#value' => $content); '#value' => $content);
return theme('fieldset', $collection_fieldset); return theme('fieldset', $collection_fieldset);
} }
} }

20
plugins/slide_viewer.inc

@ -1,15 +1,34 @@
<?php <?php
// $Id$ // $Id$
/**
* @file
* ShowSlideStreamsInFieldSets class
*/
/**
* ShowSlideStreamInFieldSets ??????
*/
class ShowSlideStreamsInFieldSets { class ShowSlideStreamsInFieldSets {
private $pid = NULL; private $pid = NULL;
/**
* Contructor
* @param type $pid
*/
function ShowSlideStreamsInFieldSets($pid) { function ShowSlideStreamsInFieldSets($pid) {
//drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); //drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$this->pid = $pid; $this->pid = $pid;
} }
/**
* Show JPEG
* @global type $base_url
* @global type $user
* @return type
*/
function showJPG() { function showJPG() {
module_load_include('inc', 'fedora_repository', 'plugins/tagging_form'); module_load_include('inc', 'fedora_repository', 'plugins/tagging_form');
module_load_include('inc', 'fedora_repository', 'plugins/ShowStreamsInFieldSets'); module_load_include('inc', 'fedora_repository', 'plugins/ShowStreamsInFieldSets');
@ -44,4 +63,5 @@ class ShowSlideStreamsInFieldSets {
return $tabset; return $tabset;
} }
} }

30
plugins/tagging_form.inc

@ -1,11 +1,17 @@
<?php <?php
// $Id$ // $Id$
/* /**
* To change this template, choose Tools | Templates * @file
* and open the template in the editor. * Tagging Form???
*/ */
/**
* Show subject tags ???
* @param type $pid
* @return string
*/
function _show_subject_tags($pid) { function _show_subject_tags($pid) {
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
module_load_include('inc', 'fedora_repository', 'api/dublin_core'); module_load_include('inc', 'fedora_repository', 'api/dublin_core');
@ -22,6 +28,13 @@ function _show_subject_tags($pid) {
return $output; return $output;
} }
/**
* Fedora repository image tagging form ????
* @global type $base_url
* @param type $form_state
* @param type $pid
* @return type
*/
function fedora_repository_image_tagging_form($form_state, $pid) { function fedora_repository_image_tagging_form($form_state, $pid) {
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
module_load_include('inc', 'fedora_repository', 'api/dublin_core'); module_load_include('inc', 'fedora_repository', 'api/dublin_core');
@ -88,6 +101,11 @@ function fedora_repository_image_tagging_form($form_state, $pid) {
return $form; return $form;
} }
/**
* Hook image button process ???
* @param type $form
* @return string
*/
function hook_imagebutton_process($form) { function hook_imagebutton_process($form) {
$form['op_x'] = array( $form['op_x'] = array(
'#name' => $form['#name'] . '_x', '#name' => $form['#name'] . '_x',
@ -98,6 +116,12 @@ function hook_imagebutton_process($form) {
return $form; return $form;
} }
/**
* Fedora repository image tagging from submit ???
* @global type $user
* @param type $form
* @param type $form_state
*/
function fedora_repository_image_tagging_form_submit($form, &$form_state) { function fedora_repository_image_tagging_form_submit($form, &$form_state) {
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
module_load_include('inc', 'fedora_repository', 'api/tagging'); module_load_include('inc', 'fedora_repository', 'api/tagging');

Loading…
Cancel
Save