Browse Source

Generate the download form.

...  As opposed to spitting out markup for it directly.
pull/126/head
Adam Vessey 13 years ago
parent
commit
948bba9827
  1. 20
      ObjectHelper.inc
  2. 36
      fedora_repository.module
  3. 2
      plugins/tagging_form.inc

20
ObjectHelper.inc

@ -358,7 +358,7 @@ class ObjectHelper {
$content = ''; $content = '';
$id = $dataStreamValue->ID; $id = $dataStreamValue->ID;
$label = $dataStreamValue->label; $label = $dataStreamValue->label;
$label = str_replace("_", " ", $label); //$label = str_replace("_", " ", $label);
$label_deslashed = preg_replace('/\//i', '${1}_', $label); // Necessary to handle the case of Datastream labels that contain slashes. Ugh. $label_deslashed = preg_replace('/\//i', '${1}_', $label); // Necessary to handle the case of Datastream labels that contain slashes. Ugh.
$mimeType = $dataStreamValue->MIMEType; $mimeType = $dataStreamValue->MIMEType;
@ -367,20 +367,8 @@ class ObjectHelper {
'target' => '_blank', 'target' => '_blank',
), ),
)); ));
$action = url("fedora/repository/object_download/$pid/$id/$label_deslashed");
$downloadVersion = '<form method="GET" action="' . $action . '"><input type="submit" value="' . t('Download') . '"></form>'; $downloadVersion = drupal_get_form('fedora_repository_download_datastream_form', $pid, $id, $label_deslashed);
if (user_access(ObjectHelper::$EDIT_FEDORA_METADATA)) {
$versions = $item->get_datastream_history($id);
if (is_array($versions)) {
$downloadVersion = '<form method="GET" action="' . $action . '" onsubmit="this.action=\'' . $action . '\' + \'/\'+this.version.value;">';
$downloadVersion .= '<input type="submit" value="' . t('Download') . '">';
$downloadVersion .= '<select name="version">';
foreach ($versions as $version) {
$downloadVersion .= '<option>' . $version->createDate . '</option>';
}
$downloadVersion .= '</select></form>';
}
}
return array( return array(
array( array(
@ -1026,7 +1014,7 @@ EOQ;
$next_pid = $parent; $next_pid = $parent;
} }
else { else {
watchdog('fedora_repository', 'Error generating breadcrumbs for %pid. Verify there exists relationships back up to %root. (May also be due to a hierarchy deeper than %max_depth).', array('%pid' => $pid, '%root' => $root, '%max_depth' => $max_depth), WATCHDOG_WARNING); watchdog('fedora_repository', 'Error generating breadcrumbs for %pid. Verify there exists relationships back up to %root. (May also be due to a hierarchy deeper than %max_depth).', array('%pid' => $pid, '%root' => $root, '%max_depth' => $max_level), WATCHDOG_WARNING);
$breadcrumbs[] = '...'; //Add an non-link, as we don't know how to get back to the root. $breadcrumbs[] = '...'; //Add an non-link, as we don't know how to get back to the root.
$next_pid = $root; //And cue the last two links to render and break recursion (on the next pass). $next_pid = $root; //And cue the last two links to render and break recursion (on the next pass).
} }

36
fedora_repository.module

@ -623,6 +623,42 @@ function fedora_repository_purge_stream_form_submit($form, &$form_state) {
$form_state['redirect'] = $base_url . "/fedora/repository/$pid"; $form_state['redirect'] = $base_url . "/fedora/repository/$pid";
} }
function fedora_repository_download_datastream_form(&$form_state, $pid, $dsid, $label) {
$form = array(
'#action' => url("fedora/repository/object_download/$pid/$dsid/$label"),
'submit' => array(
'#type' => 'submit',
'#value' => t('Download'),
),
);
if (user_access(ObjectHelper::$EDIT_FEDORA_METADATA)) {
$item = new Fedora_Item($pid);
$versions = $item->get_datastream_history($dsid);
$version_array = array();
if (is_array($versions)) {
foreach ($versions as $version) {
$version_array[] = $version->createDate;
}
}
else {
$version_array[] = $versions->createDate;
}
if (count($version_array) > 1) {
$form['#attributes'] = array(
'onsubmit' => 'this.action="' . $form['#action'] . '/" + this.version.value;'
);
$form['version'] = array(
'#type' => 'select',
'#options' => array_combine($version_array, $version_array),
);
}
}
return $form;
}
/** /**
* fedora repository replace stream * fedora repository replace stream
* @param type $pid * @param type $pid

2
plugins/tagging_form.inc

@ -70,7 +70,7 @@ function fedora_repository_image_tagging_form($form_state, $pid) {
$tag_title_text = t('Added by @creator.', array( $tag_title_text = t('Added by @creator.', array(
'@creator' => $tag['creator'], '@creator' => $tag['creator'],
)); ));
$tag_mnpl_search_path = "fedora/repository/mnpl_advanced_search/tag:{$tag['name']}" $tag_mnpl_search_path = "fedora/repository/mnpl_advanced_search/tag:{$tag['name']}";
$form_tag['tag'] = array( $form_tag['tag'] = array(
'#value' => l($tag['name'], $tag_mnpl_search_path, array('attributes' => array( '#value' => l($tag['name'], $tag_mnpl_search_path, array('attributes' => array(
'title' => $tag_title_text 'title' => $tag_title_text

Loading…
Cancel
Save