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;
}
/**
* Returns a UTF-8-encoded transcripiton of the string given in $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() {
$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);
foreach ($enabled_solution_packs as $solution_pack_module => $solution_pack_info) {
$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;
}
@ -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.
* @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.
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$form = array();
@ -1779,23 +1791,32 @@ function fedora_repository_solution_pack_form($form, $solution_pack_name, $objec
);
$needs_update = FALSE;
$needs_install = FALSE;
$form['solution_pack_module'] = array(
'#type' => 'hidden',
'#value' => $solution_pack_module,
);
$form['solution_pack']['objects'] = array(
'#type' => 'fieldset',
'#title' => "Objects",
// '#tree' => TRUE,
'#weight' => 10,
'#attributes' => array('class' => 'collapsed'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$table_header = array('PID', 'Status');
$table_rows = array();
foreach($objects as $object) {
if (isset($object['pid'])) {
$pid = $object['pid'];
$item = new Fedora_Item($pid);
$table_row = array($object['pid']);
$object_status = t('Up-to-date');
if (!$item->exists()) {
$object_status = 'Missing';
$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.
@ -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']);
if ($available_version > $installed_version) {
$needs_update = TRUE;
$object['update'] = TRUE;
$object_status = 'Out of date';
}
}
$form['solution_pack']['objects'][$object['pid']] = array(
'#title' => $object['pid'],
'#value' => $object['pid'],
'#type' => 'item',
);
array_push($table_row, $object_status);
$table_rows[] = $table_row;
}
}
$form['solution_pack']['objects']['table'] = array(
'#type' => 'markup',
'#value' => theme_table($table_header, $table_rows),
);
$form['install'] = array(
'#name' => 'install',
'#value' => t('Install'),
'#disabled' => !$needs_install,
'#type' => 'button',
'#type' => 'submit',
'#action' => 'install',
);
$form['update'] = array(
'#name' => 'update',
'#value' => t('Update'),
'#disabled' => !$needs_update,
'#type' => 'button',
'#action' => 'update',
);
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
* 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)
$module_path = drupal_get_path('module', 'islandora_newspaper');
return array(
'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,
'islandora_newspaper' => array(
'module' => 'islandora_newspaper',
'title' => 'Islandora Newspaper',
'objects' => 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,
),
),
),
);

Loading…
Cancel
Save