Where to put a link to an online editor?

Hey,
I am currently working on the Fidus Writer <–> OJS integration plugin [1]. We basically create a link as part of a submission on OJS. When the user clicks the link, he is sent to the gateway part of the plugin, which reads the various the submission id and ID of the corresponding document on FW, then determines the current user’s access rights and if the user is allowed to access the document, forwards him/her to the document on Fidus Writer, loggint eh user in automatically…

This seems to work quite well, but the question is whete to put the link. We currently have it in the title field. This is OK, but it makes the UX a bit odd. For example, reviewers will see that there are no files connected to the submission, and they have to know that instead of looking at the list of files, they have to click on the link in the title field.

The question is therefore: Is there a better field of the submission where one could put such a link?

[1] https://github.com/OSCOSS/OJSIntegrationRestAPIplugin/tree/develop

1 Like

Hi @Johannes_Wilm,

UI/UX wise, is there a place you’d like to put it? If you have something in mind I can perhaps help with some suggestions on hooks etc.

Regards,
Alec Smecher
Public Knowledge Project Team

Well, kind of where the files are usually listed now. I guess that would also be better as the link would be hidden whenever the files wouldn’t be shown.

Is there any field of the submission that can be made to be displayed somewhere fairly close to where the submission files would usually be?

Alternatively, I was starting to experiment with trying to instead create a fake submitted file entry and then adding a hook to intercept ReviewerAction::​downloadReviewerFile and instead forward the user to FW from there. But I’m not sure OJS is really set up to deal with ‘fake files’ and whether it will be running into issues all the time because it cannot actually find a file on the harddrive that corresponds to its submission files. Maybe you can comment on that: Are there things in the code that will try to work with the files on disk? Or should it be possible to fool it like this as long as one has hooks in place to take care of cases where the user tries to download the file? I see there are several functions that seem to be looking at the file that is in the background, and if they are called a lot from the core code, then that will probably create too many problems if there isn’t actually anything there.

Could one alternative be to create a 0 byte sized blob (or very small) and actually let it save that to the harddisk so it actually has a file on disk and doesn’t complain that it has nothing to connect to.

Also, is there a chart of all the hooks that exist that is newer than the 2.1 technical reference [1], or is this still pretty accurate?

[1] https://pkp.gitbooks.io/ojs-2-x-technical-reference/content/en/hook_list.html

Hi @Johannes_Wilm,

That hook list is woefully outdated (as is the current Technical Reference) – current documents are more along the lines of the Doxygen reference, but that won’t help you if you’re looking for hooks.

You might have a look at how the OJS markup plugin behaves in this regard – off the top of my head, it injects new row actions into the existing file list.

Regards,
Alec Smecher
Public Knowledge Project Team

I see, I had been looking through the reference you mention and it’s good for some things, but not exactly for finding hooks. I have spent the past week or so trying to find names of hooks and functions by grep’ing through the source code, reading all the files that seem interesting in lib/pkp/classes/, Googling, this forum, the documentation you linked to, temporarily changing the ojs source code to see what is happening, looking at the database and how it changes. And still all but one of the hooks I am trying to listen to don’t seem to work for me [1] - at this moment I am guessing because the plugin is registered as a siteplugin or some such thing, but also about that it doesn’t seem like I can find much documentation.

I wonder - is there a recommended way of finding hooks and function names? I must admit my PHP is rather rusty after 10 years of Python/JS, but additionally it seems rather complicated finding all the right hook names, etc. .

Thanks for the pointer to the OJS markup plugin. I had actually read the sourcecode of that plugin, but I must have missed the part about injecting rows.

[1] Don’t work: ‘reviewassignmentdao::_insertobject’, ‘EditorAction::addReviewer’, ‘FileManager::downloadFile’, ‘reviewassignmentdao::_deletebyid’, ‘reviewrounddao::_insertobject’. Does work: ‘PluginRegistry::loadCategory’

Hi @Johannes_Wilm,

We badly need to address the lack of documentation on certain aspects of OJS 3.x but we’re wary of doing what we’ve done before, which is to write a whack of documentation and fail to maintain it. I’d like to drastically reduce the number of hooks and improve their utility, and then either document them thoroughly or put together some kind of self-documentation tool. Unfortunately none of this has yet become a reality, and in the meantime the existing set of plugins and code grepping are the best ways to find hooks.

I suspect you’re having trouble with hooks being called because your plugin isn’t registered. Make sure your plugin has a version.xml descriptor in its directory, and then run php tools/upgrade.php upgrade to register it. That’s a developer’s work-around – if you were installing this plugin in production, then you’d use the Plugin Gallery or upload the plugin to the setup area, and both of those would register the plugin for you as well. When the plugin is registered it’ll have an entry in the versions table, and you should see hooks come to life.

If you want to quickly check what hooks are getting called for a request, try adding an error_log($hookName); to the HookRegistry::call function.

Regards,
Alec Smecher
Public Knowledge Project Team

Hey, the issue with the version table and that the name mentioned in version.xml needs to match the pathname of the plugin was something I also ran into a few days ago, but that wasn’t it this time. This time it was that some of the hook listeners can/need to be inside of

if ($this->getEnabled()) {...}

Whereas others have to be outside of this check to function. I believe I saw some other plugins do the same. Things like this look a bit unintuitive to newcomers. I think your ideas for documenting and fewer hooks sound good. Some things are even close to impossible to grep at, such as hooks forinsertion into database tables.

Thanks again!

1 Like