From fa9126f8bf23ce7dca04b58f4603ab183b33dfe8 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 26 Nov 2010 19:11:22 -0600 Subject: [PATCH 01/14] Updated removeIngestMethodParam to work when there is no module defined for the rule but the default value 'fedora_repository' is passed. --- ContentModel.inc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ContentModel.inc b/ContentModel.inc index b952e2c7..4cc66976 100644 --- a/ContentModel.inc +++ b/ContentModel.inc @@ -1855,11 +1855,10 @@ class ContentModel extends XMLDatastream { $methodsEl = $rule->getElementsByTagName('ingest_methods')->item(0); $methods = $methodsEl->getElementsByTagName('ingest_method'); for ($i=0; !$found && $i < $methods->length; $i++) { - if ($methods->item($i)->getAttribute('module') == $module && $methods->item($i)->getAttribute('file') == $file && $methods->item($i)->getAttribute('class') == $class && $methods->item($i)->getAttribute('method') == $method) { + if (( trim($methods->item($i)->getAttribute('module')) == $module || (trim($methods->item($i)->getAttribute('module')) == '' && $module == 'fedora_repository')) && trim($methods->item($i)->getAttribute('file')) == $file && trim($methods->item($i)->getAttribute('class')) == $class && trim($methods->item($i)->getAttribute('method')) == $method) { $found = $methods->item($i); } } - if ($found !== FALSE) { $methodEl = $found; $paramsEl = $found->getElementsByTagName('parameters'); From e697cf4f15b05573874908548adecb69bfbab43a Mon Sep 17 00:00:00 2001 From: jesterhazy Date: Sat, 4 Dec 2010 11:16:57 -0600 Subject: [PATCH 02/14] removed content model checks in makeObject(...) --- ObjectHelper.inc | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/ObjectHelper.inc b/ObjectHelper.inc index 9341a6c6..0cb66eff 100644 --- a/ObjectHelper.inc +++ b/ObjectHelper.inc @@ -59,20 +59,6 @@ class ObjectHelper { drupal_access_denied(); return ' '; } - - if (($cm = ContentModel::loadFromObject($pid)) == FALSE) { - drupal_set_message(t("You do not have access to objects without an Islandora Content Model."), 'error'); - drupal_access_denied(); - return ' '; - } - - $cmDatastreams = $cm->listDatastreams(); - - if ( !((isset($user) && in_array('administrator',$user->roles)) || in_array($dsID,$cmDatastreams))) { - drupal_set_message(t("You do not have access to the specified datastream."), 'error'); - drupal_access_denied(); - return ' '; - } module_load_include('inc', 'fedora_repository', 'api/fedora_item'); $item = new Fedora_Item($pid); From 7e6aaecedb9b0e54445f321658085267fc396d29 Mon Sep 17 00:00:00 2001 From: mroy Date: Tue, 7 Dec 2010 13:16:28 -0600 Subject: [PATCH 03/14] Added a workflow client plugin for running exiftool. --- workflow_client/plugins/exif.inc | 72 ++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 workflow_client/plugins/exif.inc diff --git a/workflow_client/plugins/exif.inc b/workflow_client/plugins/exif.inc new file mode 100644 index 00000000..5a1ba414 --- /dev/null +++ b/workflow_client/plugins/exif.inc @@ -0,0 +1,72 @@ + 0) { + $this->setMessage(t('Missing parameter(s) "%params" for exif process on "%pid"', array('%params' => join(',', $missing_params), '%pid' => $pid))); + return FALSE; + } + + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + + $item = new fedora_item($pid); + $dslist = $item->get_datastreams_list_as_array(); + if (!isset($dslist[$parameters['dsid']])) { + $this->setMessage(t('Datastream "%dsid" could not be found for exif process on "%pid"', array('%dsid' => $parameters['dsid'], '%pid' => $pid))); + return FALSE; + } + + $ds = $dslist[$parameters['dsid']]; + $file = '/tmp/'. $ds['label']; + $dest_ds = isset($parameters['dest_ds']) ? $parameters['dest_ds'] : 'EXIF'; + + $objectHelper = new ObjectHelper(); + $objectHelper->makeObject($pid, $parameters['dsid'], FALSE, NULL, $file); + + if (!file_exists($file)) { + $this->setMessage('couldnt get datastream '. $parameters['dsid'] .' as '. $file); + return FALSE; + } + + $system = getenv('System'); + $returnValue=TRUE; + $output=array(); + + $command = '/usr/local/exif/exiftool -X '. $file; + exec($command, $output, $returnValue); + + if (!file_exists($file . $file_suffix)) { + $this->setMessage('command failed: '. htmlentities($command ."\n" . join("\n", $output) ."\n return value: $returnValue")); + @unlink($file); + return FALSE; + } + + if ($returnValue == '0') { + if (isset($dslist[$dest_ds])) { + $item->purge_datastream($dest_ds); + } + + $ret = $item->add_datastream_from_string(join("\n",$output), $dest_ds, $ds['label'] . $file_suffix, 'text/xml', 'X','Added by workflow process EXIF.'); + @unlink($file); + @unlink($file . $file_suffix); + + if (!$ret) { + $this->setMessage(t('Unable to add datastream "%dsid" to "%pid".', array('%dsid' => $dest_ds, '%pid' => $pid))); + return FALSE; + } + + return TRUE; + + } + } +} From 500f3ebd0039e8d929f5cae6dcdd272dab457400 Mon Sep 17 00:00:00 2001 From: Zachary Howarth Date: Thu, 9 Dec 2010 15:51:01 -0400 Subject: [PATCH 04/14] Restore menu title on Digital Repository (fedora/repository). --- formClass.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/formClass.inc b/formClass.inc index 8505f402..6e0161fd 100644 --- a/formClass.inc +++ b/formClass.inc @@ -78,7 +78,7 @@ class formClass { // 'access' => TRUE ); $items['fedora/repository'] = array( -// 'title' => t('Digital repository'), + 'title' => t('Digital repository'), 'page callback' => 'repository_page', 'type' => MENU_NORMAL_ITEM, // 'page arguments'=>array(1), From 69a06d695f3df15c18e1d3b8c388ed322d41273a Mon Sep 17 00:00:00 2001 From: Alexander O'Neill Date: Fri, 10 Dec 2010 13:38:12 -0400 Subject: [PATCH 05/14] Updated schema of large images collection. --- content_models/islandora_largeimages.xml | 654 +++++++++++++---------- 1 file changed, 357 insertions(+), 297 deletions(-) diff --git a/content_models/islandora_largeimages.xml b/content_models/islandora_largeimages.xml index 6a152ad4..a0bbfe9b 100644 --- a/content_models/islandora_largeimages.xml +++ b/content_models/islandora_largeimages.xml @@ -1,298 +1,358 @@ - - - - - - - - - - - - - - -ingest - -fedoraAdmin -2010-01-26T21:29:20.416Z -Created with Admin GUI "New Object" command - - - -addDatastream -COLLECTION_POLICY -fedoraAdmin -2010-01-26T21:30:55.607Z -DatastreamsPane generated this logMessage. - - - -addDatastream -RELS-EXT -fedoraAdmin -2010-01-26T21:33:14.125Z - - - - -modifyDatastreamByValue -COLLECTION_POLICY -fedoraAdmin -2010-03-04T12:50:05.983Z - - - - -modifyDatastreamByValue -COLLECTION_POLICY -fedoraAdmin -2010-03-11T21:01:44.921Z - - - - - - - - - - - Large Image Collection - islandora:largeimages - - - - - - - - - - - islandora:slide - islandora:slideCModel - ISLANDORACM - - - - isMemberOfCollection - - dc.description - - dc.title - dc.title - - - dc.creator - dc.creator - - - dc.description - dc.description - - - dc.date - dc.date - - - dc.identifier - dc.identifier - - - dc.language - dc.language - - - dc.publisher - dc.publisher - - - dc.rights - dc.rights - - - dc.subject - dc.subject - - - dc.relation - dc.relation - - - dcterms.temporal - dcterms.temporal - - - dcterms.spatial - dcterms.spatial - - - fgs.DS.first.text - Full Text - - - - - - - - - - - islandora:slide - islandora:slideCModel - ISLANDORACM - - - islandora:herb - islandora:herbCModel - ISLANDORACM - - - isMemberOfCollection - - dc.description - - dc.title - dc.title - - - dc.creator - dc.creator - - - dc.description - dc.description - - - dc.date - dc.date - - - dc.identifier - dc.identifier - - - dc.language - dc.language - - - dc.publisher - dc.publisher - - - dc.rights - dc.rights - - - dc.subject - dc.subject - - - dc.relation - dc.relation - - - dcterms.temporal - dcterms.temporal - - - dcterms.spatial - dcterms.spatial - - - fgs.DS.first.text - Full Text - - - - - - - - - - - islandora:slide - islandora:slideCModel - ISLANDORACM - - - isMemberOfCollection - - dc.description - - dc.title - dc.title - - - dc.creator - dc.creator - - - dc.description - dc.description - - - dc.date - dc.date - - - dc.identifier - dc.identifier - - - dc.language - dc.language - - - dc.publisher - dc.publisher - - - dc.rights - dc.rights - - - dc.subject - dc.subject - - - dc.relation - dc.relation - - - dcterms.temporal - dcterms.temporal - - - dcterms.spatial - dcterms.spatial - - - fgs.DS.first.text - Full Text - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + ingest + + fedoraAdmin + 2010-01-26T21:29:20.416Z + Created with Admin GUI "New Object" command + + + + addDatastream + COLLECTION_POLICY + fedoraAdmin + 2010-01-26T21:30:55.607Z + DatastreamsPane generated this logMessage. + + + + addDatastream + RELS-EXT + fedoraAdmin + 2010-01-26T21:33:14.125Z + + + + + modifyDatastreamByValue + COLLECTION_POLICY + fedoraAdmin + 2010-03-04T12:50:05.983Z + + + + + modifyDatastreamByValue + COLLECTION_POLICY + fedoraAdmin + 2010-03-11T21:01:44.921Z + + + + + ingest + + admin + 2010-12-10T17:29:47.073Z + Fedora Object Ingested + + + + addDatastream + TN + admin + 2010-12-10T17:29:47.200Z + Ingested object TN + + + + modifyDatastreamByValue + COLLECTION_POLICY + fedoraAdmin + 2010-12-10T17:32:17.345Z + + + + + + + + + + + Large Image Collection + islandora:largeimages + + + + + + + + + + + islandora:slide + islandora:slideCModel + ISLANDORACM + + + isMemberOfCollection + + dc.description + + dc.title + dc.title + + + dc.creator + dc.creator + + + dc.description + dc.description + + + dc.date + dc.date + + + dc.identifier + dc.identifier + + + dc.language + dc.language + + + dc.publisher + dc.publisher + + + dc.rights + dc.rights + + + dc.subject + dc.subject + + + dc.relation + dc.relation + + + dcterms.temporal + dcterms.temporal + + + dcterms.spatial + dcterms.spatial + + + fgs.DS.first.text + Full Text + + + + + + + + + + + islandora:slide + islandora:slideCModel + ISLANDORACM + + + islandora:herb + islandora:herbCModel + ISLANDORACM + + + isMemberOfCollection + + dc.description + + dc.title + dc.title + + + dc.creator + dc.creator + + + dc.description + dc.description + + + dc.date + dc.date + + + dc.identifier + dc.identifier + + + dc.language + dc.language + + + dc.publisher + dc.publisher + + + dc.rights + dc.rights + + + dc.subject + dc.subject + + + dc.relation + dc.relation + + + dcterms.temporal + dcterms.temporal + + + dcterms.spatial + dcterms.spatial + + + fgs.DS.first.text + Full Text + + + + + + + + + + + islandora:slide + islandora:slideCModel + ISLANDORACM + + + isMemberOfCollection + + dc.description + + dc.title + dc.title + + + dc.creator + dc.creator + + + dc.description + dc.description + + + dc.date + dc.date + + + dc.identifier + dc.identifier + + + dc.language + dc.language + + + dc.publisher + dc.publisher + + + dc.rights + dc.rights + + + dc.subject + dc.subject + + + dc.relation + dc.relation + + + dcterms.temporal + dcterms.temporal + + + dcterms.spatial + dcterms.spatial + + + fgs.DS.first.text + Full Text + + + + + + + + + + + + + dc.title + dc.creator + dc.description + dc.date + dc.identifier + dc.language + dc.publisher + dc.rights + dc.subject + dc.relation + dcterms.temporal + dcterms.spatial + Full Text + + isMemberOfCollection + + + + + + + + + + + + + + + + + + + + + + From 861ef05951f0f4465b9d8ec43ed49d191868dddf Mon Sep 17 00:00:00 2001 From: mroy Date: Tue, 14 Dec 2010 13:57:22 -0600 Subject: [PATCH 06/14] Added content model checks in makeObject(...) Added new restriction option to the fedora collection list settings page that allows you to enable/disable restrcitions. Defaults to restrict for security. --- ObjectHelper.inc | 17 ++++++++++++++++- formClass.inc | 21 ++++++++++++++------- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/ObjectHelper.inc b/ObjectHelper.inc index 7520907c..ab4cb617 100644 --- a/ObjectHelper.inc +++ b/ObjectHelper.inc @@ -54,13 +54,28 @@ class ObjectHelper { return ' '; } - if (!fedora_repository_access(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { drupal_set_message(t("You do not have access Fedora objects within the attempted namespace."), 'error'); drupal_access_denied(); return ' '; } + + if (variable_get('fedora_object_restrict_datastreams', TRUE) == TRUE ) { + if (($cm = ContentModel::loadFromObject($pid)) == FALSE) { + drupal_set_message(t("You do not have access to objects without an Islandora Content Model."), 'error'); + drupal_access_denied(); + return ' '; + } + + $cmDatastreams = $cm->listDatastreams(); + if ( !((isset($user) && in_array('administrator',$user->roles)) || in_array($dsID,$cmDatastreams))) { + drupal_set_message(t("You do not have access to the specified datastream."), 'error'); + drupal_access_denied(); + return ' '; + } + } + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); $item = new Fedora_Item($pid); diff --git a/formClass.inc b/formClass.inc index 6e0161fd..e9995a90 100644 --- a/formClass.inc +++ b/formClass.inc @@ -361,13 +361,13 @@ class formClass { ); */ - $form['fedora_object_display_title'] = array( - '#type' => 'select', - '#title' => t('Display Object Title Behaviour'), - '#default_value'=> variable_get('fedora_object_display_title', ObjectHelper::$DISPLAY_ALWAYS), - '#options' => array(ObjectHelper::$DISPLAY_ALWAYS=>t('Always'),ObjectHelper::$DISPLAY_NEVER=>t('Never'),ObjectHelper::$DISPLAY_NO_MODEL_OUTPUT=>t('Only if no Content Model display output.')), - '#description' => t('Determines when to display the object (or collection) title when viewing an object/collection page.'), - ); + $form['fedora_object_display_title'] = array( + '#type' => 'select', + '#title' => t('Display Object Title Behaviour'), + '#default_value'=> variable_get('fedora_object_display_title', ObjectHelper::$DISPLAY_ALWAYS), + '#options' => array(ObjectHelper::$DISPLAY_ALWAYS=>t('Always'),ObjectHelper::$DISPLAY_NEVER=>t('Never'),ObjectHelper::$DISPLAY_NO_MODEL_OUTPUT=>t('Only if no Content Model display output.')), + '#description' => t('Determines when to display the object (or collection) title when viewing an object/collection page.'), + ); $form['fedora_object_display_description'] = array( @@ -377,6 +377,13 @@ class formClass { '#options' => array(ObjectHelper::$DISPLAY_ALWAYS=>t('Always'),ObjectHelper::$DISPLAY_NEVER=>t('Never'),ObjectHelper::$DISPLAY_NO_MODEL_OUTPUT=>t('Only if no Content Model display output.')), '#description' => t('Determines when to display the default object (or collection) description fieldset when viewing an object/collection page.'), ); + + $form['fedora_object_restrict_datastreams'] = array( + '#type' => 'checkbox', + '#title' => t('Restrict Access to Fedora Object Datastreams'), + '#default_value'=> variable_get('fedora_object_restrict_datastreams', TRUE), + '#description' => t('When enabled, restricts access to fedora object datastreams that are not listed in the Islandora Content Model for the object (unless the user is an administrator).'), + ); $form['fedora_collection_display_list'] = array( '#type' => 'select', From 39acc688d368edaaa256e33986d7886deb3a2ae5 Mon Sep 17 00:00:00 2001 From: mroy Date: Tue, 14 Dec 2010 16:24:52 -0600 Subject: [PATCH 07/14] Updated to make the /fedora/repository page title a variable configurable in the fedora collection list configuration. --- formClass.inc | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/formClass.inc b/formClass.inc index e9995a90..20840ba7 100644 --- a/formClass.inc +++ b/formClass.inc @@ -77,8 +77,14 @@ class formClass { 'access arguments' => array('view fedora collection'), // 'access' => TRUE ); + $repository_title = variable_get('fedora_repository_title','Digital repository'); + if (trim($repository_title)!= '') { + $respository_title=t($repository_title); + } else { + $repository_title= NULL; + } $items['fedora/repository'] = array( - 'title' => t('Digital repository'), + 'title' => $repository_title, 'page callback' => 'repository_page', 'type' => MENU_NORMAL_ITEM, // 'page arguments'=>array(1), @@ -361,6 +367,14 @@ class formClass { ); */ + $form['fedora_repository_title'] = array( + '#type' => 'textfield', + '#title' => t('Fedora Repository Title'), + '#default_value'=> variable_get('fedora_repository_title', 'Digital Repository'), + '#description' => t('The title displayed when viewing collections and objects in /fedora/repository. Leave blank to display no title. Note that the menus must be rebuilt after changing this variable.'), + ); + + $form['fedora_object_display_title'] = array( '#type' => 'select', '#title' => t('Display Object Title Behaviour'), @@ -370,6 +384,7 @@ class formClass { ); + $form['fedora_object_display_description'] = array( '#type' => 'select', '#title' => t('Display Object Description Behaviour'), From 28a408978e46262b0143f06fb2676e8dfde50389 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 14 Dec 2010 17:39:04 -0600 Subject: [PATCH 08/14] Updated to only list datastreams that are in the Islandora Content Model in the detailed list of content. This can also be disabled with the 'Restrict Access to Fedora Object Datastreams' option in the fedora collection list settings page. All datastreams are listed for administrators. --- ObjectHelper.inc | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/ObjectHelper.inc b/ObjectHelper.inc index ab4cb617..d4b4799a 100644 --- a/ObjectHelper.inc +++ b/ObjectHelper.inc @@ -406,11 +406,12 @@ class ObjectHelper { * */ function get_formatted_datastream_list($object_pid, $contentModels, &$fedoraItem) { - global $fedoraUser, $fedoraPass, $base_url; + global $fedoraUser, $fedoraPass, $base_url, $user; module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); module_load_include('inc', 'fedora_repository', 'ObjectHelper'); module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - + module_load_include('inc', 'fedora_repository', 'ContentModel'); + $path = drupal_get_path('module', 'fedora_repository'); $dataStreamBody = ''; $fedoraItem = new Fedora_Item($object_pid); @@ -427,21 +428,29 @@ class ObjectHelper { $hasOBJStream = NULL; $hasTNStream = FALSE; $dataStreamBody = "
\n"; + + $cmDatastreams = array(); + if (variable_get('fedora_object_restrict_datastreams', TRUE) == TRUE && ($cm = ContentModel::loadFromObject($object_pid)) !== FALSE) { + $cmDatastreams = $cm->listDatastreams(); + } $dataStreamBody .= $this->get_parent_objects_asHTML($object_pid); $dataStreamBody .= ''; foreach ($object as $datastream) { foreach ($datastream as $datastreamValue) { - if ($datastreamValue->ID == 'OBJ') { - $hasOBJStream = '1'; - $mainStreamLabel = $datastreamValue->label; - $mainStreamLabel = str_replace("_", " ", $mainStreamLabel); - } - if ($datastreamValue->ID == 'TN') { - $hasTNStream = TRUE; - } - //create the links to each datastream - $dataStreamBody .= $this->create_link_for_ds($object_pid, $datastreamValue); //"\n"; + + if (variable_get('fedora_object_restrict_datastreams', TRUE) == FALSE || ((isset($user) && in_array('administrator',$user->roles)) || in_array($datastreamValue->ID,$cmDatastreams))) { + if ($datastreamValue->ID == 'OBJ') { + $hasOBJStream = '1'; + $mainStreamLabel = $datastreamValue->label; + $mainStreamLabel = str_replace("_", " ", $mainStreamLabel); + } + if ($datastreamValue->ID == 'TN') { + $hasTNStream = TRUE; + } + //create the links to each datastream + $dataStreamBody .= $this->create_link_for_ds($object_pid, $datastreamValue); //"\n"; + } } } $dataStreamBody .= "

' . t("!text", array('!text' => $availableDataStreamsText)) . '

$key :$value
$key :$value
\n"; From 9412cfff89b550e75efd834a716eb40bac96c1ed Mon Sep 17 00:00:00 2001 From: root Date: Tue, 14 Dec 2010 17:43:28 -0600 Subject: [PATCH 09/14] Modified to include content model as a field cmodel_t in solr doc. Also does some basic checking and returns messages if the xsl fails to load/run --- workflow_client/plugins/solr_index.inc | 32 +++++++++++++++++++------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/workflow_client/plugins/solr_index.inc b/workflow_client/plugins/solr_index.inc index 2c45901d..0b770462 100644 --- a/workflow_client/plugins/solr_index.inc +++ b/workflow_client/plugins/solr_index.inc @@ -27,6 +27,8 @@ class solr_index extends Process { } module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'ContentModel'); + $xsltDom = NULL; if (isset($parameters['xslt'])) { list($template_pid, $template_dsid) = explode('/', $parameters['xslt']); @@ -44,6 +46,11 @@ class solr_index extends Process { $xsltDom->load(drupal_get_path('module', 'islandora_workflow_client') .'/xsl/'. trim($parameters['xslt_file'])); } + if ($xsdlDom === FALSE) { + $this->setMessage(t('Unable to load xslt.')); + return FALSE; + } + $item = new fedora_item($pid); $dslist = $item->get_datastreams_list_as_array(); if (!isset($dslist[$parameters['dsid']])) { @@ -59,9 +66,12 @@ class solr_index extends Process { $proc = new XSLTProcessor(); $proc->importStylesheet($xsltDom); - $solrDoc = $proc->transformToXML($dom); - - $solrDom = DOMDocument::loadXML($solrDoc); + $solrDom = $proc->transformToDOC($dom); + + if ($solrDoc === FALSE) { + $this->setMessage(t('Document transform failed.')); + return FALSE; + } $doc = $solrDom->getElementsByTagName('doc'); if ($doc->length > 0) { $doc=$doc->item(0); @@ -72,13 +82,19 @@ class solr_index extends Process { $field->setAttribute('name', 'workflow_process_t'); $doc->appendChild($field); } - + + if (($cm = ContentModel::loadFromObject($pid)) !== FALSE) { + $field=$solrDom->createElement('field', $cm->pid); + $field->setAttribute('name', 'cmodel_t'); + $doc->appendChild($field); + } + if (isset($dslist['DC'])) { - $dc = $item->get_datastream('DC'); - $field=$solrDom->createElement('field',$dc->createDate); - $field->setAttribute('name','created_d'); - $doc->appendChild($field); + $dc = $item->get_datastream('DC'); + $field=$solrDom->createElement('field',$dc->createDate); + $field->setAttribute('name','created_d'); + $doc->appendChild($field); } } From 5fdebe566629393ac8510702bc1cba8cc37c7082 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 14 Dec 2010 17:44:26 -0600 Subject: [PATCH 10/14] Removes a check for a return file that was a remnant from another process. Updated the label of the new exif datastream to make more sense. --- workflow_client/plugins/exif.inc | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/workflow_client/plugins/exif.inc b/workflow_client/plugins/exif.inc index 5a1ba414..d53e83f3 100644 --- a/workflow_client/plugins/exif.inc +++ b/workflow_client/plugins/exif.inc @@ -45,18 +45,12 @@ class exif extends Process { $command = '/usr/local/exif/exiftool -X '. $file; exec($command, $output, $returnValue); - if (!file_exists($file . $file_suffix)) { - $this->setMessage('command failed: '. htmlentities($command ."\n" . join("\n", $output) ."\n return value: $returnValue")); - @unlink($file); - return FALSE; - } - if ($returnValue == '0') { if (isset($dslist[$dest_ds])) { $item->purge_datastream($dest_ds); } - $ret = $item->add_datastream_from_string(join("\n",$output), $dest_ds, $ds['label'] . $file_suffix, 'text/xml', 'X','Added by workflow process EXIF.'); + $ret = $item->add_datastream_from_string(join("\n",$output), $dest_ds, 'EXIF_Technical_Metadata.xml' , 'text/xml', 'X','Added by workflow process EXIF.'); @unlink($file); @unlink($file . $file_suffix); From 9ab9ba075113d51d97d24755b8c0eb61639c4bd4 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 14 Dec 2010 17:46:30 -0600 Subject: [PATCH 11/14] Added some checks to the displayMetadata method so that it does not cause errors if the exif datastream is empty or missing. --- plugins/Exiftool.inc | 53 +++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/plugins/Exiftool.inc b/plugins/Exiftool.inc index d4feac7a..ec6d7ad0 100644 --- a/plugins/Exiftool.inc +++ b/plugins/Exiftool.inc @@ -32,32 +32,35 @@ class Exiftool { function displayMetadata() { $output=''; - $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 .= ''; + $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); - } - } + $fieldset = array( + '#title' => t("!text", array('!text' => 'Technical Metadata')), + '#collapsible' => TRUE, + '#collapsed' => TRUE, + '#value' => $output + ); + $output = theme('fieldset', $fieldset); + } + } + } return $output; } From 19fb1623e07176ac66a0f87c38a73ca11b4a5b90 Mon Sep 17 00:00:00 2001 From: mroy Date: Wed, 15 Dec 2010 15:08:49 -0600 Subject: [PATCH 12/14] Partial fix for ISLANDORA-134. Saves XML datastreams using the mimetype application/xml (instead of null) and also uses the label 'Collection Policy' for collection policies and 'Islandora Content Model' for content models (by default). This may or may not resolve the issue of the datstream being switched to managed content. Needs to be verified on the demos collection. --- CollectionPolicy.inc | 15 +++++++++++++++ ContentModel.inc | 4 ++-- XMLDatastream.inc | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CollectionPolicy.inc b/CollectionPolicy.inc index cb769085..be92f8b7 100644 --- a/CollectionPolicy.inc +++ b/CollectionPolicy.inc @@ -181,6 +181,21 @@ class CollectionPolicy extends XMLDatastream { return $ret; } + + /** + * Constructor + * NOTE: Use the static constructor methods whenever possible. + * + * @param string $xmlStr + * @param string $pid + * @param string $dsid + * @return XMLDatastream $cm + */ + public function __construct($xmlStr, $pid = NULL, $dsid = NULL) { + parent::__construct($xmlStr,$pid,$dsid); + $this->name= 'Collection Policy'; + } + /** * Attempts to convert from the old XML schema to the new by * traversing the XML DOM and building a new DOM. When done diff --git a/ContentModel.inc b/ContentModel.inc index 4cc66976..381fa9ac 100644 --- a/ContentModel.inc +++ b/ContentModel.inc @@ -101,7 +101,7 @@ class ContentModel extends XMLDatastream { return $ret; } - + /** * Ingests a minimum Content Model to the specified pid/dsid. @@ -224,7 +224,7 @@ class ContentModel extends XMLDatastream { parent::__construct($xmlStr, $pid, $dsid); $this->pid_namespace = $pid_namespace; - $this->name = $name; + $this->name = ($name == NULL)?'Islandora Content Model':$name; } /** diff --git a/XMLDatastream.inc b/XMLDatastream.inc index e99cbbca..77c357de 100644 --- a/XMLDatastream.inc +++ b/XMLDatastream.inc @@ -223,7 +223,7 @@ printerWindow.document.write(text); module_load_include('inc', 'Fedora_Repository', 'api/fedora_item'); if ($this->validate()) { $item = new Fedora_Item($this->pid); - $item->modify_datastream_by_value($this->dumpXml(), $this->dsid, $this->name, NULL); + $item->modify_datastream_by_value($this->dumpXml(), $this->dsid, $this->name, 'application/xml'); return TRUE; } return FALSE; From 415c950bae8fe50e0f6b15e3810be6e495b05ceb Mon Sep 17 00:00:00 2001 From: mroy Date: Wed, 15 Dec 2010 17:48:21 -0600 Subject: [PATCH 13/14] Fixed a bug with the entity editor keeping data from one ingest to the next. Fixed it by having the form handler plugin clear the ['people']. In order to do this, I needed to add & to the parameters list of the form handler. --- ContentModel.inc | 5 ++-- fedora_repository.module | 2 +- form_elements/includes/people.inc | 25 ++++++++++++++------ form_elements/islandora_form_elements.module | 5 ++-- plugins/ModsFormBuilder.inc | 6 +++-- 5 files changed, 28 insertions(+), 15 deletions(-) diff --git a/ContentModel.inc b/ContentModel.inc index 381fa9ac..5ed33d59 100644 --- a/ContentModel.inc +++ b/ContentModel.inc @@ -1372,9 +1372,10 @@ class ContentModel extends XMLDatastream { * Executes the form handler from the element of . * * @param &$formData + * @param &$form_state * @return boolean $success */ - public function execFormHandler(&$data) { + public function execFormHandler(&$data,&$form_state) { $ret = FALSE; if ($this->validate()) { $method =$this->xml->getElementsByTagName('ingest_form')->item(0)->getElementsByTagName('form_builder_method')->item(0); @@ -1396,7 +1397,7 @@ class ContentModel extends XMLDatastream { self::$errors[] = 'Execute Form Handler: method \''. $className .'->'. $methodName .'\' does not exist.'; } else { - $class->$methodName($data); + $class->$methodName($data,$form_state); $ret = TRUE; } } diff --git a/fedora_repository.module b/fedora_repository.module index 093bdb2d..abd323c0 100644 --- a/fedora_repository.module +++ b/fedora_repository.module @@ -144,7 +144,7 @@ function fedora_repository_ingest_form_submit($form, &$form_state) { $form_state['values']['content_model_pid'] = $contentModelPid; $form_state['values']['relationship'] = $relationship; - $err = (!$cm->execFormHandler($form_state['values'])); + $err = (!$cm->execFormHandler($form_state['values'],$form_state)); $_SESSION['fedora_ingest_files'] = ''; //empty this variable diff --git a/form_elements/includes/people.inc b/form_elements/includes/people.inc index 9d44055f..f19bf9b8 100644 --- a/form_elements/includes/people.inc +++ b/form_elements/includes/people.inc @@ -40,12 +40,15 @@ function _ife_find_people_element($form, &$keys = array()) { } function ife_people_ahah() { + + if (!isset($_POST['form_build_id'])) return; $form_state = array('storage' => NULL, 'submitted' => FALSE); $form_build_id = $_POST['form_build_id']; $form = form_get_cache($form_build_id, $form_state); + $args = $form['#parameters']; $form_id = array_shift($args); $form['#post'] = $_POST; @@ -57,10 +60,11 @@ function ife_people_ahah() { $form['#post'] = $_POST; drupal_process_form($form_id, $form, $form_state); - + +// ob_start(); echo '
';   echo $_POST['form_build_id']."\n"; var_dump($form_state);   echo '
'; $dump = ob_get_contents(); ob_end_clean(); + $form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id); $qt_form = _ife_find_people_element($form); -// ob_start(); echo '
'; echo $form_state['clicked_button']['#parents'][2]; var_dump($form_state['storage']['people']); echo'
'; $dump = ob_get_contents(); ob_end_clean(); unset($qt_form['#prefix'], $qt_form['#suffix']); // Prevent duplicate wrappers. $javascript = drupal_add_js(NULL, NULL, 'header'); @@ -105,7 +109,7 @@ function ife_remove_person_submit($form, &$form_state) { unset($form_state['submit_handlers']); form_execute_handlers('submit', $form, $form_state); $form_state['storage']['people'] = $people; - $form_state['rebuild'] = TRUE; + //$form_state['rebuild'] = TRUE; } @@ -117,6 +121,7 @@ function ife_add_person_submit($form, &$form_state) { $keys = array(); $qt_form = _ife_find_people_element($form, $keys); $peopleVals = &$form_state['values']; + while (count($keys) > 0) { $key = array_pop($keys); if (isset($peopleVals[$key])) { @@ -129,12 +134,16 @@ function ife_add_person_submit($form, &$form_state) { foreach ($peopleVals['people'] as $val) { $people[] = $val; } - $people[] = array('name' => '', 'date'=>'', 'role' => '', 'subject' => ''); + + //only add new person if we are not adding from repository. + if (!isset($form_state['post']['add_from_repository']) || trim($form_state['post']['add_from_repository']) == '') { + $people[] = array('name' => '', 'date'=>'', 'role' => '', 'subject' => ''); + } unset($form_state['submit_handlers']); form_execute_handlers('submit', $form, $form_state); $form_state['storage']['people'] = $people; - $form_state['rebuild'] = TRUE; + // $form_state['rebuild'] = TRUE; } @@ -147,12 +156,14 @@ function ife_add_org_submit($form, &$form_state) { $keys = array(); $qt_form = _ife_find_people_element($form, $keys); $peopleVals = &$form_state['values']; + while (count($keys) > 0) { $key = array_pop($keys); if (isset($peopleVals[$key])) { $peopleVals = &$peopleVals[$key]; } } + if (!is_array($peopleVals['people'])) $peopleVals['people'] = array(); @@ -164,7 +175,7 @@ function ife_add_org_submit($form, &$form_state) { unset($form_state['submit_handlers']); form_execute_handlers('submit', $form, $form_state); $form_state['storage']['people'] = $people; - $form_state['rebuild'] = TRUE; + //$form_state['rebuild'] = TRUE; } @@ -194,7 +205,7 @@ function ife_add_conf_submit($form, &$form_state) { unset($form_state['submit_handlers']); form_execute_handlers('submit', $form, $form_state); $form_state['storage']['people'] = $people; - $form_state['rebuild'] = TRUE; + //$form_state['rebuild'] = TRUE; } diff --git a/form_elements/islandora_form_elements.module b/form_elements/islandora_form_elements.module index 75214db0..e174693b 100644 --- a/form_elements/islandora_form_elements.module +++ b/form_elements/islandora_form_elements.module @@ -129,7 +129,7 @@ function ife_fieldset_children_has_value($el) function ife_people_process($element,$edit,&$form_state) { - + $element['#tree'] = TRUE; $element['#prefix'] = '
'; $element['#suffix'] = '
'; @@ -141,7 +141,6 @@ function ife_people_process($element,$edit,&$form_state) '#theme' => 'people_items', ); - if (isset($form_state['post'][$element['#name']]['add_from_repository']) && trim($form_state['post'][$element['#name']]['add_from_repository']) != '') { $people= array(); @@ -156,7 +155,7 @@ function ife_people_process($element,$edit,&$form_state) $json = json_decode($form_state['post'][$element['#name']]['add_from_repository']); $person=array(); -// ob_start(); echo '
'; var_dump($json); echo '
'; drupal_set_message(ob_get_contents()); ob_end_clean(); + switch ($json->type) { diff --git a/plugins/ModsFormBuilder.inc b/plugins/ModsFormBuilder.inc index 47dab34c..d3907d38 100644 --- a/plugins/ModsFormBuilder.inc +++ b/plugins/ModsFormBuilder.inc @@ -231,10 +231,12 @@ class ModsFormBuilder extends FormBuilder { } - function handleModsForm($form_values) { + 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. + $dom = new DomDocument("1.0", "UTF-8"); $dom->formatOutput = TRUE; $pid=$form_values['pid']; @@ -272,7 +274,7 @@ 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 From 5987a08c292e2fcbcf3bee9769b193199667eb39 Mon Sep 17 00:00:00 2001 From: mroy Date: Wed, 15 Dec 2010 18:36:19 -0600 Subject: [PATCH 14/14] Added markup field type. Updated form builder to accept the new markup element type. --- .../islandora_content_modeller.module | 10 ++++++---- plugins/FormBuilder.inc | 17 +++++++++++------ 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/content_modeller/islandora_content_modeller.module b/content_modeller/islandora_content_modeller.module index 8d64e84e..4c1a4b6a 100644 --- a/content_modeller/islandora_content_modeller.module +++ b/content_modeller/islandora_content_modeller.module @@ -2684,8 +2684,9 @@ function icm_model_add_ingestFormElement(&$form_state,$params=null) 'other_select'=>t('Select (with \'other\' option)'), 'datepicker'=>t('Datepicker'), 'copyright'=>t('Creative-Commons Copyright Chooser'), - 'hidden'=>t('Hidden'), - 'file'=>t('File Upload (browse)'), + 'hidden'=>t('Hidden'), + 'file'=>t('File Upload (browse)'), + 'markup'=>t('HTML Markup (no field)'), ), '#description'=> t('The type of form element to display.') ); @@ -2849,8 +2850,9 @@ function icm_model_edit_ingestFormElement(&$form_state,$params=null) 'other_select'=>t('Select (with \'other\' option)'), 'datepicker'=>t('Datepicker'), 'copyright'=>t('Creative-Commons Copyright Chooser'), - 'hidden'=>t('Hidden'), - 'file'=>t('File Upload (browse)'), + 'hidden'=>t('Hidden'), + 'file'=>t('File Upload (browse)'), + 'markup'=>t('HTML Markup (no field)'), ), '#description'=> t('The type of form element to display.
Warning: Changing the type from "Select" or "Radio" to anything else will cause any authoritative list to be permanently removed.') ); diff --git a/plugins/FormBuilder.inc b/plugins/FormBuilder.inc index 7cb8acdc..dbedda75 100644 --- a/plugins/FormBuilder.inc +++ b/plugins/FormBuilder.inc @@ -312,12 +312,17 @@ class FormBuilder { ); foreach ($elements as $element) { - $el = array( - '#title' => $element['label'], - '#required' => ($element['required'] ? 1 : 0), - '#description' => $element['description'], - '#type' => $element['type'] - ); + + 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'];