Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion lib/Controller/DisplayController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class DisplayController extends Controller {

private $l10nFactory;

private $config;

/**
* @param string $AppName
* @param IRequest $request
Expand All @@ -36,12 +38,29 @@ class DisplayController extends Controller {
public function __construct(string $AppName,
IRequest $request,
IURLGenerator $urlGenerator,
IConfig $config,
L10NFactory $l10nFactory) {
parent::__construct($AppName, $request);
$this->urlGenerator = $urlGenerator;
$this->config = $config;
$this->l10nFactory = $l10nFactory;
}

/**
* URL of the stylesheet a legacy theme provides for the editor, with its
* modification time against caching, or null if the theme has none
*/
private function getThemeStylesheet(): ?string {
$theme = $this->config->getSystemValueString('theme', '') ?: 'default';
$path = '/themes/' . $theme . '/apps/files_mindmap/css/style.css';
// No public API exposes the server root
$file = \OC::$SERVERROOT . $path;
if (!is_file($file)) {
return null;
}
return $this->urlGenerator->getWebroot() . $path . '?v=' . filemtime($file);
}

/**
* @PublicPage
* @NoCSRFRequired
Expand All @@ -51,7 +70,8 @@ public function __construct(string $AppName,
public function showMindmapViewer(): TemplateResponse {
$params = [
'urlGenerator' => $this->urlGenerator,
'lang' => $this->l10nFactory->findLanguage()
'lang' => $this->l10nFactory->findLanguage(),
'themeStylesheet' => $this->getThemeStylesheet(),
];
$response = new TemplateResponse($this->appName, 'viewer', $params, 'blank');
$response->addHeader('Cache-Control', 'no-cache');
Expand Down
4 changes: 4 additions & 0 deletions templates/viewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@
line-height: 1.2;
}
</style>
<?php if ($themeStylesheet !== null): ?>
<!-- after the editor's own styles, so the theme's rules take precedence -->
<link rel="stylesheet" href="<?php p($themeStylesheet) ?>" />
<?php endif; ?>
</head>
<script nonce="<?=$nonce?>">
var lang = '<?=$lang?>';
Expand Down