trans = $trans; $this->logger = $logger; $this->config = $config; } /** * Print config section * * @return TemplateResponse */ public function index() { $data = [ "documentserver" => $this->config->GetDocumentServerUrl(), "secret" => $this->config->GetDocumentServerSecret() ]; return new TemplateResponse($this->appName, "settings", $data, "blank"); } /** * Save the document server address * * @param string $documentserver - document service address * @param string $secret - secret key for signature * * @return array */ public function settings($documentserver, $secret) { $this->config->SetDocumentServerUrl($documentserver); $this->config->SetDocumentServerSecret($secret); $documentserver = $this->config->GetDocumentServerUrl(); if (!empty($documentserver)) { $error = $this->checkDocServiceUrl(); } return [ "documentserver" => $this->config->GetDocumentServerUrl(), "error" => $error ]; } /** * Get supported formats * * @return array * * @NoAdminRequired */ public function formats(){ return $this->config->formats; } /** * Checking document service location * * @param string $documentServer - document service address * * @return string */ private function checkDocServiceUrl() { $documentService = new DocumentService($this->trans, $this->config); try { $commandResponse = $documentService->CommandRequest("version"); $this->logger->debug("CommandRequest on check: " . json_encode($commandResponse), array("app" => $this->appName)); $version = floatval($commandResponse->version); if ($version < 4.2) { throw new \Exception($this->trans->t("Not supported version")); } } catch (\Exception $e) { $this->logger->error("CommandRequest on check error: " . $e->getMessage(), array("app" => $this->appName)); return $e->getMessage(); } return ""; } }