From 5110efd0867284736a091da2699e6ffed2bc619e Mon Sep 17 00:00:00 2001 From: krisbulman Date: Tue, 29 May 2012 09:06:30 -0300 Subject: [PATCH] moved add datastream link to action item --- includes/datastream.inc | 4 ++-- islandora.module | 53 +++++++++++++++++++++++++++++++---------- 2 files changed, 43 insertions(+), 14 deletions(-) diff --git a/includes/datastream.inc b/includes/datastream.inc index 2c7e58b2..197d5e2b 100644 --- a/includes/datastream.inc +++ b/includes/datastream.inc @@ -280,8 +280,8 @@ function islandora_add_datastream_form($form, &$form_state, $object_id) { $form['add_fieldset'] = array( '#type' => 'fieldset', '#title' => 'Add a datastream', - '#collapsible' => TRUE, - '#collapsed' => TRUE, + '#collapsible' => FALSE, + '#collapsed' => FALSE, ); $form['add_fieldset']['add_datastream_label'] = array( '#value' => t('

Add Datastream:

'), diff --git a/islandora.module b/islandora.module index 521101bc..99b3ff7b 100644 --- a/islandora.module +++ b/islandora.module @@ -108,16 +108,7 @@ function islandora_menu() { 'access arguments' => array(FEDORA_VIEW), ); - - $items['islandora/object/%/add'] = array( - 'title' => 'Add to an object', - 'file' => 'includes/datastream.inc', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('islandora_add_datastream_form',2), - 'type' => MENU_NORMAL_ITEM, - 'access arguments' => array(FEDORA_ADD_DS) - ); - + $items['islandora/object/%/view'] = array( 'title' => 'View', @@ -153,6 +144,7 @@ function islandora_menu() { 'weight' => -10, ); + $items['islandora/object/%/manage/properties'] = array( 'title' => 'Properties', 'page callback' => 'drupal_get_form', @@ -163,7 +155,6 @@ function islandora_menu() { 'weight' => -5, ); - $items['islandora/object/%/delete'] = array( 'title' => 'Purge object', 'page callback' => 'islandora_purge_object', @@ -172,6 +163,26 @@ function islandora_menu() { 'access arguments' => array(FEDORA_PURGE), ); + $items['islandora/object/%/manage/datastreams/add'] = array( + 'title' => 'Add a datastream', + 'file' => 'includes/datastream.inc', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('islandora_add_datastream_form', 2), + 'type' => MENU_NORMAL_ITEM, + 'access arguments' => array(FEDORA_ADD_DS) + ); + + + // $items['islandora/object/%/add'] = array( + // 'title' => 'Add to an object', + // 'file' => 'includes/datastream.inc', + // 'page callback' => 'drupal_get_form', + // 'page arguments' => array('islandora_add_datastream_form',2), + // 'type' => MENU_NORMAL_ITEM, + // 'access arguments' => array(FEDORA_ADD_DS) + // ); + + $items['islandora/object/%/datastream/%'] = array( 'title' => 'View datastream', 'page callback' => 'islandora_datastream_as_attachment', @@ -223,6 +234,24 @@ function islandora_admin_paths_alter(&$paths) { $paths['*/manage*'] = TRUE; } + +/** + * Implements hook_menu_local_tasks_alter(). + */ +function islandora_menu_local_tasks_alter(&$data, $router_item, $root_path) { + // Add action link 'islandora/object/%/manage/datastreams'. + $object_id = $router_item['page_arguments'][0]; + if ($root_path == 'islandora/object/%/manage/datastreams') { + $item = menu_get_item("islandora/object/$object_id/manage/datastreams/add"); + if ($item['access']) { + $data['actions']['output'][] = array( + '#theme' => 'menu_local_action', + '#link' => $item, + ); + } + } +} + /** * determines whether we can see the object or not * checks PID namespace permissions, and user permissions @@ -616,7 +645,7 @@ function islandora_preprocess_islandora_default_edit(&$variables) { $datastreams = array(); $variables['islandora_editmetadata_url'] = $base_url . '/islandora/edit_form/' . $islandora_object->id; module_load_include('inc','islandora','includes/datastream'); - $variables['add_datastream_form'] = drupal_get_form('islandora_add_datastream_form', $islandora_object->id); + // $variables['add_datastream_form'] = drupal_get_form('islandora_add_datastream_form', $islandora_object->id); foreach ($islandora_object as $ds) { $datastreams['download_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/download'; $datastreams['view_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/view';