From 9e757f15d0905e3f229741f3c0addb7704bf3266 Mon Sep 17 00:00:00 2001 From: Jesse Woo Date: Wed, 2 Aug 2023 14:15:23 -0700 Subject: [PATCH] added in author by Citation id --- .../com_citations/models/citation.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/core/components/com_citations/models/citation.php b/core/components/com_citations/models/citation.php index 160606afe82..60703f9b2d9 100644 --- a/core/components/com_citations/models/citation.php +++ b/core/components/com_citations/models/citation.php @@ -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 */ @@ -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 * @@ -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();