Skip to content

pkp/pkp-lib#13221 Implement crossref's citedBy - #108

Open
taslangraham wants to merge 2 commits into
pkp:mainfrom
taslangraham:i13221-main
Open

taslangraham wants to merge 2 commits into
pkp:mainfrom
taslangraham:i13221-main

Conversation

@taslangraham

@taslangraham taslangraham commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

@taslangraham taslangraham changed the title pkp/pkp-lib#13192 Implemented crossref's citedBy feature pkp/pkp-lib#13221 Implemented crossref's citedBy feature Sep 8, 2026
@taslangraham taslangraham changed the title pkp/pkp-lib#13221 Implemented crossref's citedBy feature pkp/pkp-lib#13221 Implement crossref's citedBy feature Sep 8, 2026
@taslangraham taslangraham changed the title pkp/pkp-lib#13221 Implement crossref's citedBy feature pkp/pkp-lib#13221 Implement crossref's citedBy Sep 8, 2026
@taslangraham
taslangraham force-pushed the i13221-main branch 3 times, most recently from 6925927 to d25433a Compare September 9, 2026 20:25
@taslangraham
taslangraham marked this pull request as ready for review September 9, 2026 20:34

@bozana bozana left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @taslangraham, here a few comments! Thanks a lot! Great work!

Comment thread CrossrefCitedBy.php Outdated
*/
public function registerEnabledHooks(): void
{
Hook::add('Templates::Article::Details::Metrics::CitedBy', $this->displayCitedByComponent(...));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To double check with Devika and Jarda, but here the hook Templates::Article::Footer::PageFooter could maybe be used for default theme.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were you able to confirm?

Comment thread CrossrefCitedBy.php Outdated
public function registerEnabledHooks(): void
{
Hook::add('Templates::Article::Details::Metrics::CitedBy', $this->displayCitedByComponent(...));
Hook::add('Templates::Article::Metrics::CitedByCount', $this->displayCitedByCountComponent(...));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm... this I do not know where would best be displayed in the default theme... maybe no need at all...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went ahead and removed it.

Comment thread CrossrefCitedByController.php Outdated
Comment thread CrossrefCitedByController.php Outdated
Comment thread CrossrefCitedByController.php Outdated
Comment thread CrossrefCitedBy.php Outdated
Comment thread CrossrefCitedBy.php Outdated
Comment thread CrossrefPlugin.php

return $success;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe to leave this blank line here :-)

Comment thread CrossrefPlugin.php Outdated
],
'citedBy' => (object) [
'type' => 'boolean',
],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it maybe be an easy way to require username+password if this field is enabled?
Would something like this work or be enough:

'username' => (object) [
    'type' => 'string',
    'validation' => ['nullable', 'max:120', 'required_if:citedBy,true'],
],
'password' => (object) [
    'type' => 'string',
    'validation' => ['nullable', 'max:50', 'required_if:citedBy,true'],
],

?

@taslangraham
taslangraham force-pushed the i13221-main branch 2 times, most recently from 5e82ed0 to 9c989d4 Compare September 15, 2026 14:42
@taslangraham
taslangraham force-pushed the i13221-main branch 6 times, most recently from e5dee28 to ed7814e Compare September 15, 2026 19:52

@bozana bozana left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @taslangraham, a few comments. I wanted also to test it but have not managed yet.
Thanks a lot!

Comment thread CrossrefCitedBy.php

$templateMgr->addJavaScript(
'CrossrefCitedByBody',
"{$request->getBaseUrl()}/{$this-> plugin->getPluginPath()}/public/build/crossref.js",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we add java script 4 times in this function?
hmmm... Crossmark adds it too...
Is requiresVueRuntime() as in Crossmark case needed?

Also, note that there is a space after $this-> in several places here

Comment thread templates/citedBy.blade
--}}
<section class="item cited-by" data-vue-root>
<pkp-cited-by v-bind='{$citedByConfig|json_encode}'></pkp-cited-by>
</section>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a smarty template syntax? Shouldn't it be something similar to crossmarkButton.blade?

--}}
<div class="item cited-by-count" data-vue-root>
<pkp-cited-by-count v-bind='{$citedByConfig|json_encode}'></pkp-cited-by-count>
</div>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a smarty template syntax? Shouldn't it be something similar to crossmarkButton.blade?

Comment thread CrossrefCitedBy.php
}

/** @var Submission $article */
$article = &$params[0];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the hook used I believe we need this:
$displayedArticle = $smarty->getTemplateVars('article');

Comment thread CrossrefCitedBy.php
public function setupCitedByComponents(string $hookName, array $params): bool
{
$request = $params[0];
$isCitedByEnabled = (bool)$this->plugin->getSetting($this->plugin->getCurrentContextId(), 'citedBy');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here and in the Controller one and the same function should be used to determine isEnabled. Else, the journal could change the registration agency but leave the crossref plugin enabled (with enabled citedBy).
Maybe to have it as an extra function in this class, that checks the configured registration agency, the setting citedBy and the credentials ?

citation.year,
citation.volume,
citation.authors,
citation.pages,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pages or firstPage ?

case 'conf_cite':
$result['title'] = $item->{$type}->volume_title ? (string)$item->{$type}->volume_title : null;
$result['journal'] = $item->{$type}->series_title ? (string)$item->{$type}->series_title : null;
$result['componentNumber'] = $item->{$type}->component_number ? (int)$item->{$type}->component_number : null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also here I would use string and not int

if ($citeType === 'msg') {
// The msg cite type contains a forward link to other cite types.
// So we recursively get those citations as well.
// See https://data.crossref.org/reports/help/schema_doc/crossref_query_output2.0/2_0.html#msg

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm... I think msg is just a string and sub-element of forward_link or query element, so I do not think this is needed here?

Comment thread CrossrefCitedBy.php
'report_cite',
'standard_cite'
];
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very difficult to maintain -- if something changes and new types are added...
Could extractCitationsFromXMLList() instead take any child element of forward_link whose name ends in _cite, and read its no matter what the type is? 🤔

Comment thread public/build/crossref.css
*
* Copyright (c) 2026 Simon Fraser University
* Copyright (c) 2026 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

somehow for crossref plugin we use MIT license, so maybe to apply everywhere:
Distributed under The MIT License. For full terms see the file LICENSE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants