Skip to content

Commit

Permalink
added in author by Citation id
Browse files Browse the repository at this point in the history
  • Loading branch information
jessewoo authored and nkissebe committed Oct 5, 2023
1 parent 0c553cb commit 9e757f1
Showing 1 changed file with 15 additions and 2 deletions.
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

0 comments on commit 9e757f1

Please sign in to comment.