Skip to content

Commit

Permalink
Merge pull request #149 from ONLYOFFICE/develop
Browse files Browse the repository at this point in the history
Release/1.2.0
  • Loading branch information
LinneyS authored Jan 24, 2018
2 parents 7f2a61b + b284386 commit ca756a3
Show file tree
Hide file tree
Showing 14 changed files with 160 additions and 23 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Change Log

## 1.2.0
## Added
- disabling for incorrect settings
- Brazilian Poruguese translation
- detecting mobile

## Changed
- initialization script
- case sensitivity in extension
- сreating files with an existing name

## 1.1.6
## Changed
- update description
Expand Down
2 changes: 1 addition & 1 deletion appinfo/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function __construct(array $urlParams = []) {
$eventDispatcher = \OC::$server->getEventDispatcher();
$eventDispatcher->addListener("OCA\Files::loadAdditionalScripts",
function() {
if (!empty($this->appConfig->GetDocumentServerUrl())) {
if (!empty($this->appConfig->GetDocumentServerUrl()) && $this->appConfig->SettingsAreSuccessful()) {
Util::addScript("onlyoffice", "main");
Util::addStyle("onlyoffice", "main");
}
Expand Down
4 changes: 2 additions & 2 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<description>ONLYOFFICE connector enables you to edit Office documents within ONLYOFFICE from the familiar web interface. This will create a new Open in ONLYOFFICE action within the document library for Office documents. This allows multiple users to collaborate in real time and to save back those changes to your file storage.</description>
<licence>agpl</licence>
<author>Ascensio System SIA</author>
<version>1.1.6</version>
<version>1.2.0</version>
<namespace>Onlyoffice</namespace>
<types>
<filesystem/>
Expand All @@ -29,7 +29,7 @@
<screenshot>https://raw.githubusercontent.com/ONLYOFFICE/onlyoffice-owncloud/master/screenshots/settings.png</screenshot>
<dependencies>
<owncloud min-version="9.0" max-version="10.0" />
<nextcloud min-version="11" max-version="12"/>
<nextcloud min-version="11" max-version="13"/>
</dependencies>
<settings>
<admin>OCA\Onlyoffice\AdminSettings</admin>
Expand Down
Binary file modified assets/pt_BR/new.docx
Binary file not shown.
Binary file modified assets/pt_BR/new.pptx
Binary file not shown.
Binary file modified assets/pt_BR/new.xlsx
Binary file not shown.
21 changes: 16 additions & 5 deletions controller/editorcontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ class EditorController extends Controller {
*/
private $crypt;

/**
* Mobile regex from https://github.com/ONLYOFFICE/CommunityServer/blob/v9.1.1/web/studio/ASC.Web.Studio/web.appsettings.config#L35
*/
const USER_AGENT_MOBILE = "/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/i";

/**
* @param string $AppName - application name
* @param IRequest $request - request object
Expand Down Expand Up @@ -162,7 +167,7 @@ public function create($name, $dir) {
return ["error" => $this->trans->t("You don't have enough permission to create")];
}

$name = $userFolder->getNonExistingName($name);
$name = $folder->getNonExistingName($name);
$filePath = $dir . DIRECTORY_SEPARATOR . $name;
$ext = strtolower("." . pathinfo($filePath, PATHINFO_EXTENSION));

Expand Down Expand Up @@ -221,7 +226,7 @@ public function convert($fileId) {
}

$fileName = $file->getName();
$ext = pathinfo($fileName, PATHINFO_EXTENSION);
$ext = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
$format = $this->config->formats[$ext];
if (!isset($format)) {
$this->logger->info("Format for convertion not supported: " . $fileName, array("app" => $this->appName));
Expand Down Expand Up @@ -349,7 +354,7 @@ public function config($fileId) {
}

$fileName = $file->getName();
$ext = pathinfo($fileName, PATHINFO_EXTENSION);
$ext = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
$format = $this->config->formats[$ext];
if (!isset($format)) {
$this->logger->info("Format is not supported for editing: " . $fileName, array("app" => $this->appName));
Expand All @@ -376,9 +381,14 @@ public function config($fileId) {
$callback = str_replace($this->urlGenerator->getAbsoluteURL("/"), $this->config->GetStorageUrl(), $callback);
}

$type = "desktop";
if (\OC::$server->getRequest()->isUserAgent([$this::USER_AGENT_MOBILE])) {
$type = "mobile";
}

$params = [
"document" => [
"fileType" => pathinfo($fileName, PATHINFO_EXTENSION),
"fileType" => $ext,
"key" => DocumentService::GenerateRevisionId($key),
"title" => $fileName,
"url" => $fileUrl,
Expand All @@ -397,7 +407,8 @@ public function config($fileId) {
"id" => $userId,
"name" => $this->userSession->getUser()->getDisplayName()
]
]
],
"type" => $type
];

if (!empty($this->config->GetDocumentServerSecret())) {
Expand Down
1 change: 1 addition & 0 deletions controller/settingscontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ public function SaveSettings($documentserver,
$documentserver = $this->config->GetDocumentServerUrl();
if (!empty($documentserver)) {
$error = $this->checkDocServiceUrl();
$this->config->SetSettingsError($error);
}

$this->config->DropSKey();
Expand Down
13 changes: 5 additions & 8 deletions js/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,13 @@
};
}

OCA.Onlyoffice.OpenEditor = function (fileId, error) {

OCA.Onlyoffice.InitEditor = function () {
var displayError = function (error) {
$("#iframeEditor").text(error).addClass("error");
};

if (error.length) {
displayError(error)
return;
}

if (!fileId.length) {
var fileId = $("#iframeEditor").data("id");
if (!fileId) {
displayError(t(OCA.Onlyoffice.AppName, "FileId is empty"));
return;
}
Expand Down Expand Up @@ -93,4 +88,6 @@
});
};

$(document).ready(OCA.Onlyoffice.InitEditor);

})(jQuery, OCA);
49 changes: 49 additions & 0 deletions l10n/pt_BR.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
OC.L10N.register(
"onlyoffice",
{
"Access denied" : "Acesso negado",
"Invalid request" : "Solicitação inválida",
"Files not found" : "Arquivos não encontrados",
"File not found" : "Arquivo não encontrado",
"Not permitted" : "Não permitido",
"Download failed" : "Baixar arquivo falhou",
"The required folder was not found" : "A pasta requisitada não foi encontrada",
"You don't have enough permission to create" : "Você não tem permissões suficientes para criar",
"Template not found" : "Modelo não encontrado",
"Can't create file" : "Não é possível criar o arquivo",
"Format is not supported" : "Formato não suportado",
"Conversion is not required" : "Não é necessário converter",
"Failed to download converted file" : "Falha ao baixar arquivo convertido",
"ONLYOFFICE app is not configured. Please contact admin" : "Aplicação ONLYOFFICE não está configurada. Favor contatar o administrador",
"FileId is empty" : "FileId (ID de arquivo) está vazio",
"You do not have enough permissions to view the file" : "Você não tem permissões suficientes para ver o arquivo",
"Error occurred in the document service" : "Ocorreu um erro no serviço de documentos",
"Not supported version" : "Versão não suportada",
"ONLYOFFICE cannot be reached. Please contact admin" : "Não foi possível conectar ao ONLYOFFICE. Favor contatar o administrador.",
"Loading, please wait." : "Carregando, por favor aguarde.",
"File created" : "Arquivo criado",
"The document file you open will be converted to the Office Open XML format for faster viewing and editing." : "O documento será convertido para o formato Office Open XML para melhor edição e visualização.",
"Convert and open document" : "Converter e abrir o documento",
"Open in ONLYOFFICE" : "Abrir no ONLYOFFICE",
"Document" : "Documento",
"Spreadsheet" : "Planilha",
"Presentation" : "Apresentação",
"Error when trying to connect" : "Erro ao tentar conectar",
"Settings have been successfully updated" : "Configurações salvas com sucesso",
"Bad Request or timeout error" : "Pedido ruim ou erro de limite de tempo",
"Server can't read xml" : "Servidor não pode ler xml",
"Bad Response. Errors: " : "Resposta ruim. Erros:",
"Documentation" : "Documentação",
"ONLYOFFICE Document Service Location specifies the address of the server with the document services installed. Please change the '<documentserver>' for the server address in the below line." : "O Endereço do Serviço de Edição de Documentos especifica o servidor onde o serviço de documentos está instalado.\nPor favor mude '<documentserver>' para o endereço do servidor na linha abaixo.",
"Encryption App is enabled, the application cannot work. You can continue working with the application if you enable master key." : "A criptografia de arquivos está ativada, este aplicativo não pode operar. Ative a chave mestre se quiser continuar trabalhando.",
"Document Editing Service address" : "Endereço do Serviço de Edição de Documentos",
"Advanced server settings" : "Configurações avançadas do servidor",
"Document Editing Service address for internal requests from the server" : "Endereço do Serviço de Edição de Documentos para pedidos internos do servidor",
"Server address for internal requests from the Document Editing Service" : "Endereço do servidor para pedidos internos do Serviço de Edição de Documentos",
"Secret key (leave blank to disable)" : "Chave secreta (deixe em branco para desativar)",
"Open file in the same tab" : "Abrir arquivo na mesma aba",
"The default application for opening the format" : "Aplicação padrão para os formatos",
"Save" : "Salvar",
"Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Conteúdo Misto não é permitido. É necessário um endereço HTTPS para o Servidor de Documentos."
},
"nplurals=2; plural=(n != 1);");
47 changes: 47 additions & 0 deletions l10n/pt_BR.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{ "translations": {
"Access denied" : "Acesso negado",
"Invalid request" : "Solicitação inválida",
"Files not found" : "Arquivos não encontrados",
"File not found" : "Arquivo não encontrado",
"Not permitted" : "Não permitido",
"Download failed" : "Baixar arquivo falhou",
"The required folder was not found" : "A pasta requisitada não foi encontrada",
"You don't have enough permission to create" : "Você não tem permissões suficientes para criar",
"Template not found" : "Modelo não encontrado",
"Can't create file" : "Não é possível criar o arquivo",
"Format is not supported" : "Formato não suportado",
"Conversion is not required" : "Não é necessário converter",
"Failed to download converted file" : "Falha ao baixar arquivo convertido",
"ONLYOFFICE app is not configured. Please contact admin" : "Aplicação ONLYOFFICE não está configurada. Favor contatar o administrador",
"FileId is empty" : "FileId (ID de arquivo) está vazio",
"You do not have enough permissions to view the file" : "Você não tem permissões suficientes para ver o arquivo",
"Error occurred in the document service" : "Ocorreu um erro no serviço de documentos",
"Not supported version" : "Versão não suportada",
"ONLYOFFICE cannot be reached. Please contact admin" : "Não foi possível conectar ao ONLYOFFICE. Favor contatar o administrador.",
"Loading, please wait." : "Carregando, por favor aguarde.",
"File created" : "Arquivo criado",
"The document file you open will be converted to the Office Open XML format for faster viewing and editing." : "O documento será convertido para o formato Office Open XML para melhor edição e visualização.",
"Convert and open document" : "Converter e abrir o documento",
"Open in ONLYOFFICE" : "Abrir no ONLYOFFICE",
"Document" : "Documento",
"Spreadsheet" : "Planilha",
"Presentation" : "Apresentação",
"Error when trying to connect" : "Erro ao tentar conectar",
"Settings have been successfully updated" : "Configurações salvas com sucesso",
"Bad Request or timeout error" : "Pedido ruim ou erro de limite de tempo",
"Server can't read xml" : "Servidor não pode ler xml",
"Bad Response. Errors: " : "Resposta ruim. Erros:",
"Documentation" : "Documentação",
"ONLYOFFICE Document Service Location specifies the address of the server with the document services installed. Please change the '<documentserver>' for the server address in the below line." : "O Endereço do Serviço de Edição de Documentos especifica o servidor onde o serviço de documentos está instalado.\nPor favor mude '<documentserver>' para o endereço do servidor na linha abaixo.",
"Encryption App is enabled, the application cannot work. You can continue working with the application if you enable master key." : "A criptografia de arquivos está ativada, este aplicativo não pode operar. Ative a chave mestre se quiser continuar trabalhando.",
"Document Editing Service address" : "Endereço do Serviço de Edição de Documentos",
"Advanced server settings" : "Configurações avançadas do servidor",
"Document Editing Service address for internal requests from the server" : "Endereço do Serviço de Edição de Documentos para pedidos internos do servidor",
"Server address for internal requests from the Document Editing Service" : "Endereço do servidor para pedidos internos do Serviço de Edição de Documentos",
"Secret key (leave blank to disable)" : "Chave secreta (deixe em branco para desativar)",
"Open file in the same tab" : "Abrir arquivo na mesma aba",
"The default application for opening the format" : "Aplicação padrão para os formatos",
"Save" : "Salvar",
"Mixed Active Content is not allowed. HTTPS address for Document Server is required." : "Conteúdo Misto não é permitido. É necessário um endereço HTTPS para o Servidor de Documentos."
},"pluralForm" :"nplurals=2; plural=(n != 1);"
}
25 changes: 25 additions & 0 deletions lib/appconfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ class AppConfig {
*/
private $_jwtHeader = "jwt_header";

/**
* The config key for the settings error
*
* @var string
*/
private $_settingsError = "settings_error";

/**
* @param string $AppName - application name
*/
Expand Down Expand Up @@ -366,6 +373,24 @@ public function JwtHeader() {
return $header;
}

/**
* Save the status settings
*
* @param boolean $value - error
*/
public function SetSettingsError($value) {
$this->config->setAppValue($this->appName, $this->_settingsError, $value);
}

/**
* Get the status settings
*
* @return boolean
*/
public function SettingsAreSuccessful() {
return empty($this->config->getAppValue($this->appName, $this->_settingsError, ""));
}


/**
* Additional data about formats
Expand Down
4 changes: 2 additions & 2 deletions lib/documentservice.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function SendRequestToConvertService($document_uri, $from_extension, $to_extensi

$opts = array("http" => array(
"method" => "POST",
"timeout" => "120000",
"timeout" => "120",
"header"=> "Content-type: application/json\r\n",
"content" => $data
)
Expand Down Expand Up @@ -270,7 +270,7 @@ function CommandRequest($method) {

$opts = array("http" => array(
"method" => "POST",
"timeout" => "120000",
"timeout" => "60",
"header"=> "Content-type: application/json\r\n",
"content" => $data
)
Expand Down
6 changes: 1 addition & 5 deletions templates/editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

<div id="app">

<div id="iframeEditor"></div>
<div id="iframeEditor" data-id="<?php p($_["fileId"]) ?>"></div>

<?php if (!empty($_["documentServerUrl"])) {
print_unescaped("<script nonce=\"") .
Expand All @@ -40,8 +40,4 @@
print_unescaped("web-apps/apps/api/documents/api.js\" type=\"text/javascript\"></script>");
} ?>

<script type="text/javascript" nonce="<?php p(base64_encode($_["requesttoken"])) ?>">
OCA.Onlyoffice.OpenEditor("<?php p($_["fileId"]) ?>", "<?php empty($_["error"]) ? "" : p($_["error"]) ?>");
</script>

</div>

0 comments on commit ca756a3

Please sign in to comment.