Actualización

This commit is contained in:
Xes
2025-04-10 12:36:07 +02:00
parent 1da7c3f3b9
commit 4aff98e77b
3147 changed files with 320647 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
# ENV
DOCS_INTEGRATION_SDK_PRODUCT_NAME=ONLYOFFICE
# Document server
DOCS_INTEGRATION_SDK_DOCUMENT_SERVER_URL=
DOCS_INTEGRATION_SDK_DOCUMENT_SERVER_API_URL=/web-apps/apps/api/documents/api.js
DOCS_INTEGRATION_SDK_DOCUMENT_SERVER_API_PRELOADER_URL=/web-apps/apps/api/documents/cache-scripts.html
DOCS_INTEGRATION_SDK_DOCUMENT_SERVER_HEALTHCHECK_URL=/healthcheck
# JWT
DOCS_INTEGRATION_SDK_JWT_HEADER=Authorization
DOCS_INTEGRATION_SDK_JWT_PREFIX="Bearer "
DOCS_INTEGRATION_SDK_JWT_KEY=
DOCS_INTEGRATION_SDK_JWT_LEEWAY=3
# Editing service
DOCS_INTEGRATION_SDK_EDITING_SERVICE_INSERT_IMAGE=bmp|gif|jpeg|jpg|png|tif|tiff
DOCS_INTEGRATION_SDK_EDITING_SERVICE_MAX_FILE_SIZE=104857600
DOCS_INTEGRATION_SDK_EDITING_SERVICE_MOBILE_USER_AGENT="android|avantgo|playbook|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|symbian|treo|up\\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino"
# Convert service
DOCS_INTEGRATION_SDK_CONVERT_SERVICE_URL=/ConvertService.ashx
DOCS_INTEGRATION_SDK_CONVERT_SERVICE_SYNC_SOCKET_TIMEOUT=60
DOCS_INTEGRATION_SDK_CONVERT_SERVICE_MAX_FILE_SIZE=104857600
# Command service
DOCS_INTEGRATION_SDK_COMMAND_SERVICE_URL=/coauthoring/CommandService.ashx
# Docbuilder service
DOCS_INTEGRATION_SDK_DOCBUILDER_SERVICE_URL=/docbuilder
# HTTP
DOCS_INTEGRATION_SDK_HTTP_CONNECTION_TIMEOUT=10
DOCS_INTEGRATION_SDK_HTTP_REQUEST_TIMEOUT=10
DOCS_INTEGRATION_SDK_HTTP_IGNORE_SSL=false

View File

@@ -0,0 +1,4 @@
# Authors
* Ascensio System SIA: <integration@onlyoffice.com>

View File

@@ -0,0 +1,26 @@
# Change Log
## 1.0.1
- minor fixes
- fix settings check
## 1.0.0
- common interfaces
- list supported formats
- empty file templates
- demo server settings
## 0.0.5
- default empty templates
## 0.0.4
- minor fixes
## 0.0.3
- support pdf form
## 0.0.2
- remove git submodules
## 0.0.1
- Initial release

View File

@@ -0,0 +1,162 @@
# ONLYOFFICE Docs Integration PHP SDK
ONLYOFFICE Docs Integration PHP SDK provides common interfaces and default implementations for integrating ONLYOFFICE Document Server into your own website or application on PHP.
## Prerequisites
* **PHP**: version 7.4.0 and higher
### Managers
| Manager | Description | Default implementation |
| ----------------------------- | ----------------------------------------------------------------------- | -------------------------------- |
| DocumentManagerInterface | This manager is used for working with files, and string data associated with documents. | DocumentManager (abstract) |
| FormatsManagerInterface | This manager is used for working with document formats. | FormatsManager |
| JwtManagerInterface | This manager is used for generating and verifying authorization tokens. | JwtManager (abstract) |
| SettingsManagerInterface | This manager is used to manage integration application settings. | SettingsManager (abstract) |
### Services
| Service | Description | Default implementation |
| ----------------------------- | ----------------------------------------------------------------------- | -------------------------------- |
| CallbackServiceInterface | This service is used for processing the response of the Document Server. | CallbackService (abstract) |
| DocEditorConfigServiceInterface | This configuration generation service is used for opening the document editor. | DocEditorConfigService |
| RequestServiceInterface | This service is used to make requests to the ONLYOFFICE Document Server. | RequestService (abstract) |
## Usage
1. Implement the methods of the abstract **DocumentManager** class:
```php
public function getDocumentKey(string $fileId, bool $embedded = false)
{
return self::generateRevisionId($fileId);
}
public function getDocumentName(string $fileId)
{
return "sample.docx";
}
public static function getLangMapping()
{
return null;
}
public static function getFileUrl(string $fileId)
{
return "https://example-server.example/fileId/download/";
}
public static function getCallbackUrl(string $fileId)
{
return "https://example-server.example/callback";
}
public static function getGobackUrl(string $fileId)
{
return "https://example-server.example/filelist";
}
public static function getCreateUrl(string $fileId)
{
return "https://example-server.example/fileId";
}
```
2. Implement the methods of the abstract **JwtManager** class (use third-party libraries for JWT encoding and decoding, whichever is convenient for you):
```php
public function encode($token, $key, $algorithm = "HS256")
{
return "SOME.JWT.STRING";
}
public function decode($token, $key, $algorithm = "HS256")
{
return json_encode([]);
}
```
3. Implement the methods of the abstract **SettingsManager** class:
```php
public function getServerUrl()
{
return "https://example-server.example/";
}
public function getSetting($settingName)
{
return null;
}
public function setSetting($settingName, $value, $createSetting = false)
{
// if ($createSetting === true) {
// $this->yourMethodForCreateNewSetting($settingName, $value);
// return;
// }
// $this->yourMethodForSetNewValueForSetting($settingName, $value);
}
```
4. Implement the methods of the abstract **SettingsManager** class:
```php
public function processTrackerStatusEditing()
{
// $someTrackResult["error"] = 0;
// return json_encode($someTrackResult);
}
public function processTrackerStatusMustsave()
{
// $someTrackResult["error"] = 0;
// return json_encode($someTrackResult);
}
public function processTrackerStatusCorrupted()
{
// $someTrackResult["error"] = 0;
// return json_encode($someTrackResult);
}
public function processTrackerStatusClosed()
{
// $someTrackResult["error"] = 0;
// return json_encode($someTrackResult);
}
public function processTrackerStatusForcesave()
{
// $someTrackResult["error"] = 0;
// return json_encode($someTrackResult);
}
```
5. Create a class that implements the **HttpClientInterface** interface (use PHP Client URL Library or any other third-party library to make requests):
```php
class YourHttpClient implements HttpClientInterface
{
public function __construct()
{
$this->responseStatusCode = null;
$this->responseBody = null;
}
public function getStatusCode()
{
return $this->responseStatusCode;
}
public function getBody()
{
return $this->responseBody;
}
public function request($url, $method = 'GET', $opts = [])
{
$this->responseStatusCode = 200;
$this->responseBody = "{\"status\": \"OK\"}";
}
}
```
6. Implement the method of the abstract **RequestService** class:
```php
public function getFileUrlForConvert()
{
return "https://example-server.example/file-url-for-check-convert";
}
```
7. Use DocEditorConfigService to create a config model for the editors in your own controllers.

View File

@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<ruleset name="Custom Standard">
<description>A custom coding standard</description>
<rule ref="PSR2"/>
<rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="120"/>
<property name="absoluteLineLimit" value="0"/>
</properties>
</rule>
<rule ref="Squiz.NamingConventions.ValidVariableName"/>
<rule ref="Squiz.NamingConventions.ValidVariableName.PublicHasUnderscore">
<severity>0</severity>
</rule>
<rule ref="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore">
<severity>0</severity>
</rule>
</ruleset>

View File

@@ -0,0 +1,4 @@
# Authors
* Ascensio System SIA: <integration@onlyoffice.com>

View File

@@ -0,0 +1,15 @@
# Change Log
## 2.0.0
- pdf documentType for djvu, docxf, oform, oxps, pdf, xps
- fb2 additional mime
## 1.1.0
- filling pdf
- conversion formats for txt, csv
- formats for auto conversion
## 1.0.0
- formats for viewing, editing and lossy editing
- formats for conversions
- mime-types of formats

View File

@@ -0,0 +1,52 @@
## Overview
This repository contains the list of file formats (electronic documents, forms, spreadsheets, presentations) supported by ONLYOFFICE editors and describes the properties of each file format type.
The repository is used in:
* [Document Server integration example](https://github.com/ONLYOFFICE/document-server-integration)
* [ONLYOFFICE Docs Integration Java SDK](https://github.com/ONLYOFFICE/docs-integration-sdk-java)
* [ONLYOFFICE Docs Integration PHP SDK](https://github.com/ONLYOFFICE/docs-integration-sdk-php)
* [Nextcloud ONLYOFFICE integration app](https://github.com/ONLYOFFICE/onlyoffice-nextcloud)
* [Nuxeo ONLYOFFICE integration plugin](https://github.com/ONLYOFFICE/onlyoffice-nuxeo)
* [ONLYOFFICE integration app for Confluence Cloud](https://github.com/ONLYOFFICE/onlyoffice-confluence-cloud)
* [ownCloud ONLYOFFICE integration app](https://github.com/ONLYOFFICE/onlyoffice-owncloud)
* [Redmine ONLYOFFICE Integration Plugin](https://github.com/ONLYOFFICE/onlyoffice-redmine)
* [WordPress ONLYOFFICE integration plugin](https://github.com/ONLYOFFICE/onlyoffice-wordpress)
## Project info
ONLYOFFICE Docs (Document Server): [github.com/ONLYOFFICE/DocumentServer](https://github.com/ONLYOFFICE/DocumentServer)
Official website: [www.onlyoffice.com](https://www.onlyoffice.com/)
## Supported formats
**For viewing:**
* **WORD**: DOC, DOCM, DOCX, DOT, DOTM, DOTX, EPUB, FB2, FODT, HTM, HTML, MHT, MHTML, ODT, OTT, RTF, STW, SXW, TXT, WPS, WPT, XML
* **CELL**: CSV, ET, ETT, FODS, ODS, OTS, SXC, XLS, XLSB, XLSM, XLSX, XLT, XLTM, XLTX
* **SLIDE**: DPS, DPT, FODP, ODP, OTP, POT, POTM, POTX, PPS, PPSM, PPSX, PPT, PPTM, PPTX, SXI
* **PDF**: DJVU, DOCXF, OFORM, OXPS, PDF, XPS
**For editing:**
* **WORD**: DOCM, DOCX, DOTM, DOTX
* **CELL**: XLSM, XLSX, XLTM, XLTX
* **SLIDE**: POTM, POTX, PPSM, PPSX, PPTM, PPTX
* **PDF**: PDF
**For editing with possible loss of information:**
* **WORD**: EPUB, FB2, HTML, ODT, OTT, RTF, TXT
* **CELL**: CSV, ODS, OTS
* **SLIDE**: ODP, OTP
**For filling:**
* **PDF**: PDF
**For converting to Office Open XML formats:**
* **WORD:** DOC, DOCM, DOT, DOTM, DOTX, EPUB, FB2, FODT, HTM, HTML, MHT, MHTML, ODT, OTT, RTF, STW, SXW, WPS, WPT, XML
* **CELL:** ET, ETT, FODS, ODS, OTS, SXC, XLS, XLSB, XLSM, XLT, XLTM, XLTX
* **SLIDE:** DPS, DPT, FODP, ODP, OTP, POT, POTM, POTX, PPS, PPSM, PPSX, PPT, PPTM, SXI
* **PDF**: DOCXF, OXPS, PDF, XPS

View File

@@ -0,0 +1,288 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Manager\Document;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
use Onlyoffice\DocsIntegrationSdk\Manager\Settings\SettingsManager;
use Onlyoffice\DocsIntegrationSdk\Manager\Document\DocumentManagerInterface;
use Onlyoffice\DocsIntegrationSdk\Models\Format;
use Onlyoffice\DocsIntegrationSdk\Manager\Formats\FormatsManager;
use Onlyoffice\DocsIntegrationSdk\Util\CommonError;
abstract class DocumentManager implements DocumentManagerInterface
{
private const PATHINFO_DIRNAME = "dirname";
private const PATHINFO_BASENAME = "basename";
private const PATHINFO_EXTENSION = "extension";
private const PATHINFO_FILENAME = "filename";
private const FORMATINFO_TYPE = "type";
private const FORMATINFO_ACTIONS = "actions";
private const FORMATINFO_CONVERT = "convert";
private const FORMATINFO_MIMES = "mimes";
private const FORMATINFO_MIME = "mime";
/**
* Formats list
*/
public $formats;
public $locale;
public $lang;
public $settingsManager;
public const APP_NAME = "onlyoffice";
abstract public function getDocumentKey(string $fileId, bool $embedded);
abstract public function getDocumentName(string $fileId);
abstract public static function getLangMapping();
abstract public function getFileUrl(string $fileId);
abstract public function getCallbackUrl(string $fileId);
abstract public function getGobackUrl(string $fileId);
abstract public function getCreateUrl(string $fileId);
public function __construct(
SettingsManager $settingsManager,
FormatsManager $formats = null,
$systemLangCode = "en"
) {
$this->lang = $systemLangCode;
$this->lang = $systemLangCode;
if (empty($formats)) {
$formats = new FormatsManager(true);
}
if (isset(static::getLangMapping()[$systemLangCode]) && !empty(static::getLangMapping()[$systemLangCode])) {
$locale = static::getLangMapping()[$systemLangCode];
} else {
$locale = "default";
}
$this->formats = $formats;
$this->settingsManager = $settingsManager;
}
public function getEmptyTemplate($fileExt)
{
$filePath = dirname(dirname(dirname(__DIR__)))
.DIRECTORY_SEPARATOR.
"resources".
DIRECTORY_SEPARATOR.
"assets".
DIRECTORY_SEPARATOR.
"document-templates".
DIRECTORY_SEPARATOR.
$this->locale.
DIRECTORY_SEPARATOR.
"new.".
$fileExt;
if (!file_exists($filePath)) {
throw new \Exception(CommonError::message(CommonError::FILE_TEMPLATE_IS_NOT_EXISTS));
}
return $filePath;
}
/**
* Get temporary file
*
* @return array
*/
public function getTempFile()
{
$fileUrl = null;
$templatePath = $this->getEmptyTemplate("docx");
$fileUrl = $this->getFileUrl("new.docx");
return [
"fileUrl" => $fileUrl,
"filePath" => $templatePath
];
}
public function getFormatInfo(string $extension, string $option = null)
{
$search = null;
$formats = $this->formats->getFormatsList();
if (!array_key_exists($extension, $formats)) {
foreach ($formats as $format) {
if ($format->getName() === $extension) {
$search = $format;
break;
}
}
if ($search === null) {
return null;
}
} else {
$search = $formats[$extension];
}
switch ($option) {
case self::FORMATINFO_TYPE:
return $search->getType();
case self::FORMATINFO_ACTIONS:
return $search->getActions();
case self::FORMATINFO_CONVERT:
return $search->getConvert();
case self::FORMATINFO_MIMES:
return $search->getMimes();
case self::FORMATINFO_MIME:
return $search->getMimes()[0];
default:
return $search;
}
}
/**
* Return file type by extension
*/
public function getDocType(string $extension)
{
return $this->getFormatInfo($extension, self::FORMATINFO_TYPE);
}
/**
* Return actions for file by extension
*/
public function getDocActions(string $extension)
{
return $this->getFormatInfo($extension, self::FORMATINFO_ACTIONS);
}
/**
* Return convert extensions for file by current extension
*/
public function getDocConvert(string $extension)
{
return $this->getFormatInfo($extension, self::FORMATINFO_CONVERT);
}
/**
* Return array of all mime types for file by extension
*/
public function getDocMimes(string $extension)
{
return $this->getFormatInfo($extension, self::FORMATINFO_MIMES);
}
/**
* Return mime type of the file by extension
*/
public function getDocMimeType(string $extension)
{
return $this->getFormatInfo($extension, self::FORMATINFO_MIME);
}
/**
* Return file path info
*/
public function getPathInfo(string $filePath, string $option = null)
{
$result = ["dirname" => "", "basename" => "", "extension" => "", "filename" => ""];
$pathInfo = [];
if (preg_match("#^(.*?)[\\\\/]*(([^/\\\\]*?)(\.([^.\\\\/]+?)|))[\\\\/.]*$#m", $filePath, $pathInfo)) {
if (array_key_exists(1, $pathInfo)) {
$result["dirname"] = $pathInfo[1];
}
if (array_key_exists(2, $pathInfo)) {
$result["basename"] = $pathInfo[2];
}
if (array_key_exists(5, $pathInfo)) {
$result["extension"] = mb_strtolower($pathInfo[5]);
}
if (array_key_exists(3, $pathInfo)) {
$result["filename"] = $pathInfo[3];
}
}
switch ($option) {
case self::PATHINFO_DIRNAME:
return $result["dirname"];
case self::PATHINFO_BASENAME:
return $result["basename"];
case self::PATHINFO_EXTENSION:
return $result["extension"];
case self::PATHINFO_FILENAME:
return $result["filename"];
default:
return $result;
}
}
public function getDirName(string $filePath)
{
return $this->getPathInfo($filePath, self::PATHINFO_DIRNAME);
}
public function getBaseName(string $filePath)
{
return $this->getPathInfo($filePath, self::PATHINFO_BASENAME);
}
public function getExt(string $filePath)
{
return $this->getPathInfo($filePath, self::PATHINFO_EXTENSION);
}
public function getFileName(string $filePath)
{
return $this->getPathInfo($filePath, self::PATHINFO_FILENAME);
}
public function isDocumentViewable(string $filePath)
{
return $this->getFormatInfo($this->getExt($filePath))->isViewable();
}
public function isDocumentEditable(string $filePath)
{
return $this->getFormatInfo($this->getExt($filePath))->isEditable();
}
public function isDocumentConvertable(string $filePath)
{
return $this->getFormatInfo($this->getExt($filePath))->isAutoConvertable();
}
public function isDocumentFillable(string $filePath)
{
return $this->getFormatInfo($this->getExt($filePath))->isFillable();
}
public function isDocumentReadOnly(string $filePath = "")
{
return false;
}
public function getDocumentAccessRights(string $filePath = "")
{
return true;
}
/**
* Translation key to a supported form
*/
public static function generateRevisionId(string $expectedKey)
{
if (strlen($expectedKey) > 20) {
$expectedKey = crc32($expectedKey);
}
$key = preg_replace("[^0-9-.a-zA-Z_=]", "_", $expectedKey);
$key = substr($key, 0, min(array(strlen($key), 20)));
return $key;
}
}

View File

@@ -0,0 +1,214 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Manager\Document;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
interface DocumentManagerInterface
{
/**
* Generates a unique document identifier used by the service to recognize the document.
*
* @param string $fileId The file ID.
* @param bool $embedded Specifies if the editor is opened in the embedded mode (true) or not (false).
* @throws Exception If the processing fails unexpectedly.
* @return string The unique document identifier.
*/
public function getDocumentKey(string $fileId, bool $embedded);
/**
* Returns the document name by file ID.
*
* @param string $fileId The file ID.
* @throws Exception If the processing fails unexpectedly.
* @return string Document name
*/
public function getDocumentName(string $fileId);
/**
* Returns the locale by lang code
*
* @throws Exception If the processing fails unexpectedly.
* @return string Locale
*/
public static function getLangMapping();
/**
* Returns the URL to download a file with the ID specified in the request.
*
* @param string $fileId The file ID.
* @throws Exception If the processing fails unexpectedly.
* @return string The URL to download a file.
*/
public function getFileUrl(string $fileId);
/**
* Returns the URL to the callback handler.
*
* @param string $fileId The file ID.
* @throws Exception If the processing fails unexpectedly.
* @return string The URL to the callback handler.
*/
public function getCallbackUrl(string $fileId);
/**
* Returns the URL to the location folder of a file with the ID specified in the request.
*
* @param string $fileId The file ID.
* @throws Exception If the processing fails unexpectedly.
* @return string The URL to the file location folder.
*/
public function getGobackUrl(string $fileId);
/**
* Returns the URL to create a new file with the ID specified in the request.
*
* @param string $fileId The file ID.
* @throws Exception If the processing fails unexpectedly.
* @return string The URL to create a new file.
*/
public function getCreateUrl(string $fileId);
/**
* Returns the path of empty file from assets/document-templates by extension.
*
* @param string $fileExt Extension of the file.
* @throws Exception If the processing fails unexpectedly.
* @return string The URL to create a new file.
*/
public function getEmptyTemplate(string $fileExt);
/**
* Returns temporary file info (path and url as array)
*
* @throws Exception If the processing fails unexpectedly.
* @return array Temporary file info.
*/
public function getTempFile();
/**
* Return file type by extension
*
* @param string $extension Extension of the file.
* @throws Exception If the processing fails unexpectedly.
* @return string File type
*/
public function getDocType(string $extension);
/**
* Return actions for file by extension
*
* @param string $extension Extension of the file.
* @throws Exception If the processing fails unexpectedly.
* @return array Actions for file by extension
*/
public function getDocActions(string $extension);
/**
* Return convert extensions for file by current extension
*
* @param string $extension Extension of the file.
* @throws Exception If the processing fails unexpectedly.
* @return array Convert extensions for file by current extension
*/
public function getDocConvert(string $extension);
/**
* Return array of all mime types for file by extension
*
* @param string $extension Extension of the file.
* @throws Exception If the processing fails unexpectedly.
* @return array All mime types for file by extension
*/
public function getDocMimes(string $extension);
/**
* Return one mime type of the file by extension
*
* @param string $extension Extension of the file.
* @throws Exception If the processing fails unexpectedly.
* @return string Mime type of the file by extension
*/
public function getDocMimeType(string $extension);
/**
* Returns the file base name without the full path and extension.
*
* @param string $filePath The file path.
* @return string The file name without the extension or null if the file name is empty.
*/
public function getBaseName(string $filePath);
/**
* Returns the file extension.
*
* @param string $filePath The file path.
* @return string The file extension.
*/
public function getExt(string $filePath);
/**
* Returns the file name.
*
* @param string $filePath The file path.
* @return string The file name.
*/
public function getFileName(string $filePath);
/**
* Determines whether a document with a name specified in the request is viewable.
*
* @param string $filePath The file path.
* @return bool True if the document is viewable.
*/
public function isDocumentViewable(string $filePath);
/**
* Determines whether a document with a name specified in the request is editable.
*
* @param string $filePath The file path.
* @return bool True if the document is editable.
*/
public function isDocumentEditable(string $filePath);
/**
* Determines whether a document with a name specified in the request is convertable.
*
* @param string $filePath The file path.
* @return bool True if the document is convertable.
*/
public function isDocumentConvertable(string $filePath);
/**
* Determines whether a document with a name specified in the request is fillable.
*
* @param string $filePath The file path.
* @return bool True if the document is fillable.
*/
public function isDocumentFillable(string $filePath);
/**
* Translation key to a supported form
*
* @param string $expectedKey The expected key for document.
* @return string Generated key
*/
public static function generateRevisionId(string $expectedKey);
}

View File

@@ -0,0 +1,151 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Manager\Formats;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
use Onlyoffice\DocsIntegrationSdk\Util\CommonError;
use Onlyoffice\DocsIntegrationSdk\Models\Format;
/**
* Document formats manager.
*
* @package Onlyoffice\DocsIntegrationSdk\Manager\Formats
*/
class FormatsManager implements FormatsManagerInterface
{
/**
* List of formats
*
* @var array
*/
protected $formatsList;
public function __construct($nameAssoc = false)
{
$formats = self::getFormats();
if ($nameAssoc === false) {
$this->formatsList = self::buildDefaultFormatsArray($formats);
} else {
$this->formatsList = self::buildNamedFormatsArray($formats);
}
}
protected static function buildDefaultFormatsArray(array $formats)
{
$formatsList = [];
foreach ($formats as $format) {
array_push($formatsList, new Format(
$format->name,
$format->type,
$format->actions,
$format->convert,
$format->mime
));
}
return $formatsList;
}
protected static function buildNamedFormatsArray(array $formats)
{
$formatsList = [];
foreach ($formats as $format) {
$currentFormat = new Format(
$format->name,
$format->type,
$format->actions,
$format->convert,
$format->mime
);
$formatsList[$currentFormat->getName()] = $currentFormat;
}
return $formatsList;
}
private static function getFormats()
{
$formats = file_get_contents(dirname(dirname(dirname(__DIR__))).
DIRECTORY_SEPARATOR.
"resources".
DIRECTORY_SEPARATOR.
"assets".
DIRECTORY_SEPARATOR.
"document-formats".
DIRECTORY_SEPARATOR.
"onlyoffice-docs-formats.json");
if (!empty($formats)) {
$formats = json_decode($formats);
if (!empty($formats)) {
return $formats;
}
throw new \Exception(CommonError::message(CommonError::EMPTY_FORMATS_ASSET));
}
throw new \Exception(CommonError::message(CommonError::EMPTY_FORMATS_ASSET));
}
public function getFormatsList()
{
return $this->formatsList;
}
public function getViewableList()
{
$viewableList = [];
foreach ($this->formatsList as $format) {
if ($format->isViewable()) {
array_push($viewableList, $format);
}
}
return $viewableList;
}
public function getEditableList()
{
$editableList = [];
foreach ($this->formatsList as $format) {
if ($format->isEditable()) {
array_push($editableList, $format);
}
}
return $editableList;
}
public function getConvertableList()
{
$convertableList = [];
foreach ($this->formatsList as $format) {
if ($format->isAutoConvertable()) {
array_push($convertableList, $format);
}
}
return $convertableList;
}
public function getFillableList()
{
$fillableList = [];
foreach ($this->formatsList as $format) {
if ($format->isFillable()) {
array_push($fillableList, $format);
}
}
return $fillableList;
}
}

View File

@@ -0,0 +1,66 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Manager\Formats;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
/**
* Interface Formats.
*
* @package Onlyoffice\DocsIntegrationSdk\Manager\Formats
*/
interface FormatsManagerInterface
{
/**
* Returns the list of all formats.
*
* @return array List of all formats
*/
public function getFormatsList();
/**
* Returns the list of viewable formats.
*
* @return array List of viewable formats
*/
public function getViewableList();
/**
* Returns the list of editable formats.
*
* @return array List of editable formats
*/
public function getEditableList();
/**
* Returns the list of convertable formats.
*
* @return array List of convertable formats
*/
public function getConvertableList();
/**
* Returns the list of fillable formats.
*
* @return array List of fillable formats
*/
public function getFillableList();
}

View File

@@ -0,0 +1,109 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Manager\Security;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
use Onlyoffice\DocsIntegrationSdk\Manager\Settings\SettingsManager;
use Onlyoffice\DocsIntegrationSdk\Manager\Security\JwtManagerInterface;
use Firebase\JWT\JWT;
use Firebase\JWT\Key;
/**
* Default JWT Manager.
*
* @package Onlyoffice\DocsIntegrationSdk\Manager\Security
*/
abstract class JwtManager implements JwtManagerInterface
{
private SettingsManager $settingsManager;
public function __construct(SettingsManager $settingsManager)
{
$this->settingsManager = $settingsManager;
}
abstract public function encode($payload, $key, $algorithm = "HS256");
abstract public function decode($token, $key, $algorithm = "HS256");
/**
* Check if a secret key to generate token exists or not.
*
* @return bool
*/
public function isJwtEnabled()
{
return !empty($this->settingsManager->getJwtKey());
}
/**
* Encode a payload object into a token using a secret key
*
* @param array $payload
*
* @return string
*/
public function jwtEncode($payload, $key = null)
{
if (empty($key)) {
$key = $this->settingsManager->getJwtKey();
}
return $this->encode($payload, $key);
}
/**
* Decode a token into a payload object using a secret key
*
* @param string $token
*
* @return string
*/
public function jwtDecode($token)
{
try {
$payload = $this->decode($token, $this->settingsManager->getJwtKey());
} catch (\UnexpectedValueException $e) {
$payload = "";
}
return $payload;
}
/**
* Create an object from the token
*
* @param string $token - token
*
* @return array
*/
public function readHash($token, $securityKey)
{
$result = null;
$error = null;
if ($token === null) {
return [$result, "Token is empty"];
}
try {
$result = $this->decode($token, $securityKey);
} catch (\UnexpectedValueException $e) {
$error = $e->getMessage();
}
return [$result, $error];
}
}

View File

@@ -0,0 +1,59 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Manager\Security;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
/**
* Interface JwtManager.
*
* @package Onlyoffice\DocsIntegrationSdk\Manager\Security
*/
interface JwtManagerInterface
{
/**
* Checks is JWT enabled or not.
*
* @throws Exception If the processing fails unexpectedly.
* @return bool True if JWT is enabled.
*/
public function isJwtEnabled();
/**
* Encode a payload object into a token using a secret key
*
* @param array $payload
* @param string $key
*
* @return string
*/
public function jwtEncode($payload, $key);
/**
* Create an object from the token
*
* @param string $token
* @param string $securityKey
*
* @return array
*/
public function readHash($token, $securityKey);
}

View File

@@ -0,0 +1,435 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Manager\Settings;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
use Onlyoffice\DocsIntegrationSdk\Manager\Settings\SettingsManagerInterface;
use Onlyoffice\DocsIntegrationSdk\Util\EnvUtil;
use Dotenv\Dotenv;
/**
* Default Settings Manager.
*
* @package Onlyoffice\DocsIntegrationSdk\Manager\Settings
*/
abstract class SettingsManager implements SettingsManagerInterface
{
abstract public function getServerUrl();
abstract public function getSetting($settingName);
abstract public function setSetting($settingName, $value, $createSetting = false);
/**
* The settings key for the demo server
*
* @var string
*/
protected $useDemoName = "demo";
/**
* The settings key for the document server address
*
* @var string
*/
protected $documentServerUrl = "documentServerUrl";
/**
* The config key for the document server address available from storage
*
* @var string
*/
protected $documentServerInternalUrl = "documentServerInternalUrl";
/**
* The config key for the storage url
*
* @var string
*/
protected $storageUrl = "storageUrl";
/**
* The config key for JWT header
*
* @var string
*/
protected $jwtHeader = "jwtHeader";
/**
* The config key for JWT secret key
*
* @var string
*/
protected $jwtKey = "jwtKey";
/**
* The config key for JWT prefix
*
* @var string
*/
protected $jwtPrefix = "jwtPrefix";
/**
* The config key for JWT leeway
*
* @var string
*/
protected $jwtLeeway = "jwtLeeway";
/**
* The config key for HTTP ignore SSL setting
*
* @var string
*/
protected $httpIgnoreSSL = "ignoreSSL";
/** The demo url. */
protected const DEMO_URL = "https://onlinedocs.docs.onlyoffice.com/";
/** The demo security header. */
protected const DEMO_JWT_HEADER = "AuthorizationJWT";
/** The demo security key. */
protected const DEMO_JWT_KEY = "sn2puSUF7muF5Jas";
/** The demo security prefix. */
protected const DEMO_JWT_PREFIX = "Bearer ";
/** The number of days that the demo server can be used. */
protected const DEMO_TRIAL_PERIOD = 30;
protected const ENV_SETTINGS_PREFIX = "DOCS_INTEGRATION_SDK";
public function __construct()
{
EnvUtil::loadEnvSettings();
}
/**
* Get status of demo server
*
* @return bool
*/
public function useDemo()
{
return $this->getDemoData()["enabled"] === true;
}
/**
* Get demo data
*
* @return array
*/
public function getDemoData()
{
$data = $this->getSetting($this->useDemoName);
if (empty($data)) {
$data = [
"available" => true,
"enabled" => false
];
$this->setSetting($this->useDemoName, json_encode($data), true);
return $data;
}
$data = json_decode($data, true);
if (isset($data['start'])) {
$overdue = $data["start"];
$overdue += 24 * 60 * 60 *$this->getDemoParams()["TRIAL"];
if ($overdue > time()) {
$data["available"] = true;
$data["enabled"] = $data["enabled"] === true;
} else {
$data["available"] = false;
$data["enabled"] = false;
$this->setSetting($this->useDemoName, json_encode($data));
}
}
return $data;
}
/**
* Switch on demo server
*
* @param bool $value - select demo
*
* @return bool
*/
public function selectDemo($value)
{
$data = $this->getDemoData();
if ($value === true && !$data["available"]) {
return false;
}
$data["enabled"] = $value === true;
if (!isset($data["start"])) {
$data["start"] = time();
}
$this->setSetting($this->useDemoName, json_encode($data));
return true;
}
private function getBaseSettingValue(string $settingKey, string $envKey, string $demoKey = "")
{
if ($this->useDemo() && !empty($demoKey)) {
return $demoKey;
}
$settingValue = $this->getSetting($settingKey);
if (empty($settingValue) && !empty($_ENV[$envKey])) {
$settingValue = $_ENV[$envKey];
}
return $settingValue;
}
/**
* Get the document service address from the application configuration
*
* @return string
*/
public function getDocumentServerUrl()
{
$url = $this->getBaseSettingValue(
$this->documentServerUrl,
EnvUtil::envKey("DOCUMENT_SERVER_URL"),
self::DEMO_URL
);
$url = !empty($url) ? $this->normalizeUrl($url) : "";
return (string)$url;
}
public function getDocumentServerInternalUrl()
{
if ($this->useDemo()) {
return $this->getDocumentServerUrl();
}
$url = $this->getSetting($this->documentServerInternalUrl);
if (empty($url)) {
return $this->getDocumentServerUrl();
}
return (string)$url;
}
public function getStorageUrl()
{
$url = $this->getSetting($this->storageUrl);
return !empty($url) ? $url : "";
}
/**
* Replace domain in document server url with internal address from configuration
*
* @param string $url - document server url
*
* @return string
*/
public function replaceDocumentServerUrlToInternal($url)
{
$documentServerUrl = $this->getDocumentServerInternalUrl();
if (!empty($documentServerUrl)) {
$from = $this->getDocumentServerUrl();
if (!preg_match("/^https?:\/\//i", $from)) {
$parsedUrl = parse_url($url);
$from = $parsedUrl["scheme"].
"://".
$parsedUrl["host"].
(array_key_exists("port", $parsedUrl) ? (":" . $parsedUrl["port"]) : "") . $from;
}
$url = $from !== $documentServerUrl ?? str_replace($from, $documentServerUrl, $url);
}
return $url;
}
private function getDocumentServerCustomUrl($settingKey, $useInternalUrl = false)
{
if (!$useInternalUrl) {
$serverUrl = $this->getDocumentServerUrl();
} else {
$serverUrl = $this->getDocumentServerInternalUrl();
}
$customUrl = "";
if (!empty($serverUrl) && !empty($_ENV[EnvUtil::envKey($settingKey)])) {
$customUrl = $_ENV[EnvUtil::envKey($settingKey)];
$customUrl = $this->normalizeUrl($serverUrl .= $customUrl);
}
return (string)$customUrl;
}
/**
* Get the document server API URL
*
* @return string
*/
public function getDocumentServerApiUrl($useInternalUrl = false)
{
return $this->getDocumentServerCustomUrl("DOCUMENT_SERVER_API_URL", $useInternalUrl) ?:
$this->normalizeUrl($this->getDocumentServerUrl()."/web-apps/apps/api/documents/api.js");
}
/**
* Get the document server preloader url
*
* @return string
*/
public function getDocumentServerPreloaderUrl($useInternalUrl = false)
{
return $this->getDocumentServerCustomUrl("DOCUMENT_SERVER_API_PRELOADER_URL", $useInternalUrl) ?:
$this->normalizeUrl($this->getDocumentServerUrl()."/web-apps/apps/api/documents/cache-scripts.html");
}
/**
* Get the document server healthcheck url
*
* @return string
*/
public function getDocumentServerHealthcheckUrl($useInternalUrl = false)
{
return $this->getDocumentServerCustomUrl("DOCUMENT_SERVER_HEALTHCHECK_URL", $useInternalUrl) ?:
$this->normalizeUrl($this->getDocumentServerUrl()."/healthcheck");
}
/**
* Get the convert service url
*
* @return string
*/
public function getConvertServiceUrl($useInternalUrl = false)
{
return $this->getDocumentServerCustomUrl("CONVERT_SERVICE_URL", $useInternalUrl) ?:
$this->normalizeUrl($this->getDocumentServerUrl()."/ConvertService.ashx");
}
/**
* Get the command service url
*
* @return string
*/
public function getCommandServiceUrl($useInternalUrl = false)
{
return $this->getDocumentServerCustomUrl("COMMAND_SERVICE_URL", $useInternalUrl) ?:
$this->normalizeUrl($this->getDocumentServerUrl()."/coauthoring/CommandService.ashx");
}
/**
* Get the JWT Header
*
* @return string
*/
public function getJwtHeader()
{
$jwtHeader = $this->getBaseSettingValue($this->jwtHeader, EnvUtil::envKey("JWT_HEADER"), self::DEMO_JWT_HEADER);
return (string)$jwtHeader;
}
/**
* Get the JWT secret
*
* @return string
*/
public function getJwtKey()
{
$jwtKey = $this->getBaseSettingValue($this->jwtKey, EnvUtil::envKey("JWT_KEY"), self::DEMO_JWT_KEY);
return (string)$jwtKey;
}
/**
* Get the JWT prefix
*
* @return string
*/
public function getJwtPrefix()
{
$jwtPrefix = $this->getBaseSettingValue($this->jwtPrefix, EnvUtil::envKey("JWT_PREFIX"), self::DEMO_JWT_PREFIX);
return (string)$jwtPrefix;
}
/**
* Get the JWT leeway
*
* @return string
*/
public function getJwtLeeway()
{
$jwtLeeway = $this->getBaseSettingValue($this->jwtLeeway, EnvUtil::envKey("JWT_LEEWAY"));
return (string)$jwtLeeway;
}
/**
* Get the ignore SSL value
*
* @return bool
*/
public function isIgnoreSSL()
{
if (!$this->useDemo()) {
return boolval($this->getBaseSettingValue($this->httpIgnoreSSL, EnvUtil::envKey("HTTP_IGNORE_SSL")))
=== true;
}
return false;
}
/**
* Get demo params
*
* @return array
*/
public function getDemoParams()
{
return [
"ADDR" => self::DEMO_URL,
"HEADER" => self::DEMO_JWT_HEADER,
"SECRET" => self::DEMO_JWT_KEY,
"PREFIX" => self::DEMO_JWT_PREFIX,
"TRIAL" => self::DEMO_TRIAL_PERIOD
];
}
/**
* Add backslash to url if it's needed
*
* @return string
*/
public function processUrl($url)
{
if ($url !== null && $url !== "/") {
$url = rtrim($url, "/");
if (strlen($url) > 0) {
$url = $url . "/";
}
}
return $url;
}
public function normalizeUrl($url)
{
$url = preg_replace('/([^:])(\/{2,})/', '$1/', $url);
$url = filter_var($url, FILTER_SANITIZE_URL);
return $url;
}
}

View File

@@ -0,0 +1,150 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Manager\Settings;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
/**
* Interface Settings Manager.
*
* @package Onlyoffice\DocsIntegrationSdk\Manager\Settings
*/
interface SettingsManagerInterface
{
/**
* Get the setting value by setting name.
*
* @param string $settingName Name of setting.
* @throws Exception If the processing fails unexpectedly.
*/
public function getSetting($settingName);
/**
* Set the setting value.
*
* @param string $settingName Name of setting.
* @param $value Value of setting.
* @param bool $createSetting If True, then create a new setting with the value.
* @throws Exception If the processing fails unexpectedly.
*/
public function setSetting($settingName, $value, $createSetting);
/**
* Get status of demo server
*
* @return bool
*/
public function useDemo();
/**
* Get the data for demo connection
*
* @return array
*/
public function getDemoData();
/**
* Switch on demo server
*
* @param bool $value - select demo
*
* @return bool
*/
public function selectDemo($value);
/**
* Get the document service address from the application configuration
*
* @return string
*/
public function getDocumentServerUrl();
/**
* Get the document server API URL from the application configuration
*
* @return string
*/
public function getDocumentServerApiUrl();
/**
* Get the preloader URL from the application configuration
*
* @return string
*/
public function getDocumentServerPreloaderUrl();
/**
* Get the healthcheck URL from the application configuration
*
* @return string
*/
public function getDocumentServerHealthcheckUrl();
/**
* Get the convert service URL from the application configuration
*
* @return string
*/
public function getConvertServiceUrl();
/**
* Get the command service URL from the application configuration
*
* @return string
*/
public function getCommandServiceUrl();
/**
* Get the JWT Header
*
* @return string
*/
public function getJwtHeader();
/**
* Get the JWT Key
*
* @return string
*/
public function getJwtKey();
/**
* Get the JWT prefix
*
* @return string
*/
public function getJwtPrefix();
/**
* Get the JWT Leeway
*
* @return string
*/
public function getJwtLeeway();
/**
* Checks whether the setting to ignore SSL certificate is enabled.
*
* @return bool True if the setting to ignore SSL certificate is enabled.
*/
public function isIgnoreSSL();
}

View File

@@ -0,0 +1,66 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
class Anonymous extends JsonSerializable
{
protected $request;
protected $label;
public function __construct(bool $request = true, string $label = "Guest")
{
$this->request = $request;
$this->label = $label;
}
/**
* Get the value of request
*/
public function getRequest()
{
return $this->request;
}
/**
* Set the value of request
*/
public function setRequest($request)
{
$this->request = $request;
}
/**
* Get the value of label
*/
public function getLabel()
{
return $this->label;
}
/**
* Set the value of label
*/
public function setLabel($label)
{
$this->label = $label;
}
}

View File

@@ -0,0 +1,223 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
use Onlyoffice\DocsIntegrationSdk\Models\CallbackAction;
use Onlyoffice\DocsIntegrationSdk\Models\CallbackForceSaveType;
use Onlyoffice\DocsIntegrationSdk\Models\CallbackDocStatus;
use Onlyoffice\DocsIntegrationSdk\Models\History;
class Callback extends JsonSerializable
{
protected $actions; //array of CallbackAction
protected $changesurl;
protected $fileType;
protected $forceSaveType;
protected $history;
protected $key;
protected $status;
protected $url;
protected $users;
protected $token;
public function __construct(
array $actions = [],
string $changesurl = "",
string $fileType = "",
CallbackForceSaveType $forceSaveType = null,
History $history = null,
string $key = "",
CallbackDocStatus $status = null,
string $url = "",
array $users = [],
string $token = ""
) {
$this->actions = $actions;
$this->changesurl = $changesurl;
$this->fileType = $fileType;
$this->forceSaveType = $forceSaveType !== null ? $forceSaveType : new CallbackForceSaveType;
$this->history = $history !== null ? $history : new History;
$this->key = $key;
$this->status = $status !== null ? $status : new CallbackDocStatus;
$this->url = $url;
$this->users = $users;
$this->token = $token;
}
/**
* Get the value of actions
*/
public function getActions()
{
return $this->actions;
}
/**
* Set the value of actions
*/
public function setActions($actions)
{
$this->actions = $actions;
}
/**
* Get the value of changesurl
*/
public function getChangesurl()
{
return $this->changesurl;
}
/**
* Set the value of changesurl
*/
public function setChangesurl($changesurl)
{
$this->changesurl = $changesurl;
}
/**
* Get the value of fileType
*/
public function getFileType()
{
return $this->fileType;
}
/**
* Set the value of fileType
*/
public function setFileType($fileType)
{
$this->fileType = $fileType;
}
/**
* Get the value of forceSaveType
*/
public function getForceSaveType()
{
return $this->forceSaveType;
}
/**
* Set the value of forceSaveType
*/
public function setForceSaveType($forceSaveType)
{
$this->forceSaveType = $forceSaveType;
}
/**
* Get the value of history
*/
public function getHistory()
{
return $this->history;
}
/**
* Set the value of history
*/
public function setHistory($history)
{
$this->history = $history;
}
/**
* Get the value of key
*/
public function getKey()
{
return $this->key;
}
/**
* Set the value of key
*/
public function setKey($key)
{
$this->key = $key;
}
/**
* Get the value of status
*/
public function getStatus()
{
return $this->status;
}
/**
* Set the value of status
*/
public function setStatus($status)
{
$this->status = $status;
}
/**
* Get the value of url
*/
public function getUrl()
{
return $this->url;
}
/**
* Set the value of url
*/
public function setUrl($url)
{
$this->url = $url;
}
/**
* Get the value of users
*/
public function getUsers()
{
return $this->users;
}
/**
* Set the value of users
*/
public function setUsers($users)
{
$this->users = $users;
}
/**
* Get the value of token
*/
public function getToken()
{
return $this->token;
}
/**
* Set the value of token
*/
public function setToken($token)
{
$this->token = $token;
}
}

View File

@@ -0,0 +1,66 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
use Onlyoffice\DocsIntegrationSdk\Models\CallbackActionType;
class CallbackAction extends JsonSerializable
{
protected $type;
protected $userId;
public function __construct(CallbackActionType $type = null, string $userId = "")
{
$this->type = $type !== null ? $type : new CallbackActionType;
$this->userId = $userId;
}
/**
* Get the value of type
*/
public function getType()
{
return $this->type;
}
/**
* Set the value of type
*/
public function setType($type)
{
$this->type = $type;
}
/**
* Get the value of userId
*/
public function getUserId()
{
return $this->userId;
}
/**
* Set the value of userId
*/
public function setUserId($userId)
{
$this->userId = $userId;
}
}

View File

@@ -0,0 +1,38 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
use Onlyoffice\DocsIntegrationSdk\Util\BasicEnum;
class CallbackActionType extends BasicEnum
{
const DISCONNECTED = 0;
const CONNECTED = 1;
const CLICK_FORCESAVE = 2;
public function __construct($type = null)
{
if (!self::isValidValue($type) && $type !== null) {
throw new \Exception("Unknown callback action type");
} else {
$this->value = $type;
}
}
}

View File

@@ -0,0 +1,41 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
use Onlyoffice\DocsIntegrationSdk\Util\BasicEnum;
class CallbackDocStatus extends BasicEnum
{
const EDITING = 1;
const SAVE = 2;
const SAVE_CORRUPTED = 3;
const CLOSED = 4;
const FORCESAVE = 6;
const FORCESAVE_CORRUPTED = 7;
public function __construct($status = null)
{
if (!self::isValidValue($status) && $status !== null) {
throw new \Exception("Unknown callback document status");
} else {
$this->value= $status;
}
}
}

View File

@@ -0,0 +1,38 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
use Onlyoffice\DocsIntegrationSdk\Util\BasicEnum;
class CallbackForceSaveType extends BasicEnum
{
const COMMAND_SERVICE = 0;
const SAVE_BUTTON = 1;
const TIMER = 2;
public function __construct($type = null)
{
if (!self::isValidValue($type) && $type !== null) {
throw new \Exception("Unknown callback forcesave type");
} else {
$this->value = $type;
}
}
}

View File

@@ -0,0 +1,66 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
use Onlyoffice\DocsIntegrationSdk\Util\User;
class Changes extends JsonSerializable
{
protected $created;
protected $user;
public function __construct(string $created = "", User $user = null)
{
$this->created = $created;
$this->user = $histuserory !== null ? $user : new User;
}
/**
* Get the value of created
*/
public function getCreated()
{
return $this->created;
}
/**
* Set the value of created
*/
public function setCreated($created)
{
$this->created = $created;
}
/**
* Get the value of user
*/
public function getUser()
{
return $this->user;
}
/**
* Set the value of user
*/
public function setUser($user)
{
$this->user = $user;
}
}

View File

@@ -0,0 +1,67 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
use Onlyoffice\DocsIntegrationSdk\Models\CoEditingMode;
class CoEditing extends JsonSerializable
{
protected $mode;
protected $change;
public function __construct(CoEditingMode $mode = null, bool $change = true)
{
$this->mode = $mode !== null ? $mode : new CoEditingMode;
$this->change = $change;
}
/**
* Get the value of mode
*/
public function getMode()
{
return $this->mode;
}
/**
* Set the value of mode
*/
public function setMode($mode)
{
$this->mode = $mode;
}
/**
* Get the value of change
*/
public function getChange()
{
return $this->change;
}
/**
* Set the value of change
*/
public function setChange($change)
{
$this->change = $change;
}
}

View File

@@ -0,0 +1,37 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
use Onlyoffice\DocsIntegrationSdk\Util\BasicEnum;
class CoEditingMode extends BasicEnum
{
const FAST = "fast";
const STRICT = "strict";
public function __construct($mode = null)
{
if (!self::isValidValue($mode) && $mode !== null) {
throw new \Exception("Unknown co-editing mode");
} else {
$this->value = $mode !== null ? $mode : self::FAST;
}
}
}

View File

@@ -0,0 +1,83 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
class CommentGroups extends JsonSerializable
{
protected $edit;
protected $remove;
protected $view;
public function __construct(array $edit = [], array $remove = [], array $view = [])
{
$this->edit = $edit;
$this->remove = $remove;
$this->view = $view;
}
/**
* Get the value of edit
*/
public function getEdit()
{
return $this->edit;
}
/**
* Set the value of edit
*/
public function setEdit($edit)
{
$this->edit = $edit;
}
/**
* Get the value of remove
*/
public function getRemove()
{
return $this->remove;
}
/**
* Set the value of remove
*/
public function setRemove($remove)
{
$this->remove = $remove;
}
/**
* Get the value of view
*/
public function getView()
{
return $this->view;
}
/**
* Set the value of view
*/
public function setView($view)
{
$this->view = $view;
}
}

View File

@@ -0,0 +1,168 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
use Onlyoffice\DocsIntegrationSdk\Models\DocumentType;
use Onlyoffice\DocsIntegrationSdk\Models\DocEditorConfig;
use Onlyoffice\DocsIntegrationSdk\Models\Document;
use Onlyoffice\DocsIntegrationSdk\Models\Type;
class Config extends JsonSerializable
{
protected $documentType;
protected $height;
protected $width;
protected $token;
protected $type;
protected $editorConfig;
protected $document;
public function __construct(
DocumentType $documentType,
string $height,
string $width,
string $token,
Type $type,
DocEditorConfig $editorConfig,
Document $document
) {
$this->documentType = $documentType;
$this->height = $height;
$this->width = $width;
$this->token = $token;
$this->type = $type;
$this->editorConfig = $editorConfig;
$this->document = $document;
}
/**
* Get the value of documentType
*/
public function getDocumentType()
{
return $this->documentType;
}
/**
* Set the value of documentType
*/
public function setDocumentType($documentType)
{
$this->documentType = $documentType;
}
/**
* Get the value of height
*/
public function getHeight()
{
return $this->height;
}
/**
* Set the value of height
*/
public function setHeight($height)
{
$this->height = $height;
}
/**
* Get the value of width
*/
public function getWidth()
{
return $this->width;
}
/**
* Set the value of width
*/
public function setWidth($width)
{
$this->width = $width;
}
/**
* Get the value of token
*/
public function getToken()
{
return $this->token;
}
/**
* Set the value of token
*/
public function setToken($token)
{
$this->token = $token;
}
/**
* Get the value of type
*/
public function getType()
{
return $this->type;
}
/**
* Set the value of type
*/
public function setType($type)
{
$this->type = $type;
}
/**
* Get the value of editorConfig
*/
public function getEditorConfig()
{
return $this->editorConfig;
}
/**
* Set the value of editorConfig
*/
public function setEditorConfig($editorConfig)
{
$this->editorConfig = $editorConfig;
}
/**
* Get the value of document
*/
public function getDocument()
{
return $this->document;
}
/**
* Set the value of document
*/
public function setDocument($document)
{
$this->document = $document;
}
}

View File

@@ -0,0 +1,258 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
use Onlyoffice\DocsIntegrationSdk\Models\ConvertRequestThumbnail;
class ConvertRequest extends JsonSerializable
{
protected $async;
protected $codePage;
protected $delimiter;
protected $filetype;
protected $key;
protected $outputtype;
protected $password;
protected $region;
protected $thumbnail;
protected $title;
protected $token;
protected $url;
public function __construct(
bool $async = false,
int $codepage = 65001,
int $delimiter = 0,
string $filetype = "",
string $key = "",
string $outputtype = "",
string $password = "",
string $region = "",
?ConvertRequestThumbnail $thumbnail = null,
string $title = "",
string $token = "",
string $url = ""
) {
$this->async = $async;
$this->codePage = $codePage;
$this->delimiter = $delimiter;
$this->filetype = $filetype;
$this->key = $key;
$this->outputtype = $outputtype;
$this->password = $password;
$this->region = $region;
$this->thumbnail = $thumbnail !== null ? $thumbnail : new ConvertRequestThumbnail;
$this->title = $title;
$this->token = $token;
$this->url = $url;
}
/**
* Get the value of async
*/
public function getAsync()
{
return $this->async;
}
/**
* Set the value of async
*/
public function setAsync($async)
{
$this->async = $async;
}
/**
* Get the value of codePage
*/
public function getCodePage()
{
return $this->codePage;
}
/**
* Set the value of codePage
*/
public function setCodePage($codePage)
{
$this->codePage = $codePage;
}
/**
* Get the value of delimiter
*/
public function getDelimiter()
{
return $this->delimiter;
}
/**
* Set the value of delimiter
*/
public function setDelimiter($delimiter)
{
$this->delimiter = $delimiter;
}
/**
* Get the value of filetype
*/
public function getFiletype()
{
return $this->filetype;
}
/**
* Set the value of filetype
*/
public function setFiletype($filetype)
{
$this->filetype = $filetype;
}
/**
* Get the value of key
*/
public function getKey()
{
return $this->key;
}
/**
* Set the value of key
*/
public function setKey($key)
{
$this->key = $key;
}
/**
* Get the value of outputtype
*/
public function getOutputtype()
{
return $this->outputtype;
}
/**
* Set the value of outputtype
*/
public function setOutputtype($outputtype)
{
$this->outputtype = $outputtype;
}
/**
* Get the value of password
*/
public function getPassword()
{
return $this->password;
}
/**
* Set the value of password
*/
public function setPassword($password)
{
$this->password = $password;
}
/**
* Get the value of region
*/
public function getRegion()
{
return $this->region;
}
/**
* Set the value of region
*/
public function setRegion($region)
{
$this->region = $region;
}
/**
* Get the value of thumbnail
*/
public function getThumbnail()
{
return $this->thumbnail;
}
/**
* Set the value of thumbnail
*/
public function setThumbnail($thumbnail)
{
$this->thumbnail = $thumbnail;
}
/**
* Get the value of title
*/
public function getTitle()
{
return $this->title;
}
/**
* Set the value of title
*/
public function setTitle($title)
{
$this->title = $title;
}
/**
* Get the value of token
*/
public function getToken()
{
return $this->token;
}
/**
* Set the value of token
*/
public function setToken($token)
{
$this->token = $token;
}
/**
* Get the value of url
*/
public function getUrl()
{
return $this->url;
}
/**
* Set the value of url
*/
public function setUrl($url)
{
$this->url = $url;
}
}

View File

@@ -0,0 +1,103 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
class ConvertRequestThumbnail extends JsonSerializable
{
protected $aspect;
protected $first;
protected $height;
protected $width;
public function __construct(int $aspect = 2, bool $first = true, int $height = 100, int $width = 100)
{
$this->aspect = $aspect;
$this->first = $first;
$this->height = $height;
$this->width = $width;
}
/**
* Get the value of aspect
*/
public function getAspect()
{
return $this->aspect;
}
/**
* Set the value of aspect
*/
public function setAspect($aspect)
{
$this->aspect = $aspect;
}
/**
* Get the value of first
*/
public function getFirst()
{
return $this->first;
}
/**
* Set the value of first
*/
public function setFirst($first)
{
$this->first = $first;
}
/**
* Get the value of height
*/
public function getHeight()
{
return $this->height;
}
/**
* Set the value of height
*/
public function setHeight($height)
{
$this->height = $height;
}
/**
* Get the value of width
*/
public function getWidth()
{
return $this->width;
}
/**
* Set the value of width
*/
public function setWidth($width)
{
$this->width = $width;
}
}

View File

@@ -0,0 +1,181 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
class Customer extends JsonSerializable
{
protected $address;
protected $info;
protected $logo;
protected $logoDark;
protected $mail;
protected $name;
protected $phone;
protected $www;
public function __construct(
string $address = "",
string $info = "",
string $logo = "",
string $logoDark = "",
string $mail = "",
string $name = "",
string $phone = "",
string $www = ""
) {
$this->address = $address;
$this->info = $info;
$this->logo = $logo;
$this->logoDark = $logoDark;
$this->mail = $mail;
$this->name = $name;
$this->phone = $phone;
$this->www = $www;
}
/**
* Get the value of address
*/
public function getAddress()
{
return $this->address;
}
/**
* Set the value of address
*/
public function setAddress($address)
{
$this->address = $address;
}
/**
* Get the value of info
*/
public function getInfo()
{
return $this->info;
}
/**
* Set the value of info
*/
public function setInfo($info)
{
$this->info = $info;
}
/**
* Get the value of logo
*/
public function getLogo()
{
return $this->logo;
}
/**
* Set the value of logo
*/
public function setLogo($logo)
{
$this->logo = $logo;
}
/**
* Get the value of logoDark
*/
public function getLogoDark()
{
return $this->logoDark;
}
/**
* Set the value of logoDark
*/
public function setLogoDark($logoDark)
{
$this->logoDark = $logoDark;
}
/**
* Get the value of mail
*/
public function getMail()
{
return $this->mail;
}
/**
* Set the value of mail
*/
public function setMail($mail)
{
$this->mail = $mail;
}
/**
* Get the value of name
*/
public function getName()
{
return $this->name;
}
/**
* Set the value of name
*/
public function setName($name)
{
$this->name = $name;
}
/**
* Get the value of phone
*/
public function getPhone()
{
return $this->phone;
}
/**
* Set the value of phone
*/
public function setPhone($phone)
{
$this->phone = $phone;
}
/**
* Get the value of www
*/
public function getWww()
{
return $this->www;
}
/**
* Set the value of www
*/
public function setWww($www)
{
$this->www = $www;
}
}

View File

@@ -0,0 +1,586 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
use Onlyoffice\DocsIntegrationSdk\Models\Anonymous;
use Onlyoffice\DocsIntegrationSdk\Models\Customer;
use Onlyoffice\DocsIntegrationSdk\Models\Features;
use Onlyoffice\DocsIntegrationSdk\Models\Logo;
use Onlyoffice\DocsIntegrationSdk\Models\Review;
use Onlyoffice\DocsIntegrationSdk\Models\Unit;
class Customization extends JsonSerializable
{
protected $anonymous;
protected $autosave;
protected $comments;
protected $compactHeader;
protected $compactToolbar;
protected $compatibleFeatures;
protected $customer;
protected $features;
protected $feedback;
protected $forcesave;
protected $goback;
protected $help;
protected $hideNotes;
protected $hideRightMenu;
protected $hideRulers;
protected $integrationMode;
protected $logo;
protected $macros;
protected $macrosMode;
protected $mentionShare;
protected $mobileForceView;
protected $plugins;
protected $review;
protected $submitForm;
protected $toolbarHideFileName;
protected $toolbarNoTabs;
protected $uiTheme;
protected $unit;
protected $zoom;
public function __construct(
?Anonymous $anonymous = null,
?bool $autosave = null,
?bool $comments = null,
?bool $compactHeader = null,
?bool $compactToolbar = null,
?bool $compatibleFeatures = null,
?Customer $customer = null,
?Features $features = null,
?bool $feedback = null,
?bool $forcesave = null,
?GoBack $goback = null,
?bool $help = true,
?bool $hideNotes = null,
?bool $hideRightMenu = null,
?bool $hideRulers = null,
?string $integrationMode = "embed",
?Logo $logo = null,
?bool $macros = null,
?MacrosMode $macrosMode = null,
?bool $mentionShare = null,
?bool $mobileForceView = null,
?bool $plugins = null,
?Review $review = null,
?bool $submitForm = null,
?bool $toolbarHideFileName = null,
?bool $toolbarNoTabs = null,
?string $uiTheme = "",
?Unit $unit = null,
?int $zoom = 100
) {
$this->anonymous = $anonymous;
$this->autosave = $autosave;
$this->comments = $comments;
$this->compactHeader = $compactHeader;
$this->compactToolbar = $compactToolbar;
$this->compatibleFeatures = $compatibleFeatures;
$this->customer = $customer;
$this->features = $features;
$this->feedback = $feedback;
$this->forcesave = $forcesave;
$this->goback = $goback;
$this->help = $help;
$this->hideNotes = $hideNotes;
$this->hideRightMenu = $hideRightMenu;
$this->hideRulers = $hideRulers;
$this->integrationMode = $integrationMode;
$this->logo = $logo;
$this->macros = $macros;
$this->macrosMode = $macrosMode;
$this->mentionShare = $mentionShare;
$this->mobileForceView = $mobileForceView;
$this->plugins = $plugins;
$this->review = $review;
$this->submitForm = $submitForm;
$this->toolbarHideFileName = $toolbarHideFileName;
$this->toolbarNoTabs = $toolbarNoTabs;
$this->uiTheme = $uiTheme;
$this->unit = $unit;
$this->zoom = $zoom;
}
/**
* Get the value of anonymous
*/
public function getAnonymous()
{
return $this->anonymous;
}
/**
* Set the value of anonymous
*/
public function setAnonymous($anonymous)
{
$this->anonymous = $anonymous;
}
/**
* Get the value of autosave
*/
public function getAutosave()
{
return $this->autosave;
}
/**
* Set the value of autosave
*/
public function setAutosave($autosave)
{
$this->autosave = $autosave;
}
/**
* Get the value of comments
*/
public function getComments()
{
return $this->comments;
}
/**
* Set the value of comments
*/
public function setComments($comments)
{
$this->comments = $comments;
}
/**
* Get the value of compactHeader
*/
public function getCompactHeader()
{
return $this->compactHeader;
}
/**
* Set the value of compactHeader
*/
public function setCompactHeader($compactHeader)
{
$this->compactHeader = $compactHeader;
}
/**
* Get the value of compactToolbar
*/
public function getCompactToolbar()
{
return $this->compactToolbar;
}
/**
* Set the value of compactToolbar
*/
public function setCompactToolbar($compactToolbar)
{
$this->compactToolbar = $compactToolbar;
}
/**
* Get the value of compatibleFeatures
*/
public function getCompatibleFeatures()
{
return $this->compatibleFeatures;
}
/**
* Set the value of compatibleFeatures
*/
public function setCompatibleFeatures($compatibleFeatures)
{
$this->compatibleFeatures = $compatibleFeatures;
}
/**
* Get the value of customer
*/
public function getCustomer()
{
return $this->customer;
}
/**
* Set the value of customer
*/
public function setCustomer($customer)
{
$this->customer = $customer;
}
/**
* Get the value of features
*/
public function getFeatures()
{
return $this->features;
}
/**
* Set the value of features
*/
public function setFeatures($features)
{
$this->features = $features;
}
/**
* Get the value of feedback
*/
public function getFeedback()
{
return $this->feedback;
}
/**
* Set the value of feedback
*/
public function setFeedback($feedback)
{
$this->feedback = $feedback;
}
/**
* Get the value of forcesave
*/
public function getForcesave()
{
return $this->forcesave;
}
/**
* Set the value of forcesave
*/
public function setForcesave($forcesave)
{
$this->forcesave = $forcesave;
}
/**
* Get the value of goback
*/
public function getGoback()
{
return $this->goback;
}
/**
* Set the value of goback
*/
public function setGoback($goback)
{
$this->goback = $goback;
}
/**
* Get the value of help
*/
public function getHelp()
{
return $this->help;
}
/**
* Set the value of help
*/
public function setHelp($help)
{
$this->help = $help;
}
/**
* Get the value of hideNotes
*/
public function getHideNotes()
{
return $this->hideNotes;
}
/**
* Set the value of hideNotes
*/
public function setHideNotes($hideNotes)
{
$this->hideNotes = $hideNotes;
}
/**
* Get the value of hideRightMenu
*/
public function getHideRightMenu()
{
return $this->hideRightMenu;
}
/**
* Set the value of hideRightMenu
*/
public function setHideRightMenu($hideRightMenu)
{
$this->hideRightMenu = $hideRightMenu;
}
/**
* Get the value of hideRulers
*/
public function getHideRulers()
{
return $this->hideRulers;
}
/**
* Set the value of hideRulers
*/
public function setHideRulers($hideRulers)
{
$this->hideRulers = $hideRulers;
}
/**
* Get the value of integrationMode
*/
public function getIntegrationMode()
{
return $this->integrationMode;
}
/**
* Set the value of integrationMode
*/
public function setIntegrationMode($integrationMode)
{
$this->integrationMode = $integrationMode;
}
/**
* Get the value of logo
*/
public function getLogo()
{
return $this->logo;
}
/**
* Set the value of logo
*/
public function setLogo($logo)
{
$this->logo = $logo;
}
/**
* Get the value of macros
*/
public function getMacros()
{
return $this->macros;
}
/**
* Set the value of macros
*/
public function setMacros($macros)
{
$this->macros = $macros;
}
/**
* Get the value of macrosMode
*/
public function getMacrosMode()
{
return $this->macrosMode;
}
/**
* Set the value of macrosMode
*/
public function setMacrosMode($macrosMode)
{
$this->macrosMode = $macrosMode;
}
/**
* Get the value of mentionShare
*/
public function getMentionShare()
{
return $this->mentionShare;
}
/**
* Set the value of mentionShare
*/
public function setMentionShare($mentionShare)
{
$this->mentionShare = $mentionShare;
}
/**
* Get the value of mobileForceView
*/
public function getMobileForceView()
{
return $this->mobileForceView;
}
/**
* Set the value of mobileForceView
*/
public function setMobileForceView($mobileForceView)
{
$this->mobileForceView = $mobileForceView;
}
/**
* Get the value of plugins
*/
public function getPlugins()
{
return $this->plugins;
}
/**
* Set the value of plugins
*/
public function setPlugins($plugins)
{
$this->plugins = $plugins;
}
/**
* Get the value of review
*/
public function getReview()
{
return $this->review;
}
/**
* Set the value of review
*/
public function setReview($review)
{
$this->review = $review;
}
/**
* Get the value of submitForm
*/
public function getSubmitForm()
{
return $this->submitForm;
}
/**
* Set the value of submitForm
*/
public function setSubmitForm($submitForm)
{
$this->submitForm = $submitForm;
}
/**
* Get the value of toolbarHideFileName
*/
public function getToolbarHideFileName()
{
return $this->toolbarHideFileName;
}
/**
* Set the value of toolbarHideFileName
*/
public function setToolbarHideFileName($toolbarHideFileName)
{
$this->toolbarHideFileName = $toolbarHideFileName;
}
/**
* Get the value of toolbarNoTabs
*/
public function getToolbarNoTabs()
{
return $this->toolbarNoTabs;
}
/**
* Set the value of toolbarNoTabs
*/
public function setToolbarNoTabs($toolbarNoTabs)
{
$this->toolbarNoTabs = $toolbarNoTabs;
}
/**
* Get the value of uiTheme
*/
public function getUiTheme()
{
return $this->uiTheme;
}
/**
* Set the value of uiTheme
*/
public function setUiTheme($uiTheme)
{
$this->uiTheme = $uiTheme;
}
/**
* Get the value of unit
*/
public function getUnit()
{
return $this->unit;
}
/**
* Set the value of unit
*/
public function setUnit($unit)
{
$this->unit = $unit;
}
/**
* Get the value of zoom
*/
public function getZoom()
{
return $this->zoom;
}
/**
* Set the value of zoom
*/
public function setZoom($zoom)
{
$this->zoom = $zoom;
}
}

View File

@@ -0,0 +1,276 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
use Onlyoffice\DocsIntegrationSdk\Models\CoEditing;
use Onlyoffice\DocsIntegrationSdk\Models\EditorsMode;
use Onlyoffice\DocsIntegrationSdk\Models\Recent;
use Onlyoffice\DocsIntegrationSdk\Models\Template;
use Onlyoffice\DocsIntegrationSdk\Models\User;
use Onlyoffice\DocsIntegrationSdk\Models\Customization;
use Onlyoffice\DocsIntegrationSdk\Models\Embedded;
class DocEditorConfig extends JsonSerializable
{
protected $callbackUrl;
protected $coEditing;
protected $createUrl;
protected $lang;
protected $location;
protected $mode;
protected $recent; // array of Recent
protected $region;
protected $templates; // aray of Template
protected $user;
protected $customization;
protected $embedded;
public function __construct(
?string $callbackUrl = "",
?CoEditing $coEditing = null,
?string $createUrl = "",
?string $lang = "en",
?string $location = "",
?EditorsMode $mode = null,
?array $recent = null,
?string $region = "en-US",
?array $templates = null,
?User $user = null,
?Customization $customization = null,
?Embedded $embedded = null
) {
$this->callbackUrl = $callbackUrl;
$this->coEditing = $coEditing;
$this->createUrl = $createUrl;
$this->lang = $lang;
$this->location = $location;
$this->mode = $mode;
$this->recent = $recent;
$this->region = $region;
$this->templates = $templates;
$this->user = $user;
$this->customization = $customization;
$this->embedded = $embedded;
}
/**
* Get the value of callbackUrl
*/
public function getCallbackUrl()
{
return $this->callbackUrl;
}
/**
* Set the value of callbackUrl
*
*/
public function setCallbackUrl($callbackUrl)
{
$this->callbackUrl = $callbackUrl;
}
/**
* Get the value of coEditing
*/
public function getCoEditing()
{
return $this->coEditing;
}
/**
* Set the value of coEditing
*
*/
public function setCoEditing($coEditing)
{
$this->coEditing = $coEditing;
}
/**
* Get the value of createUrl
*/
public function getCreateUrl()
{
return $this->createUrl;
}
/**
* Set the value of createUrl
*
*/
public function setCreateUrl($createUrl)
{
$this->createUrl = $createUrl;
}
/**
* Get the value of lang
*/
public function getLang()
{
return $this->lang;
}
/**
* Set the value of lang
*
*/
public function setLang($lang)
{
$this->lang = $lang;
}
/**
* Get the value of location
*/
public function getLocation()
{
return $this->location;
}
/**
* Set the value of location
*
*/
public function setLocation($location)
{
$this->location = $location;
}
/**
* Get the value of mode
*/
public function getMode()
{
return $this->mode;
}
/**
* Set the value of mode
*
*/
public function setMode($mode)
{
$this->mode = $mode;
}
/**
* Get the value of recent
*/
public function getRecent()
{
return $this->recent;
}
/**
* Set the value of recent
*
*/
public function setRecent($recent)
{
$this->recent = $recent;
}
/**
* Get the value of region
*/
public function getRegion()
{
return $this->region;
}
/**
* Set the value of region
*
*/
public function setRegion($region)
{
$this->region = $region;
}
/**
* Get the value of templates
*/
public function getTemplates()
{
return $this->templates;
}
/**
* Set the value of templates
*
*/
public function setTemplates($templates)
{
$this->templates = $templates;
}
/**
* Get the value of user
*/
public function getUser()
{
return $this->user;
}
/**
* Set the value of user
*
*/
public function setUser($user)
{
$this->user = $user;
}
/**
* Get the value of customization
*/
public function getCustomization()
{
return $this->customization;
}
/**
* Set the value of customization
*
*/
public function setCustomization($customization)
{
$this->customization = $customization;
}
/**
* Get the value of embedded
*/
public function getEmbedded()
{
return $this->embedded;
}
/**
* Set the value of embedded
*
*/
public function setEmbedded($embedded)
{
$this->embedded = $embedded;
}
}

View File

@@ -0,0 +1,169 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
use Onlyoffice\DocsIntegrationSdk\Models\DocumentType;
use Onlyoffice\DocsIntegrationSdk\Models\ReferenceData;
use Onlyoffice\DocsIntegrationSdk\Models\Info;
use Onlyoffice\DocsIntegrationSdk\Models\Permissions;
class Document extends JsonSerializable
{
protected $fileType;
protected $key;
protected $referenceData;
protected $title;
protected $url;
protected $info;
protected $permissions;
public function __construct(
?string $fileType,
?string $key,
?ReferenceData $referenceData,
?string $title,
?string $url,
?Info $info,
?Permissions $permissions
) {
$this->fileType = $fileType;
$this->key = $key;
$this->referenceData = $referenceData;
$this->title = $title;
$this->url = $url;
$this->info = $info;
$this->permissions = $permissions;
}
/**
* Get the value of fileType
*/
public function getFileType()
{
return $this->fileType;
}
/**
* Set the value of fileType
*/
public function setFileType($fileType)
{
$this->fileType = $fileType;
}
/**
* Get the value of key
*/
public function getKey()
{
return $this->key;
}
/**
* Set the value of key
*/
public function setKey($key)
{
$this->key = $key;
}
/**
* Get the value of referenceData
*/
public function getReferenceData()
{
return $this->referenceData;
}
/**
* Set the value of referenceData
*/
public function setReferenceData($referenceData)
{
$this->referenceData = $referenceData;
}
/**
* Get the value of title
*/
public function getTitle()
{
return $this->title;
}
/**
* Set the value of title
*/
public function setTitle($title)
{
$this->title = $title;
}
/**
* Get the value of url
*/
public function getUrl()
{
return $this->url;
}
/**
* Set the value of url
*/
public function setUrl($url)
{
$this->url = $url;
}
/**
* Get the value of info
*/
public function getInfo()
{
return $this->info;
}
/**
* Set the value of info
*/
public function setInfo($info)
{
$this->info = $info;
}
/**
* Get the value of permissions
*/
public function getPermissions()
{
return $this->permissions;
}
/**
* Set the value of permissions
*/
public function setPermissions($permissions)
{
$this->permissions = $permissions;
}
}

View File

@@ -0,0 +1,39 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
use Onlyoffice\DocsIntegrationSdk\Util\BasicEnum;
class DocumentType extends BasicEnum
{
const WORD = "word";
const CELL = "cell";
const SLIDE = "slide";
const PDF = "pdf";
public function __construct($type = null)
{
if (!self::isValidValue($type) && $type !== null) {
throw new \Exception("Unknown document type");
} else {
$this->value = $type;
}
}
}

View File

@@ -0,0 +1,37 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
use Onlyoffice\DocsIntegrationSdk\Util\BasicEnum;
class EditorsMode extends BasicEnum
{
const VIEW = "view";
const EDIT = "edit";
public function __construct($editorsMode = null)
{
if (!self::isValidValue($editorsMode) && $editorsMode !== null) {
throw new \Exception("Unknown editors mode");
} else {
$this->value = $editorsMode !== null ? $editorsMode : self::EDIT;
}
}
}

View File

@@ -0,0 +1,110 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
use Onlyoffice\DocsIntegrationSdk\Models\Toolbar;
class Embedded extends JsonSerializable
{
protected $embedUrl;
protected $fullscreenUrl;
protected $saveUrl;
protected $shareUrl;
protected $toolbarDocked;
public function __construct(
string $embedUrl = "",
string $fullscreenUrl = "",
string $saveUrl = "",
string $shareUrl = "",
Toolbar $toolbarDocked = null
) {
$this->embedUrl = $embedUrl;
$this->fullscreenUrl = $fullscreenUrl;
$this->saveUrl = $saveUrl;
$this->shareUrl = $shareUrl;
$this->toolbarDocked = $toolbarDocked !== null ? $toolbarDocked : new Toolbar;
}
/**
* Get the value of embedUrl
*/
public function getEmbedUrl()
{
return $this->embedUrl;
}
/**
* Set the value of embedUrl
*/
public function setEmbedUrl($embedUrl)
{
$this->embedUrl = $embedUrl;
}
/**
* Get the value of fullscreenUrl
*/
public function getFullscreenUrl()
{
return $this->fullscreenUrl;
}
/**
* Set the value of fullscreenUrl
*/
public function setFullscreenUrl($fullscreenUrl)
{
$this->fullscreenUrl = $fullscreenUrl;
}
/**
* Get the value of saveUrl
*/
public function getSaveUrl()
{
return $this->saveUrl;
}
/**
* Set the value of saveUrl
*/
public function setSaveUrl($saveUrl)
{
$this->saveUrl = $saveUrl;
}
/**
* Get the value of toolbarDocked
*/
public function getToolbarDocked()
{
return $this->toolbarDocked;
}
/**
* Set the value of toolbarDocked
*/
public function setToolbarDocked($toolbarDocked)
{
$this->toolbarDocked = $toolbarDocked;
}
}

View File

@@ -0,0 +1,47 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
class Features extends JsonSerializable
{
protected $spellcheck;
public function __construct(bool $spellcheck = true)
{
$this->spellcheck = $spellcheck;
}
/**
* Get the value of spellcheck
*/
public function getSpellcheck()
{
return $this->spellcheck;
}
/**
* Set the value of spellcheck
*/
public function setSpellcheck($spellcheck)
{
$this->spellcheck = $spellcheck;
}
}

View File

@@ -0,0 +1,129 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
class Format extends JsonSerializable
{
protected $name;
protected $type;
protected $actions;
protected $convert;
protected $mime;
public function __construct(
string $name,
string $type = "",
array $actions = [],
array $convert = [],
array $mime = []
) {
$this->name = $name;
$this->type = $type;
$this->actions = $actions;
$this->convert = $convert;
$this->mime = $mime;
}
public function getName()
{
return $this->name;
}
public function setName(string $name)
{
$this->name = $name;
}
public function getType()
{
return $this->type;
}
public function setType(string $type)
{
$this->type = $type;
}
public function getActions()
{
return $this->actions;
}
public function setActions(array $actions)
{
$this->actions = $actions;
}
public function getConvert()
{
return $this->convert;
}
public function setConvert(array $convert)
{
$this->convert = $convert;
}
public function getMimes()
{
return $this->mime;
}
public function setMimes(array $mime)
{
$this->mime = $mime;
}
protected function hasAction(string $search)
{
return in_array($search, $this->actions);
}
public function isViewable()
{
return $this->hasAction("view");
}
public function isStrictlyEditable()
{
return $this->hasAction("edit");
}
public function isLossyEditable()
{
return $this->hasAction("lossy-edit");
}
public function isEditable()
{
return $this->hasAction("edit") || $this->hasAction("lossy-edit");
}
public function isAutoConvertable()
{
$this->hasAction("auto-convert");
}
public function isFillable()
{
return $this->hasAction("fill");
}
}

View File

@@ -0,0 +1,101 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
class GoBack extends JsonSerializable
{
protected $blank;
protected $requestClose;
protected $text;
protected $url;
public function __construct(bool $blank = true, bool $requestClose = false, string $text = "", string $url = "")
{
$this->blank = $blank;
$this->requestClose = $requestClose;
$this->text = $text;
$this->url = $url;
}
/**
* Get the value of blank
*/
public function getBlank()
{
return $this->blank;
}
/**
* Set the value of blank
*/
public function setBlank($blank)
{
$this->blank = $blank;
}
/**
* Get the value of requestClose
*/
public function getRequestClose()
{
return $this->requestClose;
}
/**
* Set the value of requestClose
*/
public function setRequestClose($requestClose)
{
$this->requestClose = $requestClose;
}
/**
* Get the value of text
*/
public function getText()
{
return $this->text;
}
/**
* Set the value of text
*/
public function setText($text)
{
$this->text = $text;
}
/**
* Get the value of url
*/
public function getUrl()
{
return $this->url;
}
/**
* Set the value of url
*/
public function setUrl($url)
{
$this->url = $url;
}
}

View File

@@ -0,0 +1,58 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
use Onlyoffice\DocsIntegrationSdk\Util\Changes;
class History extends JsonSerializable
{
protected $serverVersion;
protected $changes; // array of Changes
public function __construct(string $serverVersion = "", array $changes = [])
{
$this->serverVersion = $serverVersion;
$this->changes = $changes;
}
/**
* Get the value of serverVersion
*/
public function getServerVersion()
{
return $this->serverVersion;
}
/**
* Set the value of serverVersion
*/
public function setServerVersion($serverVersion)
{
$this->serverVersion = $serverVersion;
}
/**
* Set the value of changes
*/
public function setChanges($changes)
{
$this->changes = $changes;
}
}

View File

@@ -0,0 +1,125 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
use Onlyoffice\DocsIntegrationSdk\Models\SharingSettings;
class Info extends JsonSerializable
{
protected $favorite;
protected $folder;
protected $owner;
protected $sharingSettings; // array of SharingSettings
protected $uploaded;
public function __construct(
bool $favorite = false,
string $folder = "",
string $owner = "",
array $sharingSettings = [],
string $uploaded = ""
) {
$this->favorite = $favorite;
$this->folder = $folder;
$this->owner = $owner;
$this->sharingSettings = $sharingSettings;
$this->uploaded = $uploaded;
}
/**
* Get the value of favorite
*/
public function getFavorite()
{
return $this->favorite;
}
/**
* Set the value of favorite
*/
public function setFavorite($favorite)
{
$this->favorite = $favorite;
}
/**
* Get the value of folder
*/
public function getFolder()
{
return $this->folder;
}
/**
* Set the value of folder
*/
public function setFolder($folder)
{
$this->folder = $folder;
}
/**
* Get the value of owner
*/
public function getOwner()
{
return $this->owner;
}
/**
* Set the value of owner
*/
public function setOwner($owner)
{
$this->owner = $owner;
}
/**
* Get the value of sharingSettings
*/
public function getSharingSettings()
{
return $this->sharingSettings;
}
/**
* Set the value of sharingSettings
*/
public function setSharingSettings($sharingSettings)
{
$this->sharingSettings = $sharingSettings;
}
/**
* Get the value of uploaded
*/
public function getUploaded()
{
return $this->uploaded;
}
/**
* Set the value of uploaded
*/
public function setUploaded($uploaded)
{
$this->uploaded = $uploaded;
}
}

View File

@@ -0,0 +1,57 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
abstract class JsonSerializable implements \JsonSerializable
{
public function jsonSerialize()
{
$vars = get_object_vars($this);
foreach ($vars as $key => $var) {
if (empty($var) && !is_bool($var)) {
unset($vars[$key]);
} else {
if (is_object($var)) {
if (property_exists($var, "value")) {
if (empty($var->value)) {
unset($vars[$key]);
} else {
$vars[$key] = $var->value;
}
}
}
}
}
return $vars;
}
public function mapFromArray(array $values)
{
foreach ($values as $key => $value) {
try {
$mapperFunction = "set" . lcfirst($key);
$this->{$mapperFunction}($value);
} catch (\Exception $e) {
continue;
}
}
}
}

View File

@@ -0,0 +1,101 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
class Logo extends JsonSerializable
{
protected $image;
protected $imageDark;
protected $url;
protected $visible;
public function __construct(string $image = "", string $imageDark = "", string $url = "", bool $visible = true)
{
$this->image = $image;
$this->imageDark = $imageDark;
$this->url = $url;
$this->visible = $visible;
}
/**
* Get the value of image
*/
public function getImage()
{
return $this->image;
}
/**
* Set the value of image
*/
public function setImage($image)
{
$this->image = $image;
}
/**
* Get the value of imageDark
*/
public function getImageDark()
{
return $this->imageDark;
}
/**
* Set the value of imageDark
*/
public function setImageDark($imageDark)
{
$this->imageDark = $imageDark;
}
/**
* Get the value of imageEmbedded
*/
public function getImageEmbedded()
{
return $this->imageEmbedded;
}
/**
* Set the value of imageEmbedded
*/
public function setImageEmbedded($imageEmbedded)
{
$this->imageEmbedded = $imageEmbedded;
}
/**
* Get the value of url
*/
public function getUrl()
{
return $this->url;
}
/**
* Set the value of url
*/
public function setUrl($url)
{
$this->url = $url;
}
}

View File

@@ -0,0 +1,38 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
use Onlyoffice\DocsIntegrationSdk\Util\BasicEnum;
class MacrosMode extends BasicEnum
{
const DISABLE = "disable";
const ENABLE = "enable";
const WARN = "warn";
public function __construct($macrosMode = null)
{
if (!self::isValidValue($macrosMode) && $macrosMode !== null) {
throw new \Exception("Unknown macros mode");
} else {
$this->value = $macrosMode !== null ? $macrosMode : self::WARN;
}
}
}

View File

@@ -0,0 +1,353 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
use Onlyoffice\DocsIntegrationSdk\Models\CommentGroups;
class Permissions extends JsonSerializable
{
protected $chat;
protected $comment;
protected $commentGroups;
protected $copy;
protected $deleteCommentAuthorOnly;
protected $download;
protected $edit;
protected $editCommentAuthorOnly;
protected $fillForms;
protected $modifyContentControl;
protected $modifyFilter;
protected $print;
protected $protect;
protected $rename;
protected $review;
protected $reviewGroups; //string array
protected $userInfoGroups; //string array
public function __construct(
?bool $chat = true,
?bool $comment = true,
?CommentGroups $commentGroups = null,
?bool $copy = true,
?bool $deleteCommentAuthorOnly = false,
?bool $download = true,
?bool $edit = true,
?bool $editCommentAuthorOnly = false,
?bool $fillForms = true,
?bool $modifyContentControl = true,
?bool $modifyFilter = true,
?bool $print = true,
?bool $protect = true,
?bool $rename = false,
?bool $review = false,
?array $reviewGroups = null,
?array $userInfoGroups = null
) {
$this->chat = $chat;
$this->comment = $comment;
$this->commentGroups = $commentGroups !== null ? $commentGroups : new CommentGroups;
$this->copy = $copy;
$this->deleteCommentAuthorOnly = $deleteCommentAuthorOnly;
$this->download = $download;
$this->edit = $edit;
$this->editCommentAuthorOnly = $editCommentAuthorOnly;
$this->fillForms = $fillForms;
$this->modifyContentControl = $modifyContentControl;
$this->modifyFilter = $modifyFilter;
$this->print = $print;
$this->protect = $protect;
$this->rename = $rename;
$this->review = $review;
$this->reviewGroups = $reviewGroups;
$this->userInfoGroups = $userInfoGroups;
}
/**
* Get the value of chat
*/
public function getChat()
{
return $this->chat;
}
/**
* Set the value of chat
*/
public function setChat($chat)
{
$this->chat = $chat;
}
/**
* Get the value of comment
*/
public function getComment()
{
return $this->comment;
}
/**
* Set the value of comment
*/
public function setComment($comment)
{
$this->comment = $comment;
}
/**
* Get the value of commentGroups
*/
public function getCommentGroups()
{
return $this->commentGroups;
}
/**
* Set the value of commentGroups
*/
public function setCommentGroups($commentGroups)
{
$this->commentGroups = $commentGroups;
}
/**
* Get the value of copy
*/
public function getCopy()
{
return $this->copy;
}
/**
* Set the value of copy
*/
public function setCopy($copy)
{
$this->copy = $copy;
}
/**
* Get the value of deleteCommentAuthorOnly
*/
public function getDeleteCommentAuthorOnly()
{
return $this->deleteCommentAuthorOnly;
}
/**
* Set the value of deleteCommentAuthorOnly
*/
public function setDeleteCommentAuthorOnly($deleteCommentAuthorOnly)
{
$this->deleteCommentAuthorOnly = $deleteCommentAuthorOnly;
}
/**
* Get the value of download
*/
public function getDownload()
{
return $this->download;
}
/**
* Set the value of download
*/
public function setDownload($download)
{
$this->download = $download;
}
/**
* Get the value of edit
*/
public function getEdit()
{
return $this->edit;
}
/**
* Set the value of edit
*/
public function setEdit($edit)
{
$this->edit = $edit;
}
/**
* Get the value of editCommentAuthorOnly
*/
public function getEditCommentAuthorOnly()
{
return $this->editCommentAuthorOnly;
}
/**
* Set the value of editCommentAuthorOnly
*/
public function setEditCommentAuthorOnly($editCommentAuthorOnly)
{
$this->editCommentAuthorOnly = $editCommentAuthorOnly;
}
/**
* Get the value of fillForms
*/
public function getFillForms()
{
return $this->fillForms;
}
/**
* Set the value of fillForms
*/
public function setFillForms($fillForms)
{
$this->fillForms = $fillForms;
}
/**
* Get the value of modifyContentControl
*/
public function getModifyContentControl()
{
return $this->modifyContentControl;
}
/**
* Set the value of modifyContentControl
*/
public function setModifyContentControl($modifyContentControl)
{
$this->modifyContentControl = $modifyContentControl;
}
/**
* Get the value of modifyFilter
*/
public function getModifyFilter()
{
return $this->modifyFilter;
}
/**
* Set the value of modifyFilter
*/
public function setModifyFilter($modifyFilter)
{
$this->modifyFilter = $modifyFilter;
}
/**
* Get the value of print
*/
public function getPrint()
{
return $this->print;
}
/**
* Set the value of print
*/
public function setPrint($print)
{
$this->print = $print;
}
/**
* Get the value of protect
*/
public function getProtect()
{
return $this->protect;
}
/**
* Set the value of protect
*/
public function setProtect($protect)
{
$this->protect = $protect;
}
/**
* Get the value of rename
*/
public function getRename()
{
return $this->rename;
}
/**
* Set the value of rename
*/
public function setRename($rename)
{
$this->rename = $rename;
}
/**
* Get the value of review
*/
public function getReview()
{
return $this->review;
}
/**
* Set the value of review
*/
public function setReview($review)
{
$this->review = $review;
}
/**
* Get the value of reviewGroups
*/
public function getReviewGroups()
{
return $this->reviewGroups;
}
/**
* Set the value of reviewGroups
*/
public function setReviewGroups($reviewGroups)
{
$this->reviewGroups = $reviewGroups;
}
/**
* Get the value of userInfoGroups
*/
public function getUserInfoGroups()
{
return $this->userInfoGroups;
}
/**
* Set the value of userInfoGroups
*/
public function setUserInfoGroups($userInfoGroups)
{
$this->userInfoGroups = $userInfoGroups;
}
}

View File

@@ -0,0 +1,84 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
class Recent extends JsonSerializable
{
protected $folder;
protected $title;
protected $url;
public function __construct(string $folder = "", string $title = "", string $url = "")
{
$this->folder = $folder;
$this->title = $title;
$this->url = $url;
}
/**
* Get the value of folder
*/
public function getFolder()
{
return $this->folder;
}
/**
* Set the value of folder
*/
public function setFolder($folder)
{
$this->folder = $folder;
}
/**
* Get the value of title
*/
public function getTitle()
{
return $this->title;
}
/**
* Set the value of title
*/
public function setTitle($title)
{
$this->title = $title;
}
/**
* Get the value of url
*/
public function getUrl()
{
return $this->url;
}
/**
* Set the value of url
*/
public function setUrl($url)
{
$this->url = $url;
}
}

View File

@@ -0,0 +1,83 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
class ReferenceData extends JsonSerializable
{
protected $fileKey;
protected $instanceId;
protected $key;
public function __construct(?string $fileKey = "", ?string $instanceId = "", ?string $key = "")
{
$this->fileKey = $fileKey;
$this->instanceId = $instanceId;
$this->key = $key;
}
/**
* Get the value of fileKey
*/
public function getFileKey()
{
return $this->fileKey;
}
/**
* Set the value of fileKey
*/
public function setFileKey($fileKey)
{
$this->fileKey = $fileKey;
}
/**
* Get the value of instanceId
*/
public function getInstanceId()
{
return $this->instanceId;
}
/**
* Set the value of instanceId
*/
public function setInstanceId($instanceId)
{
$this->instanceId = $instanceId;
}
/**
* Get the value of key
*/
public function getKey()
{
return $this->key;
}
/**
* Set the value of key
*/
public function setKey($key)
{
$this->key = $key;
}
}

View File

@@ -0,0 +1,125 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
use Onlyoffice\DocsIntegrationSdk\Models\ReviewDisplay;
class Review extends JsonSerializable
{
protected $hideReviewDisplay;
protected $hoverMode;
protected $reviewDisplay;
protected $showReviewChanges;
protected $trackChanges;
public function __construct(
bool $hideReviewDisplay = false,
bool $hoverMode = false,
ReviewDisplay $reviewDisplay = null,
bool $showReviewChanges = false,
bool $trackChanges = true
) {
$this->hideReviewDisplay = $hideReviewDisplay;
$this->hoverMode = $hoverMode;
$this->reviewDisplay = $reviewDisplay !== null ? $reviewDisplay : new ReviewDisplay;
$this->showReviewChanges = $showReviewChanges;
$this->trackChanges = $trackChanges;
}
/**
* Get the value of hideReviewDisplay
*/
public function getHideReviewDisplay()
{
return $this->hideReviewDisplay;
}
/**
* Set the value of hideReviewDisplay
*/
public function setHideReviewDisplay($hideReviewDisplay)
{
$this->hideReviewDisplay = $hideReviewDisplay;
}
/**
* Get the value of hoverMode
*/
public function getHoverMode()
{
return $this->hoverMode;
}
/**
* Set the value of hoverMode
*/
public function setHoverMode($hoverMode)
{
$this->hoverMode = $hoverMode;
}
/**
* Get the value of reviewDisplay
*/
public function getReviewDisplay()
{
return $this->reviewDisplay;
}
/**
* Set the value of reviewDisplay
*/
public function setReviewDisplay($reviewDisplay)
{
$this->reviewDisplay = $reviewDisplay;
}
/**
* Get the value of showReviewChanges
*/
public function getShowReviewChanges()
{
return $this->showReviewChanges;
}
/**
* Set the value of showReviewChanges
*/
public function setShowReviewChanges($showReviewChanges)
{
$this->showReviewChanges = $showReviewChanges;
}
/**
* Get the value of trackChanges
*/
public function getTrackChanges()
{
return $this->trackChanges;
}
/**
* Set the value of trackChanges
*/
public function setTrackChanges($trackChanges)
{
$this->trackChanges = $trackChanges;
}
}

View File

@@ -0,0 +1,39 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
use Onlyoffice\DocsIntegrationSdk\Util\BasicEnum;
class ReviewDisplay extends BasicEnum
{
const MARKUP = "markup";
const SIMPLE = "simple";
const FINAL = "final";
const ORIGINAL = "original";
public function __construct($reviewDisplay = null)
{
if (!self::isValidValue($reviewDisplay) && $reviewDisplay !== null) {
throw new \Exception("Unknown review display type");
} else {
$this->value = $reviewDisplay !== null ? $reviewDisplay : self::ORIGINAL;
}
}
}

View File

@@ -0,0 +1,88 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
use Onlyoffice\DocsIntegrationSdk\Models\SharingSettingsPermissions;
class SharingSettings extends JsonSerializable
{
protected $isLink;
protected $sharingSettingsPermissions;
protected $user;
public function __construct(
bool $isLink = false,
SharingSettingsPermissions $sharingSettingsPermissions = null,
string $user = ""
) {
$this->isLink = $isLink;
$this->sharingSettingsPermissions =
$sharingSettingsPermissions !== null ? $sharingSettingsPermissions : new SharingSettingsPermissions;
$this->user = $user;
}
/**
* Get the value of isLink
*/
public function getIsLink()
{
return $this->isLink;
}
/**
* Set the value of isLink
*/
public function setIsLink($isLink)
{
$this->isLink = $isLink;
}
/**
* Get the value of sharingSettingsPermissions
*/
public function getSharingSettingsPermissions()
{
return $this->sharingSettingsPermissions;
}
/**
* Set the value of sharingSettingsPermissions
*/
public function setSharingSettingsPermissions($sharingSettingsPermissions)
{
$this->sharingSettingsPermissions = $sharingSettingsPermissions;
}
/**
* Get the value of user
*/
public function getUser()
{
return $this->user;
}
/**
* Set the value of user
*/
public function setUser($user)
{
$this->user = $user;
}
}

View File

@@ -0,0 +1,38 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
use Onlyoffice\DocsIntegrationSdk\Util\BasicEnum;
class SharingSettingsPermissions extends BasicEnum
{
const FULL_ACCESS = "Full Access";
const READ_ONLY = "Read Only";
const DENY_ACCESS = "Deny Access";
public function __construct($type = null)
{
if (!self::isValidValue($type) && $type !== null) {
throw new \Exception("Unknown sharing settings permission type");
} else {
$this->value = $type !== null ? $type : self::FULL_ACCESS;
}
}
}

View File

@@ -0,0 +1,84 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
class Template extends JsonSerializable
{
protected $image;
protected $title;
protected $url;
public function __construct(string $image = "", string $title = "", string $url = "")
{
$this->image = $image;
$this->title = $title;
$this->url = $url;
}
/**
* Get the value of image
*/
public function getImage()
{
return $this->image;
}
/**
* Set the value of image
*/
public function setImage($image)
{
$this->image = $image;
}
/**
* Get the value of title
*/
public function getTitle()
{
return $this->title;
}
/**
* Set the value of title
*/
public function setTitle($title)
{
$this->title = $title;
}
/**
* Get the value of url
*/
public function getUrl()
{
return $this->url;
}
/**
* Set the value of url
*/
public function setUrl($url)
{
$this->url = $url;
}
}

View File

@@ -0,0 +1,37 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
use Onlyoffice\DocsIntegrationSdk\Util\BasicEnum;
class Toolbar extends BasicEnum
{
const TOP = "top";
const BOTTOM = "bottom";
public function __construct($toolbar = null)
{
if (!self::isValidValue($toolbar) && $toolbar !== null) {
throw new \Exception("Unknown toolbar type");
} else {
$this->value = $toolbar !== null ? $toolbar : self::TOP;
}
}
}

View File

@@ -0,0 +1,39 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
use Onlyoffice\DocsIntegrationSdk\Util\BasicEnum;
class Type extends BasicEnum
{
const DESKTOP = "desktop";
const MOBILE = "mobile";
const EMBEDDED = "embedded";
public function __construct($type = null)
{
if (!self::isValidValue($type) && $type !== null) {
throw new \Exception("Unknown editors type");
} else {
$this->value = $type !== null ? $type : self::DESKTOP;
}
}
}

View File

@@ -0,0 +1,39 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
use Onlyoffice\DocsIntegrationSdk\Util\BasicEnum;
class Unit extends BasicEnum
{
const CM = "cm";
const PT = "pt";
const INCH = "inch";
public function __construct($type = null)
{
if (!self::isValidValue($type) && $type !== null) {
throw new \Exception("Unknown unit type");
} else {
$this->value = $type !== null ? $type : self::CM;
}
}
}

View File

@@ -0,0 +1,79 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Models;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
class User extends JsonSerializable
{
protected $id;
protected $name;
protected $group;
protected $image;
public function __construct(string $id = "", string $name = "", string $group = "", string $image = "")
{
$this->id = $id;
$this->name = $name;
$this->group = $group;
$this->image = $image;
}
public function getGroup()
{
return $this->group;
}
public function setGroup(string $group)
{
$this->group = $group;
}
public function getId()
{
return $this->id;
}
public function setId(string $id)
{
$this->id = $id;
}
public function getImage()
{
return $this->image;
}
public function setImage(array $image)
{
$this->image = $image;
}
public function getName()
{
return $this->name;
}
public function setName(string $name)
{
$this->name = $name;
}
}

View File

@@ -0,0 +1,117 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Service\Callback;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
/**
* Callback service Interface.
*
* @package Onlyoffice\DocsIntegrationSdk\Service\Callback
*/
use Onlyoffice\DocsIntegrationSdk\Manager\Settings\SettingsManager;
use Onlyoffice\DocsIntegrationSdk\Manager\Security\JwtManager;
use Onlyoffice\DocsIntegrationSdk\Manager\Document\DocumentManager;
use Onlyoffice\DocsIntegrationSdk\Models\Callback;
use Onlyoffice\DocsIntegrationSdk\Models\CallbackDocStatus;
use Onlyoffice\DocsIntegrationSdk\Util\CommonError;
abstract class CallbackService implements CallbackServiceInterface
{
private const TRACKERSTATUS_EDITING = 1;
private const TRACKERSTATUS_MUSTSAVE = 2;
private const TRACKERSTATUS_CORRUPTED = 3;
private const TRACKERSTATUS_CLOSED = 4;
private const TRACKERSTATUS_FORCESAVE = 6;
private const TRACKERSTATUS_CORRUPTEDFORCESAVE = 7;
protected $settingsManager;
protected $jwtManager;
abstract public function processTrackerStatusEditing(Callback $callback, string $fileid);
abstract public function processTrackerStatusMustsave(Callback $callback, string $fileid);
abstract public function processTrackerStatusCorrupted(Callback $callback, string $fileid);
abstract public function processTrackerStatusClosed(Callback $callback, string $fileid);
abstract public function processTrackerStatusForcesave(Callback $callback, string $fileid);
public function __construct(SettingsManager $settingsManager, JwtManager $jwtManager)
{
$this->settingsManager = $settingsManager;
$this->jwtManager = $jwtManager;
}
public function verifyCallback(Callback $callback, string $authorizationHeader = "")
{
if ($this->jwtManager->isJwtEnabled()) {
$token = $callback->getToken();
$payload = null;
$fromHeader = false;
if (!empty($authorizationHeader)) {
$compareHeaders = substr($authorizationHeader, 0, strlen($this->settingsManager->getJwtPrefix()));
if ($compareHeaders === $this->settingsManager->getJwtPrefix()) {
$token = $compareHeaders;
$fromHeader = true;
}
}
if (empty($token)) {
throw new \Exception(CommonError::message(CommonError::CALLBACK_NO_AUTH_TOKEN));
}
$payload = $this->jwtManager->jwtDecode($token);
$callbackFromToken = json_decode($payload, true);
if ($fromHeader) {
$callbackFromToken = $callbackFromToken["payload"];
}
$callback = new Callback;
$callback->mapFromArray($callbackFromToken);
}
return $callback;
}
public function processCallback(Callback $callback, string $fileId)
{
switch ($callback->getStatus()->getValue()) {
case CallbackDocStatus::EDITING:
return $this->processTrackerStatusEditing($callback, $fileId);
case CallbackDocStatus::SAVE:
return $this->processTrackerStatusMustsave($callback, $fileId);
case CallbackDocStatus::SAVE_CORRUPTED:
return $this->processTrackerStatusCorrupted($callback, $fileId);
case CallbackDocStatus::CLOSED:
return $this->processTrackerStatusClosed($callback, $fileId);
case CallbackDocStatus::FORCESAVE:
return $this->processTrackerStatusForcesave($callback, $fileId);
case CallbackDocStatus::FORCESAVE_CORRUPTED:
return $this->processTrackerStatusCorruptedForcesave($callback, $fileId);
default:
throw new \Exception(CommonError::message(CommonError::CALLBACK_NO_STATUS));
}
}
public function processTrackerStatusCorruptedForcesave(Callback $callback, string $fileid)
{
return $this->processTrackerStatusForcesave($callback, $fileid);
}
}

View File

@@ -0,0 +1,98 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Service\Callback;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
use Onlyoffice\DocsIntegrationSdk\Models\Callback;
interface CallbackServiceInterface
{
/**
* Verifies the Callback object.
*
* @param Callback $callback Object with the callback handler parameters.
* @param string $authorizationHeader The authorization header from the callback request.
* @throws Exception If authorization token is not found.
* @return Callback
*/
public function verifyCallback(Callback $callback, string $authorizationHeader);
/**
* Starts the callback handler.
*
* @param Callback $callback Object with the callback handler parameters.
* @param string $fileId The file ID.
* @throws Exception If the processing fails unexpectedly.
*/
public function processCallback(Callback $callback, string $fileId);
/**
* Starts the handler that is called if the callback status is 1 (EDITING).
*
* @param Callback $callback Object with the callback handler parameters.
* @param string $fileId The file ID.
* @throws Exception If the processing fails unexpectedly.
*/
public function processTrackerStatusEditing(Callback $callback, string $fileId);
/**
* Starts the handler that is called if the callback status is 2 (SAVE).
*
* @param Callback $callback Object with the callback handler parameters.
* @param string $fileId The file ID.
* @throws Exception If the processing fails unexpectedly.
*/
public function processTrackerStatusMustsave(Callback $callback, string $fileId);
/**
* Starts the handler that is called if the callback status is 3 (SAVE_CORRUPTED).
*
* @param Callback $callback Object with the callback handler parameters.
* @param string $fileId The file ID.
* @throws Exception If the processing fails unexpectedly.
*/
public function processTrackerStatusCorrupted(Callback $callback, string $fileId);
/**
* Starts the handler that is called if the callback status is 4 (CLOSED).
*
* @param Callback $callback Object with the callback handler parameters.
* @param string $fileId The file ID.
* @throws Exception If the processing fails unexpectedly.
*/
public function processTrackerStatusClosed(Callback $callback, string $fileId);
/**
* Starts the handler that is called if the callback status is 6 (FORCESAVE).
*
* @param Callback $callback Object with the callback handler parameters.
* @param string $fileId The file ID.
* @throws Exception If the processing fails unexpectedly.
*/
public function processTrackerStatusForcesave(Callback $callback, string $fileId);
/**
* Starts the handler that is called if the callback status is 7 (FORCESAVE_CORRUPTED).
*
* @param Callback $callback Object with the callback handler parameters.
* @param string $fileId The file ID.
* @throws Exception If the processing fails unexpectedly.
*/
public function processTrackerStatusCorruptedForcesave(Callback $callback, string $fileId);
}

View File

@@ -0,0 +1,207 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Service\DocEditorConfig;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
use Onlyoffice\DocsIntegrationSdk\Manager\Settings\SettingsManager;
use Onlyoffice\DocsIntegrationSdk\Manager\Document\DocumentManager;
use Onlyoffice\DocsIntegrationSdk\Service\DocEditorConfig\DocEditorConfigServiceInterface;
use Onlyoffice\DocsIntegrationSdk\Manager\Security\JwtManager;
use Onlyoffice\DocsIntegrationSdk\Util\CommonError;
use Onlyoffice\DocsIntegrationSdk\Models\Config;
use Onlyoffice\DocsIntegrationSdk\Models\CoEditing;
use Onlyoffice\DocsIntegrationSdk\Models\Customization;
use Onlyoffice\DocsIntegrationSdk\Models\DocEditorConfig;
use Onlyoffice\DocsIntegrationSdk\Models\Document;
use Onlyoffice\DocsIntegrationSdk\Models\DocumentType;
use Onlyoffice\DocsIntegrationSdk\Models\EditorsMode;
use Onlyoffice\DocsIntegrationSdk\Models\Embedded;
use Onlyoffice\DocsIntegrationSdk\Models\GoBack;
use Onlyoffice\DocsIntegrationSdk\Models\Info;
use Onlyoffice\DocsIntegrationSdk\Models\Permissions;
use Onlyoffice\DocsIntegrationSdk\Models\Recent;
use Onlyoffice\DocsIntegrationSdk\Models\ReferenceData;
use Onlyoffice\DocsIntegrationSdk\Models\Template;
use Onlyoffice\DocsIntegrationSdk\Models\Type;
use Onlyoffice\DocsIntegrationSdk\Models\User;
use Onlyoffice\DocsIntegrationSdk\Util\EnvUtil;
abstract class DocEditorConfigService implements DocEditorConfigServiceInterface
{
protected $documentManager;
protected $jwtManager;
protected $settingsManager;
public function __construct(
SettingsManager $settingsManager,
JwtManager $jwtManager,
DocumentManager $documentManager
) {
EnvUtil::loadEnvSettings();
$this->settingsManager = $settingsManager;
$this->jwtManager = $jwtManager;
$this->documentManager = $documentManager;
}
public function createConfig(string $fileId, EditorsMode $mode, string $userAgent)
{
$documentName = $this->documentManager->getDocumentName($fileId);
$type = $this->getType($userAgent);
$ext = $this->documentManager->getExt($documentName);
$documentType = new DocumentType($this->documentManager->getDocType($ext));
$document = $this->getDocument($fileId, $type);
$editorConfig = $this->getDocEditorConfig($fileId, $mode, $type);
$config = new Config(
$documentType,
"100%",
"100%",
"",
$type,
$editorConfig,
$document
);
if ($this->jwtManager->isJwtEnabled()) {
$config->setToken($this->jwtManager->jwtEncode($config));
}
return $config;
}
public function isMobileAgent(string $userAgent = "")
{
$userAgent = !empty($userAgent) ? $userAgent : $_SERVER["HTTP_USER_AGENT"];
$envKey = EnvUtil::envKey("EDITING_SERVICE_MOBILE_USER_AGENT");
// phpcs:ignore
$agentList = isset($_ENV[$envKey]) && !empty($_ENV[$envKey]) ? $_ENV[$envKey] : "android|avantgo|playbook|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|symbian|treo|up\\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino";
return preg_match($agentList, $userAgent);
}
public function getDocEditorConfig(string $fileId, EditorsMode $mode, Type $type)
{
$permissions = $this->getPermissions($fileId);
$editorConfig = new DocEditorConfig;
$editorConfig->setCoEditing($this->getCoEditing($fileId, $mode, $type));
$editorConfig->setCreateUrl($this->documentManager->getCreateUrl($fileId));
$editorConfig->setUser($this->getUser());
$editorConfig->setRecent($this->getRecent());
$editorConfig->setTemplates($this->getTemplates($fileId));
$editorConfig->setCustomization($this->getCustomization($fileId));
$editorConfig->setLang($this->getLang());
$editorConfig->setRegion($this->getRegion());
if (($permissions->getEdit() || $permissions->getFillForms() ||
$permissions->getComment() ||$permissions->getReview())
&& $mode->getValue() === EditorsMode::EDIT) {
$editorConfig->setCallbackUrl($this->documentManager->getCallbackUrl($fileId));
}
if ($type->getValue() === Type::EMBEDDED) {
$editorConfig->setEmbedded($this->getEmbedded($fileId));
}
return $editorConfig;
}
public function getDocument(string $fileId, Type $type)
{
$documentName = $this->documentManager->getDocumentName($fileId);
$permissions = $this->getPermissions($fileId);
$document = new Document(
$this->documentManager->getExt($documentName),
$this->documentManager->getDocumentKey($fileId, $type->getValue() === Type::EMBEDDED),
$this->getReferenceData($fileId),
$documentName,
$this->documentManager->getFileUrl($fileId),
$this->getInfo($fileId),
$permissions
);
return $document;
}
public function getCustomization(string $fileId)
{
$goback = new GoBack;
if (!empty($this->documentManager->getGobackUrl($fileId))) {
$goback->setUrl($this->documentManager->getGobackUrl($fileId));
}
$customization = new Customization;
$customization->setGoback($goback);
return $customization;
}
public function getPermissions(string $fileId = "")
{
return null;
}
public function getReferenceData(string $fileId = "")
{
return null;
}
public function getInfo(string $fileId = "")
{
return null;
}
public function getCoEditing(string $fileId = "", EditorsMode $mode = null, Type $type)
{
return null;
}
public function getType(string $userAgent = "")
{
return $this->isMobileAgent($userAgent) ? new Type(Type::MOBILE) : new Type(Type::DESKTOP);
}
public function getUser()
{
return null;
}
public function getRecent()
{
return null;
}
public function getTemplates($fileId)
{
return null;
}
public function getEmbedded($fileId)
{
return null;
}
public function getLang()
{
return "en";
}
public function getRegion()
{
return "en-US";
}
}

View File

@@ -0,0 +1,174 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Service\DocEditorConfig;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
/**
* Editors config service Interface.
*
* @package Onlyoffice\DocsIntegrationSdk\Service\DocEditorConfig
*/
use Onlyoffice\DocsIntegrationSdk\Models\CoEditing;
use Onlyoffice\DocsIntegrationSdk\Models\Customization;
use Onlyoffice\DocsIntegrationSdk\Models\Document;
use Onlyoffice\DocsIntegrationSdk\Models\EditorsMode;
use Onlyoffice\DocsIntegrationSdk\Models\Embedded;
use Onlyoffice\DocsIntegrationSdk\Models\Info;
use Onlyoffice\DocsIntegrationSdk\Models\Permissions;
use Onlyoffice\DocsIntegrationSdk\Models\Recent;
use Onlyoffice\DocsIntegrationSdk\Models\ReferenceData;
use Onlyoffice\DocsIntegrationSdk\Models\Type;
use Onlyoffice\DocsIntegrationSdk\Models\User;
interface DocEditorConfigServiceInterface
{
/**
* Creates a configuration for the document editor using the User-Agent request header.
*
* @param string $fileId The file ID.
* @param EditorsMode $mode The editor opening mode.
* @param string $userAgent The User-Agent request header that is used
* to determine the platform type ("desktop" or "mobile").
* @throws Exception If the processing fails unexpectedly.
* @return Config
*/
public function createConfig(string $fileId, EditorsMode $mode, string $userAgent);
/**
* Checks whether the mobile agent is used or not.
*
* @param string $userAgent The User-Agent request header.
* @throws Exception If the processing fails unexpectedly.
* @return bool
*/
public function isMobileAgent(string $userAgent);
/**
* Returns the DocEditorConfig object.
*
* @param string $fileId The file ID.
* @param EditorsMode $mode The editor opening mode.
* @param Type $type The platform type used to access the document.
* @throws Exception If the processing fails unexpectedly.
* @return DocEditorConfig
*/
public function getDocEditorConfig(string $fileId, EditorsMode $mode, Type $type);
/**
* Returns the Document object.
*
* @param string $fileId The file ID.
* @param Type $type The platform type used to access the document.
* @throws Exception If the processing fails unexpectedly.
* @return Document
*/
public function getDocument(string $fileId, Type $type);
/**
* Returns the Customization object.
*
* @param string $fileId The file ID.
* @throws Exception If the processing fails unexpectedly.
* @return Customization
*/
public function getCustomization(string $fileId);
/**
* Returns the Permissions object.
*
* @param string $fileId The file ID.
* @throws Exception If the processing fails unexpectedly.
* @return Permissions
*/
public function getPermissions(string $fileId);
/**
* Returns the ReferenceData object.
*
* @param string $fileId The file ID.
* @throws Exception If the processing fails unexpectedly.
* @return ReferenceData
*/
public function getReferenceData(string $fileId);
/**
* Returns the Info object.
*
* @param string $fileId The file ID.
* @throws Exception If the processing fails unexpectedly.
* @return Info
*/
public function getInfo(string $fileId);
/**
* Returns the CoEditing object.
*
* @param string $fileId The file ID.
* @param EditorsMode The editor opening mode.
* @param Type The platform type used to access the document.
* @throws Exception If the processing fails unexpectedly.
* @return CoEditing
*/
public function getCoEditing(string $fileId, EditorsMode $mode, Type $type);
/**
* Returns the Type object.
*
* @param string $userAgent The User-Agent request header.
* @throws Exception If the processing fails unexpectedly.
* @return Type
*/
public function getType(string $userAgent);
/**
* Returns the User object.
*
* @throws Exception If the processing fails unexpectedly.
* @return User
*/
public function getUser();
/**
* Returns array of Recent objects.
*
* @throws Exception If the processing fails unexpectedly.
* @return Recent[]
*/
public function getRecent();
/**
* Returns array of Template objects.
*
* @param string $fileId The file ID.
* @throws Exception If the processing fails unexpectedly.
* @return Template[]
*/
public function getTemplates(string $fileId);
/**
* Returns the Embedded object.
*
* @param string $fileId The file ID.
* @throws Exception If the processing fails unexpectedly.
* @return Embedded
*/
public function getEmbedded(string $fileId);
}

View File

@@ -0,0 +1,35 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Service\Request;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
/**
* Interface HttpClient.
*
* @package Onlyoffice\DocsIntegrationSdk\Service\Request
*/
interface HttpClientInterface
{
public function request($method, $url, $options);
public function getStatusCode();
public function getBody();
}

View File

@@ -0,0 +1,456 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Service\Request;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
use Onlyoffice\DocsIntegrationSdk\Manager\Document\DocumentManager;
use Onlyoffice\DocsIntegrationSdk\Manager\Settings\SettingsManager;
use Onlyoffice\DocsIntegrationSdk\Manager\Security\JwtManager;
use Onlyoffice\DocsIntegrationSdk\Models\ConvertRequest;
use Onlyoffice\DocsIntegrationSdk\Service\Request\RequestServiceInterface;
use Onlyoffice\DocsIntegrationSdk\Service\Request\HttpClientInterface;
use Onlyoffice\DocsIntegrationSdk\Util\CommandResponseError;
use Onlyoffice\DocsIntegrationSdk\Util\CommonError;
use Onlyoffice\DocsIntegrationSdk\Util\ConvertResponseError;
/**
* Default Document service.
*
* @package Onlyoffice\DocsIntegrationSdk\Service\Request
*/
abstract class RequestService implements RequestServiceInterface
{
/**
* Minimum supported version of editors
*
* @var float
*/
private const MIN_EDITORS_VERSION = 6.0;
protected SettingsManager $settingsManager;
protected JwtManager $jwtManager;
abstract public function getFileUrlForConvert();
public function __construct(
SettingsManager $settingsManager,
HttpClientInterface $httpClient,
JwtManager $jwtManager
) {
$this->settingsManager = $settingsManager;
$this->jwtManager = $jwtManager;
$this->httpClient = $httpClient;
}
/**
* Request to Document Server
*
* @param string $url - request address
* @param array $method - request method
* @param array $opts - request options
*
* @return string
*/
public function request($url, $method = "GET", $opts = [])
{
if ($this->settingsManager->isIgnoreSSL()) {
$opts["verify"] = false;
}
if (!array_key_exists("timeout", $opts)) {
$opts["timeout"] = 60;
}
$this->httpClient->request($url, $method, $opts);
if ($this->httpClient->getStatusCode() === 200) {
return $this->httpClient->getBody();
}
return "";
}
/**
* Generate an error code table of convertion
*
* @param int $errorCode - Error code
*
* @throws Exception
*/
public function processConvServResponceError($errorCode)
{
$errorMessage = '';
switch ($errorCode) {
case ConvertResponseError::UNKNOWN:
$errorMessage = ConvertResponseError::message(ConvertResponseError::UNKNOWN);
break;
case ConvertResponseError::TIMEOUT:
$errorMessage = ConvertResponseError::message(ConvertResponseError::TIMEOUT);
break;
case ConvertResponseError::CONVERSION:
$errorMessage = ConvertResponseError::message(ConvertResponseError::CONVERSION);
break;
case ConvertResponseError::DOWNLOADING:
$errorMessage = ConvertResponseError::message(ConvertResponseError::DOWNLOADING);
break;
case ConvertResponseError::PASSWORD:
$errorMessage = ConvertResponseError::message(ConvertResponseError::PASSWORD);
break;
case ConvertResponseError::DATABASE:
$errorMessage = ConvertResponseError::message(ConvertResponseError::DATABASE);
break;
case ConvertResponseError::INPUT:
$errorMessage = ConvertResponseError::message(ConvertResponseError::INPUT);
break;
case ConvertResponseError::TOKEN:
$errorMessage = ConvertResponseError::message(ConvertResponseError::TOKEN);
break;
default:
$errorMessage = "ErrorCode = " . $errorCode;
break;
}
throw new \Exception($errorMessage);
}
/**
* Generate an error code table of command
*
* @param string $errorCode - Error code
*
* @throws Exception
*/
public function processCommandServResponceError($errorCode)
{
$errorMessage = "";
switch ($errorCode) {
case CommandResponseError::NO:
return;
case CommandResponseError::KEY:
$errorMessage = CommandResponseError::message(CommandResponseError::KEY);
break;
case CommandResponseError::CALLBACK_URL:
$errorMessage = CommandResponseError::message(CommandResponseError::CALLBACK_URL);
break;
case CommandResponseError::INTERNAL_SERVER:
$errorMessage = CommandResponseError::message(CommandResponseError::INTERNAL_SERVER);
break;
case CommandResponseError::FORCE_SAVE:
$errorMessage = CommandResponseError::message(CommandResponseError::FORCE_SAVE);
break;
case CommandResponseError::COMMAND:
$errorMessage = CommandResponseError::message(CommandResponseError::COMMAND);
break;
case CommandResponseError::TOKEN:
$errorMessage = CommandResponseError::message(CommandResponseError::TOKEN);
break;
default:
$errorMessage = "ErrorCode = " . $errorCode;
break;
}
throw new \Exception($errorMessage);
}
/**
* Request health status
*
* @throws Exception
*
* @return bool
*/
public function healthcheckRequest() : bool
{
$healthcheckUrl = $this->settingsManager->getDocumentServerHealthcheckUrl();
if (empty($healthcheckUrl)) {
throw new \Exception(CommonError::message(CommonError::NO_HEALTHCHECK_ENDPOINT));
}
$response = $this->request($healthcheckUrl);
return $response === "true";
}
/**
* Request for conversion to a service
*
* @param string $documentUri - Uri for the document to convert
* @param string $fromExtension - Document extension
* @param string $toExtension - Extension to which to convert
* @param string $documentRevisionId - Key for caching on service
* @param bool - $isAsync - Perform conversions asynchronously
* @param string $region - Region
*
* @throws Exception
*
* @return array
*/
public function sendRequestToConvertService(
$documentUri,
$fromExtension,
$toExtension,
$documentRevisionId,
$isAsync,
$region = null
) {
$urlToConverter = $this->settingsManager->getConvertServiceUrl(true);
if (empty($urlToConverter)) {
throw new \Exception(CommonError::message(CommonError::NO_CONVERT_SERVICE_ENDPOINT));
}
if (empty($documentRevisionId)) {
$documentRevisionId = $documentUri;
}
$documentRevisionId = DocumentManager::generateRevisionId($documentRevisionId);
if (empty($fromExtension)) {
$fromExtension = pathinfo($documentUri)["extension"];
} else {
$fromExtension = trim($fromExtension, ".");
}
$data = new ConvertRequest;
$data->setAsync($isAsync);
$data->setUrl($documentUri);
$data->setOutputtype(trim($toExtension, "."));
$data->setFiletype($fromExtension);
$data->setTitle($documentRevisionId . "." . $fromExtension);
$data->setKey($documentRevisionId);
if (!is_null($region)) {
$data->setRegion($region);
}
$opts = [
"timeout" => "120",
"headers" => [
'Content-type' => 'application/json'
],
"body" => json_encode($data)
];
if ($this->jwtManager->isJwtEnabled()) {
$params = [
"payload" => json_decode(json_encode($data), true)
];
$token = $this->jwtManager->jwtEncode($params);
$jwtHeader = $this->settingsManager->getJwtHeader();
$jwtPrefix = $this->settingsManager->getJwtPrefix();
if (empty($jwtHeader)) {
throw new \Exception(CommonError::message(CommonError::NO_JWT_HEADER));
} elseif (empty($jwtPrefix)) {
throw new \Exception(CommonError::message(CommonError::NO_JWT_PREFIX));
}
$opts["headers"][$jwtHeader] = (string)$jwtPrefix . $token;
$token = $this->jwtManager->jwtEncode(json_decode(json_encode($data), true));
$data->setToken($token);
$opts["body"] = json_encode($data);
}
$responseXmlData = $this->request($urlToConverter, "POST", $opts);
libxml_use_internal_errors(true);
if (!function_exists("simplexml_load_file")) {
throw new \Exception(CommonError::message(CommonError::READ_XML));
}
$responseData = simplexml_load_string($responseXmlData);
if (!$responseData) {
$exc = CommonError::message(CommonError::BAD_RESPONSE_XML);
foreach (libxml_get_errors() as $error) {
$exc = $exc . PHP_EOL . $error->message;
}
throw new \Exception($exc);
}
return $responseData;
}
/**
* The method is to convert the file to the required format and return the result url
*
* @param string $documentUri - Uri for the document to convert
* @param string $fromExtension - Document extension
* @param string $toExtension - Extension to which to convert
* @param string $documentRevisionId - Key for caching on service
* @param string $region - Region
*
* @return string
*/
public function getConvertedUri($documentUri, $fromExtension, $toExtension, $documentRevisionId, $region = null)
{
$responseFromConvertService = $this->sendRequestToConvertService(
$documentUri,
$fromExtension,
$toExtension,
$documentRevisionId,
false,
$region
);
// phpcs:ignore
$errorElement = $responseFromConvertService->Error;
if ($errorElement->count() > 0) {
$this->processConvServResponceError($errorElement);
}
// phpcs:ignore
$isEndConvert = $responseFromConvertService->EndConvert;
if ($isEndConvert !== null && strtolower($isEndConvert) === "true") {
// phpcs:ignore
return is_string($responseFromConvertService->FileUrl) ? $responseFromConvertService->FileUrl : $responseFromConvertService->FileUrl->__toString();
}
return "";
}
/**
* Send command
*
* @param string $method - type of command
*
* @return array
*/
public function commandRequest($method)
{
$urlCommand = $this->settingsManager->getCommandServiceUrl(true);
if (empty($urlCommand)) {
throw new \Exception(CommonError::message(CommonError::NO_COMMAND_ENDPOINT));
}
$data = [
"c" => $method
];
$opts = [
"headers" => [
"Content-type" => "application/json"
],
"body" => json_encode($data)
];
if ($this->jwtManager->isJwtEnabled()) {
$params = [
"payload" => $data
];
$token = $this->jwtManager->jwtEncode($params);
$jwtHeader = $this->settingsManager->getJwtHeader();
$jwtPrefix = $this->settingsManager->getJwtPrefix();
if (empty($jwtHeader)) {
throw new \Exception(CommonError::message(CommonError::NO_JWT_HEADER));
} elseif (empty($jwtPrefix)) {
throw new \Exception(CommonError::message(CommonError::NO_JWT_PREFIX));
}
$opts["headers"][$jwtHeader] = $jwtPrefix . $token;
$token = $this->jwtManager->jwtEncode($data);
$data["token"] = $token;
$opts["body"] = json_encode($data);
}
$response = $this->request($urlCommand, "post", $opts);
$data = json_decode($response);
$this->processCommandServResponceError($data->error);
return $data;
}
/**
* Checking document service location
*
* @return array
*/
public function checkDocServiceUrl()
{
$version = null;
$documentServerUrl = $this->settingsManager->getDocumentServerUrl();
if (empty($documentServerUrl)) {
throw new \Exception(CommonError::message(CommonError::NO_DOCUMENT_SERVER_URL));
}
try {
if ((isset($_SERVER["HTTPS"]) && ($_SERVER["HTTPS"] == "on" || $_SERVER["HTTPS"] == 1)
|| isset($_SERVER["HTTP_X_FORWARDED_PROTO"]) && $_SERVER["HTTP_X_FORWARDED_PROTO"] == "https")
&& preg_match('/^http:\/\//i', $documentServerUrl)) {
throw new \Exception(CommonError::message(CommonError::MIXED_CONTENT));
}
} catch (\Exception $e) {
return [$e->getMessage(), $version];
}
try {
$healthcheckResponse = $this->healthcheckRequest();
if (!$healthcheckResponse) {
throw new \Exception(CommonError::message(CommonError::BAD_HEALTHCHECK_STATUS));
}
} catch (\Exception $e) {
return [$e->getMessage(), $version];
}
try {
$commandResponse = $this->commandRequest('version');
if (empty($commandResponse)) {
throw new \Exception(CommonError::message(CommonError::BAD_HEALTHCHECK_STATUS));
}
$version = $commandResponse->version;
$versionF = floatval($version);
if ($versionF > 0.0 && $versionF <= self::MIN_EDITORS_VERSION) {
throw new \Exception(CommonError::message(CommonError::NOT_SUPPORTED_VERSION));
}
} catch (\Exception $e) {
return [$e->getMessage(), $version];
}
try {
$fileUrl = $this->getFileUrlForConvert();
if (!empty($fileUrl)) {
if (!empty($this->settingsManager->getStorageUrl())) {
$fileUrl = str_replace(
$this->settingsManager->getServerUrl(),
$this->settingsManager->getStorageUrl(),
$fileUrl
);
}
$convertedFileUri = $this->getConvertedUri($fileUrl, "docx", "docx", "check_" . rand());
}
} catch (\Exception $e) {
return [$e->getMessage(), $version];
}
try {
$this->request($convertedFileUri);
} catch (\Exception $e) {
return [$e->getMessage(), $version];
}
return ["", $version];
}
}

View File

@@ -0,0 +1,134 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Service\Request;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
/**
* Interface DocumentService.
*
* @package Onlyoffice\DocsIntegrationSdk\Service\Request
*/
interface RequestServiceInterface
{
/**
* Returns url of file for convert
*
* @throws Exception If the processing fails unexpectedly.
* @return string
*/
public function getFileUrlForConvert();
/**
* Returns response body as string
*
* @param string $url Url for request.
* @param string $method Method of request.
* @param array $opts Options of request (headers, body).
* @throws Exception If the processing fails unexpectedly.
* @return string
*/
public function request(string $url, string $method, array $opts);
/**
* Returns error text by code from converting service.
*
* @param int $errorCode Code of error (See ConvertResponseError Util).
* @throws Exception If the processing fails unexpectedly.
* @return string
*/
public function processConvServResponceError(int $errorCode);
/**
* Returns error text by code from command service.
*
* @param int $errorCode Code of error (See CommandResponseError Util).
* @throws Exception If the processing fails unexpectedly.
* @return string
*/
public function processCommandServResponceError(int $errorCode);
/**
* Request health status of Document Server.
*
* @throws Exception If the processing fails unexpectedly.
* @return bool
*/
public function healthcheckRequest();
/**
* Request for conversion to a service. Returns response as array.
*
* @param string $documentUri - Uri for the document to convert
* @param string $fromExtension - Document extension
* @param string $toExtension - Extension to which to convert
* @param string $documentRevisionId - Key for caching on service
* @param bool - $isAsync - Perform conversions asynchronously
* @param string $region - Region value
* @throws Exception If the processing fails unexpectedly.
* @return array
*/
public function sendRequestToConvertService(
string $documentUri,
string $fromExtension,
string $toExtension,
string $documentRevisionId,
bool $isAsync,
string $region
);
/**
* The method is to convert the file to the required format and return the result url.
*
* @param string $documentUri - Uri for the document to convert
* @param string $fromExtension - Document extension
* @param string $toExtension - Extension to which to convert
* @param string $documentRevisionId - Key for caching on service
* @param string $region - Region value
* @throws Exception If the processing fails unexpectedly.
* @return string
*/
public function getConvertedUri(
string $documentUri,
string $fromExtension,
string $toExtension,
string $documentRevisionId,
string $region
);
/**
* Request health status of Document Server.
*
* @param string $method - type of command
* @throws Exception If the processing fails unexpectedly.
* @return array
*/
public function commandRequest(string $method);
/**
* Checking document service location
*
* @throws Exception If the processing fails unexpectedly.
* @return array
*/
public function checkDocServiceUrl();
}

View File

@@ -0,0 +1,67 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Util;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
abstract class BasicEnum
{
private static $constCacheArray = null;
private static function getConstants()
{
if (self::$constCacheArray == null) {
self::$constCacheArray = [];
}
$calledClass = get_called_class();
if (!array_key_exists($calledClass, self::$constCacheArray)) {
$reflect = new \ReflectionClass($calledClass);
self::$constCacheArray[$calledClass] = $reflect->getConstants();
}
return self::$constCacheArray[$calledClass];
}
public static function isValidName($name, $strict = false)
{
$constants = self::getConstants();
if ($strict) {
return array_key_exists($name, $constants);
}
$keys = array_map("strtolower", array_keys($constants));
return in_array(strtolower($name), $keys);
}
public static function isValidValue($value, $strict = true)
{
$values = array_values(self::getConstants());
return in_array($value, $values, $strict);
}
public function getValue()
{
return $this->value;
}
public function setValue($value)
{
$this->value = $value;
}
}

View File

@@ -0,0 +1,61 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Util;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
/**
* Error messages.
*
* @package Onlyoffice\DocsIntegrationSdk\Util
*/
class CommandResponseError
{
const NO = 0;
const KEY = 1;
const CALLBACK_URL = 2;
const INTERNAL_SERVER = 3;
const FORCE_SAVE = 4;
const COMMAND = 5;
const TOKEN = 6;
public static function message($code): string
{
switch ($code) {
case self::NO:
return "No errors";
case self::KEY:
return "Document key is missing or no document with such key could be found";
case self::CALLBACK_URL:
return "Callback url not correct";
case self::FORCE_SAVE:
return "No changes were applied to the document before the forcesave command was received";
case self::INTERNAL_SERVER:
return "Internal server error";
case self::COMMAND:
return "Command not correct";
case self::TOKEN:
return "Invalid token";
default:
return "Unknown error";
}
}
}

View File

@@ -0,0 +1,97 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Util;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
/**
* Error messages.
*
* @package Onlyoffice\DocsIntegrationSdk\Util
*/
class CommonError
{
const NO_HEALTHCHECK_ENDPOINT = 1;
const NO_DOCUMENT_SERVER_URL = 2;
const NO_CONVERT_SERVICE_ENDPOINT = 3;
const NO_JWT_HEADER = 4;
const NO_JWT_PREFIX = 5;
const READ_XML = 6;
const BAD_RESPONSE_XML = 7;
const NO_COMMAND_ENDPOINT = 8;
const MIXED_CONTENT = 9;
const BAD_HEALTHCHECK_STATUS = 10;
const DOC_SERVICE_ERROR = 11;
const NOT_SUPPORTED_VERSION = 12;
const EMPTY_FORMATS_ASSET = 13;
const FORMATS_ASSET_JSON_ERROR = 14;
const UNKNOWN_EXT = 15;
const FILE_TEMPLATE_IS_NOT_EXISTS = 16;
const NO_API_URL = 17;
const CALLBACK_NO_AUTH_TOKEN = 18;
const CALLBACK_NO_STATUS = 18;
public static function message($code): string
{
switch ($code) {
case self::NO_HEALTHCHECK_ENDPOINT:
return "There is no healthcheck endpoint in the application configuration";
case self::NO_DOCUMENT_SERVER_URL:
return "There is no document server URL in the application configuration";
case self::NO_CONVERT_SERVICE_ENDPOINT:
return "There is no convert service endpoint in the application configuration";
case self::NO_JWT_HEADER:
return "There is no JWT header in the application configuration";
case self::NO_JWT_PREFIX:
return "There is no JWT prefix in the application configuration";
case self::READ_XML:
return "Can't read XML";
case self::BAD_RESPONSE_XML:
return "Bad response";
case self::NO_COMMAND_ENDPOINT:
return "There is no command endpoint in the application configuration";
case self::MIXED_CONTENT:
return "Mixed Active Content is not allowed. HTTPS address for ONLYOFFICE Docs is required";
case self::BAD_HEALTHCHECK_STATUS:
return "Bad healthcheck status";
case self::DOC_SERVICE_ERROR:
return "Error occurred in the document service";
case self::NOT_SUPPORTED_VERSION:
return "Not supported version";
case self::EMPTY_FORMATS_ASSET:
return "Formats submodule error";
case self::FORMATS_ASSET_JSON_ERROR:
return "Formats submodule JSON error";
case self::UNKNOWN_EXT:
return "Unknown file extension";
case self::FILE_TEMPLATE_IS_NOT_EXISTS:
return "File template is not exists";
case self::NO_API_URL:
return "There is no document server API URL in the application configuration";
case self::CALLBACK_NO_AUTH_TOKEN:
return "Not found authorization token";
case self::CALLBACK_NO_STATUS:
return "Callback has no status";
default:
return "Unknown error";
}
}
}

View File

@@ -0,0 +1,64 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Util;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
/**
* Error messages.
*
* @package Onlyoffice\DocsIntegrationSdk\Util
*/
class ConvertResponseError
{
const UNKNOWN = -1;
const TIMEOUT = -2;
const CONVERSION = -3;
const DOWNLOADING = -4;
const PASSWORD = -5;
const DATABASE = -6;
const INPUT = -7;
const TOKEN = -8;
public static function message($code): string
{
switch ($code) {
case self::UNKNOWN:
return "Unknown error";
case self::TIMEOUT:
return "Timeout conversion error";
case self::CONVERSION:
return "Conversion error";
case self::DOWNLOADING:
return "Error while downloading the document file to be converted";
case self::PASSWORD:
return "Incorrect password";
case self::DATABASE:
return "Error while accessing the conversion result database";
case self::INPUT:
return "Error document request";
case self::TOKEN:
return "Invalid token";
default:
return "Undefined error";
}
}
}

View File

@@ -0,0 +1,50 @@
<?php
namespace Onlyoffice\DocsIntegrationSdk\Util;
/**
*
* (c) Copyright Ascensio System SIA 2024
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
use Dotenv\Dotenv;
/**
* ENV Utility.
*
* @package Onlyoffice\DocsIntegrationSdk\Util
*/
class EnvUtil
{
private const ENV_SETTINGS_PREFIX = "DOCS_INTEGRATION_SDK";
public function __construct()
{
static::loadEnvSettings();
}
public static function loadEnvSettings()
{
$dotenv = Dotenv::createImmutable(dirname(dirname(__DIR__)));
$dotenv->safeLoad();
}
public static function envKey($key)
{
return mb_strtoupper(self::ENV_SETTINGS_PREFIX . "_" . $key);
}
}