Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

ISLANDORA-214 add newspaper ingest form.

  • Loading branch information...
commit 0ce522c1eb9e42517c67749ac93347613357cf55 1 parent abf001d
@alxp authored
View
14 fedora_repository.solutionpacks.inc
@@ -101,6 +101,12 @@ function fedora_repository_solution_pack_form(&$form_state, $solution_pack_modul
}
if (!empty($datastreams) && is_array($datastreams)) {
foreach ($datastreams as $ds) {
+ $ds_list = $item->get_datastreams_list_as_array();
+ if (!array_key_exists($ds['dsid'], $ds_list)) {
+ $needs_update = TRUE;
+ $object_status = 'Missing datastream';
+ break;
+ }
if (isset($ds['dsversion'])) {
// Check if the datastream is versioned and needs updating.
$installed_version = fedora_repository_get_islandora_datastream_version($item, $ds['dsid']);
@@ -108,14 +114,14 @@ function fedora_repository_solution_pack_form(&$form_state, $solution_pack_modul
if ($available_version > $installed_version) {
$needs_update = TRUE;
$object_status = 'Out of date';
+ break;
}
}
}
- }
- array_push($table_row, $object_status);
-
- $table_rows[] = $table_row;
+ }
}
+ array_push($table_row, $object_status);
+ $table_rows[] = $table_row;
}
}
$form['objects']['table'] = array(
View
BIN  plugins/islandora_newspaper/Crystal_Clear_mimetype_document.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
81 plugins/islandora_newspaper/Newspaper.inc
@@ -13,9 +13,82 @@ class Newspaper {
}
}
+ public function buildDrupalForm($form = array(), $ingest_form = array(), &$form_state = array()) {
+
+ // Give the user an option to enter a custom PID
+ $form['custom_pid'] = array(
+ '#type' => 'textfield',
+ '#title' => 'Custom PID',
+ '#description' => 'If you want to manually specify the PID for the new object, enter it here. '.
+ 'Leave it blank for an automatically-generated PID.',
+ );
+
+ $form['mods'] = array(
+ '#tree' => TRUE,
+ '#prefix' => '<div id="mods-wrapper">',
+ '#suffix' => '</div>',
+ );
+ $form['mods']['mods_record'] = array(
+ '#type' => 'textarea',
+ '#title' => 'MODS Record to Import',
+ '#rows' => 20,
+
+ );
+
+ return $form;
+ }
+
+ public function handleIngestForm($form_values, &$form_state) {
+ /*
+ * process the metadata form
+ * Create fedora object
+ * Add the datastreams
+ */
+ module_load_include('inc', 'fedora_repository', 'MimeClass');
+ module_load_include('inc', 'fedora_repository', 'api/fedora_item');
+ module_load_include('inc', 'fedora_ilives', 'book');
+ $mods_list_doc = new DomDocument();
+ $mods_list_doc->loadXML($form_values['mods']['mods_record']);
+ $mods_item_doc = new DomDocument();
+ $mods_item = $mods_list_doc->getElementsByTagNameNS('http://www.loc.gov/mods/v3', 'mods')->item(0);
+ $new_mods_item = $mods_item_doc->importNode($mods_item, TRUE);
+ $mods_item_doc->appendChild($new_mods_item);
+
+ $title_info = $mods_item_doc->getElementsByTagNameNS('http://www.loc.gov/mods/v3', 'titleInfo')->item(0);
+ $title = '';
+ foreach(array('nonSort', 'title') as $title_field) {
+ $title .= $title_info->getElementsByTagNameNS('http://www.loc.gov/mods/v3', $title_field)->item(0)->nodeValue;
+ }
+
+ $mods_text = $mods_item_doc->saveXML();
+ global $user;
+ $mimetype = new MimeClass();
+
+ $new_item = Fedora_Item::ingest_new_item(!empty($form_values['custom_pid']) ? $form_values['custom_pid'] : $form_values['pid'], 'A', $title,
+ $user->name);
+
+ $new_item->add_datastream_from_string($mods_text, 'MODS',
+ 'MODS Metadata', 'text/xml', 'X');
+
+ $dc = transform_mods_to_dc($mods_text);
+ if ($dc) {
+ // Add the PID to a dc:identifier field.
+ $dc_doc = simplexml_load_string($dc);
+ $dc_doc->registerXPathNamespace('oai_dc', 'http://www.openarchives.org/OAI/2.0/oai_dc/');
+ $dc_item = $dc_doc->xpath('//oai_dc:dc');
+ foreach($dc_item as $node) {
+ $node->addChild('dc:identifier', $new_item->pid, 'http://purl.org/dc/elements/1.1/');
+ }
+ $new_item->modify_datastream_by_value($dc_doc->saveXML(), 'DC', 'Dublin Core XML Metadata', 'text/xml');
+ }
+ $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']);
+ drupal_set_message(t("Item !pid created successfully.", array('!pid' => l($new_item->pid, 'fedora/repository/'. $new_item->pid))), "status");
+ }
+
public function showFieldSets() {
-
+ module_load_include('inc', 'fedora_ilives', 'book');
global $base_url;
$tabset = array();
@@ -46,7 +119,11 @@ class Newspaper {
'#title' => 'Description',
'#content' => $item->get_dissemination('islandora:mods2htmlSdef', 'mods2html'),
);
-
+ $tabset['my_tabset']['add_pages'] = array(
+ '#type' => 'tabpage',
+ '#title' => t('Add pages'),
+ '#content' => drupal_get_form('book_add_pages_form', $this->pid),
+ );
return tabs_render($tabset);
}
View
16 plugins/islandora_newspaper/islandora_newspaper.module
@@ -39,6 +39,22 @@ function islandora_newspaper_required_fedora_objects() {
'datastream_file' => NULL,
'dsversion' => NULL,
),
+ array (
+ 'pid' => 'newspapers:collection',
+ 'cmodel' => 'islandora:collectionCModel',
+ 'parent' => 'islandora:demos',
+ 'datastreams' => array (
+ array (
+ 'dsid' => 'COLLECTION_POLICY',
+ 'datastream_file' => "$module_path/newspapers_collection_policy.xml",
+ ),
+ array (
+ 'dsid' => 'TN',
+ 'datastream_file' => "$module_path/Crystal_Clear_mimetype_document.png",
+ 'mimetype' => 'image/png',
+ ),
+ ),
+ ),
),
),
);
View
21 plugins/islandora_newspaper/newspapers_collection_policy.xml
@@ -0,0 +1,21 @@
+<collection_policy xmlns="http://www.islandora.ca" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="" xsi:schemaLocation="http://www.islandora.ca http://syn.lib.umanitoba.ca/collection_policy.xsd">
+ <content_models>
+ <content_model dsid="ISLANDORACM" name="Newspaper" namespace="islandora" pid="newspapers:issueCModel"></content_model>
+ </content_models>
+ <search_terms>
+ <term field="dc.title">dc.title</term>
+ <term field="dc.creator">dc.creator</term>
+ <term default="true" field="dc.description">dc.description</term>
+ <term field="dc.date">dc.date</term>
+ <term field="dc.identifier">dc.identifier</term>
+ <term field="dc.language">dc.language</term>
+ <term field="dc.publisher">dc.publisher</term>
+ <term field="dc.rights">dc.rights</term>
+ <term field="dc.subject">dc.subject</term>
+ <term field="dc.relation">dc.relation</term>
+ <term field="dcterms.temporal">dcterms.temporal</term>
+ <term field="dcterms.spatial">dcterms.spatial</term>
+ <term field="fgs.DS.first.text">Full Text</term>
+ </search_terms>
+ <relationship>isMemberOfCollection</relationship>
+</collection_policy>
View
161 plugins/islandora_newspaper/newspapers_issueCModel.xml
@@ -1,161 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<foxml:digitalObject PID="newspapers:issueCModel" VERSION="1.1" xmlns:foxml="info:fedora/fedora-system:def/foxml#"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="info:fedora/fedora-system:def/foxml# http://www.fedora.info/definitions/1/0/foxml1-1.xsd">
- <foxml:objectProperties>
- <foxml:property NAME="info:fedora/fedora-system:def/model#state" VALUE="Active"/>
- <foxml:property NAME="info:fedora/fedora-system:def/model#label" VALUE="Newspaper Issue Content Model"/>
- <foxml:property NAME="info:fedora/fedora-system:def/model#ownerId" VALUE="fedoraAdmin"/>
- <foxml:property NAME="info:fedora/fedora-system:def/model#createdDate" VALUE="2010-05-28T19:34:22.355Z"/>
- <foxml:property NAME="info:fedora/fedora-system:def/view#lastModifiedDate" VALUE="2010-05-31T20:00:31.353Z"/>
- </foxml:objectProperties>
- <foxml:datastream CONTROL_GROUP="X" ID="AUDIT" STATE="A" VERSIONABLE="false">
- <foxml:datastreamVersion CREATED="2010-05-28T19:34:22.355Z"
- FORMAT_URI="info:fedora/fedora-system:format/xml.fedora.audit" ID="AUDIT.0" LABEL="Audit Trail for this object" MIMETYPE="text/xml">
- <foxml:xmlContent>
- <audit:auditTrail xmlns:audit="info:fedora/fedora-system:def/audit#">
- <audit:record ID="AUDREC1">
- <audit:process type="Fedora API-M"/>
- <audit:action>ingest</audit:action>
- <audit:componentID/>
- <audit:responsibility>fedoraAdmin</audit:responsibility>
- <audit:date>2010-05-28T19:34:22.355Z</audit:date>
- <audit:justification>Created with Admin GUI "New Object" command</audit:justification>
- </audit:record>
- <audit:record ID="AUDREC2">
- <audit:process type="Fedora API-M"/>
- <audit:action>ingest</audit:action>
- <audit:componentID/>
- <audit:responsibility>fedoraAdmin</audit:responsibility>
- <audit:date>2010-05-31T15:15:15.889Z</audit:date>
- <audit:justification>Ingested from local file /Users/al/Desktop/newspapers_issueCModel.xml</audit:justification>
- </audit:record>
- <audit:record ID="AUDREC3">
- <audit:process type="Fedora API-M"/>
- <audit:action>addDatastream</audit:action>
- <audit:componentID>ISLANDORACM</audit:componentID>
- <audit:responsibility>fedoraAdmin</audit:responsibility>
- <audit:date>2010-05-31T19:28:19.883Z</audit:date>
- <audit:justification>DatastreamsPane generated this logMessage.</audit:justification>
- </audit:record>
- <audit:record ID="AUDREC4">
- <audit:process type="Fedora API-M"/>
- <audit:action>modifyDatastreamByValue</audit:action>
- <audit:componentID>RELS-EXT</audit:componentID>
- <audit:responsibility>fedoraAdmin</audit:responsibility>
- <audit:date>2010-05-31T20:00:31.353Z</audit:date>
- <audit:justification/>
- </audit:record>
- </audit:auditTrail>
- </foxml:xmlContent>
- </foxml:datastreamVersion>
- </foxml:datastream>
- <foxml:datastream CONTROL_GROUP="X" ID="RELS-EXT" STATE="A" VERSIONABLE="true">
- <foxml:datastreamVersion CREATED="2010-05-28T19:34:22.396Z" FORMAT_URI="info:fedora/fedora-system:FedoraRELSExt-1.0"
- ID="RELS-EXT1.0" LABEL="RDF Statements about this object" MIMETYPE="application/rdf+xml" SIZE="366">
- <foxml:xmlContent>
- <rdf:RDF xmlns:fedora-model="info:fedora/fedora-system:def/model#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
- <rdf:Description rdf:about="info:fedora/newspapers:issueCModel">
- <fedora-model:hasModel rdf:resource="info:fedora/fedora-system:ContentModel-3.0"/>
- </rdf:Description>
- </rdf:RDF>
- </foxml:xmlContent>
- </foxml:datastreamVersion>
- <foxml:datastreamVersion CREATED="2010-05-31T20:00:31.353Z" FORMAT_URI="info:fedora/fedora-system:FedoraRELSExt-1.0"
- ID="RELS-EXT.1" LABEL="RDF Statements about this object" MIMETYPE="application/rdf+xml" SIZE="415">
- <foxml:xmlContent>
- <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
- <rdf:Description rdf:about="info:fedora/newspapers:issueCModel">
- <hasModel rdf:resource="info:fedora/fedora-system:ContentModel-3.0" xmlns="info:fedora/fedora-system:def/model#"/>
- <hasService rdf:resource="info:fedora/ilives:viewerSdef" xmlns="info:fedora/fedora-system:def/model#"/>
- </rdf:Description>
- </rdf:RDF>
- </foxml:xmlContent>
- </foxml:datastreamVersion>
- </foxml:datastream>
- <foxml:datastream CONTROL_GROUP="X" ID="DS-COMPOSITE-MODEL" STATE="A" VERSIONABLE="true">
- <foxml:datastreamVersion CREATED="2010-05-28T19:34:22.396Z"
- FORMAT_URI="info:fedora/fedora-system:FedoraDSCompositeModel-1.0" ID="DS-COMPOSITE-MODEL1.0"
- LABEL="Datastream Composite Model" MIMETYPE="text/xml" SIZE="1120">
- <foxml:xmlContent>
- <dsCompositeModel xmlns="info:fedora/fedora-system:def/dsCompositeModel#">
- <comment xmlns="info:fedora/fedora-system:def/comment#">
- This DS-COMPOSITE-MODEL datastream is included as a starting point to
- assist in the creation of a content model. The DS-COMPOSITE-MODEL
- should define the datastreams that are required for any objects
- conforming to this content model.
- For more information about content models, see:
- http://fedora-commons.org/confluence/x/dgBI.
- For examples of completed content model objects, see the demonstration
- objects included with your Fedora distribution, such as:
- demo:CMImage, demo:UVA_STD_IMAGE, demo:DualResImageCollection,
- demo:TEI_TO_PDFDOC, and demo:XML_TO_HTMLDOC.
- For more information about the demonstration objects, see:
- http://fedora-commons.org/confluence/x/AwFI.
- </comment>
- <dsTypeModel ID="DSID">
- <form MIME="text/xml"/>
- </dsTypeModel>
- </dsCompositeModel>
- </foxml:xmlContent>
- </foxml:datastreamVersion>
- </foxml:datastream>
- <foxml:datastream CONTROL_GROUP="X" ID="DC" STATE="A" VERSIONABLE="true">
- <foxml:datastreamVersion CREATED="2010-05-28T19:34:22.355Z" FORMAT_URI="http://www.openarchives.org/OAI/2.0/oai_dc/"
- ID="DC1.0" LABEL="Dublin Core Record for this object" MIMETYPE="text/xml" SIZE="404">
- <foxml:xmlContent>
- <oai_dc:dc xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
- <dc:title>Newspaper Issue Content Model</dc:title>
- <dc:identifier>newspapers:issueCModel</dc:identifier>
- </oai_dc:dc>
- </foxml:xmlContent>
- </foxml:datastreamVersion>
- </foxml:datastream>
- <foxml:datastream CONTROL_GROUP="X" ID="ISLANDORACM" STATE="A" VERSIONABLE="true">
- <foxml:datastreamVersion CREATED="2010-05-31T19:28:19.883Z" ID="ISLANDORACM.0"
- LABEL="Newspaper issue Islandora content model definition." MIMETYPE="text/xml" SIZE="1354">
- <foxml:xmlContent>
- <content_model name="standard_herb">
- <mimetypes/>
- <display_in_fieldset>
- <datastream id="JPG">
- <method>
- <file>plugins/Newspaper.inc</file>
- <class_name>Newspaper</class_name>
- <method_name>showFieldSets</method_name>
- </method>
- </datastream>
- <datastream id="JP2"/>
- <datastream id="LOSSLESS_JP2"/>
- <datastream id="JPG"/>
- <datastream id="TN"/>
- <datastream id="DC"/>
- <datastream id="DARWIN_CORE"/>
- </display_in_fieldset>
- <ingest_rules/>
- <ingest_form dsid="DARWIN_CORE" page="2">
- <form_builder_method>
- <file>plugins/Newspaper.inc</file>
- <class_name>Newspaper</class_name>
- <method_name>buildDrupalForm</method_name>
- <form_handler>handleIngestForm</form_handler>
- </form_builder_method>
- </ingest_form>
- <edit_metadata>
- <build_form_method dsid="MODS">
- <file>plugins/Newspaper.inc</file>
- <class_name>Newspaper</class_name>
- <method_name>buildEditMetadataForm</method_name>
- </build_form_method>
- <submit_form_method dsid="MODS">
- <file>plugins/Newspaper.inc</file>
- <class_name>Newspaper</class_name>
- <method_name>handleEditMetadataForm</method_name>
- </submit_form_method>
- </edit_metadata>
- </content_model>
- </foxml:xmlContent>
- </foxml:datastreamVersion>
- </foxml:datastream>
-</foxml:digitalObject>
View
24 plugins/islandora_newspaper/newspapers_issueCModel_islandoracm.xml
@@ -0,0 +1,24 @@
+<content_model name="Newspaper" xmlns="http://www.islandora.ca" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.islandora.ca http://localhost/islandoracm.xsd">
+ <mimetypes>
+ <type>text/xml</type>
+ </mimetypes>
+ <ingest_rules>
+ <rule>
+ <applies_to>text/xml</applies_to>
+ <ingest_methods>
+ <ingest_method class="IslandoraBook" dsid="MODS" file="book.inc" method="ingestBook" modified_files_ext="" module="fedora_ilives"/>
+ </ingest_methods>
+ </rule>
+ </ingest_rules>
+ <datastreams>
+ <datastream dsid="MODS">
+ <display_method class="Newspaper" file="Newspaper.inc" method="showFieldSets" module="islandora_newspaper"/>
+ </datastream>
+ <datastream dsid="TN"/>
+ <datastream dsid="DC"/>
+ </datastreams>
+ <ingest_form dsid="MODS" page="2">
+ <form_builder_method class="Newspaper" file="Newspaper.inc" handler="handleIngestForm" method="buildDrupalForm" module="islandora_newspaper"/>
+ <form_elements/>
+ </ingest_form>
+</content_model>
Please sign in to comment.
Something went wrong with that request. Please try again.