From 705dd3b7dd286e54022675399dcf522599c35ca3 Mon Sep 17 00:00:00 2001 From: Alexander O'Neill Date: Fri, 25 Feb 2011 15:58:15 -0400 Subject: [PATCH 1/7] ISLANDORA-214 initial definition of fedora_repository_check_for_required_fedora_objects() function. --- fedora_repository.install | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/fedora_repository.install b/fedora_repository.install index de8f31e8..a90e33fc 100644 --- a/fedora_repository.install +++ b/fedora_repository.install @@ -93,4 +93,27 @@ function fedora_repository_requirements($phase) { } return $requirements; +} + +/** + * Invokes a hook to any dependent modules asking them if their installations require + * any fedora objects to be present. Modules implementing this hook should return an array + * of arrays of the form: + * + * array( 'pid', 'path-to-foxml-file', 'dsid', 'path-to-datastream-file', int dsversion) + * + * where the last three options are optional. A module can either point to a simple + * foxml file to install, or can specify a datastreamstream to check for, with a + * path to load the datastream from if it isn't there. Optionally a version number + * can be included, to enable updating of content model or collection policy streams + * that may have been updated. THis is a simple whole number that should be incremented + * when changed. This value appears in as an attribute of the topmost element of the stream, + * e.g.,: + * + * Date: Mon, 28 Feb 2011 16:22:23 -0400 Subject: [PATCH 2/7] Initial newspaper module --- plugins/{ => islandora_newspaper}/Newspaper.inc | 0 plugins/islandora_newspaper/islandora_newspaper.info | 7 +++++++ plugins/islandora_newspaper/islandora_newspaper.module | 1 + .../newspapers_guardian.xml | 0 .../newspapers_issueCModel.xml | 0 .../newspapers_pageCModel.xml | 0 .../newspapers_viewerSdep-issueCModel.xml | 0 .../newspapers_viewerSdep-pageCModel.xml | 0 8 files changed, 8 insertions(+) rename plugins/{ => islandora_newspaper}/Newspaper.inc (100%) create mode 100644 plugins/islandora_newspaper/islandora_newspaper.info create mode 100644 plugins/islandora_newspaper/islandora_newspaper.module rename plugins/{newspaper => islandora_newspaper}/newspapers_guardian.xml (100%) rename plugins/{newspaper => islandora_newspaper}/newspapers_issueCModel.xml (100%) rename plugins/{newspaper => islandora_newspaper}/newspapers_pageCModel.xml (100%) rename plugins/{newspaper => islandora_newspaper}/newspapers_viewerSdep-issueCModel.xml (100%) rename plugins/{newspaper => islandora_newspaper}/newspapers_viewerSdep-pageCModel.xml (100%) diff --git a/plugins/Newspaper.inc b/plugins/islandora_newspaper/Newspaper.inc similarity index 100% rename from plugins/Newspaper.inc rename to plugins/islandora_newspaper/Newspaper.inc diff --git a/plugins/islandora_newspaper/islandora_newspaper.info b/plugins/islandora_newspaper/islandora_newspaper.info new file mode 100644 index 00000000..bbc884a2 --- /dev/null +++ b/plugins/islandora_newspaper/islandora_newspaper.info @@ -0,0 +1,7 @@ +; $Id$ +name = Islandora Newspaper +description = Content models and support code for Newspapers +package = Fedora Repository +dependencies[] = fedora_repository +version = 6.1dev +core = 6.x diff --git a/plugins/islandora_newspaper/islandora_newspaper.module b/plugins/islandora_newspaper/islandora_newspaper.module new file mode 100644 index 00000000..b3d9bbc7 --- /dev/null +++ b/plugins/islandora_newspaper/islandora_newspaper.module @@ -0,0 +1 @@ + Date: Tue, 1 Mar 2011 13:16:02 -0400 Subject: [PATCH 3/7] Initial theme function for solution pack list. --- formClass.inc | 6 +-- .../islandora_newspaper.module | 38 +++++++++++++++++++ 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/formClass.inc b/formClass.inc index fed6d2aa..a0fed3e6 100644 --- a/formClass.inc +++ b/formClass.inc @@ -42,9 +42,9 @@ class formClass { ); $items['admin/settings/fedora_repository/demoobjects'] = array( - 'title' => t('Install demos'), - 'description' => t('Install example content models and collections to get started using Islandora and Fedora.'), - 'page callback' => 'fedora_repository_install_demos_page', + 'title' => t('Solution Packs'), + 'description' => t('Install content models and collections required by installed solution packs.'), + 'page callback' => 'fedora_repository_solution_packs_page', 'access arguments' => array('add fedora datastreams'), 'type' => MENU_LOCAL_TASK, ); diff --git a/plugins/islandora_newspaper/islandora_newspaper.module b/plugins/islandora_newspaper/islandora_newspaper.module index b3d9bbc7..8a7fe1e9 100644 --- a/plugins/islandora_newspaper/islandora_newspaper.module +++ b/plugins/islandora_newspaper/islandora_newspaper.module @@ -1 +1,39 @@ "$module_path/newspapers_issueCModel.xml", + 'pid' => NULL, + 'dsid' => NULL, + 'datastream_file' => NULL, + 'dsversion' => NULL, + ), + array( + 'foxml_file' => "$module_path/newspapers_pageCModel.xml", + 'pid' => NULL, + 'dsid' => NULL, + 'datastream_file' => NULL, + 'dsversion' => NULL, + ), + array( + 'foxml_file' => "$module_path/newspapers_viewerSdep-issueCModel.xml", + 'pid' => NULL, + 'dsid' => NULL, + 'datastream_file' => NULL, + 'dsversion' => NULL, + ), + array( + 'foxml_file' => "$module_path/newspapers_viewerSdep-pageCModel.xml", + 'pid' => NULL, + 'dsid' => NULL, + 'datastream_file' => NULL, + 'dsversion' => NULL, + ), + ); +} \ No newline at end of file From c0fd0f11f2dc9bef1c412e1561eb2a9d971eaa88 Mon Sep 17 00:00:00 2001 From: Alexander O'Neill Date: Thu, 3 Mar 2011 13:29:27 -0400 Subject: [PATCH 4/7] ISLANDORA-214 Add function to check a datastream's version. --- content_models/COLLECTIONCM.xml | 90 ++++++++++++++- fedora_repository.install | 23 ---- fedora_repository.module | 106 ++++++++++++++++++ .../islandora_newspaper.module | 56 ++++----- 4 files changed, 224 insertions(+), 51 deletions(-) diff --git a/content_models/COLLECTIONCM.xml b/content_models/COLLECTIONCM.xml index 85ed18d1..9dae85ef 100644 --- a/content_models/COLLECTIONCM.xml +++ b/content_models/COLLECTIONCM.xml @@ -1 +1,89 @@ - text/xml text/plain application/xml The name given to the resource An entity primarily responsible for making the content of the resource such as a person, organization or service. An entity primarily responsible for making the content of the resource such as a person, organization or service. none Multi Media image meeting presentation sound text Examples include an abstract, table of contents, or free-text account of the content of the resource. An entity, (including persons, organizations, or services), responsible for making the resource available. An entity responsible for contributing to the content of the resource such as a person, organization or service. Temporal scope of the content if known. Date format is YYYY-MM-DD (e.g. 1890,1910-10,or 2007-10-23) Genre of the content of the resource. Examples include: home page, novel, poem, working paper, technical report, essay, dictionary. none collection dataset event image interactive resource model party physical object place service software sound text A reference to a resource from which the present resource is derived. A unique reference to the resource; In this instance, the accession number or collection number. The language of the intellectual content of the resource. English French Reference to a related resource. Information about intellectual property rights, copyright, and various property rights. \ No newline at end of file + + + + text/xml + text/plain + application/xml + + + + + + + + + + + + + + The name given to the resource + + + An entity primarily responsible for making the content of the resource such as a person, organization or service. + + + An entity primarily responsible for making the content of the resource such as a person, organization or service. + + none + Multi Media + image + meeting + presentation + sound + text + + + + Examples include an abstract, table of contents, or free-text account of the content of the resource. + + + An entity, (including persons, organizations, or services), responsible for making the resource available. + + + An entity responsible for contributing to the content of the resource such as a person, organization or service. + + + Temporal scope of the content if known. Date format is YYYY-MM-DD (e.g. 1890,1910-10,or 2007-10-23) + + + Genre of the content of the resource. Examples include: home page, novel, poem, working paper, technical report, essay, dictionary. + + none + collection + dataset + event + image + interactive resource + model + party + physical object + place + service + software + sound + text + + + + A reference to a resource from which the present resource is derived. + + + A unique reference to the resource; In this instance, the accession number or collection number. + + + The language of the intellectual content of the resource. + + English + French + + + + Reference to a related resource. + + + Information about intellectual property rights, copyright, and various property rights. + + + + diff --git a/fedora_repository.install b/fedora_repository.install index a90e33fc..de8f31e8 100644 --- a/fedora_repository.install +++ b/fedora_repository.install @@ -93,27 +93,4 @@ function fedora_repository_requirements($phase) { } return $requirements; -} - -/** - * Invokes a hook to any dependent modules asking them if their installations require - * any fedora objects to be present. Modules implementing this hook should return an array - * of arrays of the form: - * - * array( 'pid', 'path-to-foxml-file', 'dsid', 'path-to-datastream-file', int dsversion) - * - * where the last three options are optional. A module can either point to a simple - * foxml file to install, or can specify a datastreamstream to check for, with a - * path to load the datastream from if it isn't there. Optionally a version number - * can be included, to enable updating of content model or collection policy streams - * that may have been updated. THis is a simple whole number that should be incremented - * when changed. This value appears in as an attribute of the topmost element of the stream, - * e.g.,: - * - * NULL ), ), + 'fedora_repository_solution_packs_list' => array( + 'arguments' => array( + 'solution_packs' => NULL, + ), + ), ); } @@ -1724,3 +1729,104 @@ function fedora_repository_display_schema($file) { return; } + +/** + * Invokes a hook to any dependent modules asking them if their installations require + * any fedora objects to be present. Modules implementing this hook should return an array + * of arrays of the form: + * + * array( 'pid', 'path-to-foxml-file', 'dsid', 'path-to-datastream-file', int dsversion) + * + * where the last three options are optional. A module can either point to a simple + * foxml file to install, or can specify a datastreamstream to check for, with a + * path to load the datastream from if it isn't there. Optionally a version number + * can be included, to enable updating of content model or collection policy streams + * that may have been updated. THis is a simple whole number that should be incremented + * when changed. This value appears in as an attribute of the topmost element of the stream, + * e.g.,: + * + * $objects) { + + } + return theme('fedora_repository_solution_packs_list', $required_objects); +} + +/** + * Check for installed objects and add a 'Update' or 'Install' button if some objects are missing. + * @param array $solution_pack + */ +function fedora_repository_solution_pack_form($form, &$form_state, $solution_pack_name, $objects = array()) { + // Check each object to see if it is in the repository. + + $form['name'] = array( + '#value' => $solution_pack_name, + ); + $needs_update = FALSE; + $needs_install = FALSE; + + foreach($objects as $object) { + if (isset($object['pid'])) { + $pid = $object['pid']; + + $item = new Fedora_Item($pid); + if (!$item->exists()) { + $needs_install = TRUE; + $object['install'] = TRUE; + } + elseif (isset($object['dsid']) && isset($object['datastream_file']) && isset($object['dsversion'])) { + // Check if the datastream is versioned and needs updating. + $installed_version = fedora_repository_get_islandora_datastream_version($item, $object['dsid']); + $available_version = fedora_repository_get_islandora_datastream_version(NULL, NULL, $object['datastream_file']); + if ($available_version > $installed_version) { + $needs_update = TRUE; + $object['update'] = TRUE; + } + } + $row .= "$icon"; + $row .= "Object: $pid" . t('Installed') . ""; + $row .= ""; + $output .= $row; + } + } +} + +function fedora_repository_get_islandora_datastream_version($item = NULL, $dsid = NULL, $datastream_file = NULL) { + $return = NULL; + if (isset($item)) { + $doc = simplexml_load_string($item->get_datastream_dissemination($dsid)); + } elseif (isset($datastream_file)) { + $doc = simplexml_load_file($datastream_file); + } + + if (!empty($doc)) { + $attrs = $doc->attributes(); + foreach($attrs as $name => $value) { + if ($name == 'version') { + $return = (int) $value; + break; + } + } + } + return $return; +} + +function theme_fedora_repository_solution_packs_list($solution_packs) { + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); + $output = ''; + $header = array(); + $rows = array(); + + + + + drupal_add_css(drupal_get_path('module', 'update') .'/update.css'); + return $output; +} \ No newline at end of file diff --git a/plugins/islandora_newspaper/islandora_newspaper.module b/plugins/islandora_newspaper/islandora_newspaper.module index 8a7fe1e9..9a3a567a 100644 --- a/plugins/islandora_newspaper/islandora_newspaper.module +++ b/plugins/islandora_newspaper/islandora_newspaper.module @@ -7,33 +7,35 @@ function islandora_newspaper_required_fedora_objects() { // array( 'path-to-foxml-file', 'pid', 'dsid', 'path-to-datastream-file', int dsversion, boolean required) $module_path = drupal_get_path('module', 'islandora_newspaper'); return array( - array( - 'foxml_file' => "$module_path/newspapers_issueCModel.xml", - 'pid' => NULL, - 'dsid' => NULL, - 'datastream_file' => NULL, - 'dsversion' => NULL, - ), - array( - 'foxml_file' => "$module_path/newspapers_pageCModel.xml", - 'pid' => NULL, - 'dsid' => NULL, - 'datastream_file' => NULL, - 'dsversion' => NULL, - ), - array( - 'foxml_file' => "$module_path/newspapers_viewerSdep-issueCModel.xml", - 'pid' => NULL, - 'dsid' => NULL, - 'datastream_file' => NULL, - 'dsversion' => NULL, - ), - array( - 'foxml_file' => "$module_path/newspapers_viewerSdep-pageCModel.xml", - 'pid' => NULL, - 'dsid' => NULL, - 'datastream_file' => NULL, - 'dsversion' => NULL, + 'Islandora Newspapers' => array( + array( + 'foxml_file' => "$module_path/newspapers_issueCModel.xml", + 'pid' => 'newspapers:issueCModel', + 'dsid' => NULL, + 'datastream_file' => NULL, + 'dsversion' => NULL, + ), + array( + 'foxml_file' => "$module_path/newspapers_pageCModel.xml", + 'pid' => 'newspapers:pageCModel', + 'dsid' => NULL, + 'datastream_file' => NULL, + 'dsversion' => NULL, + ), + array( + 'foxml_file' => "$module_path/newspapers_viewerSdep-issueCModel.xml", + 'pid' => 'newspapers:viewerSdep-issueCModel', + 'dsid' => NULL, + 'datastream_file' => NULL, + 'dsversion' => NULL, + ), + array( + 'foxml_file' => "$module_path/newspapers_viewerSdep-pageCModel.xml", + 'pid' => 'newspapers:viewerSdep-pageCModel', + 'dsid' => NULL, + 'datastream_file' => NULL, + 'dsversion' => NULL, + ), ), ); } \ No newline at end of file From 847987f8ed2aadeb18236aec798e959e6272f84e Mon Sep 17 00:00:00 2001 From: Alexander O'Neill Date: Thu, 3 Mar 2011 16:38:31 -0400 Subject: [PATCH 5/7] ISLANDORA-214 Add collapsible fieldset. --- fedora_repository.module | 42 +++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/fedora_repository.module b/fedora_repository.module index cdc0d567..21353a35 100644 --- a/fedora_repository.module +++ b/fedora_repository.module @@ -1753,24 +1753,31 @@ function fedora_repository_solution_packs_page() { $enabled_solution_packs = module_invoke_all('required_fedora_objects'); $output = ''; foreach ($enabled_solution_packs as $solution_pack_name => $objects) { - + $output .= drupal_get_form('fedora_repository_solution_pack_form', $solution_pack_name, $objects); } - return theme('fedora_repository_solution_packs_list', $required_objects); + return $output; } /** * Check for installed objects and add a 'Update' or 'Install' button if some objects are missing. * @param array $solution_pack */ -function fedora_repository_solution_pack_form($form, &$form_state, $solution_pack_name, $objects = array()) { +function fedora_repository_solution_pack_form($form, $solution_pack_name, $objects = array()) { // Check each object to see if it is in the repository. - - $form['name'] = array( - '#value' => $solution_pack_name, + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + $form = array(); + $form['solution_pack'] = array( + '#type' => 'fieldset', + '#title' => "Objects", + // '#tree' => TRUE, + '#collapsed' => TRUE, + '#collapsible' => TRUE, ); $needs_update = FALSE; $needs_install = FALSE; - + $form['solution_pack']['objects'] = array( + + ); foreach($objects as $object) { if (isset($object['pid'])) { $pid = $object['pid']; @@ -1789,14 +1796,27 @@ function fedora_repository_solution_pack_form($form, &$form_state, $solution_pac $object['update'] = TRUE; } } - $row .= "$icon"; - $row .= "Object: $pid" . t('Installed') . ""; - $row .= ""; - $output .= $row; + $form['solution_pack']['objects'][$object['pid']] = array( + '#title' => $object['pid'], + '#value' => $object['pid'], + '#type' => 'item', + ); + } } + return $form; } +/** + * Content model, collection view and collection policy datastreams may now optionally define a version + * number in their top-level XML element as an attribute, as in: + * Date: Fri, 4 Mar 2011 14:30:08 -0400 Subject: [PATCH 6/7] ISLANDORA-214 Collapse fieldsets. --- fedora_repository.module | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/fedora_repository.module b/fedora_repository.module index 21353a35..62fe09db 100644 --- a/fedora_repository.module +++ b/fedora_repository.module @@ -1768,15 +1768,17 @@ function fedora_repository_solution_pack_form($form, $solution_pack_name, $objec $form = array(); $form['solution_pack'] = array( '#type' => 'fieldset', - '#title' => "Objects", - // '#tree' => TRUE, - '#collapsed' => TRUE, - '#collapsible' => TRUE, + '#title' => $solution_pack_name, ); $needs_update = FALSE; $needs_install = FALSE; $form['solution_pack']['objects'] = array( - + '#type' => 'fieldset', + '#title' => "Objects", + // '#tree' => TRUE, + '#attributes' => array('class' => 'collapsed'), + '#collapsible' => TRUE, + '#collapsed' => TRUE, ); foreach($objects as $object) { if (isset($object['pid'])) { From 30ef025c979f175396de7fb9cd1c83e0401f160a Mon Sep 17 00:00:00 2001 From: Alexander O'Neill Date: Wed, 9 Mar 2011 16:41:40 -0400 Subject: [PATCH 7/7] Add update and install buttons to solution packs page. --- fedora_repository.module | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/fedora_repository.module b/fedora_repository.module index 62fe09db..8819537c 100644 --- a/fedora_repository.module +++ b/fedora_repository.module @@ -1776,6 +1776,7 @@ function fedora_repository_solution_pack_form($form, $solution_pack_name, $objec '#type' => 'fieldset', '#title' => "Objects", // '#tree' => TRUE, + '#weight' => 10, '#attributes' => array('class' => 'collapsed'), '#collapsible' => TRUE, '#collapsed' => TRUE, @@ -1806,6 +1807,20 @@ function fedora_repository_solution_pack_form($form, $solution_pack_name, $objec } } + $form['install'] = array( + '#name' => 'install', + '#value' => t('Install'), + '#disabled' => !$needs_install, + '#type' => 'button', + '#action' => 'install', + ); + $form['update'] = array( + '#name' => 'update', + '#value' => t('Update'), + '#disabled' => !$needs_update, + '#type' => 'button', + '#action' => 'update', + ); return $form; }