Browse Source

Make solution pack form submit module name.

pull/105/head
Alexander O'Neill 14 years ago
parent
commit
16e7383960
  1. 1
      api/fedora_utils.inc
  2. 62
      fedora_repository.module
  3. 60
      plugins/islandora_newspaper/islandora_newspaper.module

1
api/fedora_utils.inc

@ -70,6 +70,7 @@ function fedora_available() {
return strstr($response, 'Repository Information HTML Presentation') !== FALSE; return strstr($response, 'Repository Information HTML Presentation') !== FALSE;
} }
/** /**
* Returns a UTF-8-encoded transcripiton of the string given in $in_str. * Returns a UTF-8-encoded transcripiton of the string given in $in_str.
* @param string $in_str * @param string $in_str

62
fedora_repository.module

@ -1759,9 +1759,21 @@ function fedora_repository_display_schema($file) {
function fedora_repository_solution_packs_page() { function fedora_repository_solution_packs_page() {
$enabled_solution_packs = module_invoke_all('required_fedora_objects'); $enabled_solution_packs = module_invoke_all('required_fedora_objects');
$output = ''; $output = '';
foreach ($enabled_solution_packs as $solution_pack_name => $objects) { foreach ($enabled_solution_packs as $solution_pack_module => $solution_pack_info) {
$output .= drupal_get_form('fedora_repository_solution_pack_form', $solution_pack_name, $objects); $objects = array();
foreach ($solution_pack_info as $field => $value) {
switch ($field) {
case 'title':
$solution_pack_name = $value;
break;
case 'objects':
$objects = $value;
break;
}
}
$output .= drupal_get_form('fedora_repository_solution_pack_form', $solution_pack_module, $solution_pack_name, $objects);
} }
return $output; return $output;
} }
@ -1769,7 +1781,7 @@ function fedora_repository_solution_packs_page() {
* Check for installed objects and add a 'Update' or 'Install' button if some objects are missing. * Check for installed objects and add a 'Update' or 'Install' button if some objects are missing.
* @param array $solution_pack * @param array $solution_pack
*/ */
function fedora_repository_solution_pack_form($form, $solution_pack_name, $objects = array()) { function fedora_repository_solution_pack_form($form, $solution_pack_module, $solution_pack_name, $objects = array()) {
// Check each object to see if it is in the repository. // Check each object to see if it is in the repository.
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$form = array(); $form = array();
@ -1779,23 +1791,32 @@ function fedora_repository_solution_pack_form($form, $solution_pack_name, $objec
); );
$needs_update = FALSE; $needs_update = FALSE;
$needs_install = FALSE; $needs_install = FALSE;
$form['solution_pack_module'] = array(
'#type' => 'hidden',
'#value' => $solution_pack_module,
);
$form['solution_pack']['objects'] = array( $form['solution_pack']['objects'] = array(
'#type' => 'fieldset', '#type' => 'fieldset',
'#title' => "Objects", '#title' => "Objects",
// '#tree' => TRUE,
'#weight' => 10, '#weight' => 10,
'#attributes' => array('class' => 'collapsed'), '#attributes' => array('class' => 'collapsed'),
'#collapsible' => TRUE, '#collapsible' => TRUE,
'#collapsed' => TRUE, '#collapsed' => TRUE,
); );
$table_header = array('PID', 'Status');
$table_rows = array();
foreach($objects as $object) { foreach($objects as $object) {
if (isset($object['pid'])) { if (isset($object['pid'])) {
$pid = $object['pid']; $pid = $object['pid'];
$item = new Fedora_Item($pid); $item = new Fedora_Item($pid);
$table_row = array($object['pid']);
$object_status = t('Up-to-date');
if (!$item->exists()) { if (!$item->exists()) {
$object_status = 'Missing';
$needs_install = TRUE; $needs_install = TRUE;
$object['install'] = TRUE;
} }
elseif (isset($object['dsid']) && isset($object['datastream_file']) && isset($object['dsversion'])) { elseif (isset($object['dsid']) && isset($object['datastream_file']) && isset($object['dsversion'])) {
// Check if the datastream is versioned and needs updating. // Check if the datastream is versioned and needs updating.
@ -1803,34 +1824,35 @@ function fedora_repository_solution_pack_form($form, $solution_pack_name, $objec
$available_version = fedora_repository_get_islandora_datastream_version(NULL, NULL, $object['datastream_file']); $available_version = fedora_repository_get_islandora_datastream_version(NULL, NULL, $object['datastream_file']);
if ($available_version > $installed_version) { if ($available_version > $installed_version) {
$needs_update = TRUE; $needs_update = TRUE;
$object['update'] = TRUE; $object_status = 'Out of date';
} }
} }
$form['solution_pack']['objects'][$object['pid']] = array( array_push($table_row, $object_status);
'#title' => $object['pid'],
'#value' => $object['pid'], $table_rows[] = $table_row;
'#type' => 'item',
);
} }
} }
$form['solution_pack']['objects']['table'] = array(
'#type' => 'markup',
'#value' => theme_table($table_header, $table_rows),
);
$form['install'] = array( $form['install'] = array(
'#name' => 'install', '#name' => 'install',
'#value' => t('Install'), '#value' => t('Install'),
'#disabled' => !$needs_install, '#disabled' => !$needs_install,
'#type' => 'button', '#type' => 'submit',
'#action' => 'install', '#action' => 'install',
); );
$form['update'] = array(
'#name' => 'update',
'#value' => t('Update'),
'#disabled' => !$needs_update,
'#type' => 'button',
'#action' => 'update',
);
return $form; return $form;
} }
function fedora_repository_solution_pack_form_submit($form, &$form_state) {
$what = $form_state;
}
/** /**
* Content model, collection view and collection policy datastreams may now optionally define a version * 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: * number in their top-level XML element as an attribute, as in:

60
plugins/islandora_newspaper/islandora_newspaper.module

@ -7,34 +7,38 @@ function islandora_newspaper_required_fedora_objects() {
// array( 'path-to-foxml-file', 'pid', 'dsid', 'path-to-datastream-file', int dsversion, boolean required) // array( 'path-to-foxml-file', 'pid', 'dsid', 'path-to-datastream-file', int dsversion, boolean required)
$module_path = drupal_get_path('module', 'islandora_newspaper'); $module_path = drupal_get_path('module', 'islandora_newspaper');
return array( return array(
'Islandora Newspapers' => array( 'islandora_newspaper' => array(
array( 'module' => 'islandora_newspaper',
'foxml_file' => "$module_path/newspapers_issueCModel.xml", 'title' => 'Islandora Newspaper',
'pid' => 'newspapers:issueCModel', 'objects' => array(
'dsid' => NULL, array(
'datastream_file' => NULL, 'foxml_file' => "$module_path/newspapers_issueCModel.xml",
'dsversion' => NULL, 'pid' => 'newspapers:issueCModel',
), 'dsid' => NULL,
array( 'datastream_file' => NULL,
'foxml_file' => "$module_path/newspapers_pageCModel.xml", 'dsversion' => NULL,
'pid' => 'newspapers:pageCModel', ),
'dsid' => NULL, array(
'datastream_file' => NULL, 'foxml_file' => "$module_path/newspapers_pageCModel.xml",
'dsversion' => NULL, 'pid' => 'newspapers:pageCModel',
), 'dsid' => NULL,
array( 'datastream_file' => NULL,
'foxml_file' => "$module_path/newspapers_viewerSdep-issueCModel.xml", 'dsversion' => NULL,
'pid' => 'newspapers:viewerSdep-issueCModel', ),
'dsid' => NULL, array(
'datastream_file' => NULL, 'foxml_file' => "$module_path/newspapers_viewerSdep-issueCModel.xml",
'dsversion' => NULL, 'pid' => 'newspapers:viewerSdep-issueCModel',
), 'dsid' => NULL,
array( 'datastream_file' => NULL,
'foxml_file' => "$module_path/newspapers_viewerSdep-pageCModel.xml", 'dsversion' => NULL,
'pid' => 'newspapers:viewerSdep-pageCModel', ),
'dsid' => NULL, array(
'datastream_file' => NULL, 'foxml_file' => "$module_path/newspapers_viewerSdep-pageCModel.xml",
'dsversion' => NULL, 'pid' => 'newspapers:viewerSdep-pageCModel',
'dsid' => NULL,
'datastream_file' => NULL,
'dsversion' => NULL,
),
), ),
), ),
); );

Loading…
Cancel
Save