l10n = $l10n; $this->appConfig = $appConfig; $this->discoveryManager = $discoveryManager; } /** * @NoAdminRequired * * @return JSONResponse */ public function getSettings() { return new JSONResponse([ 'doc_format' => $this->appConfig->getAppValue('doc_format'), 'wopi_url' => $this->appConfig->getAppValue('wopi_url'), ]); } /** * @param string $wopi_url * @param string $doc_format * @return JSONResponse */ public function setSettings($wopi_url, $doc_format){ $message = $this->l10n->t('Saved'); if ($wopi_url !== null){ $this->appConfig->setAppValue('wopi_url', $wopi_url); $colon = strpos($wopi_url, ':', 0); if ($this->request->getServerProtocol() !== substr($wopi_url, 0, $colon)){ $message = $this->l10n->t('Saved with error: Collabora Online should use the same protocol as the server installation.'); } } if ($doc_format !== null) { $this->appConfig->setAppValue('doc_format', $doc_format); } $this->discoveryManager->refretch(); $response = [ 'status' => 'success', 'data' => array('message' => (string) $message) ]; return new JSONResponse($response); } }