diff --git a/module/VuFind/src/VuFind/RecordDriver/EDS.php b/module/VuFind/src/VuFind/RecordDriver/EDS.php index 8b4137565aab..1feca25a4f6c 100644 --- a/module/VuFind/src/VuFind/RecordDriver/EDS.php +++ b/module/VuFind/src/VuFind/RecordDriver/EDS.php @@ -1063,7 +1063,7 @@ function ($data) { } /** - * Get year of containing record. + * Get the start page of the item that contains this record. * * @return string */ @@ -1099,6 +1099,25 @@ public function getContainerEndPage() return ''; } + /** + * Get the page count. + * + * @return string + */ + public function getPageCount() + { + if ( + $pageCount = $this->extractEbscoDataFromRecordInfo( + 'BibRecord/BibEntity/PhysicalDescription/Pagination/PageCount' + )[0] ?? '' + ) { + return $pageCount; + } elseif ($pageCount = $this->getItem('Name', 'Pages')[0]['Data'] ?? '') { + return $pageCount; + } + return ''; + } + /** * Returns an array of formats based on publication type. * diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/RecordDriver/EDSTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/RecordDriver/EDSTest.php index 70b479855b68..e4fcc20cff4c 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/RecordDriver/EDSTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/RecordDriver/EDSTest.php @@ -903,6 +903,35 @@ public function testGetContainerEndPageNoData(): void $this->assertEquals('', $driver->getContainerEndPage()); } + /** + * Test getPageCount for a record. + * + * @return void + */ + public function testGetPageCount(): void + { + // Find page count in PhysicalDescription + $driver = $this->getDriver('valid-eds-record'); + $this->assertEquals('217', $driver->getPageCount()); + + // Fail to find it + $json = $this->getJsonFixture('eds/valid-eds-record.json'); + unset($json['RecordInfo']['BibRecord']['BibEntity']['PhysicalDescription']['Pagination']); + $driver->setRawData($json); + $this->assertEquals('', $driver->getPageCount()); + + // Find it in Items + $json['Items'][] = + [ + 'Name' => 'Pages', + 'Label' => 'Page Count', + 'Group' => 'Src', + 'Data' => '42', + ]; + $driver->setRawData($json); + $this->assertEquals('42', $driver->getPageCount()); + } + /** * Test getFormats for an ebook record. *