New Plugin of OJS3: NBN Italia

Hi all,
I made a plugin that contact the Italian NBN resolver and with username e password get an NBN from the server.
It’s the upgrade of the still existing plug in for version 2.0.
I mashed up the working code from the old plugin with code examples taken by URN and DOI plugins.
I think it’s not perfect but it works.
I hope that the developers could have a look to address me for a better code.

There are some things that still do not work well. For example, after the click the link should disappear and be replaced by a SPINNER, so the server response should appear.
But I have no idea how to make it.

The plugin code is on GitHub:

Thanks in advance,
Alfredo

2 Likes

Hi @Alfredo_Cosco,

Excellent, glad to hear about this! Can you point me to the spot in the code that generates the link action you’re having trouble with?

Thanks,
Alec Smecher
Public Knowledge Project Team

Hello @asmecher,
This is the link before the identifier creation:
821Z

Once clicked the link a number is generated by the resolver so if you reload the tab you can assign it:
879Z

It would be nice to have:

  1. the link as a button
  2. an ajax switch so you don’t have to reload the page.

The code that creates the link is in the function getLinkActions (line 159 of NBNPubIdPlugin.inc.php):

            $linkActions = array();
            import('lib.pkp.classes.linkAction.request.AjaxAction');		
	$request = Application::getRequest();	
	$contextId = $pubObject->getJournalId();
	$objectId = $pubObject->getId();
	
	// Edit object pub id
	$linkActions['editPubIdLinkActionNBN'] = new LinkAction(
		'editPubId',
		new AjaxAction(
					$request->url(
					null, 
					'grid.settings.plugins.settingsPluginGrid.Handler', 
					'manage', 
					null, 
					//$userVars
					array('verb' => 'resolve', 'plugin' => $this->getName(), 'category' => 'pubIds','context'=>$contextId, 'article'=>$objectId)
					)
				),
		__('plugins.pubIds.nbn.editor.editObjectsNBN'),
		'edit',
		__('plugins.pubIds.nbn.editor.editObjectsNBN')
	);

Thanks,
Alfredo

Hi @Alfredo_Cosco,

You might have to write your own Javascript handler for the page containing the link action in order to get it to do what you want – there are lots of examples of handlers extending AjaxFormHandler that might serve as good templates.

Regards,
Alec Smecher
Public Knowledge Project Team