From 091a21da8d1cd2807fce11014ae803b05773c493 Mon Sep 17 00:00:00 2001 From: Aysel Afsar Date: Wed, 27 Mar 2024 18:35:20 -0400 Subject: [PATCH] #106 Dicom viewer error (#107) --- lib/Controller/DisplayController.php | 13 ++++++++----- templates/viewer.php | 11 ++--------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/lib/Controller/DisplayController.php b/lib/Controller/DisplayController.php index 9bcbf64..c6c1279 100755 --- a/lib/Controller/DisplayController.php +++ b/lib/Controller/DisplayController.php @@ -54,8 +54,8 @@ public function __construct(IConfig $config, $this->publicViewerFolderPath = null; $this->publicViewerAssetsFolderPath = null; - $app_path = $this->getAppManager()->getAppPath('dicomviewer'); - $viewerFolder = $app_path . '/js/public/viewer'; + $this->appPath = $this->getAppManager()->getAppPath('dicomviewer'); + $viewerFolder = $this->appPath . '/js/public/viewer'; if (file_exists($viewerFolder)) { $this->publicViewerFolderPath = $viewerFolder; $this->publicViewerAssetsFolderPath = $viewerFolder . '/assets'; @@ -312,7 +312,8 @@ private function generateDICOMJson($dicomFilePaths, $selectedFileFullPath, $pare public function showDICOMViewer(): TemplateResponse { $params = [ 'urlGenerator' => $this->urlGenerator, - 'ignoreFrontController' => $this->config->getSystemValueBool('htaccess.IgnoreFrontController', false) || getenv('front_controller_active') === 'true' + 'ignoreFrontController' => $this->config->getSystemValueBool('htaccess.IgnoreFrontController', false) || getenv('front_controller_active') === 'true', + 'dicomViewerAppPath' => $this->appPath ]; $response = new TemplateResponse(Application::APP_ID, 'viewer', $params, 'blank'); @@ -332,7 +333,8 @@ public function showDICOMViewer(): TemplateResponse { public function showDICOMViewerModeViewer(): TemplateResponse { $params = [ 'urlGenerator' => $this->urlGenerator, - 'ignoreFrontController' => $this->config->getSystemValueBool('htaccess.IgnoreFrontController', false) || getenv('front_controller_active') === 'true' + 'ignoreFrontController' => $this->config->getSystemValueBool('htaccess.IgnoreFrontController', false) || getenv('front_controller_active') === 'true', + 'dicomViewerAppPath' => $this->appPath ]; $response = new TemplateResponse(Application::APP_ID, 'viewer', $params, 'blank'); @@ -352,7 +354,8 @@ public function showDICOMViewerModeViewer(): TemplateResponse { public function showDICOMViewerModeJson(): TemplateResponse { $params = [ 'urlGenerator' => $this->urlGenerator, - 'ignoreFrontController' => $this->config->getSystemValueBool('htaccess.IgnoreFrontController', false) || getenv('front_controller_active') === 'true' + 'ignoreFrontController' => $this->config->getSystemValueBool('htaccess.IgnoreFrontController', false) || getenv('front_controller_active') === 'true', + 'dicomViewerAppPath' => $this->appPath ]; $response = new TemplateResponse(Application::APP_ID, 'viewer', $params, 'blank'); diff --git a/templates/viewer.php b/templates/viewer.php index 7bc55a7..ece9edd 100755 --- a/templates/viewer.php +++ b/templates/viewer.php @@ -1,21 +1,14 @@ getWebroot(); if (!$ignoreFrontController) { $nextcloudBasePath .= '/index.php'; } -$publicViewerIndexPath = ''; -$appsPaths = \OC::$server->getSystemConfig()->getValue('apps_paths'); -foreach($appsPaths as $appsPath) { - $viewerIndexFile = $appsPath['path'] . '/dicomviewer/js/public/viewer/index.html'; - if (file_exists($viewerIndexFile)) { - $publicViewerIndexPath = $viewerIndexFile; - break; - } -} +$publicViewerIndexPath = $dicomViewerAppPath . '/js/public/viewer/index.html'; print str_replace('__NEXTCLOUD_BASE_PATH__', $nextcloudBasePath, file_get_contents($publicViewerIndexPath)); ?>