Skip to content
Snippets Groups Projects
Commit ff4a68ed authored by Demian Katz's avatar Demian Katz Committed by Robert Lange
Browse files

Fix problem with PDFs failing to load.

- The preferred ebook format parameter must be passed when requesting full text to ensure the correct link is returned.
parent 4a8ade7f
No related merge requests found
......@@ -29,6 +29,7 @@ namespace VuFind\Controller;
use Laminas\ServiceManager\ServiceLocatorInterface;
use VuFind\Exception\Forbidden as ForbiddenException;
use VuFindSearch\ParamBag;
/**
* EDS Record Controller
......@@ -57,14 +58,18 @@ class EdsrecordController extends AbstractRecord
}
/**
* Action to display ePub.
* Redirect to an eBook.
*
* @param string $format Format of eBook to request from API.
* @param string $method Record driver method to use to obtain target URL.
*
* @return mixed
*/
public function epubAction()
protected function redirectToEbook($format, $method)
{
$driver = $this->loadRecord();
//if the user is a guest, redirect them to the login screen.
$params = new ParamBag(['ebookpreferredformat' => $format]);
$driver = $this->loadRecord($params, true);
// If the user is a guest, redirect them to the login screen.
$auth = $this->getAuthorizationService();
if (!$auth->isGranted('access.EDSExtendedResults')) {
if (!$this->getUser()) {
......@@ -72,7 +77,17 @@ class EdsrecordController extends AbstractRecord
}
throw new ForbiddenException('Access denied.');
}
return $this->redirect()->toUrl($driver->getEpubLink());
return $this->redirect()->toUrl($driver->tryMethod($method));
}
/**
* Action to display ePub.
*
* @return mixed
*/
public function epubAction()
{
return $this->redirectToEbook('ebook-epub', 'getEpubLink');
}
/**
......@@ -82,16 +97,7 @@ class EdsrecordController extends AbstractRecord
*/
public function pdfAction()
{
$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->getPdfLink());
return $this->redirectToEbook('ebook-pdf', 'getPdfLink');
}
/**
......
......@@ -273,10 +273,16 @@ class Backend extends AbstractBackend
);
}
list($dbId, $an) = $parts;
$hlTerms = (null != $params)
$hlTerms = (null !== $params)
? $params->get('highlightterms') : null;
$extras = [];
if (null !== $params
&& ($eBookFormat = $params->get('ebookpreferredformat'))
) {
$extras['ebookpreferredformat'] = $eBookFormat;
}
$response = $this->client->retrieve(
$an, $dbId, $authenticationToken, $sessionToken, $hlTerms
$an, $dbId, $authenticationToken, $sessionToken, $hlTerms, $extras
);
} catch (ApiException $e) {
// if the auth or session token was invalid, try once more
......
......@@ -173,16 +173,17 @@ abstract class Base
* @param string $sessionToken Session token
* @param string $highlightTerms Comma separated list of terms to highlight
* in the retrieved record responses
* @param array $extraQueryParams Extra query string parameters
*
* @return array The requested record
*/
public function retrieve($an, $dbId, $authenticationToken, $sessionToken,
$highlightTerms = null
$highlightTerms = null, $extraQueryParams = []
) {
$this->debugPrint(
"Get Record. an: $an, dbid: $dbId, $highlightTerms: $highlightTerms"
);
$qs = ['an' => $an, 'dbid' => $dbId];
$qs = $extraQueryParams + ['an' => $an, 'dbid' => $dbId];
if (null != $highlightTerms) {
$qs['highlightterms'] = $highlightTerms;
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment