New 'Use OOXML by default' option in admin settings
This commit is contained in:
Родитель
f2e6c36060
Коммит
145854400e
|
@ -51,5 +51,13 @@ $eventDispatcher->addListener(
|
|||
}
|
||||
);
|
||||
|
||||
if (class_exists('\OC\Files\Type\TemplateManager')) {
|
||||
$manager = \OC_Helper::getFileTemplateManager();
|
||||
|
||||
$manager->registerTemplate('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'apps/richdocuments/assets/docxtemplate.docx');
|
||||
$manager->registerTemplate('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'apps/richdocuments/assets/xlsxtemplate.xlsx');
|
||||
$manager->registerTemplate('application/vnd.openxmlformats-officedocument.presentationml.presentation', 'apps/richdocuments/assets/pptxtemplate.pptx');
|
||||
}
|
||||
|
||||
//Listen to delete file signal
|
||||
\OCP\Util::connectHook('OC_Filesystem', 'delete', "OCA\Richdocuments\Storage", "onDelete");
|
||||
|
|
|
@ -41,5 +41,6 @@ $application->registerRoutes($this, [
|
|||
//settings
|
||||
['name' => 'settings#setSettings', 'url' => 'ajax/admin.php', 'verb' => 'POST'],
|
||||
['name' => 'settings#getSupportedMimes', 'url' => 'ajax/mimes.php', 'verb' => 'GET'],
|
||||
['name' => 'settings#getSettings', 'url' => 'ajax/settings.php', 'verb' => 'GET'],
|
||||
]
|
||||
]);
|
||||
|
|
Двоичный файл не отображается.
Двоичные данные
assets/odttemplate.odt
Двоичные данные
assets/odttemplate.odt
Двоичный файл не отображается.
Двоичный файл не отображается.
Двоичный файл не отображается.
|
@ -270,7 +270,8 @@ class DocumentController extends Controller {
|
|||
'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize),
|
||||
'allowShareWithLink' => $this->settings->getAppValue('core', 'shareapi_allow_links', 'yes'),
|
||||
'wopi_url' => $webSocket,
|
||||
'edit_groups' => $this->appConfig->getAppValue('edit_groups')
|
||||
'edit_groups' => $this->appConfig->getAppValue('edit_groups'),
|
||||
'doc_format' => $this->appConfig->getAppValue('doc_format')
|
||||
]);
|
||||
|
||||
$policy = new ContentSecurityPolicy();
|
||||
|
@ -308,6 +309,15 @@ class DocumentController extends Controller {
|
|||
case 'application/vnd.oasis.opendocument.presentation':
|
||||
$basename = $this->l10n->t('New Presentation.odp');
|
||||
break;
|
||||
case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
|
||||
$basename = $this->l10n->t('New Document.docx');
|
||||
break;
|
||||
case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':
|
||||
$basename = $this->l10n->t('New Spreadsheet.xlsx');
|
||||
break;
|
||||
case 'application/vnd.openxmlformats-officedocument.presentationml.presentation':
|
||||
$basename = $this->l10n->t('New Presentation.pptx');
|
||||
break;
|
||||
default:
|
||||
// to be safe
|
||||
$mimetype = 'application/vnd.oasis.opendocument.text';
|
||||
|
|
|
@ -43,6 +43,16 @@ class SettingsController extends Controller{
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function getSettings() {
|
||||
return array(
|
||||
'doc_format' => $this->appConfig->getAppValue('doc_format'),
|
||||
'wopi_url' => $this->appConfig->getAppValue('wopi_url')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
|
@ -63,13 +73,14 @@ class SettingsController extends Controller{
|
|||
'admin',
|
||||
[
|
||||
'wopi_url' => $this->appConfig->getAppValue('wopi_url'),
|
||||
'edit_groups' => $this->appConfig->getAppValue('edit_groups')
|
||||
'edit_groups' => $this->appConfig->getAppValue('edit_groups'),
|
||||
'doc_format' => $this->appConfig->getAppValue('doc_format')
|
||||
],
|
||||
'blank'
|
||||
);
|
||||
}
|
||||
|
||||
public function setSettings($wopi_url, $edit_groups){
|
||||
public function setSettings($wopi_url, $edit_groups, $doc_format){
|
||||
if (!is_null($wopi_url)){
|
||||
$this->appConfig->setAppValue('wopi_url', $wopi_url);
|
||||
}
|
||||
|
@ -78,6 +89,10 @@ class SettingsController extends Controller{
|
|||
$this->appConfig->setAppValue('edit_groups', $edit_groups);
|
||||
}
|
||||
|
||||
if (!is_null($doc_format)){
|
||||
$this->appConfig->setAppValue('doc_format', $doc_format);
|
||||
}
|
||||
|
||||
$richMemCache = \OC::$server->getMemCacheFactory()->create('richdocuments');
|
||||
$richMemCache->clear('discovery.xml');
|
||||
|
||||
|
|
12
js/admin.js
12
js/admin.js
|
@ -26,6 +26,13 @@ var documentsSettings = {
|
|||
);
|
||||
},
|
||||
|
||||
saveDocFormat: function(format) {
|
||||
$.post(
|
||||
OC.filePath('richdocuments', 'ajax', 'admin.php'),
|
||||
{ 'doc_format': format }
|
||||
);
|
||||
},
|
||||
|
||||
afterSave : function(response){
|
||||
$('#wopi_apply').attr('disabled', false);
|
||||
OC.msg.finishedAction('#documents-admin-msg', response);
|
||||
|
@ -45,6 +52,11 @@ var documentsSettings = {
|
|||
$('#wopi_apply').on('click', documentsSettings.save);
|
||||
documentsSettings.initEditGroups();
|
||||
|
||||
$(document).on('change', '.doc-format-ooxml', function() {
|
||||
var ooxml = this.checked;
|
||||
documentsSettings.saveDocFormat(ooxml ? 'ooxml' : 'odf');
|
||||
});
|
||||
|
||||
$(document).on('change', '#edit_group_select', function() {
|
||||
var element = $(this).parent().find('input.edit-groups-enable');
|
||||
var groups = $(this).val();
|
||||
|
|
|
@ -712,6 +712,21 @@ var documentsMain = {
|
|||
documentsMain.create('application/vnd.oasis.opendocument.presentation');
|
||||
},
|
||||
|
||||
onCreateDOCX: function(event){
|
||||
event.preventDefault();
|
||||
documentsMain.create('application/vnd.openxmlformats-officedocument.wordprocessingml.document');
|
||||
},
|
||||
|
||||
onCreateXLSX: function(event){
|
||||
event.preventDefault();
|
||||
documentsMain.create('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
||||
},
|
||||
|
||||
onCreatePPTX: function(event){
|
||||
event.preventDefault();
|
||||
documentsMain.create('application/vnd.openxmlformats-officedocument.presentationml.presentation');
|
||||
},
|
||||
|
||||
create: function(mimetype){
|
||||
var docElem = $('.documentslist .template').clone();
|
||||
docElem.removeClass('template');
|
||||
|
@ -970,7 +985,7 @@ FileList.generatePreviewUrl = function(urlSpec) {
|
|||
urlSpec.y = Math.ceil(urlSpec.y);
|
||||
urlSpec.forceIcon = 0;
|
||||
return OC.generateUrl('/core/preview.png?') + $.param(urlSpec);
|
||||
}
|
||||
};
|
||||
|
||||
FileList.isFileNameValid = function (name) {
|
||||
var trimmedName = name.trim();
|
||||
|
@ -980,14 +995,14 @@ FileList.isFileNameValid = function (name) {
|
|||
throw t('files', 'File name cannot be empty.');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
FileList.setViewerMode = function(){
|
||||
};
|
||||
FileList.findFile = function(fileName){
|
||||
fullPath = escapeHTML(FileList.getCurrentDirectory + '/' + fileName);
|
||||
return !!$('.documentslist .document:not(.template,.progress) a[original-title="' + fullPath + '"]').length
|
||||
}
|
||||
return !!$('.documentslist .document:not(.template,.progress) a[original-title="' + fullPath + '"]').length;
|
||||
};
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
|
@ -1030,10 +1045,13 @@ $(document).ready(function() {
|
|||
$('.add-document').on('click', '.add-odt', documentsMain.onCreateODT);
|
||||
$('.add-document').on('click', '.add-ods', documentsMain.onCreateODS);
|
||||
$('.add-document').on('click', '.add-odp', documentsMain.onCreateODP);
|
||||
$('.add-document').on('click', '.add-docx', documentsMain.onCreateDOCX);
|
||||
$('.add-document').on('click', '.add-xlsx', documentsMain.onCreateXLSX);
|
||||
$('.add-document').on('click', '.add-pptx', documentsMain.onCreatePPTX);
|
||||
|
||||
OC.Upload._isReceivedSharedFile = function () {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
var file_upload_start = $('#file_upload_start');
|
||||
if (typeof supportAjaxUploadWithProgress !== 'undefined' && supportAjaxUploadWithProgress()) {
|
||||
|
|
|
@ -96,6 +96,88 @@ var odfViewer = {
|
|||
onClose: function() {
|
||||
FileList.setViewerMode(false);
|
||||
$('#loleafletframe').remove();
|
||||
},
|
||||
|
||||
registerFilesMenu: function(response) {
|
||||
var ooxml = response.doc_format === 'ooxml';
|
||||
|
||||
var docExt, spreadsheetExt, presentationExt;
|
||||
var docMime, spreadsheetMime, presentationMime;
|
||||
if (ooxml) {
|
||||
docExt = 'docx';
|
||||
spreadsheetExt = 'xlsx';
|
||||
presentationExt = 'pptx';
|
||||
docMime = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
|
||||
spreadsheetMime = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
|
||||
presentationMime = 'application/vnd.openxmlformats-officedocument.presentationml.presentation';
|
||||
} else {
|
||||
docExt = 'odt';
|
||||
spreadsheetExt = 'ods';
|
||||
presentationExt = 'odp';
|
||||
docMime = 'application/vnd.oasis.opendocument.text';
|
||||
spreadsheetMime = 'application/vnd.oasis.opendocument.spreadsheet';
|
||||
presentationMime = 'application/vnd.oasis.opendocument.presentation';
|
||||
}
|
||||
|
||||
(function(OCA){
|
||||
OCA.FilesLOMenu = {
|
||||
attach: function(newFileMenu) {
|
||||
var self = this;
|
||||
|
||||
newFileMenu.addMenuEntry({
|
||||
id: 'add-' + docExt,
|
||||
displayName: t('richdocuments', 'Document'),
|
||||
templateName: 'New Document.' + docExt,
|
||||
iconClass: 'icon-filetype-document',
|
||||
fileType: 'x-office-document',
|
||||
actionHandler: function(filename) {
|
||||
self._createDocument(docMime, filename);
|
||||
}
|
||||
});
|
||||
|
||||
newFileMenu.addMenuEntry({
|
||||
id: 'add-' + spreadsheetExt,
|
||||
displayName: t('richdocuments', 'Spreadsheet'),
|
||||
templateName: 'New Spreadsheet.' + spreadsheetExt,
|
||||
iconClass: 'icon-filetype-spreadsheet',
|
||||
fileType: 'x-office-spreadsheet',
|
||||
actionHandler: function(filename) {
|
||||
self._createDocument(spreadsheetMime, filename);
|
||||
}
|
||||
});
|
||||
|
||||
newFileMenu.addMenuEntry({
|
||||
id: 'add-' + presentationExt,
|
||||
displayName: t('richdocuments', 'Presentation'),
|
||||
templateName: 'New Presentation.' + presentationExt,
|
||||
iconClass: 'icon-filetype-presentation',
|
||||
fileType: 'x-office-presentation',
|
||||
actionHandler: function(filename) {
|
||||
self._createDocument(presentationMime, filename);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_createDocument: function(mimetype, filename) {
|
||||
OCA.Files.Files.isFileNameValid(filename);
|
||||
filename = FileList.getUniqueName(filename);
|
||||
|
||||
$.post(
|
||||
OC.generateUrl('apps/richdocuments/ajax/documents/create'),
|
||||
{ mimetype : mimetype, filename: filename, dir: $('#dir').val() },
|
||||
function(response){
|
||||
if (response && response.status === 'success'){
|
||||
FileList.add(response.data, {animate: true, scrollTo: true});
|
||||
} else {
|
||||
OC.dialogs.alert(response.data.message, t('core', 'Could not create file'));
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
})(OCA);
|
||||
|
||||
OC.Plugins.register('OCA.Files.NewFileMenu', OCA.FilesLOMenu);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -109,67 +191,13 @@ $(document).ready(function() {
|
|||
{},
|
||||
odfViewer.register
|
||||
);
|
||||
|
||||
$.get(
|
||||
OC.filePath('richdocuments', 'ajax', 'settings.php'),
|
||||
{},
|
||||
odfViewer.registerFilesMenu
|
||||
);
|
||||
}
|
||||
|
||||
$('#odf_close').live('click', odfViewer.onClose);
|
||||
});
|
||||
|
||||
(function(OCA){
|
||||
OCA.FilesLOMenu = {
|
||||
attach: function(newFileMenu) {
|
||||
var self = this;
|
||||
|
||||
newFileMenu.addMenuEntry({
|
||||
id: 'add-odt',
|
||||
displayName: t('richdocuments', 'Document'),
|
||||
templateName: 'New Document.odt',
|
||||
iconClass: 'icon-filetype-document',
|
||||
fileType: 'x-office-document',
|
||||
actionHandler: function(filename) {
|
||||
self._createDocument('application/vnd.oasis.opendocument.text', filename);
|
||||
}
|
||||
});
|
||||
|
||||
newFileMenu.addMenuEntry({
|
||||
id: 'add-ods',
|
||||
displayName: t('richdocuments', 'Spreadsheet'),
|
||||
templateName: 'New Spreadsheet.ods',
|
||||
iconClass: 'icon-filetype-spreadsheet',
|
||||
fileType: 'x-office-spreadsheet',
|
||||
actionHandler: function(filename) {
|
||||
self._createDocument('application/vnd.oasis.opendocument.spreadsheet', filename);
|
||||
}
|
||||
});
|
||||
|
||||
newFileMenu.addMenuEntry({
|
||||
id: 'add-odp',
|
||||
displayName: t('richdocuments', 'Presentation'),
|
||||
templateName: 'New Presentation.odp',
|
||||
iconClass: 'icon-filetype-presentation',
|
||||
fileType: 'x-office-presentation',
|
||||
actionHandler: function(filename) {
|
||||
self._createDocument('application/vnd.oasis.opendocument.presentation', filename);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_createDocument: function(mimetype, filename) {
|
||||
OCA.Files.Files.isFileNameValid(filename);
|
||||
filename = FileList.getUniqueName(filename);
|
||||
|
||||
$.post(
|
||||
OC.generateUrl('apps/richdocuments/ajax/documents/create'),
|
||||
{ mimetype : mimetype, filename: filename, dir: $('#dir').val() },
|
||||
function(response){
|
||||
if (response && response.status === 'success'){
|
||||
FileList.add(response.data, {animate: true, scrollTo: true});
|
||||
} else {
|
||||
OC.dialogs.alert(response.data.message, t('core', 'Could not create file'));
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
})(OCA);
|
||||
|
||||
OC.Plugins.register('OCA.Files.NewFileMenu', OCA.FilesLOMenu);
|
||||
|
|
|
@ -12,4 +12,7 @@ script('richdocuments', 'admin');
|
|||
<input type="checkbox" class="edit-groups-enable" id="edit_groups_enable-richdocuments" data-appid="richdocuments" />
|
||||
<label for="edit_groups_enable-richdocuments"><?php p($l->t('Enable edit for specific groups')) ?></label>
|
||||
<input type="hidden" id="edit_group_select" value="<?php p($_['edit_groups'])?>" title="<?php p($l->t('All')); ?>" style="width: 200px">
|
||||
<br/>
|
||||
<input type="checkbox" class="doc-format-ooxml" id="doc_format_ooxml_enable-richdocuments" <?php p($_['doc_format'] === 'ooxml' ? 'checked' : '') ?> data-appid="richdocuments" />
|
||||
<label for="doc_format_ooxml_enable-richdocuments"><?php p($l->t('Use OOXML by default for new files')) ?></label>
|
||||
</div>
|
||||
|
|
|
@ -9,13 +9,13 @@ script('files', 'jquery.fileupload');
|
|||
<div id="documents-content">
|
||||
<ul class="documentslist">
|
||||
<li class="add-document">
|
||||
<a class="icon-add add-odt svg" target="_blank" href="">
|
||||
<a class="icon-add add-<?php p($_['doc_format'] === 'ooxml' ? 'docx' : 'odt') ?> svg" target="_blank" href="">
|
||||
<label><?php p($l->t('New Document')) ?></label>
|
||||
</a>
|
||||
<a class="icon-add add-ods svg" target="_blank" href="">
|
||||
<a class="icon-add add-<?php p($_['doc_format'] === 'ooxml' ? 'xlsx' : 'ods') ?> svg" target="_blank" href="">
|
||||
<label><?php p($l->t('New Spreadsheet')) ?></label>
|
||||
</a>
|
||||
<a class="icon-add add-odp svg" target="_blank" href="">
|
||||
<a class="icon-add add-<?php p($_['doc_format'] === 'ooxml' ? 'pptx' : 'odp') ?> svg" target="_blank" href="">
|
||||
<label><?php p($l->t('New Presentation')) ?></label>
|
||||
</a>
|
||||
<div id="upload" title="<?php p($l->t('Upload (max. %s)', array($_['uploadMaxHumanFilesize']))) ?>">
|
||||
|
|
Загрузка…
Ссылка в новой задаче