From 2784a19a160288e334e017ef4f671e94ae3a127f Mon Sep 17 00:00:00 2001 From: Ben Woodhead Date: Mon, 8 Aug 2011 16:13:07 -0300 Subject: [PATCH] Added doc tags --- plugins/CollectionFormBuilder.inc | 32 +- plugins/CreateCollection.inc | 30 +- plugins/DarwinCore.inc | 59 +- plugins/DemoFormBuilder.inc | 32 +- plugins/DocumentConverter.inc | 32 +- plugins/Exiftool.inc | 101 +-- plugins/Ffmpeg.inc | 37 +- plugins/Flv.inc | 109 ++-- plugins/FlvFormBuilder.inc | 24 +- plugins/FormBuilder.inc | 199 +++--- plugins/ImageManipulation.inc | 81 ++- plugins/ModsFormBuilder.inc | 863 +++++++++++++------------ plugins/PersonalCollectionClass.inc | 82 ++- plugins/QtFormBuilder.php | 143 ++-- plugins/Refworks.inc | 151 +++-- plugins/ShowDemoStreamsInFieldSets.inc | 22 +- plugins/ShowStreamsInFieldSets.inc | 111 +++- plugins/fedoraObject.inc | 33 +- plugins/herbarium.inc | 83 ++- plugins/map_viewer.inc | 29 +- plugins/qt_viewer.inc | 140 ++-- plugins/slide_viewer.inc | 34 +- plugins/tagging_form.inc | 44 +- 23 files changed, 1550 insertions(+), 921 deletions(-) diff --git a/plugins/CollectionFormBuilder.inc b/plugins/CollectionFormBuilder.inc index 6c5e33b6..26dbda26 100644 --- a/plugins/CollectionFormBuilder.inc +++ b/plugins/CollectionFormBuilder.inc @@ -1,37 +1,52 @@ getType($file); - $fileUrl = $base_url . '/'. drupal_urlencode($file); + $fileUrl = $base_url . '/' . drupal_urlencode($file); $beginIndex = strrpos($fileUrl, '/'); $dtitle = substr($fileUrl, $beginIndex + 1); - $dtitle = substr($dtitle, 0, strpos($dtitle, ".")); + $dtitle = substr($dtitle, 0, strpos($dtitle, ".")); $ds1 = $dom->createElement("foxml:datastream"); $ds1->setAttribute("ID", "COLLECTION_POLICY"); //set the ID $ds1->setAttribute("STATE", "A"); $ds1->setAttribute("CONTROL_GROUP", "M"); - $ds1v= $dom->createElement("foxml:datastreamVersion"); + $ds1v = $dom->createElement("foxml:datastreamVersion"); $ds1v->setAttribute("ID", "COLLECTION_POLICY.0"); $ds1v->setAttribute("MIMETYPE", "$dformat"); $ds1v->setAttribute("LABEL", "$dtitle"); @@ -42,4 +57,5 @@ class CollectionFormBuilder extends FormBuilder { $ds1v->appendChild($ds1content); $rootElement->appendChild($ds1); } + } diff --git a/plugins/CreateCollection.inc b/plugins/CreateCollection.inc index 0c185705..cec55648 100644 --- a/plugins/CreateCollection.inc +++ b/plugins/CreateCollection.inc @@ -1,22 +1,34 @@ owner = $item; - if ( array_key_exists('DARWIN_CORE', $item->get_datastreams_list_as_array())) { + if (array_key_exists('DARWIN_CORE', $item->get_datastreams_list_as_array())) { $dwc = $item->get_datastream_dissemination('DARWIN_CORE'); if (!empty($dwc)) { $this->darwinCoreXML = $dwc; @@ -17,10 +29,15 @@ class DarwinCore { } } + /** + * Build Drupal Form + * @param type $form + * @return int + */ public function buildDrupalForm($form = array()) { - + $dwc_xml = $this->darwinCoreXML; - + $dwc = DOMDocument::loadXML($dwc_xml); $form['dc:type'] = array( @@ -162,17 +179,22 @@ class DarwinCore { $date = $dwc->getElementsByTagNameNS('http://rs.tdwg.org/dwc/terms/', 'eventDate')->item(0)->nodeValue; $format = 'Y-m-d H:i:s'; $form['dwceventDate'] = array( - '#type' => 'date_popup', // types 'date_text' and 'date_timezone' are also supported. See .inc file. - '#title' => 'select a date', - '#default_value' => $date, - '#date_format' => $format, - '#date_label_position' => 'within', // See other available attributes and what they do in date_api_elements.inc - '#date_increment' => 15, // Optional, used by the date_select and date_popup elements to increment minutes and seconds. + '#type' => 'date_popup', // types 'date_text' and 'date_timezone' are also supported. See .inc file. + '#title' => 'select a date', + '#default_value' => $date, + '#date_format' => $format, + '#date_label_position' => 'within', // See other available attributes and what they do in date_api_elements.inc + '#date_increment' => 15, // Optional, used by the date_select and date_popup elements to increment minutes and seconds. '#description' => '', ); return $form; } + /** + * Handle Form ?? + * @global type $user + * @param type $form_values + */ public function handleForm($form_values) { module_load_include('inc', 'fedora_repository', 'api/fedora_item'); global $user; @@ -208,12 +230,20 @@ class DarwinCore { $this->darwinCoreXML = $dwc->saveXML(); } + /** + * asXML ?? + * @return type + */ public function asXML() { return $this->darwinCoreXML; } + /** + * asHTML ?? + * @return type + */ 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', 'CollectionClass'); @@ -226,8 +256,7 @@ class DarwinCore { try { $proc = new XsltProcessor(); - } - catch (Exception $e) { + } catch (Exception $e) { drupal_set_message(t("!e", array('!e' => $e->getMessage())), 'error'); return " "; } @@ -238,7 +267,7 @@ class DarwinCore { $input->loadXML(trim($xmlstr)); $xsl = $proc->importStylesheet($xsl); $newdom = $proc->transformToDoc($input); - $content=$newdom->saveXML(); + $content = $newdom->saveXML(); return $content; } @@ -256,9 +285,7 @@ class DarwinCore { 'MachineObservation' => 'MachineObservation', 'NomenclaturalChecklist' => 'NomenclaturalChecklist', ), - ); - public $dwcFields = array( 'dc:type', 'dc:language', @@ -283,8 +310,6 @@ class DarwinCore { 'dwc:eventDate', 'dwc:eventTime', ); - - public $darwinCoreXML = ' diff --git a/plugins/DemoFormBuilder.inc b/plugins/DemoFormBuilder.inc index 913d8005..9b4219db 100644 --- a/plugins/DemoFormBuilder.inc +++ b/plugins/DemoFormBuilder.inc @@ -1,31 +1,44 @@ getType($file); - $fileUrl = $base_url .'/'. drupal_urlencode($file); + $fileUrl = $base_url . '/' . drupal_urlencode($file); $beginIndex = strrpos($fileUrl, '/'); $dtitle = substr($fileUrl, $beginIndex + 1); $dtitle = urldecode($dtitle); @@ -50,7 +63,7 @@ class DemoFormBuilder extends FormBuilder { foreach ($_SESSION['fedora_ingest_files'] as $dsid => $createdFile) { $createdFile = strstr($createdFile, $file); $dformat = $mimetype->getType($createdFile); - $fileUrl = $base_url .'/'. drupal_urlencode( $createdFile ); + $fileUrl = $base_url . '/' . drupal_urlencode($createdFile); $beginIndex = strrpos($fileUrl, '/'); $dtitle = substr($fileUrl, $beginIndex + 1); $dtitle = urldecode($dtitle); @@ -60,7 +73,7 @@ class DemoFormBuilder extends FormBuilder { $ds1->setAttribute("ID", "$dsid"); $ds1->setAttribute("STATE", "A"); $ds1->setAttribute("CONTROL_GROUP", "M"); - $ds1v= $dom->createElement("foxml:datastreamVersion"); + $ds1v = $dom->createElement("foxml:datastreamVersion"); $ds1v->setAttribute("ID", "$dsid.0"); $ds1v->setAttribute("MIMETYPE", "$dformat"); $ds1v->setAttribute("LABEL", "$dtitle"); @@ -73,5 +86,6 @@ class DemoFormBuilder extends FormBuilder { } } } + } diff --git a/plugins/DocumentConverter.inc b/plugins/DocumentConverter.inc index 3aafb49f..5628cb16 100644 --- a/plugins/DocumentConverter.inc +++ b/plugins/DocumentConverter.inc @@ -3,20 +3,35 @@ // $Id$ /** - * + * @file + * Document Converter Class + */ + +/** * This class implements document (doc, odt, pdf, etc.) conversion for a generic * multi-format document collection. */ - class DocumentConverter { private $converter_service_url = "http://localhost:8080/converter/service"; + /** + * Constructor + * @param type $converter_url + */ public function __construct($converter_url = NULL) { if (!empty($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) { module_load_include('inc', 'fedora_repository', 'MimeClass'); @@ -32,7 +47,7 @@ class DocumentConverter { $outputType = $helper->get_mimetype($output_ext); $inputData = file_get_contents($file); - $outputFile = $file ."_". $dsid .".". $output_ext; + $outputFile = $file . "_" . $dsid . "." . $output_ext; #debug: #drupal_set_message("inputType: $inputType", 'status'); @@ -40,8 +55,8 @@ class DocumentConverter { #drupal_set_message("outputFile: $outputFile", 'status'); $ch = curl_init($this->converter_service_url); - curl_setopt($ch, CURLOPT_HTTPHEADER, array( "Content-Type: $inputType", "Accept: $outputType" ) ); - curl_setopt($ch, CURLOPT_POST, 1 ); + curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: $inputType", "Accept: $outputType")); + curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 120); // times out after 2 minutes curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable curl_setopt($ch, CURLOPT_POSTFIELDS, $inputData); // add POST fields @@ -52,23 +67,24 @@ class DocumentConverter { $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); - if (200 == $code) { + if (200 == $code) { $returnValue = file_put_contents($outputFile, $data); if ($returnValue > 0) { drupal_set_message("Conversion successful.", 'status'); $_SESSION['fedora_ingest_files']["$dsid"] = $outputFile; return $outputFile; - } + } else { return $returnValue; // a.k.a. FALSE. } - } + } else { drupal_set_message("Conversion Failed. Webservice returned $code.", 'status'); return FALSE; } } + } /* diff --git a/plugins/Exiftool.inc b/plugins/Exiftool.inc index ec6d7ad0..81cc46ef 100644 --- a/plugins/Exiftool.inc +++ b/plugins/Exiftool.inc @@ -1,17 +1,24 @@ pid = $pid; @@ -19,49 +26,61 @@ class Exiftool { $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) { $system = getenv('System'); - $file_suffix = '_'. $dsid . '.xml'; - $returnValue=TRUE; - $output=array(); + $file_suffix = '_' . $dsid . '.xml'; + $returnValue = TRUE; + $output = array(); exec('exiftool -X ' . escapeshellarg($file) . '', $output); - file_put_contents($file.$file_suffix, implode("\n", $output)); + file_put_contents($file . $file_suffix, implode("\n", $output)); $_SESSION['fedora_ingest_files']["$dsid"] = $file . $file_suffix; return TRUE; } - - function displayMetadata() { - $output=''; - $exif = $this->item->get_datastream_dissemination('EXIF'); - if (trim($exif) != '') { - $exifDom = DOMDocument::loadXML($this->item->get_datastream_dissemination('EXIF')); - if ($exifDom != NULL) { - $description = $exifDom->getElementsByTagNameNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#','Description'); - if ($description->length > 0) { - $description=$description->item(0); - $output .= ''; - - $fieldset = array( - '#title' => t("!text", array('!text' => 'Technical Metadata')), - '#collapsible' => TRUE, - '#collapsed' => TRUE, - '#value' => $output - ); - $output = theme('fieldset', $fieldset); - } - } - } + + /** + * display metadata ??? + * @return type + */ + function displayMetadata() { + $output = ''; + $exif = $this->item->get_datastream_dissemination('EXIF'); + if (trim($exif) != '') { + $exifDom = DOMDocument::loadXML($this->item->get_datastream_dissemination('EXIF')); + if ($exifDom != NULL) { + $description = $exifDom->getElementsByTagNameNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'Description'); + if ($description->length > 0) { + $description = $description->item(0); + $output .= ''; + + $fieldset = array( + '#title' => t("!text", array('!text' => 'Technical Metadata')), + '#collapsible' => TRUE, + '#collapsed' => TRUE, + '#value' => $output + ); + $output = theme('fieldset', $fieldset); + } + } + } return $output; } - + } diff --git a/plugins/Ffmpeg.inc b/plugins/Ffmpeg.inc index f2faedac..90436808 100644 --- a/plugins/Ffmpeg.inc +++ b/plugins/Ffmpeg.inc @@ -1,26 +1,44 @@ '00:00:10', 's' => null); + $defaults = array('ss' => '00:00:10', 's' => null); $params = array_merge($defaults, $parameterArray); $system = getenv('System'); - $file_suffix = '_'. $dsid . '.' . $file_ext; - $returnValue=TRUE; - $output=array(); + $file_suffix = '_' . $dsid . '.' . $file_ext; + $returnValue = TRUE; + $output = array(); $size = ''; - if($params['s'] != null) { + if ($params['s'] != null) { $size = ' -s ' . escapeshellarg($params['s']); } exec('ffmpeg -i ' . escapeshellarg($file) . ' -r 1 -ss ' . escapeshellarg($params['ss']) . ' ' . $size . ' -t 1 ' . escapeshellarg($file . $file_suffix)); @@ -32,4 +50,5 @@ class Ffmpeg { $_SESSION['fedora_ingest_files']["$dsid"] = $file . $file_suffix; return TRUE; } + } diff --git a/plugins/Flv.inc b/plugins/Flv.inc index 4b16fe7d..4345428f 100644 --- a/plugins/Flv.inc +++ b/plugins/Flv.inc @@ -1,18 +1,31 @@ createElement("foxml:datastream"); $datastream->setAttribute("ID", "QDC"); @@ -33,7 +46,7 @@ class FormBuilder { $oai->setAttribute('xmlns:xsi', "http://www.w3.org/2001/XMLSchema-instance"); $content->appendChild($oai); //dc elements - $previousElement=NULL; //used in case we have to nest elements for qualified dublin core + $previousElement = NULL; //used in case we have to nest elements for qualified dublin core foreach ($form_values as $key => $value) { $index = strrpos($key, '-'); if ($index > 01) { @@ -42,7 +55,7 @@ class FormBuilder { $test = substr($key, 0, 2); - if ($test=='dc'||$test=='ap') {//don't try to process other form values + if ($test == 'dc' || $test == 'ap') {//don't try to process other form values try { if (!strcmp(substr($key, 0, 4), 'app_')) { $key = substr($key, 4); @@ -52,8 +65,7 @@ class FormBuilder { $previousElement = $dom->createElement($key, $value); $oai->appendChild($previousElement); } - } - catch (exception $e) { + } catch (exception $e) { drupal_set_message(t("!e", array('!e' => $e->getMessage())), 'error'); continue; } @@ -62,10 +74,15 @@ class FormBuilder { } } + /** + * Handle QDC Form ??? + * @param type $form_values + * @return type + */ function handleQDCForm($form_values) { $dom = new DomDocument("1.0", "UTF-8"); $dom->formatOutput = TRUE; - $pid=$form_values['pid']; + $pid = $form_values['pid']; $rootElement = $dom->createElement("foxml:digitalObject"); $rootElement->setAttribute('PID', "$pid"); $rootElement->setAttribute('xmlns:foxml', "info:fedora/fedora-system:def/foxml#"); @@ -87,13 +104,13 @@ class FormBuilder { try { $soapHelper = new ConnectionHelper(); - $client=$soapHelper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl')); + $client = $soapHelper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl')); if ($client == NULL) { drupal_set_message(t('Error getting SOAP client.'), 'error'); return; } - $object=$client->__soapCall('ingest', array($params)); + $object = $client->__soapCall('ingest', array($params)); $deleteFiles = $form_values['delete_file']; //remove files from drupal file system if ($deleteFiles > 0) { @@ -102,20 +119,25 @@ class FormBuilder { } unlink($form_values['fullpath']); } - } - catch (exception $e) { + } catch (exception $e) { drupal_set_message(t('Error ingesting object: !e', array('!e' => $e->getMessage())), 'error'); return; } } + /** + * Create Fedora DataStream + * @param type $form_values + * @param type $dom + * @param type $rootElement + */ function createFedoraDataStreams($form_values, &$dom, &$rootElement) { module_load_include('inc', 'fedora_repository', 'MimeClass'); $mimetype = new MimeClass(); $server = NULL; - $file=$form_values['ingest-file-location']; + $file = $form_values['ingest-file-location']; $dformat = $mimetype->getType($file); - $fileUrl = 'http://'. $_SERVER['HTTP_HOST'] . $file; + $fileUrl = 'http://' . $_SERVER['HTTP_HOST'] . $file; $beginIndex = strrpos($fileUrl, '/'); $dtitle = substr($fileUrl, $beginIndex + 1); $dtitle = substr($dtitle, 0, strpos($dtitle, ".")); @@ -123,7 +145,7 @@ class FormBuilder { $ds1->setAttribute("ID", "OBJ"); $ds1->setAttribute("STATE", "A"); $ds1->setAttribute("CONTROL_GROUP", "M"); - $ds1v= $dom->createElement("foxml:datastreamVersion"); + $ds1v = $dom->createElement("foxml:datastreamVersion"); $ds1v->setAttribute("ID", "OBJ.0"); $ds1v->setAttribute("MIMETYPE", "$dformat"); $ds1v->setAttribute("LABEL", "$dtitle"); @@ -137,16 +159,16 @@ class FormBuilder { foreach ($_SESSION['fedora_ingest_files'] as $dsid => $createdFile) { $createdFile = strstr($createdFile, $file); $dformat = $mimetype->getType($createdFile); - $fileUrl = 'http://'. $_SERVER['HTTP_HOST'] . $createdFile; + $fileUrl = 'http://' . $_SERVER['HTTP_HOST'] . $createdFile; $beginIndex = strrpos($fileUrl, '/'); $dtitle = substr($fileUrl, $beginIndex + 1); - $dtitle = substr($dtitle, 0, strpos($dtitle, ".")); - $dtitle = $dtitle . '_'. $dsid; + $dtitle = substr($dtitle, 0, strpos($dtitle, ".")); + $dtitle = $dtitle . '_' . $dsid; $ds1 = $dom->createElement("foxml:datastream"); $ds1->setAttribute("ID", "$dsid"); $ds1->setAttribute("STATE", "A"); $ds1->setAttribute("CONTROL_GROUP", "M"); - $ds1v= $dom->createElement("foxml:datastreamVersion"); + $ds1v = $dom->createElement("foxml:datastreamVersion"); $ds1v->setAttribute("ID", "$dsid.0"); $ds1v->setAttribute("MIMETYPE", "$dformat"); $ds1v->setAttribute("LABEL", "$dtitle"); @@ -158,9 +180,12 @@ class FormBuilder { $rootElement->appendChild($ds1); } } - + /** * creates the RELS-EXT for the foxml + * @param type $form_values + * @param type $dom + * @param type $rootElement */ function createRelationShips($form_values, &$dom, &$rootElement) { $drdf = $dom->createElement("foxml:datastream"); @@ -190,14 +215,16 @@ class FormBuilder { $rdf->appendChild($rdfdesc); $rdfdesc->appendChild($member); $rootElement->appendChild($drdf); - } - + /** * creates the standard foxml properties + * @param type $form_values + * @param type $dom + * @param type $rootElement */ function createStandardFedoraStuff($form_values, &$dom, &$rootElement) { - /*foxml object properties section */ + /* foxml object properties section */ $objproperties = $dom->createElement("foxml:objectProperties"); $prop1 = $dom->createElement("foxml:property"); $prop1->setAttribute("NAME", "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"); @@ -222,11 +249,17 @@ class FormBuilder { $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) { $form['indicator2'] = array( - '#type' => 'fieldset', - '#title' => t('Ingest Digital Object Step #2') + '#type' => 'fieldset', + '#title' => t('Ingest Digital Object Step #2') ); foreach ($ingest_form_definition->form_elements->element as $element) { $name = strip_tags($element->name->asXML()); @@ -234,7 +267,7 @@ class FormBuilder { $required = strip_tags($element->required->asXML()); $required = strtolower($required); if ($required != 'TRUE') { - $required='0'; + $required = '0'; } $description = strip_tags($element->description->asXML()); @@ -247,20 +280,19 @@ class FormBuilder { $options["$field"] = $value; } $form['indicator2']["$name"] = array( - '#title' => $title, - '#required' => $required, - '#description' => $description, - '#type' => $type, - '#options' => $options, + '#title' => $title, + '#required' => $required, + '#description' => $description, + '#type' => $type, + '#options' => $options, ); - } else { $form['indicator2']["$name"] = array( - '#title' => $title, - '#required' => $required, - '#description' => $description, - '#type' => $type + '#title' => $title, + '#required' => $required, + '#description' => $description, + '#type' => $type ); } } @@ -269,3 +301,4 @@ class FormBuilder { } } + diff --git a/plugins/FlvFormBuilder.inc b/plugins/FlvFormBuilder.inc index 37b0e0d2..7f929fdd 100644 --- a/plugins/FlvFormBuilder.inc +++ b/plugins/FlvFormBuilder.inc @@ -1,20 +1,33 @@ getType($file); //$fileUrl = 'http://'.$_SERVER['HTTP_HOST'].$file; - $fileUrl = $base_url .'/'. drupal_urlencode($file); + $fileUrl = $base_url . '/' . drupal_urlencode($file); $beginIndex = strrpos($fileUrl, '/'); $dtitle = substr($fileUrl, $beginIndex + 1); $dtitle = substr($dtitle, 0, strpos($dtitle, ".")); @@ -32,7 +45,7 @@ class FlvFormBuilder extends FormBuilder { $ds1->setAttribute("ID", "FLV"); $ds1->setAttribute("STATE", "A"); $ds1->setAttribute("CONTROL_GROUP", "M"); - $ds1v= $dom->createElement("foxml:datastreamVersion"); + $ds1v = $dom->createElement("foxml:datastreamVersion"); $ds1v->setAttribute("ID", "FLV.0"); $ds1v->setAttribute("MIMETYPE", "$dformat"); $ds1v->setAttribute("LABEL", "$dtitle"); @@ -44,7 +57,7 @@ class FlvFormBuilder extends FormBuilder { $rootElement->appendChild($ds1); $createdFile = drupal_get_path('module', 'Fedora_Repository') . '/images/flashThumb.jpg'; - $fileUrl = $base_url .'/'. drupal_urlencode($createdFile); //'http://'.$_SERVER['HTTP_HOST'].'/'.$createdFile; + $fileUrl = $base_url . '/' . drupal_urlencode($createdFile); //'http://'.$_SERVER['HTTP_HOST'].'/'.$createdFile; $ds1 = $dom->createElement("foxml:datastream"); $ds1->setAttribute("ID", "TN"); $ds1->setAttribute("STATE", "A"); @@ -60,5 +73,6 @@ class FlvFormBuilder extends FormBuilder { $ds1v->appendChild($ds1content); $rootElement->appendChild($ds1); } + } diff --git a/plugins/FormBuilder.inc b/plugins/FormBuilder.inc index 4fd3fa7d..075e0dfb 100644 --- a/plugins/FormBuilder.inc +++ b/plugins/FormBuilder.inc @@ -2,19 +2,31 @@ // $Id$ -/* - * Created on 19-Feb-08 - * - * +/** + * @file + * FormBuilder class + */ + +/** * implements methods from content model ingest form xml * builds a dc metadata form -*/ + */ class FormBuilder { + + /** + * Constructor + */ function FormBuilder() { module_load_include('inc', 'FormBuilder', ''); drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); } + /** + * Create QDC Stream ?? + * @param type $form_values + * @param type $dom + * @param type $rootElement + */ function createQDCStream($form_values, &$dom, &$rootElement) { $datastream = $dom->createElement("foxml:datastream"); $datastream->setAttribute("ID", "DC"); @@ -35,7 +47,7 @@ class FormBuilder { $oai->setAttribute('xmlns:xsi', "http://www.w3.org/2001/XMLSchema-instance"); $content->appendChild($oai); //dc elements - $previousElement=NULL;//used in case we have to nest elements for qualified dublin core + $previousElement = NULL; //used in case we have to nest elements for qualified dublin core foreach ($form_values as $key => $value) { $key = str_replace('_', ':', $key); $index = strrpos($key, '-'); @@ -55,18 +67,22 @@ class FormBuilder { $previousElement = $dom->createElement($key, $value); $oai->appendChild($previousElement); } - } - catch (exception $e) { + } catch (exception $e) { drupal_set_message(t("!e", array('!e' => $e->getMessage())), 'error'); continue; } } $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) { module_load_include('inc', 'fedora_repository', 'ObjectHelper'); $objectHelper = new ObjectHelper(); @@ -78,8 +94,7 @@ class FormBuilder { } try { $xml = new SimpleXMLElement($policyStreamDoc); - } - catch (Exception $e) { + } catch (Exception $e) { 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'); return FALSE; @@ -91,7 +106,7 @@ class FormBuilder { return FALSE; } $dom->importNode($policyElement, TRUE); - $value=$policyElement->appendXML($policyStreamDoc); + $value = $policyElement->appendXML($policyStreamDoc); if (!$value) { drupal_set_message(t('Error creating security policy stream.')); watchdog(t("Fedora_Repository"), t("Error creating security policy stream, could not parse collection policy template file."), NULL, WATCHDOG_NOTICE); @@ -114,14 +129,18 @@ class FormBuilder { return TRUE; } - + /** + * Handle QDC Form ?? + * @param type $form_values + * @return type + */ function handleQDCForm($form_values) { module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'CollectionPolicy'); - + $dom = new DomDocument("1.0", "UTF-8"); $dom->formatOutput = TRUE; - $pid=$form_values['pid']; + $pid = $form_values['pid']; $rootElement = $dom->createElement("foxml:digitalObject"); $rootElement->setAttribute('VERSION', '1.1'); $rootElement->setAttribute('PID', "$pid"); @@ -134,13 +153,13 @@ class FormBuilder { // Create relationships $this->createRelationShips($form_values, $dom, $rootElement); $collectionPid = $form_values['collection_pid']; - + if (($cp = CollectionPolicy::LoadFromCollection($collectionPid)) !== FALSE) { - $collectionName = trim($cp->getName()); + $collectionName = trim($cp->getName()); if (trim($collectionName) != '') { $form_values['dc_relation'] = $collectionName; } - } + } // Create dublin core $this->createQDCStream($form_values, $dom, $rootElement); @@ -150,43 +169,49 @@ class FormBuilder { $this->createPolicy($collectionPid, &$dom, &$rootElement); try { - + $object = Fedora_Item::ingest_from_FOXML($dom); if (!empty($object->pid)) { // drupal_set_message("Item ". l($object->pid, 'fedora/repository/'. $object->pid) . " created successfully.", "status"); - drupal_set_message(t("Item !pid created successfully.", array('!pid' => l($object->pid, 'fedora/repository/'. $object->pid))), "status"); + drupal_set_message(t("Item !pid created successfully.", array('!pid' => l($object->pid, 'fedora/repository/' . $object->pid))), "status"); } - if (!empty( $_SESSION['fedora_ingest_files'])) { + if (!empty($_SESSION['fedora_ingest_files'])) { foreach ($_SESSION['fedora_ingest_files'] as $dsid => $createdFile) { file_delete($createdFile); } } 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'); watchdog(t("Fedora_Repository"), t("Error ingesting object: !e", array('!e' => $e->getMessage())), NULL, WATCHDOG_ERROR); 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) { module_load_include('inc', 'fedora_repository', 'MimeClass'); global $base_url; $mimetype = new MimeClass(); - $server=NULL; - $file=$form_values['ingest-file-location']; + $server = NULL; + $file = $form_values['ingest-file-location']; - if (!empty( $file)) { + if (!empty($file)) { $dformat = $mimetype->getType($file); - + $parts = explode('/', $file); foreach ($parts as $n => $part) { $parts[$n] = rawurlencode($part); } $path = implode('/', $parts); $fileUrl = $base_url . '/' . $path; - + $beginIndex = strrpos($fileUrl, '/'); $dtitle = substr($fileUrl, $beginIndex + 1); $dtitle = urldecode($dtitle); @@ -194,7 +219,7 @@ class FormBuilder { $ds1->setAttribute("ID", "OBJ"); $ds1->setAttribute("STATE", "A"); $ds1->setAttribute("CONTROL_GROUP", "M"); - $ds1v= $dom->createElement("foxml:datastreamVersion"); + $ds1v = $dom->createElement("foxml:datastreamVersion"); $rootElement->appendChild($ds1); $ds1v->setAttribute("ID", "OBJ.0"); @@ -207,27 +232,24 @@ class FormBuilder { $ds1v->appendChild($ds1content); } if (!empty($_SESSION['fedora_ingest_files'])) { - - - + foreach ($_SESSION['fedora_ingest_files'] as $dsid => $createdFile) { - - - if (!empty($file)) { - $found = strstr($createdFile, $file); - if ($found !== FALSE) { - $createdFile = $found; - } - } + + if (!empty($file)) { + $found = strstr($createdFile, $file); + if ($found !== FALSE) { + $createdFile = $found; + } + } $dformat = $mimetype->getType($createdFile); - $parts = explode('/', $createdFile); + $parts = explode('/', $createdFile); foreach ($parts as $n => $part) { $parts[$n] = rawurlencode($part); } $path = implode('/', $parts); $fileUrl = $base_url . '/' . $path; - + $beginIndex = strrpos($fileUrl, '/'); $dtitle = substr($fileUrl, $beginIndex + 1); $dtitle = urldecode($dtitle); @@ -236,7 +258,7 @@ class FormBuilder { $ds1->setAttribute("ID", "$dsid"); $ds1->setAttribute("STATE", "A"); $ds1->setAttribute("CONTROL_GROUP", "M"); - $ds1v= $dom->createElement("foxml:datastreamVersion"); + $ds1v = $dom->createElement("foxml:datastreamVersion"); $ds1v->setAttribute("ID", "$dsid.0"); $ds1v->setAttribute("MIMETYPE", "$dformat"); $ds1v->setAttribute("LABEL", "$dtitle"); @@ -250,9 +272,11 @@ class FormBuilder { } } - /** * Creates the RELS-EXT for the foxml + * @param type $form_values + * @param type $dom + * @param type $rootElement */ function createRelationShips($form_values, &$dom, &$rootElement) { $drdf = $dom->createElement("foxml:datastream"); @@ -278,11 +302,11 @@ class FormBuilder { if (!isset($relationship)) { $relationship = 'isMemberOfCollection'; } - $member = $dom->createElement("fedora:". $relationship); + $member = $dom->createElement("fedora:" . $relationship); $membr = $form_values['collection_pid']; $member->setAttribute("rdf:resource", "info:fedora/$membr"); $rdfHasModel = $dom->createElement("fedora-model:hasModel"); - $contentModelPid=$form_values['content_model_pid']; + $contentModelPid = $form_values['content_model_pid']; $rdfHasModel->setAttribute("rdf:resource", "info:fedora/$contentModelPid"); $drdf->appendChild($dvrdf); $dvrdf->appendChild($dvcontent); @@ -293,9 +317,11 @@ class FormBuilder { $rootElement->appendChild($drdf); } - /** * Creates the standard foxml properties + * @param type $form_values + * @param type $dom + * @param type $rootElement */ function createStandardFedoraStuff($form_values, &$dom, &$rootElement) { // Foxml object properties section @@ -315,57 +341,66 @@ class FormBuilder { $rootElement->appendChild($objproperties); } - + /** + * Build QDC Form + * @param type $form + * @param type $elements + * @param type $form_values + * @return string + */ function buildQDCForm(&$form, $elements, &$form_values) { $form['#multistep'] = TRUE; // used so that it triggers a form rebuild every time. $form['indicator2'] = array( '#type' => 'fieldset', '#title' => t('Ingest digital object step #2'), ); - + foreach ($elements as $element) { - - if ($element['type'] == 'markup') { - $el = array('#value'=> $element['description']); - } else { - $el = array( - '#title' => $element['label'], - '#required' => ($element['required'] ? 1 : 0), - '#description' => $element['description'], - '#type' => $element['type'] - ); - } - $name = explode('][', $element['name']); - $elLocation = &$form['indicator2']; - while (isset($elLocation[$name[0]]) && ($partial = array_shift($name)) != NULL) { - $elLocation = &$elLocation[$partial]; - } - - $autocomplete_path = FALSE; - $autocomplete_omit_collection = FALSE; + if ($element['type'] == 'markup') { + $el = array('#value' => $element['description']); + } + else { + $el = array( + '#title' => $element['label'], + '#required' => ($element['required'] ? 1 : 0), + '#description' => $element['description'], + '#type' => $element['type'] + ); + } + + $name = explode('][', $element['name']); + $elLocation = &$form['indicator2']; + while (isset($elLocation[$name[0]]) && ($partial = array_shift($name)) != NULL) { + $elLocation = &$elLocation[$partial]; + } + + $autocomplete_path = FALSE; + $autocomplete_omit_collection = FALSE; foreach ($element['parameters'] as $key => $val) { if ($key == '#autocomplete_path') { - $autocomplete_path = $val; - } elseif ($key == '#autocomplete_omit_collection') { - $autocomplete_omit_collection = TRUE; - } else { - $el[$key]=$val; - } + $autocomplete_path = $val; + } + elseif ($key == '#autocomplete_omit_collection') { + $autocomplete_omit_collection = TRUE; + } + else { + $el[$key] = $val; + } } - if ($autocomplete_path !== FALSE) { - $el['#autocomplete_path'] = $autocomplete_path . (!$autocomplete_omit_collection?'/'.$form_values['storage']['collection_pid']:'/'); - } + if ($autocomplete_path !== FALSE) { + $el['#autocomplete_path'] = $autocomplete_path . (!$autocomplete_omit_collection ? '/' . $form_values['storage']['collection_pid'] : '/'); + } if ($element['type'] == 'select' || $element['type'] == 'other_select') { - $el['#options']= isset($element['authoritative_list'])?$element['authoritative_list']:array(); + $el['#options'] = isset($element['authoritative_list']) ? $element['authoritative_list'] : array(); } - + $elLocation[join('][', $name)] = $el; } - + return $form; } - + } diff --git a/plugins/ImageManipulation.inc b/plugins/ImageManipulation.inc index 9971c367..c9125862 100644 --- a/plugins/ImageManipulation.inc +++ b/plugins/ImageManipulation.inc @@ -2,40 +2,54 @@ // $Id$ -/* - * - * - * This Class implements the methods defined in the STANDARD_IMAGE content model +/** + * @file + * Image Manipulation class */ +/** + * This Class implements the methods defined in the STANDARD_IMAGE content model + */ class ImageManipulation { + /** + * Constructor + */ function ImageManipulation() { 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) { $system = getenv('System'); $file_suffix = '_' . $dsid . '.' . $file_ext; - $width = $parameterArray['width']; + $width = $parameterArray['width']; if (!isset($parameterArray['height'])) { - $height = $width; - } else { - $height = $parameterArray['height']; + $height = $width; + } + else { + $height = $parameterArray['height']; } $returnValue = TRUE; $output = array(); - - $destDir = dirname($file).'/work'; - $destFile = $destDir .'/'. basename($file) . $file_suffix; - if (!is_dir($destDir)) { + + $destDir = dirname($file) . '/work'; + $destFile = $destDir . '/' . basename($file) . $file_suffix; + if (!is_dir($destDir)) { @mkdir($destDir); } if (!file_exists($destFile)) { - exec('convert -resize ' . $width . 'x'.$height.' -quality 85 "' . $file . '"[0] -strip "' .$destFile . '" 2>&1 &', $output, $returnValue); + exec('convert -resize ' . $width . 'x' . $height . ' -quality 85 "' . $file . '"[0] -strip "' . $destFile . '" 2>&1 &', $output, $returnValue); } else $returnValue = '0'; @@ -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) { $file_suffix = '_' . $dsid . '.' . $file_ext; $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) { $file_suffix = "_$dsid.$file_ext"; $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) { $height = $parameterArray['height']; $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) { $height = $parameterArray['height']; $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) { // var_dump($parameterArray);exit(0); $file_suffix = '_' . $dsid . '.' . $file_ext; diff --git a/plugins/ModsFormBuilder.inc b/plugins/ModsFormBuilder.inc index 6eb36d1b..b9741dca 100644 --- a/plugins/ModsFormBuilder.inc +++ b/plugins/ModsFormBuilder.inc @@ -2,244 +2,268 @@ // $Id$ +/** + * @file + * ModsFormBuilder class + */ module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder'); + +/** + * ModsFormBuilder class ??? + */ class ModsFormBuilder extends FormBuilder { + static $MODS_NS = 'http://www.loc.gov/mods/v3'; protected $cm; protected $item; - protected $pid; - - function __construct($pid=null) - { - parent::__construct(); - if ($pid !== null) - { - module_load_include('inc', 'fedora_repository', 'ContentModel'); - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - - $this->pid=$pid; - $this->cm = ContentModel::loadFromObject($pid); - $this->item = new fedora_item($pid); - } - } - - function handleEditMetadataForm(&$form_id, &$form_values, &$soap_client) - { + protected $pid; + + /** + * Constructor + * @param type $pid + */ + function __construct($pid=null) { + parent::__construct(); + if ($pid !== null) { + module_load_include('inc', 'fedora_repository', 'ContentModel'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + + $this->pid = $pid; + $this->cm = ContentModel::loadFromObject($pid); + $this->item = new fedora_item($pid); + } + } + + /** + * 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->formatOutput = TRUE; - $mods = $this->modsFromForm($form_values,$dom); + $mods = $this->modsFromForm($form_values, $dom); $dom->appendChild($mods); - + if ($this->item->modify_datastream_by_value($dom->saveXML(), 'MODS', "MODS Record", 'text/xml') !== NULL) { - drupal_set_message(t('Successfully updated MODS datastream for object %pid', array('%pid'=>$this->pid))); - } - drupal_goto('/fedora/repository/'.$this->pid); - } - - function buildEditMetadataForm() - { - $form['#multistep'] = TRUE; // used so that it triggers a form rebuild every time. - $form['indicator2'] = array( - '#type' => 'fieldset', - '#title' => t('Edit metadata'), - ); - + drupal_set_message(t('Successfully updated MODS datastream for object %pid', array('%pid' => $this->pid))); + } + drupal_goto('/fedora/repository/' . $this->pid); + } + + /** + * Build Edit Metadata Form + * @return array + */ + function buildEditMetadataForm() { + $form['#multistep'] = TRUE; // used so that it triggers a form rebuild every time. + $form['indicator2'] = array( + '#type' => 'fieldset', + '#title' => t('Edit metadata'), + ); + if ($this->cm !== FALSE && $this->item != NULL) { - $form['pid'] = array('#type'=>'hidden','#value'=>$this->pid); - + $form['pid'] = array('#type' => 'hidden', '#value' => $this->pid); + $elements = $this->cm->getIngestFormElements(); - $content = $this->item->get_datastream_dissemination('MODS'); - - if (trim($content) != '') { - $dom = DOMDocument::loadXML($content); - $xpath = new DOMXPath($dom); - // Register the php: namespace (required) - $xpath->registerNamespace("php", "http://php.net/xpath"); - - // Register PHP functions (no restrictions) - $xpath->registerPHPFunctions(); - - foreach ($elements as $element) { - - $el = array( - '#title' => $element['label'], - '#required' => ($element['required'] ? 1 : 0), - '#description' => $element['description'], - '#type' => $element['type'] - ); - - $includeEl = true; - $elname = explode('][', $element['name']); - $elLocation = &$form['indicator2']; - while (isset($elLocation[$name[0]]) && ($partial = array_shift($elname)) != NULL) { - $elLocation = &$elLocation[$partial]; - } - - foreach ($element['parameters'] as $key => $val) { - switch ($key) { - case '#autocomplete_path': - $val .= '/'. $form_values['storage']['collection_pid']; - break; - - case '#exclude_from_edit_metadata': - $includeEl=FALSE; - break; - - - case '#edit_metadata_xpath': - $nodeList = $xpath->evaluate($val); + $content = $this->item->get_datastream_dissemination('MODS'); + + if (trim($content) != '') { + $dom = DOMDocument::loadXML($content); + $xpath = new DOMXPath($dom); + // Register the php: namespace (required) + $xpath->registerNamespace("php", "http://php.net/xpath"); + + // Register PHP functions (no restrictions) + $xpath->registerPHPFunctions(); + + foreach ($elements as $element) { + + $el = array( + '#title' => $element['label'], + '#required' => ($element['required'] ? 1 : 0), + '#description' => $element['description'], + '#type' => $element['type'] + ); + + $includeEl = true; + $elname = explode('][', $element['name']); + $elLocation = &$form['indicator2']; + while (isset($elLocation[$name[0]]) && ($partial = array_shift($elname)) != NULL) { + $elLocation = &$elLocation[$partial]; + } + + foreach ($element['parameters'] as $key => $val) { + switch ($key) { + case '#autocomplete_path': + $val .= '/' . $form_values['storage']['collection_pid']; + break; + + case '#exclude_from_edit_metadata': + $includeEl = FALSE; + break; + + + case '#edit_metadata_xpath': + $nodeList = $xpath->evaluate($val); // echo $val. ' '.$nodeList->length.' '; // echo $nodeList->item(0)->nodeValue.' '; // echo '
'; - if (is_string($nodeList)) - { - $el['#default_value']=$nodeList; - } else if ($nodeList->length > 1) - { - $el['#default_value'] = array(); - foreach ($nodeList as $node) - { - $el['#default_value'][] = $node->nodeValue; - } - } else if ($nodeList->length > 0) - { - if ($el['#type'] == 'list') { - $values=array(); - for ($i=0;$i<$nodeList->length;$i++) { - $values[]=$nodeList->item($i)->nodeValue; - } - $el['#default_value']=join('; ',$values); - } else { - $el['#default_value'] = $nodeList->item(0)->nodeValue; - } - } - break; - } - - if ($key != '#sticky') { - $el[$key]=$val; - } - - } - - if ($element['type'] == 'people') - { - - $names = $xpath->evaluate('/mods:mods/mods:name'); - $people=array(); - foreach ($names as $mname) { - - $type = $mname->getAttribute('type'); - $role = $mname->getElementsByTagName('roleTerm')->item(0)->nodeValue; - - $nameParts = $mname->getElementsByTagName('namePart'); - foreach ($nameParts as $namePart) - { - switch ($namePart->getAttribute('type')) { - case 'given': $given = $namePart->nodeValue; break; - case 'family': $family = $namePart->nodeValue; break; - case 'termsOfAddress': $title = $namePart->nodeValue; break; - case 'date': $date = $namePart->nodeValue; break; - default: $name = $namePart->nodeValue; break; + if (is_string($nodeList)) { + $el['#default_value'] = $nodeList; + } + else if ($nodeList->length > 1) { + $el['#default_value'] = array(); + foreach ($nodeList as $node) { + $el['#default_value'][] = $node->nodeValue; + } + } + else if ($nodeList->length > 0) { + if ($el['#type'] == 'list') { + $values = array(); + for ($i = 0; $i < $nodeList->length; $i++) { + $values[] = $nodeList->item($i)->nodeValue; + } + $el['#default_value'] = join('; ', $values); + } + else { + $el['#default_value'] = $nodeList->item(0)->nodeValue; + } + } + break; + } + + if ($key != '#sticky') { + $el[$key] = $val; + } } - } - - $person=array('role'=>$role); - switch ($type) - { - case 'personal': - if (isset($given) && isset($family) && !isset($name)) { - $name = (isset($title)?$title.' ':'').$family.', '.$family; - } - $person['name']=$name; - $person['date']=$date; - break; - case 'organization': - $person['organization'] = $name; - break; - case 'conference': - $person['conference']=$name; - $person['date']=$date; - break; - } - $people[]=$person; - } - - $names = $xpath->evaluate('/mods:mods/mods:subject/mods:name'); - foreach ($names as $mname) { - - $type = $mname->getAttribute('type'); - - $nameParts = $mname->getElementsByTagName('namePart'); - foreach ($nameParts as $namePart) - { - switch ($namePart->getAttribute('type')) { - case 'given': $given = $namePart->nodeValue; break; - case 'family': $family = $namePart->nodeValue; break; - case 'termsOfAddress': $title = $namePart->nodeValue; break; - case 'date': $date = $namePart->nodeValue; break; - default: $name = $namePart->nodeValue; break; - } - } - - $person=array('subject'=>1); - switch ($type) - { - case 'personal': - if (isset($given) && isset($family) && !isset($name)) { - $name = (isset($title)?$title.' ':'').$family.', '.$family; - } - $person['name']=$name; - $person['date']=$date; - break; - case 'organization': - $person['organization'] = $name; - break; - case 'conference': - $person['conference']=$name; - $person['date']=$date; - break; - } - $people[]=$person; - } - - $el['#default_value'] = $people; - - } - - - if ($element['type'] == 'select' || $element['type'] == 'other_select') { - $el['#options']= isset($element['authoritative_list'])?$element['authoritative_list']:array(); - } - - if ($includeEl) { - $elLocation[join('][', $elname)] = $el; - } - } - - $form['submit'] = array( - '#type' => 'submit', - '#submit' => array('fedora_repository_edit_qdc_form_submit'), - '#value' => 'Save Metadata' - ); - - return $form; + if ($element['type'] == 'people') { + + $names = $xpath->evaluate('/mods:mods/mods:name'); + $people = array(); + foreach ($names as $mname) { + + $type = $mname->getAttribute('type'); + $role = $mname->getElementsByTagName('roleTerm')->item(0)->nodeValue; + + $nameParts = $mname->getElementsByTagName('namePart'); + foreach ($nameParts as $namePart) { + switch ($namePart->getAttribute('type')) { + case 'given': $given = $namePart->nodeValue; + break; + case 'family': $family = $namePart->nodeValue; + break; + case 'termsOfAddress': $title = $namePart->nodeValue; + break; + case 'date': $date = $namePart->nodeValue; + break; + default: $name = $namePart->nodeValue; + break; + } + } + + $person = array('role' => $role); + switch ($type) { + case 'personal': + if (isset($given) && isset($family) && !isset($name)) { + $name = (isset($title) ? $title . ' ' : '') . $family . ', ' . $family; + } + $person['name'] = $name; + $person['date'] = $date; + break; + case 'organization': + $person['organization'] = $name; + break; + case 'conference': + $person['conference'] = $name; + $person['date'] = $date; + break; + } + $people[] = $person; + } + + $names = $xpath->evaluate('/mods:mods/mods:subject/mods:name'); + foreach ($names as $mname) { + + $type = $mname->getAttribute('type'); + + $nameParts = $mname->getElementsByTagName('namePart'); + foreach ($nameParts as $namePart) { + switch ($namePart->getAttribute('type')) { + case 'given': $given = $namePart->nodeValue; + break; + case 'family': $family = $namePart->nodeValue; + break; + case 'termsOfAddress': $title = $namePart->nodeValue; + break; + case 'date': $date = $namePart->nodeValue; + break; + default: $name = $namePart->nodeValue; + break; + } + } + + $person = array('subject' => 1); + switch ($type) { + case 'personal': + if (isset($given) && isset($family) && !isset($name)) { + $name = (isset($title) ? $title . ' ' : '') . $family . ', ' . $family; + } + $person['name'] = $name; + $person['date'] = $date; + break; + case 'organization': + $person['organization'] = $name; + break; + case 'conference': + $person['conference'] = $name; + $person['date'] = $date; + break; + } + $people[] = $person; + } + + $el['#default_value'] = $people; + } + + + if ($element['type'] == 'select' || $element['type'] == 'other_select') { + $el['#options'] = isset($element['authoritative_list']) ? $element['authoritative_list'] : array(); + } + + if ($includeEl) { + $elLocation[join('][', $elname)] = $el; + } + } + + $form['submit'] = array( + '#type' => 'submit', + '#submit' => array('fedora_repository_edit_qdc_form_submit'), + '#value' => 'Save Metadata' + ); + + return $form; } } - - } - - function handleModsForm(&$form_values,&$form_state) { + } + + /** + * Handle Mods Form + * @param &$form_values + * @param &$form_state + */ + function handleModsForm(&$form_values, &$form_state) { module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'CollectionPolicy'); - - $form_state['storage']['people']=NULL; //clears out old entities for the next run of the formbuilder. - + + $form_state['storage']['people'] = NULL; //clears out old entities for the next run of the formbuilder. + $dom = new DomDocument("1.0", "UTF-8"); $dom->formatOutput = TRUE; - $pid=$form_values['pid']; + $pid = $form_values['pid']; $rootElement = $dom->createElement("foxml:digitalObject"); $rootElement->setAttribute('VERSION', '1.1'); $rootElement->setAttribute('PID', "$pid"); @@ -247,24 +271,24 @@ class ModsFormBuilder extends FormBuilder { $rootElement->setAttribute('xmlns:xsi', "http://www.w3.org/2001/XMLSchema-instance"); $rootElement->setAttribute('xsi:schemaLocation', "info:fedora/fedora-system:def/foxml# http://www.fedora.info/definitions/1/0/foxml1-1.xsd"); $dom->appendChild($rootElement); - + // Create standard fedora stuff $form_values['dc:title'] = $form_values['mods_title']; $this->createStandardFedoraStuff($form_values, $dom, $rootElement); - + // Create relationships $this->createRelationShips($form_values, $dom, $rootElement); $collectionPid = $form_values['collection_pid']; - + if (($cp = CollectionPolicy::LoadFromCollection($collectionPid)) !== FALSE) { - $collectionName =trim($cp->getName()); - if (trim($collectionName)!='') { - $form_values['dc_relation']=$collectionName; + $collectionName = trim($cp->getName()); + if (trim($collectionName) != '') { + $form_values['dc_relation'] = $collectionName; } - } + } // Create MODS $this->createModsStream($form_values, $dom, $rootElement); - $this->createCollectionPolicy($form_values, $dom, $rootElement); + $this->createCollectionPolicy($form_values, $dom, $rootElement); $this->createWorkflowStream($form_values, $dom, $rootElement); if (!empty($form_values['ingest-file-location'])) { @@ -274,33 +298,37 @@ class ModsFormBuilder extends FormBuilder { // header('Content-type: application/xml'); // echo $dom->saveXML(); exit(); - + try { - $object = Fedora_Item::ingest_from_FOXML($dom); - //for some reason, ingest_from_FOXML does not generate a JMS message - //I just modify the workflow DS and it sends a JMS message. - $item = new Fedora_Item($object->pid); - $item->modify_datastream_by_value( $item->get_datastream_dissemination('WORKFLOW'), 'WORKFLOW', "Workflow Record", 'text/xml'); - - if (!empty($object->pid)) { - drupal_set_message(t("Item !pid created successfully.", array('!pid' => l($object->pid, 'fedora/repository/'. $object->pid))), "status"); - } - if (!empty( $_SESSION['fedora_ingest_files'])) { - foreach ($_SESSION['fedora_ingest_files'] as $dsid => $createdFile) { - file_delete($createdFile); - } - } - file_delete($form_values['ingest-file-location']); - } - catch (exception $e) { + $object = Fedora_Item::ingest_from_FOXML($dom); + //for some reason, ingest_from_FOXML does not generate a JMS message + //I just modify the workflow DS and it sends a JMS message. + $item = new Fedora_Item($object->pid); + $item->modify_datastream_by_value($item->get_datastream_dissemination('WORKFLOW'), 'WORKFLOW', "Workflow Record", 'text/xml'); + + if (!empty($object->pid)) { + drupal_set_message(t("Item !pid created successfully.", array('!pid' => l($object->pid, 'fedora/repository/' . $object->pid))), "status"); + } + if (!empty($_SESSION['fedora_ingest_files'])) { + foreach ($_SESSION['fedora_ingest_files'] as $dsid => $createdFile) { + file_delete($createdFile); + } + } + file_delete($form_values['ingest-file-location']); + } catch (exception $e) { 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); return; } - } - - - function createCollectionPolicy($form_values, &$dom, &$rootElement) { + } + + /** + * Create Collection Policy ?? + * @param $form_values + * @param &$dom + * @param &$rootElement + */ + function createCollectionPolicy($form_values, &$dom, &$rootElement) { module_load_include('inc', 'fedora_repository', 'api/fedora_item'); $model = new fedora_item($form_values['content_model_pid']); $ds_list = $model->get_datastreams_list_as_array(); @@ -308,10 +336,10 @@ class ModsFormBuilder extends FormBuilder { $cp = $model->get_datastream_dissemination('COLLECTION_POLICY_TMPL'); $cpDom = DOMDocument::loadXML($cp); $cpRootEl = $cpDom->getElementsByTagName('collection_policy'); - if ($cpRootEl->length >0) { - $cpRootEl=$cpRootEl->item(0); + if ($cpRootEl->length > 0) { + $cpRootEl = $cpRootEl->item(0); $newNode = $dom->importNode($cpRootEl, TRUE); - + $datastream = $dom->createElement("foxml:datastream"); $datastream->setAttribute("ID", "COLLECTION_POLICY"); $datastream->setAttribute("STATE", "A"); @@ -328,7 +356,13 @@ class ModsFormBuilder extends FormBuilder { } } } - + + /** + * Create Workflow Stream ?? + * @param $form_values + * @param &$dom + * @param &$rootElement + */ function createWorkflowStream($form_values, &$dom, &$rootElement) { module_load_include('inc', 'fedora_repository', 'api/fedora_item'); $model = new fedora_item($form_values['content_model_pid']); @@ -337,10 +371,10 @@ class ModsFormBuilder extends FormBuilder { $workflow = $model->get_datastream_dissemination('WORKFLOW_TMPL'); $workflowDom = DOMDocument::loadXML($workflow); $workflowRootEl = $workflowDom->getElementsByTagName('workflow'); - if ($workflowRootEl->length >0) { - $workflowRootEl=$workflowRootEl->item(0); + if ($workflowRootEl->length > 0) { + $workflowRootEl = $workflowRootEl->item(0); $newNode = $dom->importNode($workflowRootEl, TRUE); - + $datastream = $dom->createElement("foxml:datastream"); $datastream->setAttribute("ID", "WORKFLOW"); $datastream->setAttribute("STATE", "A"); @@ -357,9 +391,15 @@ class ModsFormBuilder extends FormBuilder { } } } - + + /** + * Create mods Stream ?? + * @param $form_values + * @param &$dom + * @param &$rootElement + */ function createModsStream($form_values, &$dom, &$rootElement) { - + $datastream = $dom->createElement("foxml:datastream"); $datastream->setAttribute("ID", "MODS"); $datastream->setAttribute("STATE", "A"); @@ -371,63 +411,67 @@ class ModsFormBuilder extends FormBuilder { $datastream->appendChild($version); $content = $dom->createElement("foxml:xmlContent"); $version->appendChild($content); - - $mods = $this->modsFromForm($form_values,$dom); + + $mods = $this->modsFromForm($form_values, $dom); $content->appendChild($mods); - - $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->setAttribute('version', '3.4'); $mods->setAttribute('xmlns:xlink', "http://www.w3.org/1999/xlink"); $mods->setAttribute('xmlns:mods', "http://www.loc.gov/mods/v3"); $mods->setAttribute('xmlns:xsi', "http://www.w3.org/2001/XMLSchema-instance"); $mods->setAttribute('xsi:schemaLocation', "http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-0.xsd"); - - + + if (isset($form_values['mods_title']) && trim($form_values['mods_title']) != '') { $titleinfo = $dom->createElement('mods:titleInfo'); - $title = $dom->createElement('mods:title', htmlspecialchars($form_values['mods_title'])); + $title = $dom->createElement('mods:title', htmlspecialchars($form_values['mods_title'])); $titleinfo->appendChild($title); $mods->appendChild($titleinfo); } - - if (isset($form_values['mods_alternative_titles']) && trim($form_values['mods_alternative_titles']) != '') { - $titles=preg_split('/\s+\;\s+/',trim($form_values['mods_alternative_titles'])); + + if (isset($form_values['mods_alternative_titles']) && trim($form_values['mods_alternative_titles']) != '') { + $titles = preg_split('/\s+\;\s+/', trim($form_values['mods_alternative_titles'])); foreach ($titles as $t) { - $titleinfo = $dom->createElement('mods:titleInfo'); - $titleinfo->setAttribute('type','alternative') ; - $title = $dom->createElement('mods:title',$t); - $titleinfo->appendChild($title); - $mods->appendChild($titleinfo); + $titleinfo = $dom->createElement('mods:titleInfo'); + $titleinfo->setAttribute('type', 'alternative'); + $title = $dom->createElement('mods:title', $t); + $titleinfo->appendChild($title); + $mods->appendChild($titleinfo); } } - - if (isset($form_values['mods_alternative_title']) && trim($form_values['mods_alternative_title']) != '') { - $titleinfo = $dom->createElement('mods:titleInfo'); - $titleinfo->setAttribute('type','alternative') ; - $title = $dom->createElement('mods:title',trim($form_values['mods_alternative_title'])); - $titleinfo->appendChild($title); - $mods->appendChild($titleinfo); - } - + + if (isset($form_values['mods_alternative_title']) && trim($form_values['mods_alternative_title']) != '') { + $titleinfo = $dom->createElement('mods:titleInfo'); + $titleinfo->setAttribute('type', 'alternative'); + $title = $dom->createElement('mods:title', trim($form_values['mods_alternative_title'])); + $titleinfo->appendChild($title); + $mods->appendChild($titleinfo); + } + if (isset($form_values['mods_description']) && trim($form_values['mods_description']) != '') { - $abstract = $dom->createElement('mods:abstract', htmlspecialchars(trim($form_values['mods_description']))); - $mods->appendChild($abstract); + $abstract = $dom->createElement('mods:abstract', htmlspecialchars(trim($form_values['mods_description']))); + $mods->appendChild($abstract); } - + if (isset($form_values['pid']) && trim($form_values['pid']) != '') { - $identifier = $dom->createElement('mods:identifier', htmlspecialchars(trim(preg_replace('/\:/','\/',$form_values['pid'])))); + $identifier = $dom->createElement('mods:identifier', htmlspecialchars(trim(preg_replace('/\:/', '\/', $form_values['pid'])))); $identifier->setAttribute('type', 'hdl'); $mods->appendChild($identifier); } - + if (isset($form_values['collection_pid']) && trim($form_values['collection_pid']) != '') { $relatedItem = $dom->createElement('mods:relatedItem'); $relatedItem->setAttribute('type', 'isMemberOfCollection'); @@ -435,13 +479,13 @@ class ModsFormBuilder extends FormBuilder { $relatedItem->appendChild($identifier); $mods->appendChild($relatedItem); } - + if (isset($form_values['mods_identifier']) && trim($form_values['mods_identifier']) != '') { $identifier = $dom->createElement('mods:identifier', htmlspecialchars(trim($form_values['mods_identifier']))); $identifier->setAttribute('type', 'local'); $mods->appendChild($identifier); } - + if (isset($form_values['mods_physicalLocation']) && trim($form_values['mods_physicalLocation']) != '') { $location = $dom->createElement('mods:location'); $physLocation = $dom->createElement('mods:physicalLocation', htmlspecialchars(trim($form_values['mods_physicalLocation']))); @@ -452,154 +496,152 @@ class ModsFormBuilder extends FormBuilder { } $mods->appendChild($location); } - + $originInfo = $dom->createElement('mods:originInfo'); $addOriginInfo = FALSE; if (isset($form_values['mods_pubinfo_place']) && trim($form_values['mods_pubinfo_place']) != '') { $place = $dom->createElement('mods:place'); - $placeTerm=$dom->createElement('mods:placeTerm', htmlspecialchars(trim($form_values['mods_pubinfo_place']))); + $placeTerm = $dom->createElement('mods:placeTerm', htmlspecialchars(trim($form_values['mods_pubinfo_place']))); $placeTerm->setAttribute('type', 'text'); $place->appendChild($placeTerm); $originInfo->appendChild($place); $addOriginInfo = TRUE; } - + if (isset($form_values['mods_pubinfo_publisher']) && trim($form_values['mods_pubinfo_publisher']) != '') { $publisher = $dom->createElement('mods:publisher', htmlspecialchars(trim($form_values['mods_pubinfo_publisher']))); $originInfo->appendChild($publisher); $addOriginInfo = TRUE; } - + if (isset($form_values['mods_pubinfo_edition']) && trim($form_values['mods_pubinfo_edition']) != '') { $edition = $dom->createElement('mods:edition', htmlspecialchars(trim($form_values['mods_pubinfo_edition']))); $originInfo->appendChild($edition); $addOriginInfo = TRUE; } - - + + if (isset($form_values['mods_pubinfo_date']) && trim($form_values['mods_pubinfo_date']) != '' && isset($form_values['mods_pubinfo_dateType']) && trim($form_values['mods_pubinfo_dateType']) != '') { - if (in_array($form_values['mods_pubinfo_dateType'], array('issued', 'created', 'copyright', 'captured'))) { - $date = $dom->createElement('mods:'. trim($form_values['mods_pubinfo_dateType']) .'Date', htmlspecialchars(trim($form_values['mods_pubinfo_date']))); - } - else { - //how to handle other types? otherDate? - $date= $dom->createElement('mods:otherDate', htmlspecialchars(trim($form_values['mods_pubinfo_date']))); - $date->setAttribute('type', htmlspecialchars(trim($form_values['mods_pubinfo_dateType']))); - } - $originInfo->appendChild($date); - $addOriginInfo = TRUE; - } else { + if (in_array($form_values['mods_pubinfo_dateType'], array('issued', 'created', 'copyright', 'captured'))) { + $date = $dom->createElement('mods:' . trim($form_values['mods_pubinfo_dateType']) . 'Date', htmlspecialchars(trim($form_values['mods_pubinfo_date']))); + } + else { + //how to handle other types? otherDate? + $date = $dom->createElement('mods:otherDate', htmlspecialchars(trim($form_values['mods_pubinfo_date']))); + $date->setAttribute('type', htmlspecialchars(trim($form_values['mods_pubinfo_dateType']))); + } + $originInfo->appendChild($date); + $addOriginInfo = TRUE; + } + else { if (isset($form_values['mods_createdDate'])) { - $date = $dom->createElement('mods:createdDate',htmlspecialchars(trim($form_values['mods_createdDate']))); - $originInfo->appendChild($date); + $date = $dom->createElement('mods:createdDate', htmlspecialchars(trim($form_values['mods_createdDate']))); + $originInfo->appendChild($date); $addOriginInfo = TRUE; } - + if (isset($form_values['mods_issuedDate'])) { - $date = $dom->createElement('mods:issuedDate',htmlspecialchars(trim($form_values['mods_issuedDate']))); - $originInfo->appendChild($date); + $date = $dom->createElement('mods:issuedDate', htmlspecialchars(trim($form_values['mods_issuedDate']))); + $originInfo->appendChild($date); $addOriginInfo = TRUE; } - + if (isset($form_values['mods_copyrightDate'])) { - $date = $dom->createElement('mods:copyrightDate',htmlspecialchars(trim($form_values['mods_copyrightDate']))); - $originInfo->appendChild($date); + $date = $dom->createElement('mods:copyrightDate', htmlspecialchars(trim($form_values['mods_copyrightDate']))); + $originInfo->appendChild($date); $addOriginInfo = TRUE; } - + if (isset($form_values['mods_capturedDate'])) { - $date = $dom->createElement('mods:capturedDate',htmlspecialchars(trim($form_values['mods_capturedDate']))); - $originInfo->appendChild($date); + $date = $dom->createElement('mods:capturedDate', htmlspecialchars(trim($form_values['mods_capturedDate']))); + $originInfo->appendChild($date); $addOriginInfo = TRUE; } - } - + if (isset($form_values['mods_pubinfo_journalFreq']) && trim($form_values['mods_pubinfo_journalFreq']) != '') { $frequency = $dom->createElement('mods:frequency', htmlspecialchars(trim($form_values['mods_pubinfo_journalFreq']))); $originInfo->appendChild($frequency); - $issuance= $dom->createElement('mods:issuance', 'journal'); + $issuance = $dom->createElement('mods:issuance', 'journal'); $originInfo->appendChild($issuance); $addOriginInfo = TRUE; - } + } elseif (isset($form_values['mods_pubinfo_journalFreq'])) { - $issuance= $dom->createElement('mods:issuance', 'monographic'); + $issuance = $dom->createElement('mods:issuance', 'monographic'); $originInfo->appendChild($issuance); } - - + + if ($addOriginInfo) { $mods->appendChild($originInfo); } - + if (isset($form_values['mods_note']) && trim($form_values['mods_note']) != '') { $note = $dom->createElement('mods:note', htmlspecialchars(trim($form_values['mods_note']))); $mods->appendChild($note); - } - + } + if (isset($form_values['mods_caption']) && trim($form_values['mods_caption']) != '') { $note = $dom->createElement('mods:note', htmlspecialchars(trim($form_values['mods_caption']))); - $note->setAttribute('type','caption'); + $note->setAttribute('type', 'caption'); $mods->appendChild($note); - } - + } + if (isset($form_values['mods_format']) && trim($form_values['mods_format']) != '') { $typeOfResource = $dom->createElement('mods:typeOfResource', htmlspecialchars($form_values['mods_format'])); $mods->appendChild($typeOfResource); } - - - 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'])); - foreach ($languageList as $lang) - { - $language = $dom->createElement('mods:language'); - $langTerm = $dom->createElement('mods:languageTerm',htmlspecialchars($lang)); - $langTerm->setAttribute('type','text'); - $language->appendChild($langTerm); - $mods->appendChild($language); + foreach ($languageList as $lang) { + $language = $dom->createElement('mods:language'); + $langTerm = $dom->createElement('mods:languageTerm', htmlspecialchars($lang)); + $langTerm->setAttribute('type', 'text'); + $language->appendChild($langTerm); + $mods->appendChild($language); } } - - + + $hasSubject = FALSE; $subject = $dom->createElement('mods:subject'); - - + + // Hierarchical Geographic Subject if (isset($form_values['mods_country']) && trim($form_values['mods_country']) != '') { $hasSubject = TRUE; $geographic = $dom->createElement('mods:hierarchicalGeographic'); - - $country=$dom->createElement('mods:country', htmlspecialchars($form_values['mods_country'])); + + $country = $dom->createElement('mods:country', htmlspecialchars($form_values['mods_country'])); $geographic->appendChild($country); - + if (isset($form_values['mods_province']) && trim($form_values['mods_province']) != '') { - $province = $dom->createElement('mods:province', htmlspecialchars($form_values['mods_province'])); + $province = $dom->createElement('mods:province', htmlspecialchars($form_values['mods_province'])); $geographic->appendChild($province); } - + if (isset($form_values['mods_state']) && trim($form_values['mods_state']) != '') { - $state = $dom->createElement('mods:state', htmlspecialchars($form_values['mods_state'])); + $state = $dom->createElement('mods:state', htmlspecialchars($form_values['mods_state'])); $geographic->appendChild($state); } - + if (isset($form_values['mods_city']) && trim($form_values['mods_city']) != '') { - $city = $dom->createElement('mods:city', htmlspecialchars($form_values['mods_city'])); + $city = $dom->createElement('mods:city', htmlspecialchars($form_values['mods_city'])); $geographic->appendChild($city); } - + if (isset($form_values['mods_area']) && trim($form_values['mods_area']) != '') { - $state = $dom->createElement('mods:area', htmlspecialchars($form_values['mods_area'])); + $state = $dom->createElement('mods:area', htmlspecialchars($form_values['mods_area'])); $geographic->appendChild($state); } - - + + $subject->appendChild($geographic); } - + if (isset($form_values['mods_date']) && trim($form_values['mods_date']) != '') { $hasSubject = TRUE; $temporal = $dom->createElement('mods:temporal', htmlspecialchars($form_values['mods_date'])); @@ -608,13 +650,13 @@ class ModsFormBuilder extends FormBuilder { if (isset($form_values['mods_subjtitle']) && trim($form_values['mods_subjtitle']) != '') { $hasSubject = TRUE; - $titleInfo= $dom->createElement('mods:titleInfo'); + $titleInfo = $dom->createElement('mods:titleInfo'); $title = $dom->createElement('mods:title', htmlspecialchars($form_values['mods_subjtitle'])); $titleInfo->appendChild($title); $subject->appendChild($titleInfo); - } - - + } + + if (isset($form_values['mods_topics']) && trim($form_values['mods_topics']) != '') { $hasSubject = TRUE; $topicList = explode(';', htmlspecialchars($form_values['mods_topics'])); @@ -622,102 +664,101 @@ class ModsFormBuilder extends FormBuilder { if (isset($form_values['mods_topicAuthority']) && trim($form_values['mods_topicAuthority']) != '') { $authority = htmlspecialchars($form_values['mods_topicAuthority']); } - + foreach ($topicList as $t) { $topic = $dom->createElement('mods:topic', $t); $topic->setAttribute('authority', $authority); $subject->appendChild($topic); } } - - + + if (isset($form_values['mods_cc']['cc']) && $form_values['mods_cc']['cc']['cc_enable']) { - $commercial = trim($form_values['mods_cc']['cc']['cc_commercial']); - $modifications = trim($form_values['mods_cc']['cc']['cc_modifications']); - $jurisdiction = trim($form_values['mods_cc']['cc']['cc_jurisdiction']); - - module_load_include('inc','islandora_form_elements','includes/creative_commons.inc'); - - if (!isset(CreativeCommons::$cc_jurisdiction_vals[$jurisdiction])) - $jurisdiction=''; - $version = CreativeCommons::$cc_versions[$jurisdiction]; - - $license = 'by'. ($commercial != ''?'-'.$commercial:'') . ($modifications != ''?'-'.$modifications:'') . '/' . $version . '/'.($jurisdiction != ''?$jurisdiction.'/':'') ; - + $commercial = trim($form_values['mods_cc']['cc']['cc_commercial']); + $modifications = trim($form_values['mods_cc']['cc']['cc_modifications']); + $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'); + + if (!isset(CreativeCommons::$cc_jurisdiction_vals[$jurisdiction])) + $jurisdiction = ''; + $version = CreativeCommons::$cc_versions[$jurisdiction]; + + $license = 'by' . ($commercial != '' ? '-' . $commercial : '') . ($modifications != '' ? '-' . $modifications : '') . '/' . $version . '/' . ($jurisdiction != '' ? $jurisdiction . '/' : ''); + $accessCondition = $dom->createElement('mods:accessCondition', htmlspecialchars($license)); $accessCondition->setAttribute('type', 'Creative Commons License'); $mods->appendChild($accessCondition); - - } - + if (isset($form_values['mods_rights']) && trim($form_values['mods_rights']) != '') { $accessCondition = $dom->createElement('mods:accessCondition', htmlspecialchars($form_values['mods_rights'])); $accessCondition->setAttribute('type', 'restriction on access; use and reproduction'); $mods->appendChild($accessCondition); } - - if (isset($form_values['mods_people']) && isset($form_values['mods_people']['people']) && is_array($form_values['mods_people']['people']) ) { + + if (isset($form_values['mods_people']) && isset($form_values['mods_people']['people']) && is_array($form_values['mods_people']['people'])) { foreach ($form_values['mods_people']['people'] as $key => $val) { $name = $dom->createElement('mods:name'); - $appendName=FALSE; + $appendName = FALSE; if (isset($val['role'])) { - $role = $dom->createElement('mods:role'); - $roleTerm = $dom->createElement('mods:roleTerm', htmlspecialchars(trim($val['role']))); - $roleTerm->setAttribute('type', 'text'); - $roleTerm->setAttribute('authority', 'marcrelator'); - $role->appendChild($roleTerm); - $name->appendChild($role); + $role = $dom->createElement('mods:role'); + $roleTerm = $dom->createElement('mods:roleTerm', htmlspecialchars(trim($val['role']))); + $roleTerm->setAttribute('type', 'text'); + $roleTerm->setAttribute('authority', 'marcrelator'); + $role->appendChild($roleTerm); + $name->appendChild($role); } - + if (isset($val['organization'])) { $name->setAttribute('type', 'organization'); if (trim($val['organization']) != '') { - $namePart=$dom->createElement('mods:namePart', htmlspecialchars(trim($val['organization']))); + $namePart = $dom->createElement('mods:namePart', htmlspecialchars(trim($val['organization']))); $name->appendChild($namePart); - $appendName=TRUE; + $appendName = TRUE; } - } + } elseif (isset($val['conference'])) { $name->setAttribute('type', 'conference'); if (trim($val['conference']) != '') { - $namePart=$dom->createElement('mods:namePart', htmlspecialchars(trim($val['conference']))); + $namePart = $dom->createElement('mods:namePart', htmlspecialchars(trim($val['conference']))); $name->appendChild($namePart); - $appendName=TRUE; + $appendName = TRUE; } - } + } else { $name->setAttribute('type', 'personal'); if (trim($val['name']) != '') { - $namePart=$dom->createElement('mods:namePart', htmlspecialchars(trim($val['name']))); + $namePart = $dom->createElement('mods:namePart', htmlspecialchars(trim($val['name']))); $name->appendChild($namePart); - $appendName=TRUE; - } + $appendName = TRUE; + } } - - if (isset($val['date'])) { - $namePart=$dom->createElement('mods:namePart', htmlspecialchars(trim($val['date']))); - $namePart->setAttribute('type','date'); + + if (isset($val['date'])) { + $namePart = $dom->createElement('mods:namePart', htmlspecialchars(trim($val['date']))); + $namePart->setAttribute('type', 'date'); $name->appendChild($namePart); } - + if ($appendName) { - if (isset($val['subject'])) { + if (isset($val['subject'])) { $subject->appendChild($name); - $hasSubject=TRUE; - } else { + $hasSubject = TRUE; + } + else { $mods->appendChild($name); } } + } + } - } - } - if ($hasSubject) { $mods->appendChild($subject); } - + return $mods; } diff --git a/plugins/PersonalCollectionClass.inc b/plugins/PersonalCollectionClass.inc index 9644dd71..70d35827 100644 --- a/plugins/PersonalCollectionClass.inc +++ b/plugins/PersonalCollectionClass.inc @@ -1,11 +1,31 @@ formatOutput = TRUE; @@ -23,34 +43,38 @@ class PersonalCollectionClass { $value = $this->createPolicyStream($theUser, $dom, $rootElement); if (!$value) { - return FALSE;//error should already be logged. + return FALSE; //error should already be logged. } $this->createCollectionPolicyStream($theUser, $dom, $rootElement); try { $params = array( - 'objectXML' => $dom->saveXML(), - 'format' => "foxml1.0", - 'logMessage' => "Fedora object ingested", + 'objectXML' => $dom->saveXML(), + 'format' => "foxml1.0", + 'logMessage' => "Fedora object ingested", ); $object = $soapClient->__soapCall('ingest', array( - $params - )); - - } - catch (exception $e) { + $params + )); + } catch (exception $e) { drupal_set_message(t('Error ingesting personal collection object: !e', array('!e' => $e->getMessage())), 'error'); return FALSE; } return TRUE; } + /** + * Create Collection Policy Stream ?? + * @param type $user + * @param type $dom + * @param type $rootElement + * @return type + */ function createCollectionPolicyStream($user, $dom, $rootElement) { $collectionTemplate = file_get_contents(drupal_get_path('module', 'Fedora_Repository') . '/collection_policies/PERSONAL-COLLECTION-POLICY.xml'); try { $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); drupal_set_message(t('Problem creating personal collection policy, could not parse collection policy stream: !e', array('!e' => $e->getMessage())), 'error'); return FALSE; @@ -88,6 +112,13 @@ class PersonalCollectionClass { return TRUE; } + /** + * Create Policy Stream ?? + * @param type $user + * @param type $dom + * @param type $rootElement + * @return type + */ function createPolicyStream($user, $dom, $rootElement) { module_load_include('inc', 'fedora_repository', 'SecurityClass'); @@ -113,9 +144,15 @@ class PersonalCollectionClass { $content->appendChild($policyStream); 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) { $ds1 = $dom->createElement("foxml:datastream"); @@ -135,8 +172,14 @@ class PersonalCollectionClass { return TRUE; } + /** + * Create standard fedora stuff ?????????????????? + * @param type $user + * @param type $dom + * @param type $rootElement + */ function createStandardFedoraStuff($user, & $dom, & $rootElement) { - /*foxml object properties section */ + /* foxml object properties section */ $objproperties = $dom->createElement("foxml:objectProperties"); $prop1 = $dom->createElement("foxml:property"); $prop1->setAttribute("NAME", "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"); @@ -161,6 +204,13 @@ class PersonalCollectionClass { $rootElement->appendChild($objproperties); } + /** + * Create DC Stream ??? + * @global type $user + * @param type $theUser + * @param type $dom + * @param type $rootElement + */ function createDCStream($theUser, & $dom, & $rootElement) { global $user; $datastream = $dom->createElement("foxml:datastream"); diff --git a/plugins/QtFormBuilder.php b/plugins/QtFormBuilder.php index af66ed31..68c97644 100644 --- a/plugins/QtFormBuilder.php +++ b/plugins/QtFormBuilder.php @@ -1,76 +1,86 @@ getType($file); - //$fileUrl = 'http://'.$_SERVER['HTTP_HOST'].$file; - $fileUrl = $base_url.'/'.drupal_urlencode($file); - $beginIndex = strrpos($fileUrl,'/'); - $dtitle = substr($fileUrl,$beginIndex+1); - $dtitle = substr($dtitle, 0, strpos($dtitle, ".")); - $ds1 = $dom->createElement("foxml:datastream"); - $ds1->setAttribute("ID","OBJ"); - $ds1->setAttribute("STATE","A"); - $ds1->setAttribute("CONTROL_GROUP","M"); - $ds1v= $dom->createElement("foxml:datastreamVersion"); - $ds1v->setAttribute("ID","OBJ.0"); - $ds1v->setAttribute("MIMETYPE","$dformat"); - $ds1v->setAttribute("LABEL","$dtitle"); - $ds1content = $dom->createElement('foxml:contentLocation'); - $ds1content->setAttribute("REF","$fileUrl"); - $ds1content->setAttribute("TYPE","URL"); - $ds1->appendChild($ds1v); - $ds1v->appendChild($ds1content); - $rootElement->appendChild($ds1); +module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder'); -if(empty($_SESSION['fedora_ingest_files']) || !isset($_SESSION['fedora_ingest_files']['TN'])) { - $createdFile = drupal_get_path('module', 'Fedora_Repository').'/images/qtThumb.jpg'; - $fileUrl = $base_url.'/'.drupal_urlencode($createdFile);//'http://'.$_SERVER['HTTP_HOST'].'/'.$createdFile; - $ds1 = $dom->createElement("foxml:datastream"); - $ds1->setAttribute("ID","TN"); - $ds1->setAttribute("STATE","A"); - $ds1->setAttribute("CONTROL_GROUP","M"); - $ds1v= $dom->createElement("foxml:datastreamVersion"); - $ds1v->setAttribute("ID","TN.0"); - $ds1v->setAttribute("MIMETYPE","image/jpeg"); - $ds1v->setAttribute("LABEL","Thumbnail"); - $ds1content = $dom->createElement('foxml:contentLocation'); - $ds1content->setAttribute("REF","$fileUrl"); - $ds1content->setAttribute("TYPE","URL"); - $ds1->appendChild($ds1v); - $ds1v->appendChild($ds1content); - $rootElement->appendChild($ds1); -} +/** + * Implements methods from content model ingest form xml + * builds a dc metadata form + */ +class QtFormBuilder extends FormBuilder { + + /** + * Constructor + */ + function QtFormBuilder() { + module_load_include('php', 'Fedora_Repository', 'plugins/FormBuilder'); + drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); + } - if (!empty($_SESSION['fedora_ingest_files'])) { + /** + * 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) { + module_load_include('inc', 'fedora_repository', 'MimeClass'); + global $base_url; + $mimetype = new MimeClass(); + $server = null; + $file = $form_values['ingest-file-location']; + $dformat = $mimetype->getType($file); + //$fileUrl = 'http://'.$_SERVER['HTTP_HOST'].$file; + $fileUrl = $base_url . '/' . drupal_urlencode($file); + $beginIndex = strrpos($fileUrl, '/'); + $dtitle = substr($fileUrl, $beginIndex + 1); + $dtitle = substr($dtitle, 0, strpos($dtitle, ".")); + $ds1 = $dom->createElement("foxml:datastream"); + $ds1->setAttribute("ID", "OBJ"); + $ds1->setAttribute("STATE", "A"); + $ds1->setAttribute("CONTROL_GROUP", "M"); + $ds1v = $dom->createElement("foxml:datastreamVersion"); + $ds1v->setAttribute("ID", "OBJ.0"); + $ds1v->setAttribute("MIMETYPE", "$dformat"); + $ds1v->setAttribute("LABEL", "$dtitle"); + $ds1content = $dom->createElement('foxml:contentLocation'); + $ds1content->setAttribute("REF", "$fileUrl"); + $ds1content->setAttribute("TYPE", "URL"); + $ds1->appendChild($ds1v); + $ds1v->appendChild($ds1content); + $rootElement->appendChild($ds1); + if (empty($_SESSION['fedora_ingest_files']) || !isset($_SESSION['fedora_ingest_files']['TN'])) { + $createdFile = drupal_get_path('module', 'Fedora_Repository') . '/images/qtThumb.jpg'; + $fileUrl = $base_url . '/' . drupal_urlencode($createdFile); //'http://'.$_SERVER['HTTP_HOST'].'/'.$createdFile; + $ds1 = $dom->createElement("foxml:datastream"); + $ds1->setAttribute("ID", "TN"); + $ds1->setAttribute("STATE", "A"); + $ds1->setAttribute("CONTROL_GROUP", "M"); + $ds1v = $dom->createElement("foxml:datastreamVersion"); + $ds1v->setAttribute("ID", "TN.0"); + $ds1v->setAttribute("MIMETYPE", "image/jpeg"); + $ds1v->setAttribute("LABEL", "Thumbnail"); + $ds1content = $dom->createElement('foxml:contentLocation'); + $ds1content->setAttribute("REF", "$fileUrl"); + $ds1content->setAttribute("TYPE", "URL"); + $ds1->appendChild($ds1v); + $ds1v->appendChild($ds1content); + $rootElement->appendChild($ds1); + } + if (!empty($_SESSION['fedora_ingest_files'])) { foreach ($_SESSION['fedora_ingest_files'] as $dsid => $createdFile) { $createdFile = strstr($createdFile, $file); $dformat = $mimetype->getType($createdFile); - $fileUrl = $base_url . '/'. drupal_urlencode($createdFile); + $fileUrl = $base_url . '/' . drupal_urlencode($createdFile); $beginIndex = strrpos($fileUrl, '/'); $dtitle = substr($fileUrl, $beginIndex + 1); $dtitle = urldecode($dtitle); @@ -79,7 +89,7 @@ if(empty($_SESSION['fedora_ingest_files']) || !isset($_SESSION['fedora_ingest_fi $ds1->setAttribute("ID", "$dsid"); $ds1->setAttribute("STATE", "A"); $ds1->setAttribute("CONTROL_GROUP", "M"); - $ds1v= $dom->createElement("foxml:datastreamVersion"); + $ds1v = $dom->createElement("foxml:datastreamVersion"); $ds1v->setAttribute("ID", "$dsid.0"); $ds1v->setAttribute("MIMETYPE", "$dformat"); $ds1v->setAttribute("LABEL", "$dtitle"); @@ -91,12 +101,7 @@ if(empty($_SESSION['fedora_ingest_files']) || !isset($_SESSION['fedora_ingest_fi $rootElement->appendChild($ds1); } } + } +} - - - } - - - - } ?> diff --git a/plugins/Refworks.inc b/plugins/Refworks.inc index f6e43f95..6fc809e8 100644 --- a/plugins/Refworks.inc +++ b/plugins/Refworks.inc @@ -1,6 +1,11 @@ romeoUrlString = "http://www.sherpa.ac.uk/romeo/api24.php?issn="; } - function buildForm( &$form, $ingest_form_definition, &$form_values) { + /** + * Build Form ?? + * @param type $form + * @param type $ingest_form_definition + * @param type $form_values + * @return type + */ + function buildForm(&$form, $ingest_form_definition, &$form_values) { $form['indicator2'] = array( - '#type' => 'fieldset', - '#title' => t('Ingest digital object step #2'), + '#type' => 'fieldset', + '#title' => t('Ingest digital object step #2'), ); foreach ($ingest_form_definition->form_elements->element as $element) { $name = strip_tags($element->name->asXML()); @@ -39,11 +58,11 @@ class Refworks { $type = strip_tags($element->type->asXML()); $form['indicator2']["$name"] = array( - '#title' => $title, - '#required' => $required, - '#description' => $description, - '#prefix' => $prefix, - '#type' => $type + '#title' => $title, + '#required' => $required, + '#description' => $description, + '#prefix' => $prefix, + '#type' => $type ); } @@ -68,21 +87,26 @@ class Refworks { //$xml=simplexml_load_string(trim(file_get_contents($file),NULL,TRUE)); //$dom = dom_import_simplexml($xml);//test to see if it behaves better //$xml = new SimpleXMLElement(trim(file_get_contents($file))); - } - catch (Exception $e) { + } catch (Exception $e) { drupal_set_message(t('Error processing Refworks file: ') . $e->getMessage()); return FALSE; } $this->referenceList = array(); foreach ($xml->reference as $reference) { - array_push( $this->referenceList, $reference ); + array_push($this->referenceList, $reference); } return $this->referenceList; } - - //create A DC stream with ID of DC - function createQDCStream( &$dom, &$rootElement, $reference ) { + + /** + * Create a DC stream with ID of DC ??? + * @param type $dom + * @param type $rootElement + * @param type $reference + * @return type + */ + function createQDCStream(&$dom, &$rootElement, $reference) { $datastream = $dom->createElement("foxml:datastream"); $datastream->setAttribute("ID", "DC"); $datastream->setAttribute("STATE", "A"); @@ -126,19 +150,19 @@ class Refworks { $oai->appendChild($element); } foreach ($reference->vo as $value) { - $source .= ' Volume: '. $value; + $source .= ' Volume: ' . $value; } foreach ($reference->is as $value) { - $source .= ' Issue: '. $value; + $source .= ' Issue: ' . $value; } foreach ($reference->sp as $value) { - $source .= ' Start Page: '. $value; + $source .= ' Start Page: ' . $value; } foreach ($reference->op as $value) { - $source .= ' Other Pages: '. $value; + $source .= ' Other Pages: ' . $value; } foreach ($reference->ul as $value) { - $source .= ' URL: '. $value; + $source .= ' URL: ' . $value; } foreach ($reference->k1 as $value) { $element = $dom->createElement('dc:subject', htmlspecialchars($value, ENT_NOQUOTES, 'UTF-8')); @@ -174,17 +198,17 @@ class Refworks { $identifier .= ' ISSN/ISBN: ' . $value; //$this->romeoUrlString = $this->romeoUrlString . $value; if (!$this->issn == '') { - $this->issn=$value; + $this->issn = $value; } else { - $this->issn .= ','. $value; + $this->issn .= ',' . $value; } } foreach ($reference->ab as $value) { - $description = ' abstract: '. $value; + $description = ' abstract: ' . $value; } foreach ($reference->cr as $value) { - $description .= ' Cited reference: '. $value; + $description .= ' Cited reference: ' . $value; } $element = $dom->createElement('dc:description', htmlspecialchars($description, ENT_NOQUOTES, 'UTF-8')); $oai->appendChild($element); @@ -196,7 +220,12 @@ class Refworks { return $datastream; } - function handleForm( &$form_values ) { + /** + * Handle Form ?? + * @param type $form_values + * @return type + */ + function handleForm(&$form_values) { $errorMessage = NULL; module_load_include('inc', 'fedora_repository', 'CollectionClass'); module_load_include('inc', 'fedora_repository', 'ContentModel'); @@ -204,10 +233,10 @@ class Refworks { $contentModelPid = ContentModel::getPidFromIdentifier($form_values['models']); $contentModelDsid = ContentModel::getDSIDFromIdentifier($form_values['models']); $collectionHelper = new CollectionClass(); - $startTime=time(); + $startTime = time(); $collection_pid = $form_values['collection_pid']; - $this->parse_refworks_item( $form_values ); + $this->parse_refworks_item($form_values); $this->securityHelper = new SecurityClass(); @@ -231,18 +260,18 @@ class Refworks { $rootElement->setAttribute('xmlns:xsi', "http://www.w3.org/2001/XMLSchema-instance"); $rootElement->setAttribute('xsi:schemaLocation', "info:fedora/fedora-system:def/foxml# http://www.fedora.info/definitions/1/0/foxml1-1.xsd"); $dom->appendChild($rootElement); - + //create standard fedora stuff $qdc_element = $this->createQDCStream($dom, $rootElement, $reference); if (!$qdc_element) { drupal_set_message(t('Error creating DC for Refworks'), 'error'); continue; } - $item_title=''; + $item_title = ''; foreach ($reference->t1 as $value) { - $item_title .= ' --- '. $value; + $item_title .= ' --- ' . $value; } - $this->createStandardFedoraStuff($form_values, $dom, $rootElement, $reference ); + $this->createStandardFedoraStuff($form_values, $dom, $rootElement, $reference); $rootElement->appendChild($qdc_element); //create relationships $this->createRelationShips($form_values, $dom, $rootElement, $pid); @@ -250,14 +279,14 @@ class Refworks { $this->createFedoraDataStreams($form_values, $dom, $rootElement, $reference); - if (!empty ( $this->collectionPolicyStream)) { + if (!empty($this->collectionPolicyStream)) { $this->create_security_policies($dom, $rootElement, $reference); } $params = array( - 'objectXML' => $dom->saveXML(), - 'format' => 'info:fedora/fedora-system:FOXML-1.1', - 'logMessage' => "Fedora Object Ingested", + 'objectXML' => $dom->saveXML(), + 'format' => 'info:fedora/fedora-system:FOXML-1.1', + 'logMessage' => "Fedora Object Ingested", ); try { @@ -270,34 +299,36 @@ class Refworks { return; } $object = $client->__soapCall('ingest', array( - $params - )); + $params + )); watchdog(t("FEDORA_REPOSITORY"), t("Successfully added repository item !pid - !it", array('!pid' => $pid, '!it' => $item_title)), NULL, WATCHDOG_INFO); $deleteFiles = $form_values['delete_file']; //remove files from drupal file system if ($deleteFiles > 0) { unlink($form_values['fullpath']); } - } - catch (exception $e) { + } catch (exception $e) { $errors++; $errorMessage = 'yes'; watchdog(t("FEDORA_REPOSITORY"), t("Error during ingest !it !e", array('!it' => $item_title, '!e' => $e)), NULL, WATCHDOG_ERROR); - } + } $success++; } if (isset($errorMessage)) { - 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(); - 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'); + 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'); } /** * 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->setAttribute("ID", "RELS-EXT"); $drdf->setAttribute("CONTROL_GROUP", "X"); @@ -326,9 +357,13 @@ class Refworks { $rdfdesc->appendChild($member); $rdfdesc->appendChild($model); $rootElement->appendChild($drdf); - } + /** + * Create Romeo Datastream + * @param type $dom + * @param type $rootElement + */ function createRomeoDataStream(&$dom, &$rootElement) { $ds1 = $dom->createElement("foxml:datastream"); $ds1->setAttribute("ID", "ROMEO"); @@ -340,7 +375,7 @@ class Refworks { $ds1v->setAttribute("LABEL", "ROMEO"); $ds1content = $dom->createElement('foxml:contentLocation'); $url = $this->romeoUrlString . $this->issn; - $this->issn=''; //clear the issn's for next ingest in case we are doing batch + $this->issn = ''; //clear the issn's for next ingest in case we are doing batch $ds1content->setAttribute("REF", "$url"); $ds1content->setAttribute("TYPE", "URL"); $ds1->appendChild($ds1v); @@ -348,6 +383,14 @@ class Refworks { $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) { global $base_url; module_load_include('inc', 'fedora_repository', 'MimeClass'); @@ -374,6 +417,10 @@ class Refworks { /** * 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) { // Foxml object properties section @@ -397,10 +444,9 @@ class Refworks { $rootElement->appendChild($objproperties); } - /** * 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. * * @param array $form_values * @param DOMDocument $dom @@ -417,8 +463,8 @@ class Refworks { $ds1v->setAttribute("ID", "POLICY.0"); $ds1v->setAttribute("MIMETYPE", "text/xml"); $ds1v->setAttribute("LABEL", "POLICY Record"); - $ds1content = $dom->createElement( "foxml:xmlContent" ); - + $ds1content = $dom->createElement("foxml:xmlContent"); + $custom_policy = $this->collectionPolicyStream; $allowed_users_and_roles = array(); $allowed_users_and_roles['users'] = array(); @@ -428,11 +474,11 @@ class Refworks { array_push($allowed_users_and_roles['users'], $name); } } - if (empty( $reference->u1)) { + if (empty($reference->u1)) { // If no "u1" value exists, add the currently logged-in user to the item's security policy. array_push($allowed_users_and_roles['users'], $user->name); } - + foreach ($reference->u2 as $rolelist) { foreach (explode(';', strip_tags($rolelist->asXML())) as $role) { array_push($allowed_users_and_roles['roles'], $role); @@ -444,6 +490,7 @@ class Refworks { $ds1v->appendChild($ds1content); $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)); } + } diff --git a/plugins/ShowDemoStreamsInFieldSets.inc b/plugins/ShowDemoStreamsInFieldSets.inc index dd81410f..914c8bc5 100644 --- a/plugins/ShowDemoStreamsInFieldSets.inc +++ b/plugins/ShowDemoStreamsInFieldSets.inc @@ -1,18 +1,32 @@ pid = $pid; } + /** + * Show Medium Size ?? + * @global type $base_url + * @return type + */ function showMediumSize() { global $base_url; $collection_fieldset = array( diff --git a/plugins/ShowStreamsInFieldSets.inc b/plugins/ShowStreamsInFieldSets.inc index d0860ab2..77eada60 100644 --- a/plugins/ShowStreamsInFieldSets.inc +++ b/plugins/ShowStreamsInFieldSets.inc @@ -1,15 +1,31 @@ pid = $pid; } + /** + * Show the FLV ?? + * @return type + */ function showFlv() { //FLV is the datastream id $path = drupal_get_path('module', 'Fedora_Repository'); @@ -17,11 +33,11 @@ class ShowStreamsInFieldSets { $content = ""; $pathTojs = drupal_get_path('module', 'Fedora_Repository') . '/js/swfobject.js'; drupal_add_js("$pathTojs"); - $content .= '
Get the Flash Player to see this player.
'; - drupal_add_js('var s1 = new SWFObject("'. $fullPath . '/flash/flvplayer.swf","single","320","240","7"); + $content .= '
Get the Flash Player to see this player.
'; + drupal_add_js('var s1 = new SWFObject("' . $fullPath . '/flash/flvplayer.swf","single","320","240","7"); s1.addParam("allowfullscreen","TRUE"); - s1.addVariable("file","'. base_path() . 'fedora/repository/'. $this->pid . '/FLV/FLV.flv"); - s1.write("player'. $this->pid . 'FLV");', 'inline', 'footer'); + s1.addVariable("file","' . base_path() . 'fedora/repository/' . $this->pid . '/FLV/FLV.flv"); + s1.write("player' . $this->pid . 'FLV");', 'inline', 'footer'); $collection_fieldset = array( '#title' => t('Flash Video'), '#collapsible' => TRUE, @@ -30,30 +46,42 @@ class ShowStreamsInFieldSets { return theme('fieldset', $collection_fieldset); } + /** + * Show the TN ?? + * @global type $base_url + * @return type + */ function showTN() { global $base_url; $collection_fieldset = array( '#title' => '', '#attributes' => array(), '#collapsible' => FALSE, - '#value' => '', + '#value' => '', ); 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() { global $base_url; $collection_fieldset = array( '#collapsible' => FALSE, - '#value' => '', + '#value' => '', ); return theme('fieldset', $collection_fieldset); } /** * Embed Google Docs' PDF viewer into the page. + * @global type $base_url + * @global type $base_path + * @global type $user + * @return type */ function showPDFPreview() { global $base_url; @@ -74,21 +102,21 @@ class ShowStreamsInFieldSets { $objectHelper = new ObjectHelper(); $item = new Fedora_Item($this->pid); if (key_exists('TN', $item->datastreams)) { - $tn_url = $base_url.'/fedora/repository/'.$item->pid.'/TN'; + $tn_url = $base_url . '/fedora/repository/' . $item->pid . '/TN'; } else { - $tn_url = $base_path.drupal_get_path('module', 'fedora_repository').'/images/Crystal_Clear_app_download_manager.png'; + $tn_url = $base_path . drupal_get_path('module', 'fedora_repository') . '/images/Crystal_Clear_app_download_manager.png'; } $dc_html = $objectHelper->getFormattedDC($item); - - $dl_link = l('

View Document
', 'fedora/repository/'.$this->pid.'/OBJ', array('html' => TRUE)); - + + $dl_link = l('

View Document
', 'fedora/repository/' . $this->pid . '/OBJ', array('html' => TRUE)); + $tabset['first_tab']['tabs']['view'] = array( '#type' => 'tabpage', '#title' => t('View'), '#content' => $dl_link . $dc_html, ); - + if (fedora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $this->pid, $user)) { $editform = drupal_get_form('fedora_repository_edit_qdc_form', $this->pid, 'DC'); $tabset['first_tab']['tabs']['edit'] = array( @@ -97,23 +125,26 @@ class ShowStreamsInFieldSets { '#content' => $editform, ); } - + $tabset['second_tab'] = array( '#type' => 'tabpage', '#title' => t('Read Online'), - '#content' => "" + '#content' => "" ); // Render the tabset. return $tabset; } - + /** + * Show QDC ?? + * @return type + */ function showQdc() { module_load_include('inc', 'fedora_repository', 'ObjectHelper'); $objectHelper = new ObjectHelper(); - $content=$objectHelper->getQDC($this->pid); + $content = $objectHelper->getQDC($this->pid); $collection_fieldset = array( '#title' => t('Description'), '#collapsible' => TRUE, @@ -123,29 +154,35 @@ class ShowStreamsInFieldSets { return theme('fieldset', $collection_fieldset); } + /** + * Show Object Link ?? + * @global type $base_url + * @return type + */ function showOBJLink() { global $base_url; module_load_include('inc', 'fedora_repository', 'api/fedora_item'); $item = new Fedora_Item($this->pid); $streams = $item->get_datastreams_list_as_array(); - return "". $streams['OBJ']['label'] .""; + return "" . $streams['OBJ']['label'] . ""; } - - + /** + * Show REF works ?? + * @return type + */ function showRefworks() { - $path=drupal_get_path('module', 'fedora_repository'); + $path = drupal_get_path('module', 'fedora_repository'); module_load_include('inc', 'fedora_repository', 'ObjectHelper'); $collectionHelper = new CollectionClass(); - $xmlstr=$collectionHelper->getStream($this->pid, "refworks"); + $xmlstr = $collectionHelper->getStream($this->pid, "refworks"); html_entity_decode($xmlstr); if ($xmlstr == NULL || strlen($xmlstr) < 5) { return " "; } try { $proc = new XsltProcessor(); - } - catch (Exception $e) { + } catch (Exception $e) { drupal_set_message(t("!e", array('!e' => $e->getMessage())), 'error'); return " "; } @@ -165,9 +202,14 @@ class ShowStreamsInFieldSets { return theme('fieldset', $collection_fieldset); } + /** + * Show JP2000 + * @param type $collapsed + * @return type + */ function showJP2($collapsed = FALSE) { - $viewer_url = variable_get('fedora_base_url', '') . '/get/'. $this->pid . '/ilives:viewerSdef/getViewer'; - $html = ''; + $viewer_url = variable_get('fedora_base_url', '') . '/get/' . $this->pid . '/ilives:viewerSdef/getViewer'; + $html = ''; $fieldset = array( '#title' => t('Viewer'), '#collapsible' => TRUE, @@ -177,6 +219,11 @@ class ShowStreamsInFieldSets { return theme('fieldset', $fieldset); } + /** + * Show Romeo ?? + * @param type $collapsed + * @return type + */ function showRomeo($collapsed = FALSE) { $path = drupal_get_path('module', 'Fedora_Repository'); module_load_include('inc', 'fedora_repository', 'CollectionClass'); @@ -189,8 +236,7 @@ class ShowStreamsInFieldSets { try { $proc = new XsltProcessor(); - } - catch (Exception $e) { + } catch (Exception $e) { drupal_set_message(t("!e", array('!e' => $e->getMessage())), 'error'); return; } @@ -210,4 +256,5 @@ class ShowStreamsInFieldSets { ); return theme('fieldset', $collection_fieldset); } + } diff --git a/plugins/fedoraObject.inc b/plugins/fedoraObject.inc index 3520614c..c5521242 100644 --- a/plugins/fedoraObject.inc +++ b/plugins/fedoraObject.inc @@ -1,7 +1,22 @@ item = new Fedora_Item($pid); } } - + + /** + * Show Field Sets + * @global type $user + * @return type + */ public function showFieldSets() { global $user; $objectHelper = new ObjectHelper(); @@ -27,16 +47,16 @@ class FedoraObject { '#type' => 'tabset', ); $dc_html = $objectHelper->getFormattedDC($this->item); - + $ds_list = $objectHelper->get_formatted_datastream_list($this->pid, NULL, $this->item); - + $tabset['fedora_object_details']['tabset']['view'] = array( '#type' => 'tabpage', '#title' => t('View'), '#content' => $dc_html . $ds_list . $purge_form, ); - + if (fedora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $this->pid, $user)) { $editform = drupal_get_form('fedora_repository_edit_qdc_form', $this->pid, 'DC'); $tabset['fedora_object_details']['tabset']['edit'] = array( @@ -46,7 +66,8 @@ class FedoraObject { '#content' => $editform, ); } - + return $tabset; } + } \ No newline at end of file diff --git a/plugins/herbarium.inc b/plugins/herbarium.inc index 3af6f8bd..38d6b024 100644 --- a/plugins/herbarium.inc +++ b/plugins/herbarium.inc @@ -2,8 +2,17 @@ // $Id$ +/** + * @file + * Herbarium class + */ + +/** + * Herbarium ??? + */ class Herbarium { - function __construct($pid = '') { + + function __construct($pid = '') { module_load_include('inc', 'fedora_repository', 'api/fedora_item'); if (!empty($pid)) { $this->pid = $pid; @@ -11,15 +20,26 @@ class Herbarium { } } + /** + * Build a drupal form ?? + * @param type $form + * @param type $form_state + * @return type + */ public function buildDrupalForm($form = array(), $form_state = array()) { // We don't need to add anything beyond the standard Darwin Core form so just pass this through // If we wanted to we could add other fields. module_load_include('inc', 'fedora_repository', 'plugins/DarwinCore'); - + $dwc = new DarwinCore($this->item); return $dwc->buildDrupalForm($form); } + /** + * Build edit metadata form + * @param type $form + * @return type + */ public function buildEditMetadataForm($form = array()) { $form['submit'] = array( '#type' => 'submit', @@ -34,10 +54,17 @@ class Herbarium { '#type' => 'hidden', '#value' => "DARWIN_CORE", ); - + 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) { /* * Process the metadata form @@ -51,11 +78,15 @@ class Herbarium { $dwc = new DarwinCore($this->item); $dwc->handleForm($form_values); $this->item->purge_datastream('DARWIN_CORE'); - $this->item->add_datastream_from_string($dwc->darwinCoreXML, 'DARWIN_CORE', - 'Darwin Core Metadata', 'text/xml', 'X'); + $this->item->add_datastream_from_string($dwc->darwinCoreXML, 'DARWIN_CORE', 'Darwin Core Metadata', 'text/xml', 'X'); return TRUE; } + /** + * Handle Ingest Form + * @global type $user + * @param type $form_values + */ public function handleIngestForm($form_values) { /* * process the metadata form @@ -70,51 +101,52 @@ class Herbarium { $dwc = new DarwinCore(); $dwc->handleForm($form_values); $label = $form_values['dwc:institutionCode'] . ':' - . $form_values['dwc:collectionCode'] . ':' - . $form_values['dwc:catalogNumber']; + . $form_values['dwc:collectionCode'] . ':' + . $form_values['dwc:catalogNumber']; - $new_item = Fedora_Item::ingest_new_item($form_values['pid'], 'A', $label, - $user->name); + $new_item = Fedora_Item::ingest_new_item($form_values['pid'], 'A', $label, $user->name); - $new_item->add_datastream_from_string($dwc->darwinCoreXML, 'DARWIN_CORE', - 'Darwin Core Metadata', 'text/xml', 'X'); + $new_item->add_datastream_from_string($dwc->darwinCoreXML, 'DARWIN_CORE', 'Darwin Core Metadata', 'text/xml', 'X'); $file = $form_values['ingest-file-location']; - if (!empty( $file)) { + if (!empty($file)) { $dformat = $mimetype->getType($file); - $new_item->add_datastream_from_file($file, 'FULL_SIZE', - "$label-full-size", $dformat, 'M'); + $new_item->add_datastream_from_file($file, 'FULL_SIZE', "$label-full-size", $dformat, 'M'); } $new_item->add_relationship('hasModel', $form_values['content_model_pid'], FEDORA_MODEL_URI); $new_item->add_relationship(!empty($form_values['relationship']) ? $form_values['relationship'] : 'isMemberOfCollection', $form_values['collection_pid']); - + if (!empty($_SESSION['fedora_ingest_files'])) { foreach ($_SESSION['fedora_ingest_files'] as $dsid => $created_file) { $created_file_format = $mimetype->getType($created_file); $created_filename = strstr($created_file, $file); - $new_item->add_datastream_from_file($created_file, $dsid, - $created_filename, $created_file_format, 'M'); - + $new_item->add_datastream_from_file($created_file, $dsid, $created_filename, $created_file_format, 'M'); } } } + /** + * Show Field Sets + * @global type $base_url + * @global type $user + * @return string + */ public function showFieldSets() { module_load_include('inc', 'fedora_repository', 'plugins/tagging_form'); module_load_include('inc', 'fedora_repository', 'plugins/DarwinCore'); global $base_url; $tabset = array(); - + global $user; $qs = ''; if ($user->uid != 0) { - $qs = '?uid='. base64_encode($user->name . ':'. $user->pass); + $qs = '?uid=' . base64_encode($user->name . ':' . $user->pass); } - $viewer_url = variable_get('fedora_base_url', '') . '/get/'. $this->pid . '/ilives:viewerSdef/getViewer'. $qs; - $html = ''; + $viewer_url = variable_get('fedora_base_url', '') . '/get/' . $this->pid . '/ilives:viewerSdef/getViewer' . $qs; + $html = ''; $tabset['second_tab'] = array( // $collection_fieldset = array ( '#type' => 'tabpage', @@ -126,8 +158,8 @@ class Herbarium { '#type' => 'tabpage', '#title' => t('View'), // This will be the content of the tab. - '#content' => ''. '

'. drupal_get_form('fedora_repository_image_tagging_form', $this->pid) . '

', + '#content' => '' . '

' . drupal_get_form('fedora_repository_image_tagging_form', $this->pid) . '

', ); $dwc = new DarwinCore($this->item); @@ -138,7 +170,7 @@ class Herbarium { $tabset['third_tab']['tabset'] = array( '#type' => 'tabset', ); - + $tabset['third_tab']['tabset']['view'] = array( '#type' => 'tabpage', '#title' => t('Darwin Core'), @@ -168,4 +200,5 @@ class Herbarium { } return $tabset; } + } diff --git a/plugins/map_viewer.inc b/plugins/map_viewer.inc index 0a1bda62..3e9bcfb6 100644 --- a/plugins/map_viewer.inc +++ b/plugins/map_viewer.inc @@ -1,13 +1,33 @@ pid = $pid; } + /** + * Show JPEG + * @global type $base_url + * @global type $user + * @return type + */ function showJPG() { module_load_include('inc', 'fedora_repository', 'plugins/tagging_form'); module_load_include('inc', 'fedora_repository', 'plugins/ShowStreamsInFieldSets'); @@ -27,8 +47,8 @@ class ShowMapStreamsInFieldSets { $qs = '?uid=' . base64_encode($user->name . ':' . $user->pass); } - $viewer_url = variable_get('fedora_base_url', '') . '/get/'. $this->pid . '/ilives:viewerSdef/getViewer'. $qs; - $html = ''; + $viewer_url = variable_get('fedora_base_url', '') . '/get/' . $this->pid . '/ilives:viewerSdef/getViewer' . $qs; + $html = ''; drupal_add_css(path_to_theme() . '/header-viewer.css', 'theme'); drupal_add_css(drupal_get_path('module', 'fedora_repository') . '/js/iiv/css/jquery-ui/smoothness/jquery-ui-1.7.2.custom.css'); @@ -46,9 +66,10 @@ class ShowMapStreamsInFieldSets { '#type' => 'tabpage', '#title' => t('Description'), '#content' => $item->get_dissemination('islandora:mods2htmlSdef', 'mods2html') - . $objectHelper->get_formatted_datastream_list($this->pid, NULL, $item), + . $objectHelper->get_formatted_datastream_list($this->pid, NULL, $item), ); // Render the tabset. return tabs_render($tabset); } + } diff --git a/plugins/qt_viewer.inc b/plugins/qt_viewer.inc index 996b12b6..a61a6033 100644 --- a/plugins/qt_viewer.inc +++ b/plugins/qt_viewer.inc @@ -1,60 +1,96 @@ pid = $pid; } + /** + * Returna a new Fedora Object with the QT movie ??? + * @return fedora_item + */ function fedoraObject() { return new fedora_item($this->pid); } + /** + * Tecnical metadata ?? + * @param type $defaults + * @param type $dsid + * @return type + */ function technicalMetadata($defaults = array(), $dsid = 'OBJ_EXIFTOOL') { $data = $defaults; try { - $src = ObjectHelper::getStream($this->pid, $dsid); - - $doc = new SimpleXMLElement($src); - $doc->registerXPathNamespace('File', 'http://ns.exiftool.ca/File/1.0/'); - $doc->registerXPathNamespace('Composite', 'http://ns.exiftool.ca/Composite/1.0/'); - $mime = reset($doc->xpath('//File:MIMEType')); - $data['mime'] = $mime; - if(strpos($mime, 'audio/') !== false) { - $data['width'] = 300; - $data['height'] = 0; - } else { - $size = reset($doc->xpath('//Composite:ImageSize/text()')); - list($width, $height) = explode('x', $size); - $data['width'] = $width; - $data['height'] = $height; - } + $src = ObjectHelper::getStream($this->pid, $dsid); + + $doc = new SimpleXMLElement($src); + $doc->registerXPathNamespace('File', 'http://ns.exiftool.ca/File/1.0/'); + $doc->registerXPathNamespace('Composite', 'http://ns.exiftool.ca/Composite/1.0/'); + $mime = reset($doc->xpath('//File:MIMEType')); + $data['mime'] = $mime; + if (strpos($mime, 'audio/') !== false) { + $data['width'] = 300; + $data['height'] = 0; + } + else { + $size = reset($doc->xpath('//Composite:ImageSize/text()')); + list($width, $height) = explode('x', $size); + $data['width'] = $width; + $data['height'] = $height; + } - $data['doc'] = $src; - } catch(Exception $e) { - $data = $defaults; + $data['doc'] = $src; + } catch (Exception $e) { + $data = $defaults; } return $data; } + /** + * Get Poster Frame Datastream Information ?? + * @param type $dsid + * @return type + */ function getPosterFrameDatastreamInfo($dsid = 'FULL_SIZE') { $p = ObjectHelper::getDatastreamInfo($this->pid, $dsid); - if(empty($p) || $p == ' ' || $p === false) { + if (empty($p) || $p == ' ' || $p === false) { return false; } return $p; } + /** + * Get Media Datastream Information ?? + * @param type $dsid + * @param type $alt + * @return type + */ function getMediaDatastreamInfo($dsid = 'OBJ', $alt = array('')) { $p = ObjectHelper::getDatastreamInfo($this->pid, $dsid); - if(empty($p) || $p == ' ' || $p === false) { - if(!empty($alt)) { - $ds = array_shift($alt); - return $this->getMediaDatastreamInfo($ds, $alt); + if (empty($p) || $p == ' ' || $p === false) { + if (!empty($alt)) { + $ds = array_shift($alt); + return $this->getMediaDatastreamInfo($ds, $alt); } return false; } @@ -62,10 +98,19 @@ class ShowQtStreamsInFieldSets { return $p; } + /** + * Is download enabled. It always returns false. ??? + * @return FALSE + */ function enableDownload() { return false; } + /** + * Show the QT ??? + * @global type $base_url + * @return type + */ function showQt() { module_load_include('inc', 'fedora_repository', 'plugins/tagging_form'); module_load_include('inc', 'fedora_repository', 'plugins/ShowStreamsInFieldSets'); @@ -77,32 +122,32 @@ class ShowQtStreamsInFieldSets { $pframe = $this->getPosterFrameDatastreamInfo(); $media = $this->getMediaDatastreamInfo('PROXY', array('OBJ')); - if($media === false ) { + if ($media === false) { return ''; } global $base_url; $path = drupal_get_path('module', 'Fedora_Repository'); - $fullPath=base_path().$path; - $content= ''; - $pathTojs = drupal_get_path('module', 'Fedora_Repository').'/js/AC_Quicktime.js'; + $fullPath = base_path() . $path; + $content = ''; + $pathTojs = drupal_get_path('module', 'Fedora_Repository') . '/js/AC_Quicktime.js'; drupal_add_js($pathTojs); - $divid = 'player'.md5($this->pid).'MOV'; - $content .= '
'; - if($pframe !== false) { - $content .= '
'; - $content .= ''; + $divid = 'player' . md5($this->pid) . 'MOV'; + $content .= '
'; + if ($pframe !== false) { + $content .= '
'; + $content .= ''; $content .= '
'; $content .= '
'; } $content .= '
'; - if($this->enableDownload()) { - $url = base_path().'fedora/repository/'.$this->pid.'/OBJ/MOV.mov'; + if ($this->enableDownload()) { + $url = base_path() . 'fedora/repository/' . $this->pid . '/OBJ/MOV.mov'; $content .= 'Download Media File'; } - $src = base_path().'fedora/repository/'.$this->pid.'/' . $media->ID. '/MOV.mov'; -$qtparams = ''; - $qtparams .= "'autostart', '" . ($pframe !== false ? 'true' : 'false') . "', "; + $src = base_path() . 'fedora/repository/' . $this->pid . '/' . $media->ID . '/MOV.mov'; + $qtparams = ''; + $qtparams .= "'autostart', '" . ($pframe !== false ? 'true' : 'false') . "', "; $init = << t('Quicktime'), + '#collapsible' => TRUE, + '#collapsed' => FALSE, + '#value' => $content); + return theme('fieldset', $collection_fieldset); + } - $collection_fieldset = array( - '#title' => t('Quicktime'), - '#collapsible' => TRUE, - '#collapsed' => FALSE, - '#value' => $content); - return theme('fieldset',$collection_fieldset); - } } diff --git a/plugins/slide_viewer.inc b/plugins/slide_viewer.inc index 30d2eb01..1d23b227 100644 --- a/plugins/slide_viewer.inc +++ b/plugins/slide_viewer.inc @@ -1,15 +1,34 @@ pid = $pid; } - + + /** + * Show JPEG + * @global type $base_url + * @global type $user + * @return type + */ function showJPG() { module_load_include('inc', 'fedora_repository', 'plugins/tagging_form'); module_load_include('inc', 'fedora_repository', 'plugins/ShowStreamsInFieldSets'); @@ -17,14 +36,14 @@ class ShowSlideStreamsInFieldSets { global $user; $tabset = array(); - + $qs = ''; if ($user->uid != 0) { $qs = '?uid=' . base64_encode($user->name . ':' . $user->pass); } - $viewer_url = variable_get('fedora_base_url', 'http://localhost:8080/fedora') . '/get/'. $this->pid . '/ilives:viewerSdef/getViewer'. $qs; - $html = ''; + $viewer_url = variable_get('fedora_base_url', 'http://localhost:8080/fedora') . '/get/' . $this->pid . '/ilives:viewerSdef/getViewer' . $qs; + $html = ''; drupal_add_css(path_to_theme() . '/header-viewer.css', 'theme'); @@ -38,10 +57,11 @@ class ShowSlideStreamsInFieldSets { '#type' => 'tabpage', '#title' => t('View'), // This will be the content of the tab. - '#content' => ''. '

'. drupal_get_form('fedora_repository_image_tagging_form', $this->pid) . '

', + '#content' => '' . '

' . drupal_get_form('fedora_repository_image_tagging_form', $this->pid) . '

', ); - + return $tabset; } + } diff --git a/plugins/tagging_form.inc b/plugins/tagging_form.inc index 2b374b3c..acc826fd 100644 --- a/plugins/tagging_form.inc +++ b/plugins/tagging_form.inc @@ -1,11 +1,21 @@ tags)) { $output = "
    "; foreach ($tags->tags as $tag) { - $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) { module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/dublin_core'); @@ -29,7 +46,7 @@ function fedora_repository_image_tagging_form($form_state, $pid) { global $base_url; if (!empty($form_state['post']['pid'])) { - $pid = $form_state['post']['pid']; + $pid = $form_state['post']['pid']; } $obj = new Fedora_Item($pid); $form['tags-wrapper'] = array( @@ -49,8 +66,8 @@ function fedora_repository_image_tagging_form($form_state, $pid) { '#prefix' => '
  • ', '#suffix' => '
  • ', ); - $form['tags-wrapper']['tags'][$tag['name']]['tag'] = array( - '#prefix' => '', + $form['tags-wrapper']['tags'][$tag['name']]['tag'] = array( + '#prefix' => '', '#value' => $tag['name'], '#suffix' => '', ); @@ -58,7 +75,7 @@ function fedora_repository_image_tagging_form($form_state, $pid) { // Delete button for each existing tag. $form['tags-wrapper']['tags'][$tag['name']]['delete'] = array( '#type' => 'imagebutton', - '#image' => $base_url . '/'. drupal_get_path('module', 'fedora_repository') . '/images/remove_icon.png', + '#image' => $base_url . '/' . drupal_get_path('module', 'fedora_repository') . '/images/remove_icon.png', '#default_value' => $tag['name'], '#title' => t('Delete this tag'), ); @@ -84,10 +101,15 @@ function fedora_repository_image_tagging_form($form_state, $pid) { if (empty($form_state['pid'])) { $form_state['pid'] = $pid; } - + return $form; } +/** + * Hook image button process ??? + * @param type $form + * @return string + */ function hook_imagebutton_process($form) { $form['op_x'] = array( '#name' => $form['#name'] . '_x', @@ -98,6 +120,12 @@ function hook_imagebutton_process($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) { module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/tagging'); @@ -110,7 +138,7 @@ function fedora_repository_image_tagging_form_submit($form, &$form_state) { array_push($tagset->tags, array('name' => $form_state['values']['addtag'], 'creator' => $user->name)); } elseif (!empty($form_state['values']['delete'])) { - for ( $i=0; $i < count($tagset->tags); $i++ ) { + for ($i = 0; $i < count($tagset->tags); $i++) { if ($tagset->tags[$i]['name'] == $form_state['clicked_button']['#value']) { unset($tagset->tags[$i]); }