Browse Source

Autocomplete

pull/120/head
jonathangreen 13 years ago
parent
commit
b48aef3162
  1. 15
      includes/datastream.inc
  2. 17
      islandora.module

15
includes/datastream.inc

@ -339,6 +339,7 @@ function islandora_add_datastream_form($form, &$form_state, $object_id) {
'#value' => t('Add Datastream') '#value' => t('Add Datastream')
); );
/*
if (!empty($unused_dsids)) { if (!empty($unused_dsids)) {
$dsidsForForm = array(); $dsidsForForm = array();
foreach ($unused_dsids as $key => $value) { foreach ($unused_dsids as $key => $value) {
@ -354,17 +355,29 @@ function islandora_add_datastream_form($form, &$form_state, $object_id) {
$form['add_fieldset']['stream_id']['#options'] = $dsidsForForm; $form['add_fieldset']['stream_id']['#options'] = $dsidsForForm;
} }
else { else {
*
*/
$form['add_fieldset']['stream_id'] = array( $form['add_fieldset']['stream_id'] = array(
'#title' => 'Datastream ID', '#title' => 'Datastream ID',
'#required' => 'TRUE', '#required' => 'TRUE',
'#description' => t('An ID for this stream that is unique to this object. Must start with a letter and contain only alphanumeric characters and dashes and underscores.'), '#description' => t('An ID for this stream that is unique to this object. Must start with a letter and contain only alphanumeric characters and dashes and underscores.'),
'#type' => 'textfield', '#type' => 'textfield',
'#weight' => -1, '#weight' => -1,
'#autocomplete_path' => "islandora/object/$object_id/manage/datastreams/add/autocomplete",
); );
} //}
return $form; return $form;
} }
function islandora_datastream_autocomplete_callback($object_id) {
$dsids = islandora_get_unused_dsids($object_id);
$output = array();
foreach($dsids as $id => $ds) {
$output[$id] = $id;
}
drupal_json_output($output);
}
function islandora_datastream_get_human_readable_size($ds) { function islandora_datastream_get_human_readable_size($ds) {
module_load_include('inc', 'islandora', 'includes/utilities'); module_load_include('inc', 'islandora', 'includes/utilities');

17
islandora.module

@ -170,16 +170,13 @@ function islandora_menu() {
'access arguments' => array(FEDORA_ADD_DS) 'access arguments' => array(FEDORA_ADD_DS)
); );
$items['islandora/object/%/manage/datastreams/add/autocomplete'] = array(
// $items['islandora/object/%/add'] = array( 'file' => 'includes/datastream.inc',
// 'title' => 'Add to an object', 'page callback' => 'islandora_datastream_autocomplete_callback',
// 'file' => 'includes/datastream.inc', 'page arguments' => array(2),
// 'page callback' => 'drupal_get_form', 'type' => MENU_CALLBACK,
// 'page arguments' => array('islandora_add_datastream_form',2), 'access arguments' => array(FEDORA_ADD_DS)
// 'type' => MENU_NORMAL_ITEM, );
// 'access arguments' => array(FEDORA_ADD_DS)
// );
$items['islandora/object/%/datastream/%'] = array( $items['islandora/object/%/datastream/%'] = array(
'title' => 'View datastream', 'title' => 'View datastream',

Loading…
Cancel
Save