Skip to content

Commit

Permalink
pkp/pkp-lib/issues/6201 Add citationStyleLanguagePlugin support (#1245)
Browse files Browse the repository at this point in the history
* Add publication and chapter to hook: CatalogBookHandler::book

* Rework getBySourceChapterId() in ChapterDAO

* Add availability of hook chapterdao::getLocaleFieldNames

* Add function getChapterBySourceChapterId
  • Loading branch information
nongenti authored Feb 9, 2023
1 parent d348289 commit 11c1a3c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
26 changes: 23 additions & 3 deletions classes/monograph/ChapterDAO.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ public function getByDoiId(int $doiId): DAOResultFactory

/**
* Retrieve all chapters by source chapter id.
*
*
*/
public function getBySourceChapterId(int $sourceChapterId, bool $orderByPublicationId = true): DAOResultFactory
{
Expand All @@ -134,14 +132,36 @@ public function getBySourceChapterId(int $sourceChapterId, bool $orderByPublicat
);
}

/**
* Retrieve a chapter by source chapter ID and publication ID.
*/
public function getChapterBySourceChapterId(int $sourceChapterId, int $publicationId): Chapter|null
{
$result = $this->retrieve(
'SELECT *
FROM submission_chapters
WHERE (source_chapter_id = ? OR (source_chapter_id IS NULL AND chapter_id = ?))
AND publication_id = ?',
[$sourceChapterId, $sourceChapterId, $publicationId]
);

$row = $result->current();
return $row ? $this->_fromRow((array) $row) : null;
}

/**
* Get the list of fields for which locale data is stored.
*
* @return array
*/
public function getLocaleFieldNames()
{
return ['title', 'subtitle','abstract'];
$localFieldNames = parent::getLocaleFieldNames();
$localFieldNames[] = 'title';
$localFieldNames[] = 'subtitle';
$localFieldNames[] = 'abstract';

return $localFieldNames;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion pages/catalog/CatalogBookHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public function book($args, $request)
}

// Display
if (!Hook::call('CatalogBookHandler::book', [&$request, &$submission])) {
if (!Hook::call('CatalogBookHandler::book', [&$request, &$submission, &$this->publication, &$this->chapter])) {
$templateMgr->display('frontend/pages/book.tpl');
if ($this->isChapterRequest) {
event(new UsageEvent(Application::ASSOC_TYPE_CHAPTER, $request->getContext(), $submission, null, null, $this->chapter));
Expand Down

0 comments on commit 11c1a3c

Please sign in to comment.