Skip to content

Commit

Permalink
remove 3.3 version files and update code to modify url creation and a…
Browse files Browse the repository at this point in the history
…dd json encoding for Issue #26 (#27)

Co-authored-by: Peter West <[email protected]>
  • Loading branch information
stutzmann72 and pjwest authored Jan 7, 2025
1 parent c2c6ff6 commit 81e46ab
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 249 deletions.
152 changes: 0 additions & 152 deletions IiifViewerPlugin.inc.php

This file was deleted.

38 changes: 26 additions & 12 deletions IiifViewerPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,21 @@ public function register($category, $path, $mainContextId = null) {
if ($this->getEnabled($mainContextId)) {
$request = Application::get()->getRequest();
$url = $request->getBaseUrl() . '/' . $this->getPluginPath() . '/styles/iiifviewer.css';
$templateMgr = TemplateManager::getManager($request);

$templateMgr = TemplateManager::getManager($request);
$templateMgr->addStyleSheet('iiifViewerStyles', $url);
if (str_starts_with($context, 'ojs')) {
Hook::add('ArticleHandler::view::galley', [$this, 'articleCallback']);
Hook::add('IssueHandler::view::galley', [$this, 'issueCallback']);
} elseif (str_starts_with($context, 'omp')) {
Hook::add('CatalogBookHandler::view', [$this, 'ompViewCallback'], HOOK::SEQUENCE_NORMAL);

switch (Application::getName()) {
case 'ojs2':
Hook::add('ArticleHandler::view::galley', [$this, 'articleCallback']);
Hook::add('IssueHandler::view::galley', [$this, 'issueCallback']);
break;
case 'omp':
Hook::add('CatalogBookHandler::view', [$this, 'ompViewCallback'], HOOK::SEQUENCE_NORMAL);
break;
case 'ops':
break;
default: throw new \Exception('Unsupported application!');
}
}
return true;
Expand Down Expand Up @@ -149,19 +157,21 @@ public function articleCallback($hookName, $args) {
$bestId = $submission->getBestId();
$galleyBestId = $galley->getBestGalleyId();
$galleyFile = $galley->getFile();
$apiUrl = null;
$apiParams['inline'] = 'true';
$apiPath = [];
if ($isLatestPublication) {
$apiUrl = $request->getIndexUrl().'/'.$contextPath.'/article/download/'.$bestId.'/'.$galleyBestId.'/'.$galleyFile->getId().'?inline=1';
$apiPath = [$bestId, $galleyBestId, $galleyFile->getId()];
} else {
$apiUrl = $request->getIndexUrl().'/'.$contextPath.'/article/download/'.$bestId.'/version/'.$galleyPublication->getId().'/'.$galleyBestId.'/'.$galleyFile->getId().'?inline=1';
$apiPath = [$bestId, 'version', $galleyPublication->getId(), $galleyBestId, $galleyFile->getId()];
}

$apiUrl = $request->url( null, 'article', 'download', $apiPath, $apiParams );

$templateMgr = TemplateManager::getManager($request);
$templateMgr->assign([
'apiUrl' => $apiUrl,
'pluginUrl' => $request->getBaseUrl() . '/' . $this->getPluginPath(),
'isLatestPublication' => $isLatestPublication,

]);

$templateMgr->display($this->getTemplateResource($galleyTemplate));
Expand Down Expand Up @@ -200,7 +210,9 @@ function issueCallback($hookName, $args) {
$galleyBestId = $galley->getBestGalleyId();
$galleyFile = $galley->getFile();

$apiUrl = $request->getIndexUrl().'/'.$contextPath.'/issue/download/'.$issueBestId.'/'.$galleyBestId.'/'.$galleyFile->getId().'?inline=1';
$apiPath = [$issueBestId, $galleyBestId, $galleyFile->getId()];
$apiParams['inline'] = 'true';
$apiUrl = $request->url(null, 'issue', 'download', $apiPath, $apiParams );

$templateMgr = TemplateManager::getManager($request);
$templateMgr->assign([
Expand Down Expand Up @@ -246,7 +258,9 @@ private function viewImageFile($publicationFormat, $submission, $submissionFile,
$router = $request->getRouter();
$contextPath = $router->getRequestedContextPath($request, 1);

$apiUrl = $request->getIndexUrl().'/'.$contextPath.'/catalog/download/'.$submissionId.'/'.$format.'/'.$fileId.'?inline=1';
$apiPath = [$submissionId, $format, $fileId];
$apiParams['inline'] = 'true';
$apiUrl = $request->url(null, 'catalog', 'download', $apiPath, $apiParams );

$templateMgr = TemplateManager::getManager($request);
$templateMgr->assign(array(
Expand Down
22 changes: 0 additions & 22 deletions index.php

This file was deleted.

27 changes: 0 additions & 27 deletions locale/de_DE/locale.po

This file was deleted.

27 changes: 0 additions & 27 deletions locale/en_US/locale.po

This file was deleted.

2 changes: 1 addition & 1 deletion templates/article_image.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
sequenceMode: true,
tileSources: [{
"type": "image",
"url": "{$apiUrl}"
"url": {$apiUrl|json_encode:JSON_UNESCAPED_SLASHES}
}]
});
</script>
Expand Down
4 changes: 2 additions & 2 deletions templates/article_manifest.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
var mirador = Mirador.viewer({
"id": "my-mirador",
"manifests": {
"{$apiUrl}" :{
{$apiUrl|json_encode:JSON_UNESCAPED_SLASHES} :{
//"provider": "Basel University"
}
},
"windows": [
{
"loadedManifest": "{$apiUrl}",
"loadedManifest": {$apiUrl|json_encode:JSON_UNESCAPED_SLASHES},
"canvasIndex": 2,
"thumbnailNavigationPosition": 'far-bottom'
}
Expand Down
2 changes: 1 addition & 1 deletion templates/display.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
sequenceMode: true,
tileSources: [{
"type": "image",
"url": "{$apiUrl}"
"url": {$apiUrl|json_encode:JSON_UNESCAPED_SLASHES}
}]
});
</script>
Expand Down
4 changes: 2 additions & 2 deletions templates/display_manifest.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
var mirador = Mirador.viewer({
"id": "my-mirador",
"manifests": {
"{$apiUrl}" :{
{$apiUrl|json_encode:JSON_UNESCAPED_SLASHES} :{
//"provider": "Basel University"
}
},
"windows": [
{
"loadedManifest": "{$apiUrl}",
"loadedManifest": {$apiUrl|json_encode:JSON_UNESCAPED_SLASHES},
"canvasIndex": 2,
"thumbnailNavigationPosition": 'far-bottom'
}
Expand Down
2 changes: 1 addition & 1 deletion templates/issue_image.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
sequenceMode: true,
tileSources: [{
"type": "image",
"url": "{$apiUrl}"
"url": {$apiUrl|json_encode:JSON_UNESCAPED_SLASHES}
}]
});
</script>
Expand Down
4 changes: 2 additions & 2 deletions templates/issue_manifest.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
var mirador = Mirador.viewer({
"id": "my-mirador",
"manifests": {
"{$apiUrl}" :{
{$apiUrl|json_encode:JSON_UNESCAPED_SLASHES} :{
//"provider": "Basel University"
}
},
"windows": [
{
"loadedManifest": "{$apiUrl}",
"loadedManifest": {$apiUrl|json_encode:JSON_UNESCAPED_SLASHES},
"canvasIndex": 2,
"thumbnailNavigationPosition": 'far-bottom'
}
Expand Down

0 comments on commit 81e46ab

Please sign in to comment.