Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mismatch of author in citation between Citation View and Software Download Citation Tab #1650

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions core/components/com_citations/models/citation.php
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ public function sponsors()
}

/**
* Defines a one to many relationship with authors
* Defines a one to many relationship with authors for search results
*
* @return object
*/
Expand All @@ -558,6 +558,16 @@ public function relatedAuthors()
return $this->oneToMany('Author', 'cid');
}

/**
* Defines a one to many relationship with authors for resource citations tab
*
* @return object
*/
public function relatedAuthorsByCitation()
{
return $this->oneToMany('Author', 'cid', 'cid');
}

/**
* Defines a one to many relationship with authors
*
Expand Down Expand Up @@ -871,11 +881,14 @@ public function formatted($config = array('format' => 'apa'), $highlight = null)
{
$a = array();

// This is a string of authors from the cite object
$auth = html_entity_decode($this->$k);
$auth = (!preg_match('!\S!u', $auth)) ? utf8_encode($auth) : $auth;

// prefer the use of the relational table
$authors = $this->relatedAuthors()
// Fix for the citation tab of a resource.
// There were mismatch of author names to a citation, reason being it was using the id to match it with cid in table.
$authors = $this->relatedAuthorsByCitation()
->order('ordering', 'asc')
->order('id', 'asc')
->rows();
Expand Down