how to add a new tab to object view that is a direct link to edit mods

161 views
Skip to first unread message

domagoj...@gmail.com

unread,
Apr 9, 2015, 7:27:20 AM4/9/15
to island...@googlegroups.com
hy

when i go to view an object in the repo
my.site.name/islandora/object/repo:id

there are 3 tabs : View , Document, Manage
i would like to add a 4th called Edit MODS , which would directly lead you to editing of MODS wihtout having to go thru Manage -> Datastream -> (MODS) edit

so i tried the following way
in islandora_scholar module i added the following

function islandora_scholar_menu() {
  return array(

    'islandora/object/%islandora_object/editMODS' => array(   
      'title' => t('Edit MODS'),
      'type' => MENU_LOCAL_TASK,
      'weight' => '10',
     
      'access callback' => TRUE,
      'access arguments' => TRUE,

      'page callback' => 'islandora_edit_datastream',
      'page arguments' => array(2),

      'file' => '/includes/datastream.inc',
 
      'load arguments' => array(2),
    ),

 )
}

now that creates the link but when i click on it i get the following error : Recoverable fatal error: Argument 1 passed to islandora_edit_datastream() must be an instance of AbstractDatastream, instance of IslandoraFedoraObject given in islandora_edit_datastream() (line 296 of /data/www/drupal/sites/karaka4.srce.hr/modules/islandora_scholar/includes/datastream.inc).

i got this idea from islandora.module

  $items['islandora/object/%islandora_object/datastream/%islandora_datastream/edit'] = array(
    'title' => 'Edit datastream',
    'page callback' => 'islandora_edit_datastream',
    'page arguments' => array(4),
    'type' => MENU_CALLBACK,
    'file' => 'includes/datastream.inc',
    'access callback' => 'islandora_datastream_access',
    'access arguments' => array(ISLANDORA_METADATA_EDIT, 4),
    'load arguments' => array(2),
  );

it is the code responsible for Manage -> Datastream -> (MODS) edit 
or via link my.site.name/islandora/object/repo:id/datastream/MODS/edit which actually redirects to my.site.name/islandora/edit_form/repo:id/MODS

but i cant get it to work, i dont know how to pass it abstract object instead of fedora object, am i doing something wrong with page argument and load arguments

any advice or help appreciated

Jordan Dukart

unread,
Apr 9, 2015, 7:53:27 AM4/9/15
to island...@googlegroups.com
The islandora_edit_datastream function (https://github.com/Islandora/islandora/blob/7.x/includes/datastream.inc#L296) expects an AbstractDatastream to be passed to it. In your defined menu entry you are passing the AbstractObject to it. Your menu path should look like 'islandora/object/%islandora_object/whateverelseyouareplanningtohave/somethingelse/%islandora_datastream'. You need to pass the argument where the %islandora_datastream is at as the string gets autoloaded to represent the datastream on the current object you are on.

Jordan
--
You received this message because you are subscribed to the Google Groups "islandora-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to islandora-de...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

domagoj...@gmail.com

unread,
Apr 9, 2015, 9:20:05 AM4/9/15
to island...@googlegroups.com
i tried putting /islandora/object/%islandora_object/datastream/%islandora_datastream/edit - then the link disappeared and also messed up the one at manage-datastreams(mods)-edit

i tried your recommendation islandora/object/%islandora_object/whateverelseyouareplanningtohave/somethingelse/%islandora_datastream and it did not work
i thought it was missing islandora/object/%islandora_object/whateverelseyouareplanningtohave/somethingelse/datastream/%islandora_datastream

in both cases i got the errors:
Missing argument 2 for islandora_datastream_load()
Undefined variable: object_id in islandora_datastream_load()

then i tried
'load arguments' => array(2)
and the link disappeared again

i looked at the documentation
function islandora_datastream_load($datastream_id, $object_id)

tried islandora/object/%islandora_object/whateverelseyouareplanningtohave/somethingelse/datastream/MODS
with
'page arguments' => array(5),
'load arguments' => array(2),

and again i get passed fedora object instead of abstract object

i dont understand what whateverelseyouareplanningtohave/somethingelse should mean i just need a path that will work, and how to correctly pass arguments to islandora_edit-datastream and before that wildcards in path to islandora_datastream_load via the page arguments and load arguments

Diego Pino

unread,
Apr 9, 2015, 3:18:15 PM4/9/15
to island...@googlegroups.com
Hi,

Islandora already defines a menu callback for your functionality that does all checks for you, loads the object, the datastream, even checks if you have access to editing.

$items['islandora/object/%islandora_object/datastream/%islandora_datastream/edit']

But you wan't/need is to make a direct access to 'islandora/object/%islandora_object/datastream/MODS/edit' using a tab, not redefining all.

So a way of doing this is you make a direct call to the existing menu_callback with some checks of course…lets re-use your first try

$items[ 'islandora/object/%islandora_object/editMODS'] = array(    
     
'title' => t('Edit MODS'),

     
'type' => MENU_LOCAL_TASK,
     
'weight' => '10',

     
'access callback' => yourmodule_islandora_mods_datastream_access, // you need a way of discriminating if you can or not show this tab. Because you don't have datastream argument that can be loaded by drupal via islandora_datastream_load directly, you need a wrapper function around islandora_datastream_access, in other terms a function that calls islandora_datastream_access with the full arguments you don't have here...
     
'access arguments' => array(ISLANDORA_METADATA_EDIT, 2)// , you pass this as argument, as said before, you pass this time the whole object because you don't have the datastream. Inside the wrapper function you check if that object has a MODS datastream, if 'yes' get that datastream and call islandora_datastream_access with that object plus ISLANDORA_METADATA_EDIT returning the same islandora_datastream_access returns. If the object does not have a MODS datastream, return FALSE without calling islandora_datastream_access.
     
'page callback' => ' yourmodule_islandora_mods_datastream_edittab', //This is also a wrapper function, you don't have the MODS datastream, so you call your own function with the object as argument. (keep reading!)
     
'page arguments' => array(2),

     
'load arguments' => array(2),
   
),

}
function yourmodule_islandora_mods_datastream_edittab(abstractObject $object) {

  // So here we are. There are multiple ways of doing this. But a simple way is just to use a drupal_goto() that "redirects" to the actual menu_callback from islandora.
//basicly  get your object->id and build and url. Just make sure you add some checks, etc, or relay only on what function islandora_edit_datastream gives as result when called if you wan't so.
drupal_goto
("islandora/object/{$object->id}/datastream/MODS/edit");
//You can also add a fragment to drupal_goto() to open the redirection as an overlay as an additional $options array.
}

Thats all, double check the code please, i did not have the time to see if it's well formed, but you got the idea.

Best

Diego

domagoj...@gmail.com

unread,
Apr 10, 2015, 5:50:33 AM4/10/15
to island...@googlegroups.com
thank you, that was up to the point and explained what was confusing me

the final solution looks like this

    'islandora/object/%islandora_object/editMODS' => array(    
     
'title' => t('Edit MODS'),
     
'type' => MENU_LOCAL_TASK,
     
'weight' => '10',

     
     
'access callback' =>  'fcija_editMODStab_check',
     
'access arguments' => array(ISLANDORA_METADATA_EDIT,2),

     
'page callback' => 'fcija_editMODStab',
     
'page arguments' => array(2),
   
),

   
function fcija_editMODStab(abstractObject $object){            
        drupal_goto
("islandora/object/{$object->id}/datastream/MODS/edit");
   
}

   
function fcija_editMODStab_check($permission, abstractObject $object){            
       
if(isset($object['MODS'])) return islandora_datastream_access($permission, $object['MODS']);  
       
else return false;
   
}

domagoj...@gmail.com

unread,
Apr 10, 2015, 5:50:49 AM4/10/15
to island...@googlegroups.com
thank you, that was up to the point and explained what was confusing me

the final solution looks like this

    'islandora/object/%islandora_object/editMODS' => array(    
     
'title' => t('Edit MODS'),
     
'type' => MENU_LOCAL_TASK,
     
'weight' => '10',

     
     
'access callback' =>  'fcija_editMODStab_check',
     
'access arguments' => array(ISLANDORA_METADATA_EDIT,2),

     
'page callback' => 'fcija_editMODStab',
     
'page arguments' => array(2),
   
),

   
function fcija_editMODStab(abstractObject $object){            
        drupal_goto
("islandora/object/{$object->id}/datastream/MODS/edit");
   
}

   
function fcija_editMODStab_check($permission, abstractObject $object){            
       
if(isset($object['MODS'])) return islandora_datastream_access($permission, $object['MODS']);  
       
else return false;
   
}



On Thursday, April 9, 2015 at 9:18:15 PM UTC+2, Diego Pino wrote:

Diego Pino

unread,
Apr 10, 2015, 10:31:09 AM4/10/15
to island...@googlegroups.com
Nice! 

Rosemary Le Faive

unread,
Apr 10, 2015, 3:31:32 PM4/10/15
to island...@googlegroups.com
I've had to do this in several of my sites - it's very hard to explain to users how to go to Manage -> Datastreams -> sort through the table to MODS and follow it to the 'edit' link on the far right. 

I'm hesitant to suggest an improvement on core because frequent metadata edits aren't really the point of a repository software like Islandora... but would there be an interest in a "UI Solution Pack" where you can enable this (and perhaps other sneaky features?) 

-Rosie

Diego Pino

unread,
Apr 10, 2015, 4:45:19 PM4/10/15
to island...@googlegroups.com
Hi Rosie,

I fully agree with you on this. As many others, we are transferring to our users the responsibility of management of their own objects, and the Management interface (even when themed) adds UI complexity. I also agree on not adding extra complexity to the already existing core functionality, for admins it's ok most of the time, but in our case User's are constantly modifying metadata (or better said refining) so helping in common task is a need. +1 for a UI Solution pack, i was making some related in-house dev's for my repos, a simple task bar with icons and drop downs(block), that looks more like the one present in github, mostly taking some basic admin functionality to the main object view, but a full UI Solution pack is a great idea.

Best

Diego

Elizabeth McAulay

unread,
Apr 11, 2015, 3:45:08 PM4/11/15
to island...@googlegroups.com
I am a big fan of Rosemary's advice, so I would tend to agree with her experience. That said, I would say that we view our repository pretty differently here at UCLA, so perhaps worth discussing either here or part of the Islandora Metadata Interest Group.

We often load our content into the repository and do metadata afterward. And then we do quality control afterward. So, frequent metadata editing is part of our workflow. We have not adopted that workflow in Islandora because it isn't really optimized for that approach. So we're trying to come up with workarounds. One consideration is using a cataloging tool (OCLC tools) to create metadata and then export MODS that are then batch loaded to Islandora. We still anticipate needing to edit the metadata after the first creation.

Food for discussion!

Best,
Lisa

-----------------------------------
Elizabeth "Lisa" McAulay
Librarian for Digital Collection Development
UCLA Digital Library Program

Don Moses

unread,
Apr 12, 2015, 7:20:09 AM4/12/15
to island...@googlegroups.com
+1 for a UI Solution Pack


Will Panting

unread,
Apr 12, 2015, 12:44:22 PM4/12/15
to island...@googlegroups.com
Hi,

I imagine most changes that the community could agree on could be added to core as permissionable UI elements to eliminate the backwards compatibility and complexity issues.
As a side note calling this sort of thing a Solution Pack will be a misnomer.

William Panting

On Sun, Apr 12, 2015 at 8:20 AM, Don Moses <dmo...@upei.ca> wrote:
+1 for a UI Solution Pack


Giancarlo Birello

unread,
Apr 13, 2015, 7:37:52 AM4/13/15
to island...@googlegroups.com
+1 UI
+1 Rosie (I learn Rosie ideas are very interesting from my experience with relationships module forked from Rosie module)

Would be "magic" a switch from Admin Interface to User Interface, that is we need something in the Islandora core.
Another possibility could be AI/UI assigned by user role.

At the present we need modify metadata after ingesting so would be great one instance of Islandora for admin and one instance for users with different interfaces.

UI would be more secure without standard admin settings as fedora URL, djatoka, solution packs, etc.

Giancarlo

Diego Pino

unread,
Apr 13, 2015, 9:25:46 AM4/13/15
to island...@googlegroups.com
+1 to all ideas. Thanks Rosie for bringing this to open discussion. I still like the idea of a "Solution Pack", because this could allow to add an API so other developers could hook into this UI. Also for our particular daily workflow, there are still some open needs that the current Management Interface does not fulfil(maybe out of scope here) that could be handled as plugins that execute programmed task for a given PID list. Some examples:
- Sharing and other batch tasks depend on a paged list, so if i need to decide what to share based on a given criteria i have to "remember" which objects did match that criteria from a previous solr search.
- Copy metadata tool: We have sometimes the need to copy or merge metadata and other datastreams from one object to another. 
- Analize/fix broken RELS-EXT and orphan relations
- Compare two Objects (side-by-side)

Obviously our requirements are not necessarily common to the whole community, so implementing a bookable interface is a nice way of allowing developers to add their own functionality

Rosie, if you need some help i can give this idea some hours of coding (under your guidance) 

Have a nice week

Diego

Melissa Anez

unread,
Apr 20, 2015, 11:20:47 AM4/20/15
to island...@googlegroups.com
Regarding the idea of a UI solution for Islandora, this topic came up in last Friday's Roadmap Committee meeting [1], and we wanted to propose the formation of a temporary Islandora Interest Group [2] to dig into Islandora's UI in general. We see this as something that does not necessarily need an ongoing discussion like the other IGs, but which could really benefit from a group of interested UI folks getting together to make some recommendations. 

Does anyone want to step up as a convenor for a temporary Islandora User Experience Interest Group? I would be happy to help with the details.

Thanks,

Dave Bretthauer

unread,
Apr 20, 2015, 11:48:25 AM4/20/15
to island...@googlegroups.com

Hi Melissa,

 

I would be very interested in participating in this Interest Group; at the moment though I am not sure can serve as convener.

 

Unless the definition of "temporary" is very flexible, though, I respectfully cannot say with any certainty that discussion of user interface issues is a temporary issue. The UI for curators and administrators represents far more than a typical website with simple conversion goals; rather it is a rich web application which probably could be compared with an Oracle- or SAP-based application (this is my assumption; if anyone has worked on such applications, please let me know if you think I'm wrong). The UI already suffers from inconsistencies which we at UConn have spent some time documenting and training around--and I've spent a lot of time scratching my head for ways to improve its consistency and clarity, particularly for occasional and volunteer users. As Content Types are added and metadata needs expand, the richness and complexity of this application seems likely to do so as well.


But I am very happy to see this discussion and would like to do what I can to help. :)


Dave

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Dave Bretthauer

Librarian

Content Presentation/User Experience

University Archives, Digital Scholarship and Data Curation

University of Connecticut Libraries

369 Fairfield Way U-1005M

Storrs, CT 06269-1005

Voice (860) 486-6494

Fax: (860) 486-6100



--

Melissa Anez

unread,
Apr 20, 2015, 11:55:15 AM4/20/15
to island...@googlegroups.com
Dave,

You make an excellent point about just how "temporary" this may be. I proposed it as such to lower the bar to entry because I know time commitments are tough all around, and the immediate concern is to get at least one good round of feedback about where the pain points are in the current UI. We can certainly look at it as a longer term conversation - I just don't want to scare anyone off if they don't have the time to become part of an ongoing user group, but could participate in a focussed discussion for a few weeks or months.

All matters that can be discussed and decided by the group when it convenes, I suppose :)

- Melissa

To unsubscribe from this group and stop receiving emails from it, send an email to islandora-dev+unsubscribe@googlegroups.com.

Dave Bretthauer

unread,
Apr 20, 2015, 12:23:12 PM4/20/15
to island...@googlegroups.com
Hi Melissa,

Point well taken, and thank you for explaining that. 

The thing that's scaring me is my availability over the next eight weeks! I would rather see this work get started sooner than ask anyone to wait for me.

Dave

To unsubscribe from this group and stop receiving emails from it, send an email to islandora-de...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "islandora-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to islandora-de...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages