Hi guys,
we're using Omeka for a interdisciplinary university project. At some point we realized that simple relations between two items were not expressive enough, so I added a tiny edit field to annotate any relation that you create – for example a page number for a literature reference, a year number for a birthplace reference, … you name it, it's pretty handy.
The item relationship comment enhancement is quite straightforward, it pretty much just adds an additional field to the {prefix}_item_relations_relations table that can be filled through an additional edit field when adding a new relationship. … If you're really, really interested in that, I could point you to my respective GitHub repository to get it.
- - - - -
But here comes the problem:
Besides the possibility of adding these comments, those are obviously text fields that should be searchable. At the moment, I'm trying to think about at least improving hookAdminItemsSearch() to add a text field to the relationship search for comment searching.
However: Wouldn't it be much better to tie this search into the regular full text search (FTS)?
1st approach: I understand that the FTS utilizes the {prefix}_search_texts table that is being filled upon saving an item. Item Relations indeed has an hookAfterSaveItem($args) – but I can't figure out how to add my own addSearchText() to enhance the item's full text inside the "Save item relations" branch.
If this was indeed possible – could someone please hint me how to retrieve the respective item object that would let me use addSearchText() at this point?
… However: To my understanding (and experiments), this wouldn't actually suffice. The "Save item relations" branch of hookAfterSaveItem() is executed only for newly created relations that are still inside $args['post']. Meaning: When re-editing an item (which definitely results into re-generating its search texts), the existing relations are no longer processed – essentially meaning that their comment fields wouldn't find their way into the search text again. Duh ...
2nd approach: As described inside the "Best Practices for Plugin Development" guide, I was thinking about giving Item Relations a Mixin_Search().
However, Item Relations is not an Omeka_Record_AbstractRecord record, it's an Omeka_Plugin_AbstractPlugin plugin – so if I'm not totally mistaken, I can't actually do this. Is that correct?
3rd approach: Could I create yet another plugin that could enhance after_save_item with its own hookAfterSaveItem($args) even more? My idea would be that this would be called
- after the item is saved,
- after the item relations have been created or deleted,
- to be able to gather which items relations are actually in place now, to concatenate the item's relation comments to the item's search text in search_texts.
- - - - -
Some ideas? Any idea? ;-) I'd be really happy for any insight or at least suggestion where to look further.