Skip to content

Commit

Permalink
#106 Dicom viewer error (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
ayselafsar authored Mar 27, 2024
1 parent 5fd4698 commit 091a21d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
13 changes: 8 additions & 5 deletions lib/Controller/DisplayController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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');
Expand All @@ -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');
Expand All @@ -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');
Expand Down
11 changes: 2 additions & 9 deletions templates/viewer.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
<?php
$urlGenerator = $_['urlGenerator'];
$ignoreFrontController = $_['ignoreFrontController'];
$dicomViewerAppPath = $_['dicomViewerAppPath'];
$nextcloudBasePath = $urlGenerator->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));
?>

0 comments on commit 091a21d

Please sign in to comment.