diff --git a/languages/en.ini b/languages/en.ini index fc7db1c3faf80f53736cd59d002a308ab0e10218..640952c085a374dd3c2cd01b4218970bb4c4487f 100644 --- a/languages/en.ini +++ b/languages/en.ini @@ -363,6 +363,7 @@ Empty Book Bag = "Empty Book Bag" empty_search_disallowed = "An empty query is not allowed with the current search target" Enable Auto Config = "Enable Auto Config" End Page = "End Page" +ePub Full Text = "ePub Full Text" Era = "Era" error_inconsistent_parameters = "Sorry, an error has occurred. Inconsistent parameters detected." error_page_parameter_list_heading = "Request Parameters" diff --git a/module/VuFind/src/VuFind/Controller/EdsrecordController.php b/module/VuFind/src/VuFind/Controller/EdsrecordController.php index 564b238887f8e3291dd08311b613e939819e354c..83ea1aeb7dbb9184d41a764c82b80b37b3c9eb2d 100644 --- a/module/VuFind/src/VuFind/Controller/EdsrecordController.php +++ b/module/VuFind/src/VuFind/Controller/EdsrecordController.php @@ -56,6 +56,25 @@ class EdsrecordController extends AbstractRecord parent::__construct($sm); } + /** + * ePub display action. + * + * @return mixed + */ + public function epubAction() + { + $driver = $this->loadRecord(); + //if the user is a guest, redirect them to the login screen. + $auth = $this->getAuthorizationService(); + if (!$auth->isGranted('access.EDSExtendedResults')) { + if (!$this->getUser()) { + return $this->forceLogin(); + } + throw new ForbiddenException('Access denied.'); + } + return $this->redirect()->toUrl($driver->getEpubLink()); + } + /** * PDF display action. * diff --git a/module/VuFind/src/VuFind/RecordDriver/EDS.php b/module/VuFind/src/VuFind/RecordDriver/EDS.php index eba329676a45f93fea5a3c497572438a06fa68f5..f96b23833ab4c1e1753537f2a476bdc89c6e8268 100644 --- a/module/VuFind/src/VuFind/RecordDriver/EDS.php +++ b/module/VuFind/src/VuFind/RecordDriver/EDS.php @@ -38,6 +38,13 @@ namespace VuFind\RecordDriver; */ class EDS extends DefaultRecord { + /** + * Document types that are treated as ePub links. + * + * @var array + */ + protected $epubTypes = ['ebook-epub']; + /** * Document types that are treated as PDF links. * @@ -241,6 +248,23 @@ class EDS extends DefaultRecord ? $this->fields['Header']['PubTypeId'] : ''; } + /** + * Get the ebook availability of the record. + * + * @param array $types Types that we are interested in checking for + * + * @return bool + */ + protected function hasEbookAvailable(array $types) + { + foreach ($this->fields['FullText']['Links'] ?? [] as $link) { + if (isset($link['Type']) && in_array($link['Type'], $types)) { + return true; + } + } + return false; + } + /** * Get the PDF availability of the record. * @@ -248,13 +272,33 @@ class EDS extends DefaultRecord */ public function hasPdfAvailable() { - if (isset($this->fields['FullText']['Links'])) { - foreach ($this->fields['FullText']['Links'] as $link) { - if (isset($link['Type']) - && in_array($link['Type'], $this->pdfTypes) - ) { - return true; - } + return $this->hasEbookAvailable($this->pdfTypes); + } + + /** + * Get the ePub availability of the record. + * + * @return bool + */ + public function hasEpubAvailable() + { + return $this->hasEbookAvailable($this->epubTypes); + } + + /** + * Get the ebook url of the record. If missing, return false + * + * @param array $types Types that we are interested in checking for + * + * @return string + */ + public function getEbookLink(array $types) + { + foreach ($this->fields['FullText']['Links'] ?? [] as $link) { + if (!empty($link['Type']) && !empty($link['Url']) + && in_array($link['Type'], $types) + ) { + return $link['Url']; } } return false; @@ -267,16 +311,17 @@ class EDS extends DefaultRecord */ public function getPdfLink() { - if (isset($this->fields['FullText']['Links'])) { - foreach ($this->fields['FullText']['Links'] as $link) { - if (!empty($link['Type']) && !empty($link['Url']) - && in_array($link['Type'], $this->pdfTypes) - ) { - return $link['Url']; // return PDF link - } - } - } - return false; + return $this->getEbookLink($this->pdfTypes); + } + + /** + * Get the ePub url of the record. If missing, return false + * + * @return string + */ + public function getEpubLink() + { + return $this->getEbookLink($this->epubTypes); } /** diff --git a/module/VuFind/src/VuFind/Route/RouteGenerator.php b/module/VuFind/src/VuFind/Route/RouteGenerator.php index 90dff97bca6d954fa60e8b3a9437d625fdf57f43..a176b05f990dd2657c10a9ad5bfb501fca6cb506 100644 --- a/module/VuFind/src/VuFind/Route/RouteGenerator.php +++ b/module/VuFind/src/VuFind/Route/RouteGenerator.php @@ -60,7 +60,7 @@ class RouteGenerator $this->nonTabRecordActions = [ 'AddComment', 'DeleteComment', 'AddTag', 'DeleteTag', 'Save', 'Email', 'SMS', 'Cite', 'Export', 'RDF', 'Hold', 'Home', - 'StorageRetrievalRequest', 'AjaxTab', 'ILLRequest', 'PDF', + 'StorageRetrievalRequest', 'AjaxTab', 'ILLRequest', 'PDF', 'Epub', ]; } else { $this->nonTabRecordActions = $nonTabRecordActions; diff --git a/themes/bootstrap3/templates/RecordDriver/EDS/core.phtml b/themes/bootstrap3/templates/RecordDriver/EDS/core.phtml index 4297ed524828882c6fa473c24f251ff5ab35925e..9d9caf9e1937d9ff8b1673445976031095669701 100644 --- a/themes/bootstrap3/templates/RecordDriver/EDS/core.phtml +++ b/themes/bootstrap3/templates/RecordDriver/EDS/core.phtml @@ -36,6 +36,14 @@ </a> </span><br /> <?php endif; ?> + <?php $epubLink = $this->driver->getEpubLink(); + if ($epubLink): ?> + <span> + <a href="<?=$epubLink?>" class="icon epub fulltext"> + <?=$this->transEsc('ePub Full Text')?> + </a> + </span><br /> + <?php endif; ?> <?php if ($this->driver->hasHTMLFullTextAvailable()): ?> <span> <a href="<?=$this->recordLink()->getUrl($this->driver)?>#html" class="icon html fulltext"> diff --git a/themes/bootstrap3/templates/RecordDriver/EDS/result-list.phtml b/themes/bootstrap3/templates/RecordDriver/EDS/result-list.phtml index d42c646c30fe5dacbbaaf941780849af6650bef8..118f30ee68ce960a938a89f64a7130cea6ed0037 100644 --- a/themes/bootstrap3/templates/RecordDriver/EDS/result-list.phtml +++ b/themes/bootstrap3/templates/RecordDriver/EDS/result-list.phtml @@ -89,6 +89,12 @@ </a> <?php endif; ?> + <?php if ($this->driver->hasEpubAvailable()): ?> + <a href="<?= $this->recordLink()->getTabUrl($this->driver, 'Epub'); ?>" class="icon epub fulltext" target="_blank"> + <?=$this->transEsc('ePub Full Text')?> + </a> + <?php endif; ?> + <?php /* Links from DOI linker */ ?> <?php $doi = $this->doi($this->driver, 'results'); if ($doi->isActive()):?> <?=$doi->renderTemplate()?>